/* TUIpeer works in conjunction with an implementation of java.awt.Toolkit to provide a Text User Interface for programs using the Java AWT. Copyright (C) 1997-2000 Stuart D. Gathman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #pragma interface #include "component.h" #include class CheckedMenuItem: public MenuItem { string label; bool checked; public: CheckedMenuItem(const char *s = 0); bool isSep() const; // true if separator item void setLabel(const char *s); void setChecked(bool); bool isChecked() const { return checked; } void enable() { state(ENABLE); } void disable() { state(DISABLE); } void draw(Window *,const Rect &); ~CheckedMenuItem(); }; class FrameComponent; struct MenuContainer { MenuContainer(Menu *); void addItem(MenuItemComponent *m); void addItem(MenuItem *m); void delItem(int i); void delItem(MenuItemComponent *m); virtual void show(bool) = 0; int indexOf(Component *m); void setFrame(FrameComponent *); void display(); ~MenuContainer(); protected: Menu *menu; FrameComponent *frame; private: Array item; }; class MenuItemComponent: public Component, public CheckedMenuItem { friend class MenuContainer; protected: MenuContainer *parent; public: MenuItemComponent(); void doit(Karet *); MenuItemComponent *asMenuItem() { return this; } void remoteMethod(int cmd); ~MenuItemComponent(); }; class MenuComponent: public MenuItemComponent, public MenuContainer { Point origin; public: MenuComponent(); MenuContainer *asMenu() { return this; } void show(bool); void draw(Window *w,const Rect &r); void doit(Karet *app); void remoteMethod(int cmd); ~MenuComponent(); }; class MenuBarComponent: public Component, public MenuContainer { MenuBarComponent(const MenuBarComponent &); public: MenuBarComponent(); MenuContainer *asMenu() { return this; } void remoteMethod(int cmd); void key(int); void show(bool); ~MenuBarComponent(); };