X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/81d66cf39f810503baed79213bc3122fda0ccc7b..e702ff0f08a54622a6b0f1e2ec39537b082c3a8e:/src/msw/slider95.cpp diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 883951314d..d7a322184a 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -22,6 +22,8 @@ #ifndef WX_PRECOMP #include +#include +#include #endif #ifdef __WIN95__ @@ -29,23 +31,16 @@ #include "wx/msw/slider95.h" #include "wx/msw/private.h" -#if defined(__WIN95__) && !defined(__GNUWIN32__) +#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) #include #endif #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSlider95, wxControl) - -#if WXWIN_COMPATIBILITY -BEGIN_EVENT_TABLE(wxSlider95, wxControl) - EVT_SCROLL(wxSlider95::OnScroll) -END_EVENT_TABLE() -#endif - #endif // Slider -wxSlider95::wxSlider95(void) +wxSlider95::wxSlider95() { m_staticValue = 0; m_staticMin = 0; @@ -68,8 +63,8 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; m_staticValue = 0; m_staticMin = 0; @@ -154,6 +149,10 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, SubclassWin(GetHWND()); + SetWindowText((HWND) m_hWnd, ""); + + SetFont(parent->GetFont()); + if ( m_windowStyle & wxSL_LABELS ) { // Finally, create max value static item @@ -163,22 +162,20 @@ bool wxSlider95::Create(wxWindow *parent, wxWindowID id, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)NewControlId(), wxGetInstance(), NULL); - SetFont(parent->GetFont()); - if (GetFont()) + if (GetFont().Ok()) { -// GetFont()->RealizeResource(); - if (GetFont()->GetResourceHandle()) + if (GetFont().GetResourceHandle()) { if ( m_staticMin ) SendMessage((HWND)m_staticMin,WM_SETFONT, - (WPARAM)GetFont()->GetResourceHandle(),0L); + (WPARAM)GetFont().GetResourceHandle(),0L); if ( m_staticMax ) SendMessage((HWND)m_staticMax,WM_SETFONT, - (WPARAM)GetFont()->GetResourceHandle(),0L); + (WPARAM)GetFont().GetResourceHandle(),0L); if (m_staticValue) SendMessage((HWND)m_staticValue,WM_SETFONT, - (WPARAM)GetFont()->GetResourceHandle(),0L); + (WPARAM)GetFont().GetResourceHandle(),0L); } } } @@ -253,6 +250,11 @@ void wxSlider95::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control) event.SetPosition(newPos); event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); + + wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() ); + cevent.SetEventObject( this ); + GetEventHandler()->ProcessEvent( cevent ); + } } } @@ -262,7 +264,7 @@ void wxSlider95::MSWOnHScroll(WXWORD wParam, WXWORD pos, WXHWND control) MSWOnVScroll(wParam, pos, control); } -wxSlider95::~wxSlider95(void) +wxSlider95::~wxSlider95() { if (m_staticMin) DestroyWindow((HWND) m_staticMin); @@ -272,7 +274,7 @@ wxSlider95::~wxSlider95(void) DestroyWindow((HWND) m_staticValue); } -int wxSlider95::GetValue(void) const +int wxSlider95::GetValue() const { return ::SendMessage((HWND) GetHWND(), TBM_GETPOS, 0, 0); } @@ -341,7 +343,7 @@ void wxSlider95::GetPosition(int *x, int *y) const *y = point.y; } -void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) +void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int x1 = x; int y1 = y; @@ -366,7 +368,7 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) int cy; int cyf; - wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont()); if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) { @@ -375,12 +377,12 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) int min_len = 0; GetWindowText((HWND) m_staticMin, buf, 300); - GetTextExtent(buf, &min_len, &cyf,NULL,NULL, GetFont()); + GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & this->GetFont()); int max_len = 0; GetWindowText((HWND) m_staticMax, buf, 300); - GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); + GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & this->GetFont()); if (m_staticValue) { int new_width = (int)(wxMax(min_len, max_len)); @@ -418,6 +420,11 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) else { // No labels + // If we're prepared to use the existing size, then... + if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)) + { + GetSize(&w1, &h1); + } if ( w1 < 0 ) w1 = 200; if ( h1 < 0 ) @@ -431,11 +438,11 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) { int min_len; GetWindowText((HWND) m_staticMin, buf, 300); - GetTextExtent(buf, &min_len, &cyf,NULL,NULL,GetFont()); + GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & this->GetFont()); int max_len; GetWindowText((HWND) m_staticMax, buf, 300); - GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); + GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & this->GetFont()); if (m_staticValue) { @@ -479,6 +486,11 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) else { // No labels + // If we're prepared to use the existing size, then... + if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)) + { + GetSize(&w1, &h1); + } if ( w1 < 0 ) w1 = 20; if ( h1 < 0 ) @@ -541,17 +553,17 @@ void wxSlider95::SetPageSize(int pageSize) m_pageSize = pageSize; } -int wxSlider95::GetPageSize(void) const +int wxSlider95::GetPageSize() const { return m_pageSize; } -void wxSlider95::ClearSel(void) +void wxSlider95::ClearSel() { ::SendMessage( (HWND) GetHWND(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 ); } -void wxSlider95::ClearTicks(void) +void wxSlider95::ClearTicks() { ::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 ); } @@ -562,17 +574,17 @@ void wxSlider95::SetLineSize(int lineSize) ::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize ); } -int wxSlider95::GetLineSize(void) const +int wxSlider95::GetLineSize() const { return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 ); } -int wxSlider95::GetSelEnd(void) const +int wxSlider95::GetSelEnd() const { return (int) ::SendMessage( (HWND) GetHWND(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 ); } -int wxSlider95::GetSelStart(void) const +int wxSlider95::GetSelStart() const { return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 ); } @@ -587,7 +599,7 @@ void wxSlider95::SetThumbLength(int len) ::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 ); } -int wxSlider95::GetThumbLength(void) const +int wxSlider95::GetThumbLength() const { return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 ); } @@ -602,21 +614,6 @@ bool wxSlider95::ContainsHWND(WXHWND hWnd) const return ( hWnd == GetStaticMin() || hWnd == GetStaticMax() || hWnd == GetEditValue() ); } -#if WXWIN_COMPATIBILITY -// Backward compatibility -void wxSlider95::OnScroll(wxScrollEvent& event) -{ - wxEventType oldEvent = event.GetEventType(); - event.SetEventType( wxEVT_COMMAND_SLIDER_UPDATED ); - if ( !GetEventHandler()->ProcessEvent(event) ) - { - event.SetEventType( oldEvent ); - if (!GetParent()->GetEventHandler()->ProcessEvent(event)) - event.Skip(); - } -} -#endif - void wxSlider95::Command (wxCommandEvent & event) { SetValue (event.GetInt());