X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7af6f32725483589cd56b409368fe986f9b4e0d1..2917e9204382ec1ecc96de7fc98bd3068da2233c:/include/wx/msw/window.h diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 7d2e8bd7a3..b04aa89851 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -20,14 +20,7 @@ #pragma interface "window.h" #endif -// windows.h #defines the following identifiers which are also used in wxWin -#ifdef GetCharWidth - #undef GetCharWidth -#endif - -#ifdef FindWindow - #undef FindWindow -#endif +#include "wx/msw/winundef.h" // VZ: apparently some version of Windows send extra mouse move messages after // a mouse click. My tests under NT 4.0 and 95 didn't show it so I'm @@ -84,6 +77,9 @@ public: const wxString& name = wxPanelNameStr); // implement base class pure virtuals + virtual void SetTitle( const wxString& title); + virtual wxString GetTitle() const; + virtual void Raise(); virtual void Lower(); @@ -114,13 +110,6 @@ public: const wxFont *theFont = (const wxFont *) NULL) const; - virtual void ClientToScreen( int *x, int *y ) const; - virtual void ScreenToClient( int *x, int *y ) const; - wxPoint ClientToScreen(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } - wxPoint ScreenToClient(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } - virtual bool PopupMenu( wxMenu *menu, int x, int y ); virtual void SetScrollbar( int orient, int pos, int thumbVisible, @@ -145,30 +134,33 @@ public: virtual void SetScrollPage(int orient, int page, bool refresh = TRUE); virtual int OldGetScrollRange(int orient) const; virtual int GetScrollPage(int orient) const; -#endif // WXWIN_COMPATIBILITY - - // caret manipulation (MSW only) - virtual void CreateCaret(int w, int h); - virtual void CreateCaret(const wxBitmap *bitmap); - virtual void DestroyCaret(); - virtual void ShowCaret(bool show); - virtual void SetCaretPos(int x, int y); - virtual void GetCaretPos(int *x, int *y) const; - // event handlers (FIXME: shouldn't they be inside WXWIN_COMPATIBILITY?) + // event handlers // Handle a control command virtual void OnCommand(wxWindow& win, wxCommandEvent& event); // Override to define new behaviour for default action (e.g. double // clicking on a listbox) - virtual void OnDefaultAction(wxControl *initiatingItem); + virtual void OnDefaultAction(wxControl * WXUNUSED(initiatingItem)) { } +#endif // WXWIN_COMPATIBILITY + +#if wxUSE_CARET + // caret manipulation (old MSW only functions, see wxCaret class for the + // new API) + void CreateCaret(int w, int h); + void CreateCaret(const wxBitmap *bitmap); + void DestroyCaret(); + void ShowCaret(bool show); + void SetCaretPos(int x, int y); + void GetCaretPos(int *x, int *y) const; +#endif // wxUSE_CARET // Native resource loading (implemented in src/msw/nativdlg.cpp) // FIXME: should they really be all virtual? virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id); virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name); - virtual wxWindow* GetWindowChild1(wxWindowID id); - virtual wxWindow* GetWindowChild(wxWindowID id); + wxWindow* GetWindowChild1(wxWindowID id); + wxWindow* GetWindowChild(wxWindowID id); // implementation from now on // -------------------------- @@ -206,14 +198,12 @@ public: // Windows subclassing void SubclassWin(WXHWND hWnd); void UnsubclassWin(); - virtual bool MSWCommand(WXUINT param, WXWORD id); WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; } void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; } - virtual wxWindow *FindItem(int id) const; - virtual wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const ; - virtual void PreDelete(WXHDC dc); // Allows system cleanup + wxWindow *FindItem(int id) const; + wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = FALSE) const; // Make a Windows extended style from the given wxWindows window style virtual WXDWORD MakeExtendedStyle(long style, bool eliminateBorders = TRUE); @@ -223,8 +213,6 @@ public: // MSW only: TRUE if this control is part of the main control virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; }; - wxObject *GetChild(int number) const ; - // returns TRUE if the window has been created bool MSWCreate(int id, wxWindow *parent, @@ -235,9 +223,12 @@ public: WXDWORD style, const char *dialog_template = NULL, WXDWORD exendedStyle = 0); + virtual bool MSWCommand(WXUINT param, WXWORD id); - // Actually defined in wx_canvs.cc since requires wxCanvas declaration - virtual void MSWDeviceToLogical(float *x, float *y) const ; +#if WXWIN_COMPATIBILITY + wxObject *GetChild(int number) const; + virtual void MSWDeviceToLogical(float *x, float *y) const; +#endif // WXWIN_COMPATIBILITY // Create an appropriate wxWindow from a HWND virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd); @@ -248,33 +239,68 @@ public: // Setup background and foreground colours correctly virtual void SetupColours(); + // ------------------------------------------------------------------------ + // helpers for message handlers: these perform the same function as the + // message crackers from - they unpack WPARAM and LPARAM into + // the correct parameters + // ------------------------------------------------------------------------ + + void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam, + WXWORD *id, WXHWND *hwnd, WXWORD *cmd); + void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam, + WXWORD *state, WXWORD *minimized, WXHWND *hwnd); + void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam, + WXWORD *code, WXWORD *pos, WXHWND *hwnd); + void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam, + WXWORD *nCtlColor, WXHDC *hdc, WXHWND *hwnd); + void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam, + WXWORD *item, WXWORD *flags, WXHMENU *hmenu); + // ------------------------------------------------------------------------ // internal handlers for MSW messages: all handlers return a boolen value: // TRUE means that the handler processed the event and FALSE that it didn't // ------------------------------------------------------------------------ - // TODO: all this should go away, overriding MSWWindowProc() is enough to - // implement this functionality - virtual bool MSWOnCreate(WXLPCREATESTRUCT cs, bool *mayCreate); - virtual bool MSWOnPaint(); - virtual bool MSWOnEraseBkgnd(WXHDC pDC); - virtual bool MSWOnSize(int x, int y, WXUINT flag); + // there are several cases where we have virtual functions for Windows + // message processing: this is because these messages often require to be + // processed in a different manner in the derived classes. For all other + // messages, however, we do *not* have corresponding MSWOnXXX() function + // and if the derived class wants to process them, it should override + // MSWWindowProc() directly. - virtual bool MSWOnQueryDragIcon(WXHICON *hIcon); - virtual bool MSWOnWindowPosChanging(void *lpPos); - - // both horizontal and vertical + // scroll event (both horizontal and vertical) virtual bool MSWOnScroll(int orientation, WXWORD nSBCode, WXWORD pos, WXHWND control); - virtual bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control); - virtual bool MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam); - + // child control notifications #ifdef __WIN95__ virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); #endif // __WIN95__ - virtual bool MSWOnCtlColor(WXHBRUSH *hBrush, + // owner-drawn controls need to process these messages + virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); + virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); + + // the rest are not virtual + bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate); + bool HandleInitDialog(WXHWND hWndFocus); + bool HandleDestroy(); + + bool HandlePaint(); + bool HandleEraseBkgnd(WXHDC pDC); + + bool HandleMinimize(); + bool HandleMaximize(); + bool HandleSize(int x, int y, WXUINT flag); + bool HandleGetMinMaxInfo(void *mmInfo); + + bool HandleShow(bool show, int status); + bool HandleActivate(int flag, bool minimized, WXHWND activate); + + bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); + bool HandleSysCommand(WXWPARAM wParam, WXLPARAM lParam); + + bool HandleCtlColor(WXHBRUSH *hBrush, WXHDC hdc, WXHWND hWnd, WXUINT nCtlColor, @@ -282,31 +308,28 @@ public: WXWPARAM wParam, WXLPARAM lParam); - virtual bool MSWOnPaletteChanged(WXHWND hWndPalChange); - virtual bool MSWOnQueryNewPalette(); + bool HandlePaletteChanged(WXHWND hWndPalChange); + bool HandleQueryNewPalette(); + bool HandleSysColorChange(); - virtual bool MSWOnQueryEndSession(long logOff, bool *mayEnd); - virtual bool MSWOnEndSession(bool endSession, long logOff); + bool HandleQueryEndSession(long logOff, bool *mayEnd); + bool HandleEndSession(bool endSession, long logOff); - virtual bool MSWOnDestroy(); - virtual bool MSWOnSetFocus(WXHWND wnd); - virtual bool MSWOnKillFocus(WXHWND wnd); - virtual bool MSWOnDropFiles(WXWPARAM wParam); - virtual bool MSWOnInitDialog(WXHWND hWndFocus); - virtual bool MSWOnShow(bool show, int status); + bool HandleSetFocus(WXHWND wnd); + bool HandleKillFocus(WXHWND wnd); - virtual bool MSWOnMouseEvent(WXUINT msg, int x, int y, WXUINT flags); - virtual bool MSWOnMouseMove(int x, int y, WXUINT flags); + bool HandleDropFiles(WXWPARAM wParam); - virtual bool MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); - virtual bool MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam); - virtual bool MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam); + bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags); + bool HandleMouseMove(int x, int y, WXUINT flags); - virtual bool MSWOnActivate(int flag, bool minimized, WXHWND activate); - virtual bool MSWOnMDIActivate(long flag, WXHWND activate, WXHWND deactivate); + bool HandleChar(WXWORD wParam, WXLPARAM lParam, bool isASCII = FALSE); + bool HandleKeyDown(WXWORD wParam, WXLPARAM lParam); + bool HandleKeyUp(WXWORD wParam, WXLPARAM lParam); - virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item); - virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item); + bool HandleQueryDragIcon(WXHICON *hIcon); + + bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg); // Window procedure virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); @@ -354,12 +377,6 @@ protected: bool m_doubleClickAllowed:1; bool m_winCaptured:1; - // Caret data - bool m_caretEnabled:1; - bool m_caretShown:1; - int m_caretWidth; - int m_caretHeight; - // the size of one page for scrolling int m_xThumbSize; int m_yThumbSize; @@ -376,6 +393,8 @@ protected: wxButton *m_btnDefault; // implement the base class pure virtuals + virtual void DoClientToScreen( int *x, int *y ) const; + virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoGetPosition( int *x, int *y ) const; virtual void DoGetSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const;