]> git.saurik.com Git - wxWidgets.git/commitdiff
show resize grip on resizeable dialogs (slightly modified patch 1910654)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 May 2008 17:12:36 +0000 (17:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 11 May 2008 17:12:36 +0000 (17:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53554 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/msw/dialog.h
src/msw/dialog.cpp

index 035f9af941b5a69f310a15bf532e010a6d3b5504..2c01c0deb9dbf4d4eeede2fecce15d61e375f4ff 100644 (file)
@@ -353,6 +353,7 @@ wxMSW:
 - Allow tooltips longer than 64 (up to 128) characters in wxTaskBarIcon
 - Fix centering wxFileDialog and allow positioning it
 - Allow centering wxMessageDialog on its parent window (troelsk)
+- Show resize gripper on resizeable dialogs (Kolya Kosenko)
 - Implement support for display enumeration under WinCE (Vince Harron)
 - Use different Win32 class names in different wx instances (Thomas Hauk)
 
index e29a5e045f0f282e21c70314f78f3005964a3f71..cf91c11961f56365a05127c8434c1740f475c8c8 100644 (file)
@@ -85,6 +85,8 @@ public:
 
     virtual void Raise();
 
+    virtual void SetWindowStyleFlag(long style);
+
 #ifdef __POCKETPC__
     // Responds to the OK button in a PocketPC titlebar. This
     // can be overridden, or you can change the id used for
@@ -106,6 +108,13 @@ protected:
     // common part of all ctors
     void Init();
 
+    // these functions deal with the gripper window shown in the corner of
+    // resizeable dialogs
+    void CreateGripper();
+    void DestroyGripper();
+    void ShowGripper(bool show);
+    void ResizeGripper();
+
 private:
     wxWindow*   m_oldFocus;
     bool        m_endModalCalled; // allow for closing within InitDialog
@@ -117,6 +126,9 @@ private:
     // this pointer is non-NULL only while the modal event loop is running
     wxDialogModalData *m_modalData;
 
+    // gripper window for a resizable dialog, NULL if we're not resizable
+    WXHWND m_hGripper;
+
     DECLARE_DYNAMIC_CLASS(wxDialog)
     DECLARE_NO_COPY_CLASS(wxDialog)
 };
index 4fce3f8d479dff61bf79002bca691849a1e51862..64d7f61bc6c404f8708f98cef6e13f6350c54945 100644 (file)
@@ -152,6 +152,7 @@ void wxDialog::Init()
 #if wxUSE_TOOLBAR && defined(__POCKETPC__)
     m_dialogToolBar = NULL;
 #endif
+    m_hGripper = 0;
 }
 
 bool wxDialog::Create(wxWindow *parent,
@@ -183,6 +184,9 @@ bool wxDialog::Create(wxWindow *parent,
     CreateToolBar();
 #endif
 
+    if( HasFlag(wxRESIZE_BORDER) )
+        CreateGripper();
+
     return true;
 }
 
@@ -192,6 +196,8 @@ wxDialog::~wxDialog()
 
     // this will also reenable all the other windows for a modal dialog
     Show(false);
+
+    DestroyGripper();
 }
 
 // ----------------------------------------------------------------------------
@@ -335,6 +341,75 @@ void wxDialog::EndModal(int retCode)
     Hide();
 }
 
+// ----------------------------------------------------------------------------
+// wxDialog gripper handling
+// ----------------------------------------------------------------------------
+
+void wxDialog::SetWindowStyleFlag(long style)
+{
+    wxDialogBase::SetWindowStyleFlag(style);
+
+    if( HasFlag(wxRESIZE_BORDER) )
+        CreateGripper();
+    else
+        DestroyGripper();
+}
+
+void wxDialog::CreateGripper()
+{
+    if( !m_hGripper )
+    {
+        m_hGripper = (WXHWND)::CreateWindow
+                               (
+                                    wxT("SCROLLBAR"),
+                                    wxT(""),
+                                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
+                                    SBS_SIZEGRIP |
+                                    SBS_SIZEBOX |
+                                    SBS_SIZEBOXBOTTOMRIGHTALIGN,
+                                    0, 0, 0, 0,
+                                    GetHwnd(),
+                                    0,
+                                    wxGetInstance(),
+                                    NULL
+                               );
+
+        // position the gripper correctly after creation
+        ResizeGripper();
+    }
+}
+
+void wxDialog::DestroyGripper()
+{
+    if ( m_hGripper )
+    {
+        ::DestroyWindow((HWND) m_hGripper);
+        m_hGripper = 0;
+    }
+}
+
+void wxDialog::ShowGripper(bool show)
+{
+    wxASSERT_MSG( m_hGripper, _T("shouldn't be called if we have no gripper") );
+
+    ::ShowWindow((HWND)m_hGripper, show ? SW_SHOW : SW_HIDE);
+}
+
+void wxDialog::ResizeGripper()
+{
+    wxASSERT_MSG( m_hGripper, _T("shouldn't be called if we have no gripper") );
+
+    HWND hwndGripper = (HWND)m_hGripper;
+
+    const wxRect rectGripper = wxRectFromRECT(wxGetWindowRect(hwndGripper));
+    const wxSize size = GetClientSize() - rectGripper.GetSize();
+
+    ::SetWindowPos(hwndGripper, HWND_BOTTOM,
+                   size.x, size.y,
+                   rectGripper.width, rectGripper.height,
+                   SWP_NOACTIVATE);
+}
+
 // ----------------------------------------------------------------------------
 // wxWin event handlers
 // ----------------------------------------------------------------------------
@@ -416,6 +491,23 @@ WXLRESULT wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPar
             break;
 
         case WM_SIZE:
+            if ( m_hGripper )
+            {
+                switch ( wParam )
+                {
+                    case SIZE_MAXIMIZED:
+                        ShowGripper(false);
+                        break;
+
+                    case SIZE_RESTORED:
+                        ShowGripper(true);
+                        // fall through
+
+                    default:
+                        ResizeGripper();
+                }
+            }
+
             // the Windows dialogs unfortunately are not meant to be resizeable
             // at all and their standard class doesn't include CS_[VH]REDRAW
             // styles which means that the window is not refreshed properly