X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/da87a1ca42a81c7b7b69cb013eb52d09cd5c1b70..4a33eba645f96bf7a89397d7dbadd7d62ee2fde1:/src/msw/slider95.cpp diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index 4eb5ad1075..6e5f9c4ba3 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -36,11 +36,11 @@ #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxSlider95, wxControl) -#if WXWIN_COMPATIBILITY BEGIN_EVENT_TABLE(wxSlider95, wxControl) +#if WXWIN_COMPATIBILITY EVT_SCROLL(wxSlider95::OnScroll) -END_EVENT_TABLE() #endif +END_EVENT_TABLE() #endif @@ -57,10 +57,10 @@ wxSlider95::wxSlider95(void) m_tickFreq = 0; } -bool wxSlider95::Create(wxWindow *parent, const wxWindowID id, - const int value, const int minValue, const int maxValue, +bool wxSlider95::Create(wxWindow *parent, wxWindowID id, + int value, int minValue, int maxValue, const wxPoint& pos, - const wxSize& size, const long style, + const wxSize& size, long style, const wxValidator& validator, const wxString& name) { @@ -68,8 +68,8 @@ bool wxSlider95::Create(wxWindow *parent, const 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 +154,10 @@ bool wxSlider95::Create(wxWindow *parent, const wxWindowID id, SubclassWin(GetHWND()); + SetWindowText((HWND) m_hWnd, ""); + + SetFont(parent->GetFont()); + if ( m_windowStyle & wxSL_LABELS ) { // Finally, create max value static item @@ -163,22 +167,20 @@ bool wxSlider95::Create(wxWindow *parent, const 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); } } } @@ -189,7 +191,7 @@ bool wxSlider95::Create(wxWindow *parent, const wxWindowID id, return TRUE; } -void wxSlider95::MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control) +void wxSlider95::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control) { int position = 0; // Dummy - not used in this mode @@ -257,7 +259,7 @@ void wxSlider95::MSWOnVScroll(const WXWORD wParam, const WXWORD pos, const WXHWN } } -void wxSlider95::MSWOnHScroll(const WXWORD wParam, const WXWORD pos, const WXHWND control) +void wxSlider95::MSWOnHScroll(WXWORD wParam, WXWORD pos, WXHWND control) { MSWOnVScroll(wParam, pos, control); } @@ -277,7 +279,7 @@ int wxSlider95::GetValue(void) const return ::SendMessage((HWND) GetHWND(), TBM_GETPOS, 0, 0); } -void wxSlider95::SetValue(const int value) +void wxSlider95::SetValue(int value) { ::SendMessage((HWND) GetHWND(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value); if (m_staticValue) @@ -328,11 +330,20 @@ void wxSlider95::GetPosition(int *x, int *y) const if (parent) ::ScreenToClient((HWND) parent->GetHWND(), &point); + // We may be faking the client origin. + // So a window that's really at (0, 30) may appear + // (to wxWin apps) to be at (0, 0). + if (GetParent()) + { + wxPoint pt(GetParent()->GetClientAreaOrigin()); + point.x -= pt.x; + point.y -= pt.y; + } *x = point.x; *y = point.y; } -void wxSlider95::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags) +void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) { int x1 = x; int y1 = y; @@ -346,6 +357,8 @@ void wxSlider95::SetSize(const int x, const int y, const int width, const int he if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) y1 = currentY; + AdjustForParentClientOrigin(x1, y1, sizeFlags); + char buf[300]; int x_offset = x; @@ -353,23 +366,23 @@ void wxSlider95::SetSize(const int x, const int y, const int width, const int he int cx; // slider,min,max sizes int cy; - float cyf; + int cyf; - wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, & GetFont()); if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) { if ( m_windowStyle & wxSL_LABELS ) { - float min_len = 0.0; + 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, & GetFont()); - float max_len = 0.0; + 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, & GetFont()); if (m_staticValue) { int new_width = (int)(wxMax(min_len, max_len)); @@ -407,6 +420,11 @@ void wxSlider95::SetSize(const int x, const int y, const int width, const int he 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 ) @@ -418,13 +436,13 @@ void wxSlider95::SetSize(const int x, const int y, const int width, const int he { if ( m_windowStyle & wxSL_LABELS ) { - float min_len; + int min_len; GetWindowText((HWND) m_staticMin, buf, 300); - GetTextExtent(buf, &min_len, &cyf,NULL,NULL,GetFont()); + GetTextExtent(buf, &min_len, &cyf,NULL,NULL, & GetFont()); - float max_len; + int max_len; GetWindowText((HWND) m_staticMax, buf, 300); - GetTextExtent(buf, &max_len, &cyf,NULL,NULL, GetFont()); + GetTextExtent(buf, &max_len, &cyf,NULL,NULL, & GetFont()); if (m_staticValue) { @@ -468,6 +486,11 @@ void wxSlider95::SetSize(const int x, const int y, const int width, const int he 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 ) @@ -477,7 +500,7 @@ void wxSlider95::SetSize(const int x, const int y, const int width, const int he } } -void wxSlider95::SetRange(const int minValue, const int maxValue) +void wxSlider95::SetRange(int minValue, int maxValue) { m_rangeMin = minValue; m_rangeMax = maxValue; @@ -498,7 +521,7 @@ void wxSlider95::SetRange(const int minValue, const int maxValue) } } -WXHBRUSH wxSlider95::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor, +WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { if ( nCtlColor == CTLCOLOR_SCROLLBAR ) @@ -518,13 +541,13 @@ WXHBRUSH wxSlider95::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT } // For trackbars only -void wxSlider95::SetTickFreq(const int n, const int pos) +void wxSlider95::SetTickFreq(int n, int pos) { m_tickFreq = n; ::SendMessage( (HWND) GetHWND(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos ); } -void wxSlider95::SetPageSize(const int pageSize) +void wxSlider95::SetPageSize(int pageSize) { ::SendMessage( (HWND) GetHWND(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize ); m_pageSize = pageSize; @@ -545,7 +568,7 @@ void wxSlider95::ClearTicks(void) ::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 ); } -void wxSlider95::SetLineSize(const int lineSize) +void wxSlider95::SetLineSize(int lineSize) { m_lineSize = lineSize; ::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize ); @@ -566,12 +589,12 @@ int wxSlider95::GetSelStart(void) const return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 ); } -void wxSlider95::SetSelection(const int minPos, const int maxPos) +void wxSlider95::SetSelection(int minPos, int maxPos) { ::SendMessage( (HWND) GetHWND(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) ); } -void wxSlider95::SetThumbLength(const int len) +void wxSlider95::SetThumbLength(int len) { ::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 ); } @@ -581,7 +604,7 @@ int wxSlider95::GetThumbLength(void) const return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 ); } -void wxSlider95::SetTick(const int tickPos) +void wxSlider95::SetTick(int tickPos) { ::SendMessage( (HWND) GetHWND(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos ); } @@ -612,7 +635,7 @@ void wxSlider95::Command (wxCommandEvent & event) ProcessCommand (event); } -bool wxSlider95::Show(const bool show) +bool wxSlider95::Show(bool show) { wxWindow::Show(show);