X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..3d7e30a4186cc3379c3b21040712181a3c6d0b3b:/src/msw/stattext.cpp diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 10a2141417..3c7f1df266 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -32,23 +32,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) #endif -bool wxStaticText::Create(wxWindow *parent, const wxWindowID id, +bool wxStaticText::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, - const long style, + long style, const wxString& name) { SetName(name); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()) ; - SetForegroundColour(parent->GetDefaultForegroundColour()) ; + SetBackgroundColour(parent->GetBackgroundColour()) ; + SetForegroundColour(parent->GetForegroundColour()) ; if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; int x = pos.x; int y = pos.y; @@ -67,15 +67,16 @@ bool wxStaticText::Create(wxWindow *parent, const wxWindowID id, // Even with extended styles, need to combine with WS_BORDER // for them to look right. - if ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || - (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)) + if ( wxStyleHasBorder(m_windowStyle) ) msStyle |= WS_BORDER; - HWND static_item = CreateWindowEx(MakeExtendedStyle(m_windowStyle), "STATIC", (const char *)label, + m_hWnd = (WXHWND)::CreateWindowEx(MakeExtendedStyle(m_windowStyle), "STATIC", (const char *)label, msStyle, 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); + wxCHECK_MSG( m_hWnd, FALSE, "Failed to create static ctrl" ); + #if CTL3D /* if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS)) @@ -83,16 +84,15 @@ bool wxStaticText::Create(wxWindow *parent, const wxWindowID id, */ #endif - m_hWnd = (WXHWND)static_item; - - SubclassWin((WXHWND)static_item); + SubclassWin(m_hWnd); - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); SetSize(x, y, width, height); + return TRUE; } -void wxStaticText::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags) +void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags) { int currentX, currentY; GetPosition(¤tX, ¤tY); @@ -104,6 +104,8 @@ void wxStaticText::SetSize(const int x, const int y, const int width, const int if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) y1 = currentY; + AdjustForParentClientOrigin(x1, y1, sizeFlags); + int actualWidth = width; int actualHeight = height; @@ -112,7 +114,7 @@ void wxStaticText::SetSize(const int x, const int y, const int width, const int int cyf; ::GetWindowText((HWND) GetHWND(), buf, 300); - GetTextExtent(buf, ¤t_width, &cyf, NULL, NULL,GetFont()); + GetTextExtent(buf, ¤t_width, &cyf, NULL, NULL, & GetFont()); int ww, hh; GetSize(&ww, &hh); @@ -124,7 +126,7 @@ void wxStaticText::SetSize(const int x, const int y, const int width, const int { int cx; int cy; - wxGetCharSize(GetHWND(), &cx, &cy,GetFont()); + wxGetCharSize(GetHWND(), &cx, &cy, & GetFont()); actualWidth = (int)(current_width + cx) ; } @@ -137,22 +139,11 @@ void wxStaticText::SetSize(const int x, const int y, const int width, const int } MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE); - - if (!((width == -1) && (height == -1))) - { -#if WXWIN_COMPATIBILITY - GetEventHandler()->OldOnSize(actualWidth, actualHeight); -#else - wxSizeEvent event(wxSize(actualWidth, actualHeight), m_windowId); - event.eventObject = this; - GetEventHandler()->ProcessEvent(event); -#endif - } } void wxStaticText::SetLabel(const wxString& label) { - float w, h; + int w, h; RECT rect; wxWindow *parent = GetParent(); @@ -168,21 +159,21 @@ void wxStaticText::SetLabel(const wxString& label) ::ScreenToClient((HWND) parent->GetHWND(), &point); } - GetTextExtent(label, &w, &h, NULL, NULL, GetFont()); + GetTextExtent(label, &w, &h, NULL, NULL, & GetFont()); MoveWindow((HWND) GetHWND(), point.x, point.y, (int)(w + 10), (int)h, TRUE); SetWindowText((HWND) GetHWND(), (const char *)label); } -WXHBRUSH wxStaticText::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor, - WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, + WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { /* #if CTL3D if ( m_useCtl3D ) { HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); - + if (hbrush != (HBRUSH) 0) return hbrush; else