00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: UIObject.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.40 $ $Date: 2019/01/17 21:21:02 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * User Interface Object base class. All user interface modules are derived 00020 * from this; it provides methods for registering with the command processor 00021 * and 'signing up' for which commands it is interested in, as well as 00022 * generating commands and events. 00023 * 00024 ***************************************************************************/ 00025 #ifndef UIOBJECT_H 00026 #define UIOBJECT_H 00027 00028 class CommandQueue; 00029 class Command; 00030 class VMDApp; 00031 00036 class UIObject { 00038 int maxCmds; 00041 char *doCmd; 00042 00044 int is_on; 00045 00046 protected: 00048 VMDApp *app; 00049 00051 CommandQueue *cmdQueue; 00052 00054 void runcommand(Command *); 00055 00057 void command_wanted(int cmd); 00058 00060 virtual void reset() {} 00061 00063 int make_callbacks; 00064 00066 virtual void do_on() {} 00067 virtual void do_off() {} 00068 00069 public: 00070 UIObject(VMDApp *); 00071 virtual ~UIObject(void); 00072 00078 void On() { 00079 do_on(); 00080 is_on = 1; 00081 } 00082 void Off() { 00083 do_off(); 00084 is_on = 0; 00085 } 00086 00088 int active() const { return is_on; } 00089 00091 int want_command(int cmd) { 00092 return !(cmd >= maxCmds || cmd < 0 || !doCmd[cmd]); 00093 } 00094 00097 virtual int check_event() { return 0; } 00098 00103 virtual int act_on_command(int, Command *) { return 0; } 00104 00106 void set_callbacks(int on) { make_callbacks = on; } 00107 }; 00108 00109 #endif 00110