00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __BM_SimpleState_H__
00022 #define __BM_SimpleState_H__
00023
00024 #include "BM_API.h"
00025 #include <UT/UT_UndoManager.h>
00026 #include <UT/UT_UndoWorkerFinder.h>
00027 #include <SI/AP_Interface.h>
00028
00029 class UT_String;
00030 class RE_Render;
00031 class RE_Cursor;
00032 class UI_Feel;
00033 class UI_Menu;
00034 class BM_SceneManager;
00035 class BM_Viewport;
00036
00037 #define BM_STATE 0x00000000
00038 #define BM_HANDLE 0x10000000
00039
00040 class BM_API BM_SimpleState : public AP_Interface
00041 {
00042 public:
00043 enum BM_EntryType { BM_FULLTIME_ENTRY = 0x01,
00044 BM_OVERLAY_ENTRY = 0x02
00045 };
00046
00047
00048 BM_SimpleState(BM_SceneManager &app, const char *cursor,
00049 const char *name = 0,
00050 const char *const *vnames = 0,
00051 UI_EventMethod const *vmethods = 0);
00052
00053 virtual ~BM_SimpleState(void);
00054
00055
00056 virtual UI_Menu *getStateMenu(int ortho = 0);
00057
00058
00059 virtual UI_Menu *getSelectorMenu();
00060
00061
00062 virtual UI_Menu *getExtraStateMenu();
00063
00064
00065 virtual int enter(BM_EntryType how =
00066 BM_SimpleState::BM_OVERLAY_ENTRY) = 0;
00067 virtual void exit (void) = 0;
00068
00069
00070 virtual void interrupt(BM_SimpleState * = 0);
00071 virtual void resume (BM_SimpleState * = 0);
00072
00073
00074
00075 virtual int handleMouseEvent (UI_Event *event) = 0;
00076 virtual int handleArrowEvent (UI_Event *event) = 0;
00077 virtual int handleKeyEvent (UI_Event *event);
00078 virtual int handleParameterEvent (UI_Event *event);
00079
00080
00081
00082
00083
00084
00085 virtual void render(RE_Render *r, short x, short y);
00086
00087
00088
00089
00090
00091
00092
00093 virtual int getToolboxCount() const;
00094 virtual UI_Feel *getToolbox(int index) const;
00095
00096
00097 virtual const char *className(void) const;
00098
00099
00100 virtual int isHandle() const = 0;
00101
00102 void setVolatileViewport(BM_Viewport *view)
00103 { myVolatileViewport = view; }
00104 BM_Viewport *getVolatileViewport() const
00105 { return myVolatileViewport; }
00106
00107
00108
00109
00110 virtual int isModifier(void) const { return 0; }
00111
00112
00113 BM_SceneManager &sceneManager(void) { return mySceneManager; }
00114 const BM_SceneManager &sceneManager(void) const { return mySceneManager; }
00115
00116
00117 void setSavedState(BM_SimpleState *state)
00118 { myPrevState = state; }
00119 BM_SimpleState *getSavedState()
00120 { return myPrevState; }
00121 const BM_SimpleState *getSavedState() const
00122 { return myPrevState; }
00123
00124 virtual const char *replaceCursor(const char *newcursor);
00125
00126 const char * getCurrentCursor() const
00127 { return myCursor; }
00128
00129
00130
00131 unsigned int getViewportMask() const { return myViewportMask; }
00132
00133 const UT_UndoWorkerFinder<BM_SimpleState> &undoWorkerFinder() const
00134 { return myUndoWorkerFinder; }
00135
00136 protected:
00137
00138 virtual const char *getUIDirectory() const = 0;
00139
00140
00141 virtual int handlePopupMenuEvent(UI_Event *event);
00142
00143
00144
00145 virtual int handleKeyTypeEvent(UI_Event *event,
00146 BM_Viewport &viewport);
00147
00148
00149 void pushCursor(void);
00150 void popCursor (void);
00151 void setCursor (void);
00152 void setCursor (const char *cursorname);
00153
00154
00155
00156 void setDefaultCursor(const char *cursorname);
00157
00158
00159 void initializeUI();
00160
00161
00162 virtual void initApplication(UI_Manager *, int c, const char **v);
00163
00164
00165
00166 virtual void getUIFileName(UT_String &full_path_and_name) const;
00167
00168
00169
00170 void mouseDown(UI_Event *event);
00171 int mouseDown(void) const { return myMouseDown; }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void beginDistributedUndoBlock(const char *operation,
00182 UT_UndoBlockType blocktype);
00183 void endDistributedUndoBlock();
00184
00185
00186 void setViewportMask(unsigned mask)
00187 { myViewportMask = mask; }
00188
00189
00190
00191 int getClickInterest();
00192 void addClickInterest(int buttons);
00193 void removeClickInterest(int buttons);
00194
00195
00196 void redrawScene();
00197
00198 private:
00199 BM_SceneManager &mySceneManager;
00200 const char *myCursor;
00201 BM_SimpleState *myPrevState;
00202 BM_Viewport *myVolatileViewport;
00203
00204
00205
00206 UI_Feel *myMenuGadget;
00207 UI_Feel *myOrthoMenuGadget;
00208
00209
00210 int myDistributedUndoBlockLevel;
00211
00212 UI_Feel *mySimpleToolbox;
00213
00214 unsigned int myViewportMask;
00215
00216
00217 int myMouseDown;
00218
00219 UT_UndoWorkerFinder<BM_SimpleState> myUndoWorkerFinder;
00220 };
00221
00222 #endif