]> git.saurik.com Git - wxWidgets.git/commitdiff
1. status bar can now be positioned on top (and anywhere, in fact)
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Mar 2000 00:45:54 +0000 (00:45 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 14 Mar 2000 00:45:54 +0000 (00:45 +0000)
2. status bar without wxST_SIZEGRIP style won't have the size grip (wow)
3. scrollbars don't get the cursor of the main window any more
4. introduced wxSetCursorEvent and use it in wxSplitterWindow

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/event.h
include/wx/generic/splitter.h
include/wx/statusbr.h
src/generic/splitter.cpp
src/msw/statbr95.cpp
src/msw/window.cpp

index cae98ae030cc39b8ce8ae4b03ae5bc15af47fedf..5e2203e7e68591a70c41237d1489f869bb8f6dca 100644 (file)
@@ -54,6 +54,8 @@ wxMSW:
 - support for enhanced metafiles added, support for copying/pasting metafiles
   (WMF and enhanced ones) fixed/added.
 - implemented setting colours for push buttons
+- wxStatusBar95 may be now used in dialogs, panels (not only frames) and can be
+   positioned along the top of the screen and not only at the bottom
 - wxTreeCtrl::IsVisible() bug fixed (thanks to Gary Chessun)
 - loading/saving big (> 32K) files in wxTextCtrl works
 - tooltips work with wxRadioBox
index 98cdf33d1139c4c7387aacb00042388a7603cf27..a9303f12ad51db9a36de4900afe987824e24d20d 100644 (file)
@@ -21,6 +21,7 @@
 
 #if wxUSE_GUI
     #include "wx/gdicmn.h"
+    #include "wx/cursor.h"
 #endif
 
 #include "wx/thread.h"
@@ -118,6 +119,9 @@ enum
     wxEVT_KEY_DOWN =                          wxEVT_FIRST + 215,
     wxEVT_KEY_UP =                            wxEVT_FIRST + 216,
 
+    /* Set cursor event */
+    wxEVT_SET_CURSOR =                        wxEVT_FIRST + 230,
+
     /*
      * wxScrollbar and wxSlider event identifiers
      */
@@ -714,6 +718,35 @@ public:
     bool          m_metaDown;
 };
 
