- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# CWindow.hpp

Go to the documentation of this file.

    00001 #ifndef __CWindow__
    00002 #define __CWindow__
    00003
    00004 #include <Testing/CTrace.hpp>
    00005 #include <Host/CDLLLoader.hpp>
    00006 #include <Collections/TPointerCollection.hpp>
    00007 #include "../Basics/GUIDefines.h"
    00008 #include "../Basics/ITimedObject.hpp"
    00009 #include "../Controls/CControlRoot.hpp"
    00010 #include "IWindow.hpp"
    00011 #include "IToolTipSupportingWindow.hpp"
    00012 #include "IToolTip.hpp"
    00013 #include "CWindowTools.hpp"
    00014
    00015 //  ===========================================================================
    00016
    00017 using Exponent::Host::CDLLLoader;
    00018 using Exponent::GUI::Basics::ITimedObject;
    00019 using Exponent::GUI::Windowing::IWindow;
    00020 using Exponent::GUI::Windowing::IToolTipSupportingWindow;
    00021 using Exponent::GUI::Windowing::IToolTip;
    00022 using Exponent::GUI::Windowing::CWindowTools;
    00023 using Exponent::GUI::Controls::CControlRoot;
    00024 using Exponent::Testing::CTrace;
    00025 using Exponent::Collections::TPointerCollection;
    00026
    00027 //  ===========================================================================
    00028
    00032 #ifdef WIN32
    00033     #pragma comment (lib, "Comctl32.lib")
    00034 #endif
    00035
    00039 namespace Exponent
    00040 {
    00041     namespace GUI
    00042     {
    00043         namespace Windowing
    00044         {
    00062             class CWindow : public IWindow, public IWindowChangeListener, public IFocusListener, public IToolTipSupportingWindow
    00063             {
    00065                 EXPONENT_CLASS_DECLARATION;
    00068 //  ===========================================================================
    00069
    00070             public:
    00071
    00072 //  ===========================================================================
    00073
    00078                 CWindow(const CRect &size);
    00079
    00083                 virtual ~CWindow();
    00084
    00085 //  ===========================================================================
    00086
    00090                 virtual void referenced();
    00091
    00095                 virtual void dereference();
    00096
    00101                 virtual long getReferenceCount() const;
    00102
    00108                 virtual void getObjectDescription(char *string, const long size) const;
    00109
    00110 //  ===========================================================================
    00111
    00116                 virtual void setParentWindow(IWindow *parent) { m_windowParent = parent; }
    00117
    00122                 virtual IWindow *getParentWindow() const { return m_windowParent; }
    00123
    00124 //  ===========================================================================
    00125
    00131                 virtual void registerChildWindow(IWindow *child);
    00132
    00137                 virtual void unregisterAllChildWindows();
    00138
    00144                 virtual void unregisterChldWindow(IWindow *child);
    00145
    00146 //  ===========================================================================
    00147
    00152                 virtual const SWindowHandle *getWindowHandle() const { return m_windowHandle; }
    00153
    00158                 virtual SWindowHandle *getMutableWindowHandle() const { return m_windowHandle; }
    00159
    00164                 virtual CWindowAttributes *getWindowAttributes() const { return m_attributes; }
    00165
    00166 //  ===========================================================================
    00167
    00173                 virtual void initialiseWindow(CWindowAttributes *windowAttributes, const bool showWindow);
    00174
    00178                 virtual void uninitialiseWindow();
    00179
    00180 //  ===========================================================================
    00181
    00185                 virtual void openWindow();
    00186
    00190                 virtual void closeWindow();
    00191
    00195                 virtual void updateWindow();
    00196
    00200                 virtual void disableWindow();
    00201
    00205                 virtual void enableWindow();
    00206
    00211                 virtual void gainedFocus(IWindow *window);
    00212
    00217                 virtual void lostFocus(IWindow *window);
    00218
    00219 //  ===========================================================================
    00220
    00225                 virtual void draw(CGraphics &graphics);
    00226
    00231                 virtual void redrawWindow(const CRect &area);
    00232
    00236                 virtual void redrawWindow();
    00237
    00238                 #ifndef WIN32
    00239
    00243                 void setCompositingControl(HIViewRef ref) { m_userWindow = ref; }
    00244                 #endif
    00245
    00246 //  ===========================================================================
    00247
    00252                 virtual void setWindowPosition(const CPoint &position);
    00253
    00258                 virtual const CPoint &getWindowPosition() const { return m_windowPosition; }
    00259
    00264                 virtual void setWindowSize(const CDimension &dimension);
    00265
    00270                 virtual const CDimension &getWindowSize() const { return m_windowDimension; }
    00271
    00276                 virtual void setWindowPositionAndSize(const CRect &positionAndSize);
    00277
    00284                 virtual const CRect &getWindowPositionAndSize() const { return m_windowSize; }
    00285
    00290                 virtual void setWindowAlpha(const double alpha);
    00291
    00292 //  ===========================================================================
    00293
    00298                 virtual void handleTimerEvent(const long id);
    00299
    00305                 virtual void startTimer(const long id, const long timeInMilliseconds);
    00306
    00311                 virtual void stopTimer(const long id);
    00312
    00317                 virtual void addTimedObject(ITimedObject *timedObject);
    00318
    00323                 virtual void removeTimedObject(ITimedObject *timedObject);
    00324
    00328                 virtual void clearTimedObjects();
    00329
    00330 //  ===========================================================================
    00331
    00336                 virtual void registerFocusListener(IFocusListener *listener) { m_focusListener = listener; }
    00337
    00342                 virtual void registerWindowChangeListener(IWindowChangeListener *listener) { m_windowChangeListener = listener; }
    00343
    00348                 virtual void registerMouseListener(IMouseListener *listener) { m_mouseListener = listener; }
    00349
    00354                 virtual void registerDropFileListener(IDropFileListener *listener) { m_dropFileListener = listener; }
    00355
    00360                 virtual void registerKeyboardListener(IKeyboardListener *listener) { m_keyboardListener = listener; }
    00361
    00362 //  ===========================================================================
    00363
    00368                 virtual bool isMouseEnabled() const { return m_mouseListener != NULL; }
    00369
    00374                 virtual bool isKeyboardEnabled() const { return m_keyboardListener != NULL; }
    00375
    00380                 virtual bool isDropFileEnabled() const { return m_dropFileListener != NULL; }
    00381
    00382 //  ===========================================================================
    00383
    00384                 // Set the tooltip to display
    00385                 virtual void setToolTip(IToolTip *toolTip = NULL) { m_toolTip = toolTip; }
    00386
    00387                 // Get the mutable tool tip
    00388                 virtual IToolTip *getMutableToolTip() const { return m_toolTip; }
    00389
    00390                 // Get the tool tip
    00391                 virtual const IToolTip *getToolTip() const { return m_toolTip; }
    00392
    00393 //  ===========================================================================
    00394
    00399                 virtual CMouse *getMouse() { return &m_mouse; }
    00400
    00405                 virtual IControlRoot *getControlRoot() const { return m_theControlRoot; }
    00406
    00407 //  ===========================================================================
    00408
    00414                 virtual void windowSized(IWindow *window, const CDimension &newDimension);
    00415
    00421                 virtual void windowMoved(IWindow *window, const CPoint &newTopLeft);
    00422
    00428                 virtual bool windowClosed(IWindow *window);
    00429
    00434                 virtual void windowOpened(IWindow *window);
    00435
    00440                 virtual void windowMinimised(IWindow *window);
    00441
    00446                 virtual void windowMaximised(IWindow *window);
    00447
    00448 //  ===========================================================================
    00449
    00450             protected:
    00451
    00452 //  ===========================================================================
    00453
    00457                 virtual bool createWindow();
    00458
    00462                 virtual void destroyWindow();
    00463
    00464 //  ===========================================================================
    00465
    00467                 #ifdef WIN32
    00468
    00477                     virtual LRESULT handleWindowEvents(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam);
    00478
    00487                     virtual LRESULT handleKeyboardEvents(int nCode, WPARAM wParam, LPARAM lParam);
    00488
    00497                     LRESULT handleMouseWheelEvents(int nCode, WPARAM wParam, LPARAM lParam);
    00498
    00503                     virtual void constructMousePosition(LPARAM lParam);
    00504
    00508                     virtual void startTrackMouseEvent();
    00509
    00513                     virtual void unhookKeyboardHandler();
    00514
    00518                     void unhookWheelHandler();
    00520                 #else
    00521
    00528                     virtual pascal OSStatus handleWindowEvents(EventHandlerCallRef handler, EventRef theEvent);
    00529
    00536                     virtual pascal OSErr handleDropEvent(WindowRef window, DragRef dragReference);
    00537
    00542                     virtual void constructMousePosition(EventRef theEvent);
    00543
    00548                     virtual void constructKeyboardEvent(EventRef theEvent);
    00550                 #endif
    00551
    00553 //  ===========================================================================
    00554
    00556                 #ifdef WIN32
    00557
    00566                     static LRESULT CALLBACK WindowProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam);
    00567
    00576                     static LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
    00577
    00586                     static LRESULT CALLBACK MouseWheelProc(int nCode, WPARAM wParam, LPARAM lParam);
    00587
    00596                     static VOID CALLBACK TimerProc(HWND windowHandle, UINT message, UINT_PTR eventID, DWORD dwTime);
    00598                 #else
    00599
    00608                     static pascal OSStatus WindowProc(EventHandlerCallRef handler, EventRef theEvent, void *userData);
    00609
    00618                     static pascal OSErr handleDropMessages(WindowRef window, void *userData, DragRef dragReference);
    00619
    00626                     static void handleTimerMessages(CFRunLoopTimerRef timer, void *info);
    00628                 #endif
    00629
    00631 //  ===========================================================================
    00632
    00634                 #ifndef WIN32
    00635
    00641                     class CTimerObject : public CCountedObject
    00642                     {
    00643                     public:
    00644
    00648                         CTimerObject()
    00649                         {
    00650                             m_isActive = false;
    00651                             NULL_POINTER(m_timer);
    00652                         }
    00653
    00657                         virtual ~CTimerObject()
    00658                         {
    00659                             if (m_timer)
    00660                             {
    00661                                 CFRelease(m_timer);
    00662                             }
    00663                         }
    00664
    00665                         CFRunLoopTimerRef m_timer;
    00666                         bool m_isActive;
    00667                     };
    00669                 #endif
    00670
    00672 //  ===========================================================================
    00673
    00674                 IMouseListener *m_mouseListener;
    00675                 IDropFileListener *m_dropFileListener;
    00676                 IKeyboardListener *m_keyboardListener;
    00677                 IWindowChangeListener *m_windowChangeListener;
    00678                 IFocusListener *m_focusListener;
    00680                 CWindowAttributes *m_attributes;
    00681                 SWindowHandle *m_windowHandle;
    00682                 IWindow *m_windowParent;
    00684                 CDimension m_windowDimension;
    00685                 CPoint m_windowPosition;
    00686                 CRect m_windowSize;
    00688                 CMouse m_mouse;
    00689                 CPoint m_mousePoint;
    00690                 CGraphics m_graphics;
    00692                 CMouseEvent m_mouseEvent;
    00693                 CKeyboardEvent m_keyEvent;
    00695                 bool m_windowInitialised;
    00697                 IToolTip *m_toolTip;
    00699                 TPointerCollection<ITimedObject> *m_timedObjects;
    00701                 CControlRoot *m_theControlRoot;
    00703                 long m_referenceCount;
    00706                 #ifdef WIN32
    00707
    00708                     SETLAYERATTRIBUTE m_setLayeredWindowAttributes;
    00709                     HHOOK m_keyboardHook;
    00710                     HHOOK m_mouseHook;
    00711                     static HWND m_hookWindowHandle;
    00713                 #else
    00714
    00715                     bool m_leftClick;
    00716                     TPointerCollection<CTimerObject> *m_timerContexts;
    00717                     CRect m_redrawUpdateArea;
    00718                     bool m_updateAreaIsValid;
    00719                     HIViewRef m_userWindow;
    00721                 #endif
    00722
    00724 //  ===========================================================================
    00725
    00726             };
    00727         }
    00728     }
    00729 }
    00730 #endif  // End of CWindow.hpp