00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __AP_Interface__
00019 #define __AP_Interface__
00020
00021 #include "SI_API.h"
00022 #include <stdio.h>
00023 #include <UI/UI_Object.h>
00024 #include <UT/UT_Signal.h>
00025 #include <UT/UT_PtrArray.h>
00026 #include <UT/UT_String.h>
00027
00028 class AP_Interface;
00029 class UI_Value;
00030 class UI_Manager;
00031 class UT_SymbolTable;
00032 class UI_Feel;
00033
00034 class SI_API AP_Interface : public UI_Object {
00035 public:
00036 AP_Interface();
00037 AP_Interface(const char *myname,
00038 const char *const *names,
00039 UI_EventMethod const *methods);
00040
00041 virtual ~AP_Interface();
00042
00043 const UT_String &getName() const { return myName; }
00044 void wireInterface(UI_Manager *uims);
00045 void unwireInterface(UI_Manager *uims);
00046
00047
00048
00049
00050
00051 int parseUI(const char *filename,
00052 bool quiet = false);
00053 int parseUI(FILE *input, const char *inputname,
00054 bool quiet = false);
00055
00056 void setValueSymbol(const char *symbol, UI_Value *value,
00057 int warn = 1);
00058 UI_Value *getValueSymbol(const char *symbol, int create = 1);
00059
00060 int getValueSymbols(UT_PtrArray<const char *> &symbols,
00061 UT_PtrArray<UI_Value *> &values) const;
00062
00063 void setObjectSymbol(const char *symbol, UI_Object *who,
00064 int warn = 1);
00065 UI_Object *getObjectSymbol(const char *symbol) const;
00066 UI_Feel *getFeelSymbol(const char *symbol) const;
00067 void removeObjectSymbol(const char *symbol);
00068
00069 virtual void initApplication(UI_Manager *uims,
00070 int argc,
00071 const char **argv);
00072 void resetApplication();
00073
00074 virtual void handleEvent(UI_Event *event);
00075
00076
00077
00078
00079 virtual int saveAppData(const char *filename);
00080 virtual int loadAppState();
00081 virtual int saveAppState();
00082 virtual void saveOnCoreDump();
00083 virtual bool getCoreDumpFileName(char *buffer, int unique=0);
00084
00085
00086 static FILE *createPreferenceFile(const char *filename);
00087 static FILE *openPreferenceFile(const char *filename);
00088
00089
00090
00091 bool loadUIInitPrefs();
00092
00093
00094 void saveUIInitPrefs(const char * layout_level);
00095
00096
00097
00098 bool restoreUIInitPrefs();
00099
00100
00101
00102
00103 bool getFunctionKeyScript(UI_Event *event,
00104 UT_String &script);
00105
00106
00107
00108
00109 static void setAppExitCode(int exit_code);
00110 static int getAppExitCode();
00111
00112 protected:
00113
00114
00115
00116
00117 void setForegroundOption(int onOff);
00118 void setXTermOption(int onOff);
00119
00120 void setTheMainApplication(AP_Interface *app)
00121 {
00122 theMainApplication = app;
00123 }
00124 AP_Interface *getMainApplication() { return theMainApplication; }
00125
00126 UT_String myName;
00127 const char * const *myValueNames;
00128 UI_EventMethod const *myMethods;
00129
00130 UT_SymbolTable *getValueTable (void) const { return myValueTable; }
00131 UT_SymbolTable *getObjectTable(void) const { return myObjectTable; }
00132
00133
00134 bool getWindowGeometry(float &width, float &height,
00135 float &left, float &bottom);
00136
00137 virtual void getSignalList(int *signals, int max_signals);
00138
00139 private:
00140 void installSignalHandlers();
00141 void assignUIInitPrefs();
00142
00143 static void coredumpHandler(UTsignalHandlerArg sig_arg);
00144 static void powerFailHandlerSignalHandler(UTsignalHandlerArg);
00145 static void powerFailHandler();
00146 static void terminationWarning(uint nseconds);
00147
00148 UT_SymbolTable *myValueTable;
00149 UT_SymbolTable *myObjectTable;
00150
00151 static AP_Interface *theMainApplication;
00152 };
00153
00154 extern void APregister (AP_Interface *app);
00155 extern void APderegister(AP_Interface *app);
00156
00157
00158
00159
00160
00161
00162
00163 template<class ObjectClass> inline
00164 ObjectClass *SIgetObject(const AP_Interface *app, const char *name)
00165 {
00166 return dynamic_cast<ObjectClass *>(app->getObjectSymbol(name));
00167 }
00168
00169 template<class ValueClass> inline
00170 ValueClass *SIgetValue(const AP_Interface *app, const char *name)
00171 {
00172 return dynamic_cast<ValueClass *>(app->getValueSymbol(name, 0));
00173 }
00174
00175
00176
00177 #endif