X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..50c319beec2454b4f669b6c8cf3d089f53c979f6:/src/msw/slider95.cpp diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index f3f1e696b9..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 @@ -68,8 +68,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 +154,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 +167,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); } } } @@ -328,6 +330,15 @@ 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; } @@ -346,6 +357,8 @@ void wxSlider95::SetSize(int x, int y, int width, int height, int sizeFlags) if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) y1 = currentY; + AdjustForParentClientOrigin(x1, y1, sizeFlags); + char buf[300]; int x_offset = x; @@ -355,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, & GetFont()); if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL) { @@ -364,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, & 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, & GetFont()); if (m_staticValue) { int new_width = (int)(wxMax(min_len, max_len)); @@ -407,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 ) @@ -420,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, & 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, & GetFont()); if (m_staticValue) { @@ -468,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 )