]> git.saurik.com Git - wxWidgets.git/commitdiff
1. corrected some owner-drawn buttons bugs
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 Dec 1999 23:00:10 +0000 (23:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 Dec 1999 23:00:10 +0000 (23:00 +0000)
2. added generation of event for EVT_SPINCTRL handler to wxSpinCtrl

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

docs/latex/wx/text.tex
include/wx/msw/spinctrl.h
src/gtk/spinctrl.cpp
src/gtk1/spinctrl.cpp
src/msw/button.cpp
src/msw/spinbutt.cpp
src/msw/spinctrl.cpp

index a9bf9028d5aae5146739a9f7043ebc145d053c1b..8d12aa2afa1d2a3726f58958421d199bd0170934 100644 (file)
@@ -319,7 +319,9 @@ consisting of the from and to values.}
 
 \constfunc{wxString}{GetValue}{\void}
 
-Gets the contents of the control.
+Gets the contents of the control. Notice that for a multiline text control,
+the lines will be separated by (Unix-style) '\\n' characters, even under
+Windows where they are separated by "\\r\\n" sequence in the native control.
 
 \membersection{wxTextCtrl::IsModified}\label{wxtextctrlismodified}
 
index dbf42d7e7a39f9b1d519ede34f1a4217b8641cb5..f6c8f8fd52210371cb0aa158cc366bbab3243983 100644 (file)
@@ -63,9 +63,14 @@ protected:
     virtual void DoMoveWindow(int x, int y, int width, int height);
     virtual wxSize DoGetBestSize() const;
 
+    // the handler for wxSpinButton events
+    void OnSpinChange(wxSpinEvent& event);
+
     WXHWND m_hwndBuddy;
 
+private:
     DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
+    DECLARE_EVENT_TABLE()
 };
 
 #endif // _WX_MSW_SPINCTRL_H_
index d7bbb53e30baffad4e1ace13c2fa3f6f3323cc91..10651bf7659f31e220bd2c3a4596604537d95a1a 100644 (file)
@@ -83,7 +83,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
         !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name ))
     {
         wxFAIL_MSG( wxT("wxSpinCtrl creation failed") );
-       return FALSE;
+        return FALSE;
     }
 
     m_oldPos = initial;
@@ -196,13 +196,13 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event )
         wxWindow *top_frame = m_parent;
         while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
             top_frame = top_frame->GetParent();
-       GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+        GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
 
-       if (window->default_widget)
+        if (window->default_widget)
         {
             gtk_widget_activate (window->default_widget);
-           return;
-       }
+            return;
+        }
     }
 
     event.Skip();
index d7bbb53e30baffad4e1ace13c2fa3f6f3323cc91..10651bf7659f31e220bd2c3a4596604537d95a1a 100644 (file)
@@ -83,7 +83,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
         !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name ))
     {
         wxFAIL_MSG( wxT("wxSpinCtrl creation failed") );
-       return FALSE;
+        return FALSE;
     }
 
     m_oldPos = initial;
@@ -196,13 +196,13 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event )
         wxWindow *top_frame = m_parent;
         while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
             top_frame = top_frame->GetParent();
-       GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+        GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
 
-       if (window->default_widget)
+        if (window->default_widget)
         {
             gtk_widget_activate (window->default_widget);
-           return;
-       }
+            return;
+        }
     }
 
     event.Skip();
index 5c30bf807b52df929c0bfecac15f0bb834326850..a7df197b6c67f450d83bb11d7e2f4981ddf48300 100644 (file)
@@ -305,7 +305,7 @@ static void DrawRect(HDC hdc, const RECT& r)
 void wxButton::MakeOwnerDrawn()
 {
     long style = GetWindowLong(GetHwnd(), GWL_STYLE);
-    if ( !(style & BS_OWNERDRAW) )
+    if ( (style & BS_OWNERDRAW) != BS_OWNERDRAW )
     {
         // make it so
         style |= BS_OWNERDRAW;
@@ -475,6 +475,12 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis)
         DrawFocusRect(hdc, &rectFocus);
     }
 
+    if ( pushed )
+    {
+        // the label is shifted by 1 pixel to create "pushed" effect
+        OffsetRect(&rectBtn, 1, 1);
+    }
+
     DrawButtonText(hdc, &rectBtn, GetLabel(),
                    state & ODS_DISABLED ? GetSysColor(COLOR_GRAYTEXT)
                                         : colFg);
index deafa898b21535fcea7cbe040a8a518364843cf5..9c3b36bffb3f90220470cf126173e5e3aa303a8f 100644 (file)
@@ -54,8 +54,8 @@
 // wxWin macros
 // ----------------------------------------------------------------------------
 
-    IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
-    IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
+IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
 
 // ----------------------------------------------------------------------------
 // wxSpinButton
index 27b0b26c2d4c64864b768e42823d405d6dbd69a6..1724bf68d837687a197a2d3d9c5c704c8303f5b6 100644 (file)
 // macros
 // ----------------------------------------------------------------------------
 
-    IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
+
+BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton)
+    EVT_SPIN(-1, wxSpinCtrl::OnSpinChange)
+END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
 // constants
@@ -201,6 +205,24 @@ bool wxSpinCtrl::SetFont(const wxFont& font)
     return TRUE;
 }
 
+// ----------------------------------------------------------------------------
+// event processing
+// ----------------------------------------------------------------------------
+
+void wxSpinCtrl::OnSpinChange(wxSpinEvent& eventSpin)
+{
+    wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, GetId());
+    event.SetEventObject(this);
+    event.SetInt(eventSpin.GetPosition());
+
+    (void)GetEventHandler()->ProcessEvent(event);
+
+    if ( eventSpin.GetSkipped() )
+    {
+        event.Skip();
+    }
+}
+
 // ----------------------------------------------------------------------------
 // size calculations
 // ----------------------------------------------------------------------------