]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/os2/window.h
Removed the SaveBG hack. The real incompatibility is that the MemoryDC
[wxWidgets.git] / include / wx / os2 / window.h
index 96c4c084691e2dd741e1d12c8e868ab9fe055434..fed061bb29aacc5c8f1a26d9bb0c8bc2fc08e99b 100644 (file)
 #include <os2.h>
 
 
+// ---------------------------------------------------------------------------
+// forward declarations
+// ---------------------------------------------------------------------------
+#ifndef CW_USEDEFAULT
+#  define  CW_USEDEFAULT ((int)0x80000000)
+#endif
+
 // ---------------------------------------------------------------------------
 // forward declarations
 // ---------------------------------------------------------------------------
@@ -44,20 +51,21 @@ enum
 // wxWindow declaration for OS/2 PM
 // ---------------------------------------------------------------------------
 
-class WXDLLEXPORT wxWindow : public wxWindowBase
+class WXDLLEXPORT wxWindowOS2 : public wxWindowBase
 {
-    DECLARE_DYNAMIC_CLASS(wxWindow);
-
 public:
-    wxWindow() { Init(); }
-
-    wxWindow( wxWindow*       pParent
-             ,wxWindowID      vId
-             ,const wxPoint&  rPos = wxDefaultPosition
-             ,const wxSize&   rSize = wxDefaultSize
-             ,long            lStyle = 0
-             ,const wxString& rName = wxPanelNameStr
-            )
+    wxWindowOS2()
+    {
+        Init();
+    }
+
+    wxWindowOS2( wxWindow*       pParent
+                ,wxWindowID      vId
+                ,const wxPoint&  rPos = wxDefaultPosition
+                ,const wxSize&   rSize = wxDefaultSize
+                ,long            lStyle = 0
+                ,const wxString& rName = wxPanelNameStr
+               )
     {
         Init();
         Create( pParent
@@ -69,7 +77,7 @@ public:
               );
     }
 
-    virtual ~wxWindow();
+    virtual ~wxWindowOS2();
 
     bool Create( wxWindow*       pParent
                 ,wxWindowID      vId
@@ -87,16 +95,18 @@ public:
     virtual bool     Show(bool bShow = TRUE);
     virtual bool     Enable(bool bEnable = TRUE);
     virtual void     SetFocus(void);
+    virtual void     SetFocusFromKbd(void);
     virtual bool     Reparent(wxWindow* pNewParent);
     virtual void     WarpPointer( int x
                                  ,int y
                                 );
-    virtual void     CaptureMouse(void);
-    virtual void     ReleaseMouse(void);
     virtual void     Refresh( bool          bEraseBackground = TRUE
                              ,const wxRect* pRect = (const wxRect *)NULL
                             );
-    virtual void     Clear(void);
+    virtual void     Freeze(void);
+    virtual void     Update(void);
+    virtual void     Thaw(void);
+    virtual void     SetWindowStyleFlag(long lStyle);
     virtual bool     SetCursor(const wxCursor& rCursor);
     virtual bool     SetFont(const wxFont& rFont);
     virtual int      GetCharHeight(void) const;
@@ -108,10 +118,12 @@ public:
                                    ,int*            pExternalLeading = (int *)NULL
                                    ,const wxFont*   pTheFont = (const wxFont *)NULL
                                   ) const;
+#if wxUSE_MENUS_NATIVE
     virtual bool     DoPopupMenu( wxMenu* pMenu
                                  ,int     nX
                                  ,int     nY
                                 );
+#endif // wxUSE_MENUS_NATIVE
 
     virtual void     SetScrollbar( int  nOrient
                                   ,int  nPos
@@ -131,6 +143,8 @@ public:
                                   ,const wxRect* pRect = (wxRect *)NULL
                                  );
 
+    inline HWND                   GetScrollBarHorz(void) const {return m_hWndScrollBarHorz;}
+    inline HWND                   GetScrollBarVert(void) const {return m_hWndScrollBarVert;};
 #if wxUSE_DRAG_AND_DROP
     virtual void SetDropTarget(wxDropTarget* pDropTarget);
 #endif // wxUSE_DRAG_AND_DROP
@@ -138,47 +152,7 @@ public:
     // Accept files for dragging
     virtual void DragAcceptFiles(bool bAccept);
 
-#if WXWIN_COMPATIBILITY
-    // Set/get scroll attributes
-    virtual void SetScrollRange( int  nOrient
-                                ,int  nRange
-                                ,bool bRefresh = TRUE
-                               );
-    virtual void SetScrollPage( int  nOrient
-                               ,int  nPage
-                               ,bool bRefresh = TRUE
-                              );
-    virtual int  OldGetScrollRange(int nOrient) const;
-    virtual int  GetScrollPage(int nOrient) const;
-
-    //
-    // event handlers
-    //
-        // Handle a control command
-    virtual void OnCommand( wxWindow&       rWin
-                           ,wxCommandEvent& rEvent
-                          );
-
-        // Override to define new behaviour for default action (e.g. double
-        // clicking on a listbox)
-    virtual void OnDefaultAction(wxControl* WXUNUSED(pInitiatingItem)) { }
-#endif // WXWIN_COMPATIBILITY
-
-#if wxUSE_CARET && WXWIN_COMPATIBILITY
-    void CreateCaret( int nWidth
-                     ,int nHeight
-                    );
-    void CreateCaret(const wxBitmap* pBitmap);
-    void DestroyCaret(void);
-    void ShowCaret(bool bShow);
-    void SetCaretPos( int nX
-                     ,int nY
-                    );
-    void GetCaretPos( int* pX
-                     ,int* pY
-                    ) const;
-#endif // wxUSE_CARET
-
+#ifndef __WXUNIVERSAL__
     // Native resource loading (implemented in src/os2/nativdlg.cpp)
     // FIXME: should they really be all virtual?
     virtual bool LoadNativeDialog( wxWindow*   pParent
@@ -189,6 +163,7 @@ public:
                                  );
     wxWindow*    GetWindowChild1(wxWindowID vId);
     wxWindow*    GetWindowChild(wxWindowID vId);
+#endif //__WXUNIVERSAL__
 
     // implementation from now on
     // --------------------------
@@ -205,27 +180,26 @@ public:
 
     // event handlers
     // --------------
+    void OnSetFocus(wxFocusEvent& rEvent);
     void OnEraseBackground(wxEraseEvent& rEvent);
     void OnIdle(wxIdleEvent& rEvent);
 
 public:
+
     // For implementation purposes - sometimes decorations make the client area
     // smaller
     virtual wxPoint GetClientAreaOrigin(void) const;
 
-    // Makes an adjustment to the window position (for example, a frame that has
-    // a toolbar that it manages itself).
-    virtual void AdjustForParentClientOrigin( int& rX
-                                             ,int& rY
-                                             ,int  nSizeFlags
-                                            );
-
     // Windows subclassing
     void SubclassWin(WXHWND hWnd);
     void UnsubclassWin(void);
 
     WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
     void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
+    //
+    // Return TRUE if the window is of a standard (i.e. not wxWindows') class
+    //
+    bool IsOfStandardClass(void) const { return m_fnOldWndProc != NULL; }
 
     wxWindow* FindItem(long lId) const;
     wxWindow* FindItemByHWND( WXHWND hWnd
@@ -236,39 +210,45 @@ public:
     static WXDWORD MakeExtendedStyle( long lStyle
                                      ,bool bEliminateBorders = TRUE
                                     );
-    // Determine whether 3D effects are wanted
-    WXDWORD Determine3DEffects( WXDWORD dwDefaultBorderStyle
-                               ,bool*   pbWant3D
-                              ) const;
 
     // PM only: TRUE if this control is part of the main control
     virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return FALSE; };
 
+    // translate wxWindows style flags for this control into the PM style
+    // and optional extended style for the corresponding native control
+    //
+    // this is the function that should be overridden in the derived classes,
+    // but you will mostly use OS2GetCreateWindowFlags() below
+    virtual WXDWORD OS2GetStyle( long     lFlags
+                                ,WXDWORD* pdwExstyle = NULL
+                               ) const;
+
+    // get the MSW window flags corresponding to wxWindows ones
+    //
+    // the functions returns the flags (WS_XXX) directly and puts the ext
+    // (WS_EX_XXX) flags into the provided pointer if not NULL
+    WXDWORD OS2GetCreateWindowFlags(WXDWORD* pdwExflags = NULL) const
+        { return OS2GetStyle(GetWindowStyle(), pdwExflags); }
+
+
+    // get the HWND to be used as parent of this window with CreateWindow()
+    virtual WXHWND OS2GetParent(void) const;
+
     // returns TRUE if the window has been created
-    bool OS2Create( int           nId
-                   ,wxWindow*     pParent
-                   ,const wxChar* zWclass
-                   ,wxWindow*     pWxWin
-                   ,const wxChar* zTitle
-                   ,int           nX
-                   ,int           nY
-                   ,int           nWidth
-                   ,int           nHeight
-                   ,WXDWORD       dwStyle
-                   ,const wxChar* zDialogTemplate = NULL
-                   ,WXDWORD       dwExendedStyle = 0
-                  );
+    bool         OS2Create( PSZ            zClass
+                           ,const char*    zTitle
+                           ,WXDWORD        dwStyle
+                           ,const wxPoint& rPos
+                           ,const wxSize&  rSize
+                           ,void*          pCtlData
+                           ,WXDWORD        dwExStyle
+                           ,bool           bIsChild
+                          );
     virtual bool OS2Command( WXUINT uParam
                             ,WXWORD nId
                            );
 
-#if WXWIN_COMPATIBILITY
-    wxObject*    GetChild(int nNumber) const;
-    virtual void OS2DeviceToLogical( float* pfX
-                                    ,float* pfY
-                                   ) const;
-#endif // WXWIN_COMPATIBILITY
-
+#ifndef __WXUNIVERSAL__
     // Create an appropriate wxWindow from a HWND
     virtual wxWindow* CreateWindowFromHWND( wxWindow* pParent
                                            ,WXHWND    hWnd
@@ -276,6 +256,7 @@ public:
 
     // Make sure the window style reflects the HWND style (roughly)
     virtual void AdoptAttributesFromHWND(void);
+#endif
 
     // Setup background and foreground colours correctly
     virtual void SetupColours(void);
@@ -295,7 +276,6 @@ public:
     void UnpackActivate( WXWPARAM wParam
                         ,WXLPARAM lParam
                         ,WXWORD*  pState
-                        ,WXWORD*  pMinimized
                         ,WXHWND*  pHwnd
                        );
     void UnpackScroll( WXWPARAM wParam
@@ -304,12 +284,6 @@ public:
                       ,WXWORD*  pPos
                       ,WXHWND*  pHwnd
                      );
-    void UnpackCtlColor( WXWPARAM wParam
-                        ,WXLPARAM lParam
-                        ,WXWORD*  pCtlColor
-                        ,WXHDC*   pHdc
-                        ,WXHWND*  pHwnd
-                       );
     void UnpackMenuSelect( WXWPARAM wParam
                           ,WXLPARAM lParam
                           ,WXWORD*  pTtem
@@ -336,19 +310,16 @@ public:
                              ,WXHWND control
                             );
 
-    virtual bool OS2OnNotify( int       nIdCtrl
-                             ,WXLPARAM  lParam
-                             ,WXLPARAM* pResult
-                            );
-
     // owner-drawn controls need to process these messages
     virtual bool OS2OnDrawItem( int               nId
                                ,WXDRAWITEMSTRUCT* pItem
                               );
-    virtual bool OS2OnMeasureItem( int                  nId
+    virtual long OS2OnMeasureItem( int                  nId
                                   ,WXMEASUREITEMSTRUCT* pItem
                                  );
 
+    virtual void OnPaint(wxPaintEvent& rEvent);
+
     // the rest are not virtual
     bool HandleCreate( WXLPCREATESTRUCT vCs
                       ,bool*            pMayCreate
@@ -363,12 +334,11 @@ public:
                     ,int    nY
                     ,WXUINT uFlag
                    );
-    bool HandleGetMinMaxInfo(void* pMmInfo);
+    bool HandleGetMinMaxInfo(PSWP pMmInfo);
     bool HandleShow( bool bShow
                     ,int  nStatus
                    );
     bool HandleActivate( int    nFlag
-                        ,bool   bMinimized
                         ,WXHWND hActivate
                        );
     bool HandleCommand( WXWORD nId
@@ -378,26 +348,16 @@ public:
     bool HandleSysCommand( WXWPARAM wParam
                           ,WXLPARAM lParam
                          );
-    bool HandleCtlColor( WXHBRUSH* phBrush
-                        ,WXHDC     hDc
-                        ,WXHWND    hWnd
-                        ,WXUINT    uCtlColor
-                        ,WXUINT    uMessage
-                        ,WXWPARAM  wParam
-                        ,WXLPARAM  lParam
-                       );
-    bool HandlePaletteChanged(WXHWND hWndPalChange);
+    bool HandlePaletteChanged(void);
     bool HandleQueryNewPalette(void);
     bool HandleSysColorChange(void);
-    bool HandleQueryEndSession( long  lLogOff
-                               ,bool* pbMayEnd
-                              );
-    bool HandleEndSession( bool bEndSession
-                          ,long lLogOff
-                         );
+    bool HandleDisplayChange(void);
+    bool HandleCaptureChanged(WXHWND hBainedCapture);
+
+    bool HandleCtlColor(WXHBRUSH* hBrush);
     bool HandleSetFocus(WXHWND hWnd);
     bool HandleKillFocus(WXHWND hWnd);
-    bool HandleDropFiles(WXWPARAM wParam);
+    bool HandleEndDrag(WXWPARAM wParam);
     bool HandleMouseEvent( WXUINT uMsg
                           ,int    nX
                           ,int    nY
@@ -407,42 +367,46 @@ public:
                          ,int    nY
                          ,WXUINT uFlags
                         );
-    bool HandleChar( WXWORD   wParam
+    bool HandleChar( WXWPARAM wParam
                     ,WXLPARAM lParam
                     ,bool     bIsASCII = FALSE
                    );
-    bool HandleKeyDown( WXWORD   wParam
+    bool HandleKeyDown( WXWPARAM wParam
                        ,WXLPARAM lParam
                       );
-    bool HandleKeyUp( WXWORD   wParam
+    bool HandleKeyUp( WXWPARAM wParam
                      ,WXLPARAM lParam
                     );
     bool HandleQueryDragIcon(WXHICON* phIcon);
-    bool HandleSetCursor( WXHWND hWnd
-                         ,short  nHitTest
-                         ,int    nMouseMsg
+    bool HandleSetCursor( USHORT vId
+                         ,WXHWND hWnd
                         );
 
+    bool IsMouseInWindow(void) const;
+    bool OS2GetCreateWindowCoords( const wxPoint& rPos
+                                  ,const wxSize&  rSize
+                                  ,int&           rnX
+                                  ,int&           rnY
+                                  ,int&           rnWidth
+                                  ,int&           rnHeight
+                                 ) const;
+
     // Window procedure
-    virtual MRESULT OS2WindowProc( HWND     hwnd
-                                  ,WXUINT   uMsg
+    virtual MRESULT OS2WindowProc( WXUINT   uMsg
                                   ,WXWPARAM wParam
                                   ,WXLPARAM lParam
                                  );
 
     // Calls an appropriate default window procedure
-    virtual MRESULT OS2DefWindowProc( HWND     hwnd
-                                     ,WXUINT   uMsg
+    virtual MRESULT OS2DefWindowProc( WXUINT   uMsg
                                      ,WXWPARAM wParam
                                      ,WXLPARAM lParam
                                     );
     virtual bool    OS2ProcessMessage(WXMSG* pMsg);
+    virtual bool    OS2ShouldPreProcessMessage(WXMSG* pMsg);
     virtual bool    OS2TranslateMessage(WXMSG* pMsg);
     virtual void    OS2DestroyWindow(void);
 
-    // Detach "Window" menu from menu bar so it doesn't get deleted
-    void OS2DetachWindowMenu(void);
-
     // this function should return the brush to paint the window background
     // with or 0 for the default brush
     virtual WXHBRUSH OnCtlColor( WXHDC    hDC
@@ -453,11 +417,6 @@ public:
                                 ,WXLPARAM lParam
                                );
 
-#if WXWIN_COMPATIBILITY
-    void SetShowing(bool bShow) { (void)Show(show); }
-    bool IsUserEnabled(void) const { return IsEnabled(); }
-#endif // WXWIN_COMPATIBILITY
-
     // Responds to colour changes: passes event on to children.
     void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
 
@@ -468,19 +427,34 @@ public:
                         ,WXUINT        uFlags
                        );
 
+    void MoveChildren(int nDiff);
+    PSWP GetSwp(void) {return &m_vWinSwp;}
+
 protected:
+    // PM can't create some MSW styles natively but can perform these after
+    // creation by sending messages
+    typedef enum extra_flags { kFrameToolWindow = 0x0001
+                              ,kVertCaption     = 0x0002
+                              ,kHorzCaption     = 0x0004
+                             } EExtraFlags;
+    // Some internal sizeing id's to make it easy for event handlers
+    typedef enum size_types { kSizeNormal
+                             ,kSizeMax
+                             ,kSizeMin
+                            } ESizeTypes;
     // the window handle
     WXHWND                          m_hWnd;
 
     // the old window proc (we subclass all windows)
     WXFARPROC                       m_fnOldWndProc;
 
-    // additional (MSW specific) flags
+    // additional (OS2 specific) flags
     bool                            m_bUseCtl3D:1; // Using CTL3D for this control
     bool                            m_bBackgroundTransparent:1;
     bool                            m_bMouseInWindow:1;
-    bool                            m_bDoubleClickAllowed:1;
+    bool                            m_bLastKeydownProcessed:1;
     bool                            m_bWinCaptured:1;
+    WXDWORD                         m_dwExStyle;
 
     // the size of one page for scrolling
     int                             m_nXThumbSize;
@@ -494,6 +468,7 @@ protected:
 #endif // wxUSE_MOUSEEVENT_HACK
 
     WXHMENU                         m_hMenu; // Menu, if any
+    unsigned long                   m_ulMenubarId; // it's Id, if any
 
     // the return value of WM_GETDLGCODE handler
     long                            m_lDlgCode;
@@ -524,13 +499,12 @@ protected:
                                  ,int nHeight
                                 );
 
-    // get the size which best suits the window: e.g., for a static text it
-    // will be the width and height of the text
-    virtual wxSize DoGetBestSize(void);
+    virtual void     DoCaptureMouse(void);
+    virtual void     DoReleaseMouse(void);
 
     // move the window to the specified location and resize it: this is called
     // from both DoSetSize() and DoSetClientSize() and would usually just call
-    // ::MoveWindow() except for composite controls which will want to arrange
+    // ::WinSetWindowPos() except for composite controls which will want to arrange
     // themselves inside the given rectangle
     virtual void DoMoveWindow( int nX
                               ,int nY
@@ -542,6 +516,8 @@ protected:
     virtual void DoSetToolTip(wxToolTip* pTip);
 #endif // wxUSE_TOOLTIPS
 
+    int  GetOS2ParentHeight(wxWindowOS2* pParent);
+
 private:
     // common part of all ctors
     void Init(void);
@@ -560,13 +536,35 @@ private:
                       ,WXLPARAM  lParam
                       ,WXLPARAM* pResult
                      );
-    DECLARE_NO_COPY_CLASS(wxWindow);
+    // the helper functions used by HandleChar/KeyXXX methods
+    wxKeyEvent CreateKeyEvent( wxEventType evType
+                              ,int         nId
+                              ,WXLPARAM    lParam = 0
+                              ,WXWPARAM    wParam = 0
+                             ) const;
+
+    wxWindowList*                   m_pChildrenDisabled;
+    HWND                            m_hWndScrollBarHorz;
+    HWND                            m_hWndScrollBarVert;
+    SWP                             m_vWinSwp;
+
+    DECLARE_DYNAMIC_CLASS(wxWindowOS2);
+    DECLARE_NO_COPY_CLASS(wxWindowOS2)
     DECLARE_EVENT_TABLE()
-private:
+
+    //
     // Virtual function hiding supression
+    //
     inline virtual bool Reparent(wxWindowBase* pNewParent)
-    { return(wxWindowBase::Reparent(pNewParent));};
-};
+    { return(wxWindowBase::Reparent(pNewParent));}
+}; // end of wxWindow
+
+class wxWindowCreationHook
+{
+public:
+    wxWindowCreationHook(wxWindow* pWinBeingCreated);
+    ~wxWindowCreationHook();
+}; // end of CLASS wxWindowCreationHook
 
 // ---------------------------------------------------------------------------
 // global functions