IvfWidgetBase.h

00001 //
00002 // Copyright 1999-2006 by Structural Mechanics, Lund University.
00003 //
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Library General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later version.
00008 //
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Library General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Library General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00017 // USA.
00018 //
00019 // Please report all bugs and problems to "ivf@byggmek.lth.se".
00020 //
00021 //
00022 // Written by Jonas Lindemann
00023 //
00024 
00025 #ifndef _CIvfWidgetBase_h_
00026 #define _CIvfWidgetBase_h_
00027 
00028 #include <ivf/IvfBase.h>
00029 
00030 #include <ivfwidget/IvfEvents.h>
00031 
00032 IvfSmartPointer(CIvfWidgetBase);
00033 
00062 class IVFWIDGET_API CIvfWidgetBase : public CIvfBase {
00063 public:
00065         enum TFunctionKey {
00066                 FK_BUTTON,
00067                 FK_BACKSPACE,
00068                 FK_TAB,
00069                 FK_ENTER,
00070                 FK_PAUSE,
00071                 FK_SCROLL_LOCK,
00072                 FK_ESCAPE,
00073                 FK_HOME,
00074                 FK_LEFT,
00075                 FK_UP,
00076                 FK_RIGHT,
00077                 FK_DOWN,
00078                 FK_PAGE_UP,
00079                 FK_PAGE_DOWN,
00080                 FK_END,
00081                 FK_PRINT,
00082                 FK_INSERT,
00083                 FK_MENU,
00084                 FK_NUM_LOCK,
00085                 FK_F1,
00086                 FK_F2,
00087                 FK_F3,
00088                 FK_F4,
00089                 FK_F5,
00090                 FK_F6,
00091                 FK_F7,
00092                 FK_F8,
00093                 FK_F9,
00094                 FK_F10,
00095                 FK_F11,
00096                 FK_F12,
00097                 FK_KP0,
00098                 FK_KP1,
00099                 FK_KP2,
00100                 FK_KP3,
00101                 FK_KP4,
00102                 FK_KP5,
00103                 FK_KP6,
00104                 FK_KP7,
00105                 FK_KP8,
00106                 FK_KP9,
00107                 FK_KP_ENTER,
00108                 FK_SHIFT_L,
00109                 FK_SHIFT_R,
00110                 FK_CONTROL_L,
00111                 FK_CONTROL_R,
00112                 FK_CAPS_LOCK,
00113                 FK_META_L,
00114                 FK_META_R,
00115                 FK_ALT_L,
00116                 FK_ALT_R,
00117                 FK_DELETE
00118         };
00119 
00121         enum TModifierType {
00122                 MT_SHIFT,
00123                 MT_CTRL,
00124                 MT_ALT,
00125                 MT_NONE
00126         };
00127 
00128 private:
00129         bool m_initDone;
00130         bool m_doOverlay;
00131         int m_size[2];
00132         bool m_leftButtonDown;
00133         bool m_middleButtonDown;
00134         bool m_rightButtonDown;
00135         TModifierType m_modifierKey;
00136 
00137         bool m_idleProcessing;
00138 
00139         float m_timeouts[10];
00140 
00141         std::vector<CIvfRenderEvent*>                   m_renderEvents;
00142         std::vector<CIvfClearEvent*>                    m_clearEvents;
00143         CIvfAppLoopEvent*                                               m_appLoopEvent;
00144         std::vector<CIvfDestroyEvent*>                  m_destroyEvents;
00145         std::vector<CIvfFocusEvent*>                    m_focusEvents;
00146         std::vector<CIvfFunctionKeyEvent*>              m_functionKeyEvents;
00147         std::vector<CIvfIdleEvent*>                             m_idleEvents;
00148         std::vector<CIvfInitContextEvent*>              m_initContextEvents;
00149         std::vector<CIvfInitEvent*>                             m_initEvents;
00150         std::vector<CIvfInitOverlayEvent*>              m_initOverlayEvents;
00151         std::vector<CIvfKeyboardEvent*>                 m_keyboardEvents;
00152         std::vector<CIvfModifierDownEvent*>             m_modifierDownEvents;
00153         std::vector<CIvfModifierUpEvent*>               m_modifierUpEvents;
00154         std::vector<CIvfMouseDownEvent*>                m_mouseDownEvents;
00155         std::vector<CIvfMouseEnterEvent*>               m_mouseEnterEvents;
00156         std::vector<CIvfMouseEvent*>                    m_mouseEvents;
00157         std::vector<CIvfMouseLeaveEvent*>               m_mouseLeaveEvents;
00158         std::vector<CIvfMouseMoveEvent*>                m_mouseMoveEvents;
00159         std::vector<CIvfMouseUpEvent*>                  m_mouseUpEvents;
00160         std::vector<CIvfOverlayEvent*>                  m_overlayEvents;
00161         std::vector<CIvfResizeEvent*>                   m_resizeEvents;
00162         std::vector<CIvfUnFocusEvent*>                  m_unFocusEvents;
00163         std::vector<CIvfMenuItemEvent*>                 m_menuItemEvents;
00164 
00165         CIvfTimeoutEvent*                                               m_timeoutEvents[10];
00166 public:
00168         void addMenuItemEvent(CIvfMenuItemEvent* event);
00169 
00171         void addRenderEvent(CIvfRenderEvent* event);
00172 
00174         void addClearEvent(CIvfClearEvent* event);
00175 
00177         void assignAppLoopEvent(CIvfAppLoopEvent* event);
00178 
00180         void addDestroyEvent(CIvfDestroyEvent* event);
00181 
00183         void addFocusEvent(CIvfFocusEvent* event);
00184 
00186         void addFunctionKeyEvent(CIvfFunctionKeyEvent* event);
00187 
00189         void addIdleEvent(CIvfIdleEvent* event);
00190 
00192         void addInitContextEvent(CIvfInitContextEvent* event);
00193 
00195         void addInitEvent(CIvfInitEvent* event);
00196 
00198         void addInitOverlayEvent(CIvfInitOverlayEvent* event);
00199 
00201         void addKeyboardEvent(CIvfKeyboardEvent* event);
00202 
00204         void addModifierDownEvent(CIvfModifierDownEvent* event);
00205 
00207         void addModifierUpEvent(CIvfModifierUpEvent* event);
00208 
00210         void addMouseDownEvent(CIvfMouseDownEvent* event);
00211 
00213         void addMouseEnterEvent(CIvfMouseEnterEvent* event);
00214 
00216         void addMouseEvent(CIvfMouseEvent* event);
00217 
00219         void addMouseLeaveEvent(CIvfMouseLeaveEvent* event);
00220 
00222         void addMouseMoveEvent(CIvfMouseMoveEvent* event);
00223 
00225         void addMouseUpEvent(CIvfMouseUpEvent* event);
00226 
00228         void addOverlayEvent(CIvfOverlayEvent* event);
00229 
00231         void addResizeEvent(CIvfResizeEvent* event);
00232 
00234         void addUnFocusEvent(CIvfUnFocusEvent* event);
00235 
00237         void assignTimeoutEvent(int nbr, CIvfTimeoutEvent* event);
00238 
00240         void removeMenuItemEvent(CIvfMenuItemEvent* event);
00241 
00243         void removeRenderEvent(CIvfRenderEvent* event);
00244 
00246         void removeClearEvent(CIvfClearEvent* event);
00247 
00249         void removeDestroyEvent(CIvfDestroyEvent* event);
00250 
00252         void removeFocusEvent(CIvfFocusEvent* event);
00253 
00255         void removeFunctionKeyEvent(CIvfFunctionKeyEvent* event);
00256 
00258         void removeIdleEvent(CIvfIdleEvent* event);
00259 
00261         void removeInitContextEvent(CIvfInitContextEvent* event);
00262 
00264         void removeInitEvent(CIvfInitEvent* event);
00265 
00267         void removeInitOverlayEvent(CIvfInitOverlayEvent* event);
00268 
00270         void removeKeyboardEvent(CIvfKeyboardEvent* event);
00271 
00273         void removeModifierDownEvent(CIvfModifierDownEvent* event);
00274 
00276         void removeModifierUpEvent(CIvfModifierUpEvent* event);
00277 
00279         void removeMouseDownEvent(CIvfMouseDownEvent* event);
00280 
00282         void removeMouseEnterEvent(CIvfMouseEnterEvent* event);
00283 
00285         void removeMouseEvent(CIvfMouseEvent* event);
00286 
00288         void removeMouseLeaveEvent(CIvfMouseLeaveEvent* event);
00289 
00291         void removeMouseMoveEvent(CIvfMouseMoveEvent* event);
00292 
00294         void removeMouseUpEvent(CIvfMouseUpEvent* event);
00295 
00297         void removeOverlayEvent(CIvfOverlayEvent* event);
00298 
00300         void removeResizeEvent(CIvfResizeEvent* event);
00301 
00303         void removeUnFocusEvent(CIvfUnFocusEvent* event);
00304 
00306         void removeTimeoutEvent(int nbr);
00307 
00311         CIvfWidgetBase();
00312 
00314         virtual ~CIvfWidgetBase();
00315 
00316         IvfClassInfo("CIvfWidgetBase", CIvfBase);
00317 
00318         void redraw();
00319 
00321         bool isInitDone();
00322 
00324         bool isMiddleButtonDown();
00325 
00327         bool isRightButtonDown();
00328 
00330         bool isLeftButtonDown();
00331 
00333         bool isAnyButtonDown();
00334 
00336         void disableIdleProcessing();
00337 
00339         void enableIdleProcessing();
00340 
00342         bool isIdleProcessing();
00343         
00350         void enableTimeout(float time, int nbr);
00351 
00358         void disableTimeout(int nbr);
00359 
00361         bool isTimeoutEnabled(int nbr);
00362 
00364         float getTimeout(int number);
00365 
00367         TModifierType getModifierKey();
00368 
00370         double elapsedTime();
00371 
00373         void setPosition(int x, int y);
00374 
00376         void setSize(int w, int h);
00377 
00384         void setUseOverlay(bool flag);
00385 
00387         bool getUseOverlay();
00388 
00390         void clearMouseStatus();
00391 
00393         void setModifierKey(TModifierType key);
00394 
00396         void setMiddleButtonStatus(bool down);
00397 
00399         void setRightButtonStatus(bool down);
00400 
00402         void setLeftButtonStatus(bool down);
00403 
00411         virtual void onInit(int width, int height);
00412 
00418         virtual void onDestroy();
00419 
00426         virtual void onInitContext(int width, int height);
00427 
00436         virtual void onOverlay();
00437 
00438         virtual void onMouse(int x, int y);
00439 
00446         virtual void onMouseDown(int x, int y);
00447 
00454         virtual void onMouseUp(int x, int y);
00455 
00462         virtual void onMouseMove(int x, int y);
00463 
00470         virtual void onMouseLeave(int x, int y);
00471 
00478         virtual void onMouseEnter(int x, int y);
00479 
00486         virtual void onKeyboard(int key, int x, int y);
00487 
00494         virtual void onModifierDown();
00495 
00502         virtual void onModifierUp();
00503 
00511         virtual void onInitOverlay(int width, int height);
00512 
00519         virtual void onRender();
00520 
00521         virtual void onMenuItem(int id);
00522 
00531         virtual void onClear();
00532 
00540         virtual void onResize(int width, int height);
00541 
00547         virtual void onUnFocus();
00548 
00554         virtual void onFocus();
00555 
00562         virtual void onFunctionKey(TFunctionKey key, int x, int y);
00563 
00570         virtual void onIdle();
00571 
00578         virtual bool onTimeout0();
00579 
00586         virtual bool onTimeout1();
00587 
00594         virtual bool onTimeout2();
00595 
00602         virtual bool onTimeout3();
00603 
00610         virtual bool onTimeout4();
00611 
00618         virtual bool onTimeout5();
00619 
00626         virtual bool onTimeout6();
00627 
00634         virtual bool onTimeout7();
00635 
00642         virtual bool onTimeout8();
00643 
00650         virtual bool onTimeout9();
00651 
00658         virtual bool onAppLoop();
00659 
00667         virtual void doIdle();
00668 
00676         virtual bool doTimeout0();
00677 
00685         virtual bool doTimeout1();
00686 
00694         virtual bool doTimeout2();
00695 
00703         virtual bool doTimeout3();
00704 
00712         virtual bool doTimeout4();
00713 
00721         virtual bool doTimeout5();
00722 
00730         virtual bool doTimeout6();
00731 
00739         virtual bool doTimeout7();
00740 
00748         virtual bool doTimeout8();
00749 
00757         virtual bool doTimeout9();
00758 
00765         virtual bool doAppLoop();
00766 
00767         virtual double doElapsedTime();
00768 
00770         virtual void doInitOverlay(int width, int height);
00771 
00773         virtual void doDestroy();
00774 
00776         virtual void doOverlay();
00777 
00779         virtual void doInitContext(int width, int height);
00780 
00782         virtual void doClear();
00783 
00785         virtual void doRender();
00786 
00788         virtual void doInit(int width, int height);
00789 
00790         void doMenuItem(int id);
00791 
00798         virtual void doDisableIdleProcessing();
00799 
00806         virtual void doEnableIdleProcessing();
00807 
00814         virtual void doEnableTimeout(float time, int nbr);
00815 
00822         virtual void doDisableTimeout(int nbr);
00823         
00830         virtual void doRedraw();
00831 
00838         virtual void doMouseEnter(int x, int y);
00839 
00846         virtual void doUnFocus();
00847 
00854         virtual void doFocus();
00855 
00862         virtual void doMouseMove(int x, int y);
00863 
00870         virtual void doMouseUp(int x, int y);
00871 
00878         virtual void doMouseDown(int x, int y);
00879 
00886         virtual void doDraw();
00887 
00894         virtual void doResize(int width, int height);
00895 
00902         virtual void doMouseLeave(int x, int y);
00903 
00910         virtual void doKeyboard(int key, int x, int y);
00911 
00918         virtual void doModifierDown();
00919 
00926         virtual void doModifierUp();
00927 
00934         virtual void doFunctionKey(TFunctionKey key, int x, int y);
00935 
00936         virtual void doSetPosition(int x, int y);
00937         virtual void doSetSize(int w, int h);
00938 };
00943 #endif

Generated on Fri Sep 1 15:36:48 2006 for Interactive Visualisation Framework - Ivf++ by  doxygen 1.4.6-NO