+// Cursor set event
+
+/*
+   wxEVT_SET_CURSOR
+ */
+
+class WXDLLEXPORT wxSetCursorEvent : public wxEvent
+{
+public:
+    wxSetCursorEvent(wxCoord x, wxCoord y)
+    {
+        m_eventType = wxEVT_SET_CURSOR;
+
+        m_x = x;
+        m_y = y;
+    }
+
+    wxCoord GetX() const { return m_x; }
+    wxCoord GetY() const { return m_y; }
+
+    void SetCursor(const wxCursor& cursor) { m_cursor = cursor; }
+    const wxCursor& GetCursor() const { return m_cursor; }
+    bool HasCursor() const { return m_cursor.Ok(); }
+
+private:
+    wxCoord  m_x, m_y;
+    wxCursor m_cursor;
+};
+
 // Keyboard input event class
 
 /*
@@ -1555,6 +1588,9 @@ typedef void (wxEvtHandler::*wxMaximizeEventFunction)(wxShowEvent&);
 typedef void (wxEvtHandler::*wxNavigationKeyEventFunction)(wxNavigationKeyEvent&);
 typedef void (wxEvtHandler::*wxPaletteChangedEventFunction)(wxPaletteChangedEvent&);
 typedef void (wxEvtHandler::*wxQueryNewPaletteEventFunction)(wxQueryNewPaletteEvent&);
+typedef void (wxEvtHandler::*wxWindowCreateEventFunction)(wxWindowCreateEvent&);
+typedef void (wxEvtHandler::*wxWindowDestroyEventFunction)(wxWindowDestroyEvent&);
+typedef void (wxEvtHandler::*wxSetCursorEventFunction)(wxSetCursorEvent&);
 #endif // wxUSE_GUI
 
 // N.B. In GNU-WIN32, you *have* to take the address of a member function
@@ -1613,8 +1649,9 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \
 #define EVT_NAVIGATION_KEY(func) { wxEVT_NAVIGATION_KEY, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNavigationKeyEventFunction) & func, (wxObject *) NULL },
 #define EVT_PALETTE_CHANGED(func) { wxEVT_PALETTE_CHANGED, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxPaletteChangedEventFunction) & func, (wxObject *) NULL },
 #define EVT_QUERY_NEW_PALETTE(func) { wxEVT_QUERY_NEW_PALETTE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryNewPaletteEventFunction) & func, (wxObject *) NULL },
-#define EVT_WINDOW_CREATE(func) { wxEVT_CREATE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryNewPaletteEventFunction) & func, (wxObject *) NULL },
-#define EVT_WINDOW_DESTROY(func) { wxEVT_DESTROY, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxQueryNewPaletteEventFunction) & func, (wxObject *) NULL },
+#define EVT_WINDOW_CREATE(func) { wxEVT_CREATE, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxWindowCreateEventFunction) & func, (wxObject *) NULL },
+#define EVT_WINDOW_DESTROY(func) { wxEVT_DESTROY, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxWindowDestroyEventFunction) & func, (wxObject *) NULL },
+#define EVT_SET_CURSOR(func) { wxEVT_SET_CURSOR, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSetCursorEventFunction) & func, (wxObject *) NULL },
 
 // Mouse events
 #define EVT_LEFT_DOWN(func) { wxEVT_LEFT_DOWN, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, (wxObject *) NULL },
index d74fc68403268044fd2fdecb81bc322298cd4448..4bdd5ace6af046d6230f9eefeddf94f0aaac45f5 100644 (file)
@@ -187,6 +187,7 @@ protected:
     void OnSashPosChanging(wxSplitterEvent& event);
     void OnDoubleClick(wxSplitterEvent& event);
     void OnUnsplitEvent(wxSplitterEvent& event);
+    void OnSetCursor(wxSetCursorEvent& event);
 
     void SendUnsplitEvent(wxWindow *winRemoved);
 
index 4a0345ec52c3883af4db7c38b594bb8effe6edb2..029c7cb62126b63d9adf9444dfa45addef0b9304 100644 (file)
@@ -71,7 +71,7 @@ public:
                 wxWindowID id,
                 const wxPoint& WXUNUSED(pos) = wxDefaultPosition,
                 const wxSize& WXUNUSED(size) = wxDefaultSize,
-                long style = 0,
+                long style = wxST_SIZEGRIP,
                 const wxString& name = wxPanelNameStr)
     {
         Create(parent, id, style, name);
index e6a00ded5eb36c6f195a91da22160dee67532b96..6f45254813e16188c000d716f43d8d4ecae62391 100644 (file)
@@ -42,6 +42,8 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
     EVT_IDLE(wxSplitterWindow::OnIdle)
     EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent)
 
+    EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor)
+
     EVT_SPLITTER_SASH_POS_CHANGED(-1, wxSplitterWindow::OnSashPosChanged)
     // NB: we borrow OnSashPosChanged for purposes of
     // EVT_SPLITTER_SASH_POS_CHANGING since default implementation is identical
@@ -234,8 +236,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
             }
         }
 
-        if ( m_permitUnsplitAlways
-                || m_minimumPaneSize == 0 )
+        if ( m_permitUnsplitAlways || m_minimumPaneSize == 0 )
         {
             // Deal with possible unsplit scenarios
             if ( new_sash_position == 0 )
@@ -930,3 +931,21 @@ void wxSplitterWindow::OnUnsplitEvent(wxSplitterEvent& event)
     // for compatibility, call the virtual function
     OnUnsplit(win);
 }
+
+void wxSplitterWindow::OnSetCursor(wxSetCursorEvent& event)
+{
+    // this is currently called (and needed) under MSW only...
+#ifdef __WXMSW__
+
+    // if we don't do it, the resizing cursor might be set for child window:
+    // and like this we explicitly say that our cursor should not be used for
+    // children windows which overlap us
+
+    if ( SashHitTest(event.GetX(), event.GetY()) )
+    {
+        // default processing is ok
+        event.Skip();
+    }
+    //else: do nothing, in particular, don't call Skip()
+#endif // wxMSW
+}
index 86937ad4a9f7ae4c8b051ab700c6807ebd2e4065..c3cf3960bf90027def653d071e09cc83c8bd3626 100644 (file)
@@ -109,8 +109,22 @@ bool wxStatusBar95::Create(wxWindow *parent,
     m_windowId = id == -1 ? NewControlId() : id;
 
     DWORD wstyle = WS_CHILD | WS_VISIBLE;
-    if ( style & wxST_SIZEGRIP )
+
+    // setting SBARS_SIZEGRIP is perfectly useless: it's always on by default
+    // (at least in the version of comctl32.dll I'm using), and the only way to
+    // turn it off is to use CCS_TOP style - as we position the status bar
+    // manually anyhow (see DoMoveWindow), use CCS_TOP style if wxST_SIZEGRIP
+    // is not given
+    if ( !(style & wxST_SIZEGRIP) )
+    {
+        wstyle |= CCS_TOP;
+    }
+    else
+    {
+        // may be some versions of comctl32.dll do need it - anyhow, it won't
+        // do any harm
         wstyle |= SBARS_SIZEGRIP;
+    }
 
     m_hWnd = (WXHWND)CreateStatusWindow(wstyle,
                                         wxEmptyString,
@@ -303,10 +317,21 @@ bool wxStatusBar95::GetFieldRect(int i, wxRect& rect) const
 
 void wxStatusBar95::DoMoveWindow(int x, int y, int width, int height)
 {
-  FORWARD_WM_SIZE(GetHwnd(), SIZE_RESTORED, x, y, SendMessage);
-
-  // adjust fields widths to the new size
-  SetFieldsWidth();
+    // the status bar wnd proc must be forwarded the WM_SIZE message whenever
+    // the stat bar position/size is changed because it normally positions the
+    // control itself along bottom or top side of the parent window - failing
+    // to do so will result in nasty visual effects
+    FORWARD_WM_SIZE(GetHwnd(), SIZE_RESTORED, x, y, SendMessage);
+
+    // but now, when the standard status bar wnd proc did all it wanted to do,
+    // move the status bar to its correct location - usually this call may be
+    // omitted because for normal status bars (positioned along the bottom
+    // edge) the position is already set correctly, but if the user wants to
+    // position them in some exotic location, this is really needed
+    wxWindow::DoMoveWindow(x, y, width, height);
+
+    // adjust fields widths to the new size
+    SetFieldsWidth();
 }
 
 #endif // __WIN95__ && wxUSE_NATIVE_STATUSBAR
index 9e92ac4db25ab04d0b481b7c3c2073af17c1dcc1..b8533b3dfbb39aa5756764f3b536645a71e38725 100644 (file)
@@ -2667,29 +2667,65 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd,
                                int WXUNUSED(mouseMsg))
 {
     // the logic is as follows:
+    // -1. don't set cursor for non client area, including but not limited to
+    //     the title bar, scrollbars, &c
+    //  0. allow the user to override default behaviour by using EVT_SET_CURSOR
     //  1. if we have the cursor set it unless wxIsBusy()
     //  2. if we're a top level window, set some cursor anyhow
     //  3. if wxIsBusy(), set the busy cursor, otherwise the global one
 
+    if ( nHitTest != HTCLIENT )
+    {
+        return FALSE;
+    }
+
     HCURSOR hcursor = 0;
-    bool isBusy = wxIsBusy();
-    if ( m_cursor.Ok() )
+
+    // first ask the user code - it may wish to set the cursor in some very
+    // specific way (for example, depending on the current position)
+    POINT pt;
+    if ( !::GetCursorPos(&pt) )
+    {
+        wxLogLastError("GetCursorPos");
+    }
+
+    int x = pt.x,
+        y = pt.y;
+    ScreenToClient(&x, &y);
+    wxSetCursorEvent event(x, y);
+
+    bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event);
+    if ( processedEvtSetCursor && event.HasCursor() )
     {
-        hcursor = GetHcursorOf(m_cursor);
+        hcursor = GetHcursorOf(event.GetCursor());
     }
 
-    if ( !GetParent() )
+    if ( !hcursor )
     {
-        if ( isBusy )
+        bool isBusy = wxIsBusy();
+
+        // the test for processedEvtSetCursor is here to prevent using m_cursor
+        // if the user code caught EVT_SET_CURSOR() and returned nothing from
+        // it - this is a way to say that our cursor shouldn't be used for this
+        // point
+        if ( !processedEvtSetCursor && m_cursor.Ok() )
         {
-            hcursor = wxGetCurrentBusyCursor();
+            hcursor = GetHcursorOf(m_cursor);
         }
-        else if ( !hcursor )
+
+        if ( !GetParent() )
         {
-            const wxCursor *cursor = wxGetGlobalCursor();
-            if ( cursor && cursor->Ok() )
+            if ( isBusy )
             {
-                hcursor = GetHcursorOf(*cursor);
+                hcursor = wxGetCurrentBusyCursor();
+            }
+            else if ( !hcursor )
+            {
+                const wxCursor *cursor = wxGetGlobalCursor();
+                if ( cursor && cursor->Ok() )
+                {
+                    hcursor = GetHcursorOf(*cursor);
+                }
             }
         }
     }