WXLRESULT wxNativeContainerWindow::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { switch ( nMsg ) { case WM_CLOSE: // wxWindow itself, unlike wxFrame, doesn't react to WM_CLOSE and // just ignores it without even passing it to DefWindowProc(), // which means that the original WM_CLOSE handler wouldn't be // called if we didn't explicitly do it here. return MSWDefWindowProc(nMsg, wParam, lParam); case WM_DESTROY: // Send it to the original handler which may have some cleanup to // do as well. Notice that we must do it before calling // OnNativeDestroyed() as we can't use this object after doing it. MSWDefWindowProc(nMsg, wParam, lParam); OnNativeDestroyed(); return 0; } return wxTopLevelWindow::MSWWindowProc(nMsg, wParam, lParam); }
// Scroll to the given line (in scroll units where each unit is // the height of an item) void wxRemotelyScrolledTreeCtrl::ScrollToLine(int posHoriz, int posVert) { #ifdef __WXMSW__ if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) { UINT sbCode = SB_THUMBPOSITION; HWND vertScrollBar = 0; MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXHWND) vertScrollBar); } else #endif { wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; win->Refresh(); /* Doesn't work yet because scrolling is ignored by Scroll int xppu, yppu; wxScrolledWindow* scrolledWindow = GetScrolledWindow(); if (scrolledWindow) { scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu); win->Scroll(-1, posVert*yppu); } */ } }
bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo) { MINMAXINFO *info = (MINMAXINFO *)mmInfo; // let the default window proc calculate the size of MDI children // frames because it is based on the size of the MDI client window, // not on the values specified in wxWindow m_max variables bool processed = MSWDefWindowProc(WM_GETMINMAXINFO, 0, (LPARAM)mmInfo) != 0; int minWidth = GetMinWidth(), minHeight = GetMinHeight(); // but allow GetSizeHints() to set the min size if ( minWidth != -1 ) { info->ptMinTrackSize.x = minWidth; processed = true; } if ( minHeight != -1 ) { info->ptMinTrackSize.y = minHeight; processed = true; } return processed; }
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& WXUNUSED(rc)) { MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(dc), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc // still draws the label in its own colours, so we need to redraw the text // ourselves if we have a non default fg colour if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour dc.SetFont(GetFont()); HDC hdc = GetHdcOf(dc); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); // FIXME: value of x is hardcoded as this is what it is on my system, // no idea if it's true everywhere const int y = dc.GetCharHeight(); const int x = 9; // TODO: RTL? RECT rc = { x, 0, GetSize().x - x, y }; const wxString label = GetLabel(); ::DrawText(hdc, label, label.length(), &rc, DT_SINGLELINE | DT_VCENTER); } }
void CMusikEQGauge::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxBufferedPaintDC dc(this); wxEraseEvent erase_event(GetId(), &dc); wxGauge::OnEraseBackground(erase_event); MSWDefWindowProc(WM_PAINT, (WPARAM) (HDC) dc.GetHDC(), 0); }
WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_ACTIVATE: { WXWORD state, minimized; WXHWND hwnd; UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); processed = HandleActivate(state, minimized != 0, hwnd); } break; case WM_COMMAND: // system messages such as SC_CLOSE are sent as WM_COMMANDs to the // parent MDI frame and we must let the DefFrameProc() have them // for these commands to work (without it, closing the maximized // MDI children doesn't work, for example) { WXWORD id, cmd; WXHWND hwnd; UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); if ( id == wxID_MDI_MORE_WINDOWS || (cmd == 0 /* menu */ && id >= SC_SIZE /* first system menu command */) ) { MSWDefWindowProc(message, wParam, lParam); processed = true; } } break; case WM_CREATE: m_clientWindow = OnCreateClient(); // Uses own style for client style if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) ) { wxLogMessage(_("Failed to create MDI parent frame.")); rc = -1; } processed = true; break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; }
bool wxFrame::HandlePaint() { RECT rect; if ( ::GetUpdateRect(GetHwnd(), &rect, FALSE) ) { #if !defined(__WXMICROWIN__) && !defined(__WXWINCE__) if ( m_iconized ) { const wxIcon& icon = GetIcon(); HICON hIcon = icon.Ok() ? GetHiconOf(icon) : (HICON)GetDefaultIcon(); // Hold a pointer to the dc so long as the OnPaint() message // is being processed PAINTSTRUCT ps; HDC hdc = ::BeginPaint(GetHwnd(), &ps); // Erase background before painting or we get white background MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L); if ( hIcon ) { RECT rect; ::GetClientRect(GetHwnd(), &rect); // FIXME: why hardcoded? static const int icon_width = 32; static const int icon_height = 32; int icon_x = (int)((rect.right - icon_width)/2); int icon_y = (int)((rect.bottom - icon_height)/2); ::DrawIcon(hdc, icon_x, icon_y, hIcon); } ::EndPaint(GetHwnd(), &ps); return true; } else #endif { return wxWindow::HandlePaint(); } } else { // nothing to paint - processed return true; } }
void CScrolledTreeCtrl::ScrollToLine(int posHoriz, int posVert) { wxLogVerbose(wxT("CScrolledTreeCtrl::ScrollToLine(%d,%d)"), posHoriz, posVert); #ifdef __WXMSW__ { UINT sbCode = SB_THUMBPOSITION; HWND vertScrollBar = 0; MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXLPARAM) vertScrollBar); } #else wxGenericTreeCtrl *win = (wxGenericTreeCtrl *) this; win->Refresh(); #endif }
WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_GETMINMAXINFO: processed = HandleGetMinMaxInfo((MINMAXINFO *)lParam); break; case WM_MDIACTIVATE: { WXWORD act; WXHWND hwndAct, hwndDeact; UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact); processed = HandleMDIActivate(act, hwndAct, hwndDeact); } // fall through case WM_MOVE: // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client // scrollbars if necessary // fall through case WM_SIZE: // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird // things happen MSWDefWindowProc(message, wParam, lParam); break; case WM_WINDOWPOSCHANGING: processed = HandleWindowPosChanging((LPWINDOWPOS)lParam); break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; }
WXLRESULT wxToolMenuBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { switch ( nMsg ) { case WM_SIZE: break; case WM_MOUSEMOVE: // we don't handle mouse moves, so always pass the message to // wxControl::MSWWindowProc HandleMouseMove(wParam, lParam); break; case WM_PAINT: break; } return MSWDefWindowProc(nMsg, wParam, lParam); }
void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); wxMemoryDC memdc; RECT rc; ::GetClientRect(GetHwnd(), &rc); wxBitmap bmp(rc.right, rc.bottom); memdc.SelectObject(bmp); const wxLayoutDirection dir = dc.GetLayoutDirection(); memdc.SetLayoutDirection(dir); // if there is no special brush just use the solid background colour #if wxUSE_UXTHEME HBRUSH hbr = (HBRUSH)m_hbrBackground; #else HBRUSH hbr = 0; #endif wxBrush brush; if ( !hbr ) { brush = wxBrush(GetBackgroundColour()); hbr = GetHbrushOf(brush); } wxMSWDCImpl *impl = (wxMSWDCImpl*) memdc.GetImpl(); ::FillRect(GetHdcOf(*impl), &rc, hbr); MSWDefWindowProc(WM_PAINT, (WPARAM)(impl->GetHDC()), 0); // For some reason in RTL mode, source offset has to be -1, otherwise the // right border (physical) remains unpainted. const wxCoord ofs = dir == wxLayout_RightToLeft ? -1 : 0; dc.Blit(ofs, 0, rc.right, rc.bottom, &memdc, ofs, 0); }
WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_COMMAND: { WORD id, cmd; WXHWND hwnd; UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, &id, &hwnd, &cmd); processed = HandleCommand(id, cmd, (WXHWND)hwnd); } break; case WM_GETMINMAXINFO: processed = HandleGetMinMaxInfo((MINMAXINFO *)lParam); break; case WM_MDIACTIVATE: { WXWORD act; WXHWND hwndAct, hwndDeact; UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact); processed = HandleMDIActivate(act, hwndAct, hwndDeact); } // fall through case WM_MOVE: // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client // scrollbars if necessary // fall through case WM_SIZE: // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird // things happen MSWDefWindowProc(message, wParam, lParam); break; case WM_SYSCOMMAND: // DefMDIChildProc handles SC_{NEXT/PREV}WINDOW here, so pass it // the message (the base class version does not) return MSWDefWindowProc(message, wParam, lParam); case WM_WINDOWPOSCHANGING: processed = HandleWindowPosChanging((LPWINDOWPOS)lParam); break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; }
WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_ACTIVATE: { WXWORD state, minimized; WXHWND hwnd; UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); processed = HandleActivate(state, minimized != 0, hwnd); } break; case WM_COMMAND: { WXWORD id, cmd; WXHWND hwnd; UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); (void)HandleCommand(id, cmd, hwnd); // even if the frame didn't process it, there is no need to try it // once again (i.e. call wxFrame::HandleCommand()) - we just did it, // so pretend we processed the message anyhow processed = true; } // always pass this message DefFrameProc(), otherwise MDI menu // commands (and sys commands - more surprisingly!) won't work MSWDefWindowProc(message, wParam, lParam); break; case WM_CREATE: m_clientWindow = OnCreateClient(); // Uses own style for client style if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) ) { wxLogMessage(_("Failed to create MDI parent frame.")); rc = -1; } processed = true; break; case WM_ERASEBKGND: processed = true; // we erase background ourselves rc = true; break; case WM_MENUSELECT: { WXWORD item, flags; WXHMENU hmenu; UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); if ( m_parentFrameActive ) { processed = HandleMenuSelect(item, flags, hmenu); } else if (m_currentChild) { processed = m_currentChild-> HandleMenuSelect(item, flags, hmenu); } } break; case WM_SIZE: // though we don't (usually) resize the MDI client to exactly fit the // client area we need to pass this one to DefFrameProc to allow the children to show break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; }
WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_CLOSE: // if we can't close, tell the system that we processed the // message - otherwise it would close us processed = !Close(); break; case WM_SIZE: processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); break; case WM_COMMAND: { WORD id, cmd; WXHWND hwnd; UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, &id, &hwnd, &cmd); HandleCommand(id, cmd, (WXHWND)hwnd); // don't pass WM_COMMAND to the base class whether we processed // it or not because we did generate an event for it (our // HandleCommand() calls the base class version) and we must // not do it again or the handlers which skip the event would // be called twice processed = true; } break; case WM_INITMENUPOPUP: case WM_UNINITMENUPOPUP: // We get these messages from the menu bar even if the menu is // disabled, which is unexpected, so ignore them in this case. if ( wxMenuBar* mbar = GetMenuBar() ) { const int pos = mbar->MSWGetTopMenuPos((WXHMENU)wParam); if ( pos != wxNOT_FOUND && !mbar->IsEnabledTop(pos) ) { // This event comes from a disabled top level menu, don't // handle it. return MSWDefWindowProc(message, wParam, lParam); } } break; case WM_QUERYDRAGICON: { const wxIcon& icon = GetIcon(); HICON hIcon = icon.IsOk() ? GetHiconOf(icon) : (HICON)GetDefaultIcon(); rc = (WXLRESULT)hIcon; processed = rc != 0; } break; } #if wxUSE_TASKBARBUTTON if ( message == wxMsgTaskbarButtonCreated ) { if ( m_taskBarButton ) m_taskBarButton->Realize(); processed = true; } #endif if ( !processed ) rc = wxFrameBase::MSWWindowProc(message, wParam, lParam); return rc; }
void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); wxMemoryDC memdc; RECT rc; ::GetClientRect(GetHwnd(), &rc); wxBitmap bmp(rc.right, rc.bottom); memdc.SelectObject(bmp); const wxLayoutDirection dir = dc.GetLayoutDirection(); memdc.SetLayoutDirection(dir); const HDC hdc = GetHdcOf(memdc); // The drawing logic of the native tab control is absolutely impenetrable // but observation shows that in the current Windows versions (XP and 7), // the tab control always erases its entire background in its window proc // when the tabs are top-aligned but does not do it when the tabs are in // any other position. // // This means that we can't rely on our background colour being used for // the blank area in the tab row because this doesn't work in the default // top-aligned case, hence the hack with ExtFloodFill() below. But it also // means that we still do need to erase the DC to account for the other // cases. // // Moreover, just in case some very old or very new (or even future, // although it seems unlikely that this is ever going to change by now) // version of Windows didn't do it like this, do both things in all cases // instead of optimizing away the one of them which doesn't do anything for // the effectively used tab orientation -- better safe than fast. // Notice that we use our own background here, not the background used for // the pages, because the tab row background must blend with the parent and // so the background colour inherited from it (if any) must be used. AutoHBRUSH hbr(wxColourToRGB(GetBackgroundColour())); ::FillRect(hdc, &rc, hbr); MSWDefWindowProc(WM_PAINT, (WPARAM)hdc, 0); // At least for the top-aligned tabs, our background colour was overwritten // and so we now replace the default background with our colour. This is // horribly inefficient, of course, but seems to be the only way to do it. if ( UseBgCol() ) { SelectInHDC selectBrush(hdc, hbr); // Find the point which must contain the default background colour: // this is a hack, of course, but using this point "close" to the // corner seems to work fine in practice. int x = 0, y = 0; switch ( GetWindowStyle() & wxBK_ALIGN_MASK ) { case wxBK_TOP: x = rc.right - 2; y = 2; break; case wxBK_BOTTOM: x = rc.right - 2; y = rc.bottom - 2; break; case wxBK_LEFT: x = 2; y = rc.bottom - 2; break; case wxBK_RIGHT: x = 2; y = rc.bottom - 2; break; } ::ExtFloodFill(hdc, x, y, ::GetSysColor(COLOR_BTNFACE), FLOODFILLSURFACE); } // For some reason in RTL mode, source offset has to be -1, otherwise the // right border (physical) remains unpainted. const wxCoord ofs = dir == wxLayout_RightToLeft ? -1 : 0; dc.Blit(ofs, 0, rc.right, rc.bottom, &memdc, ofs, 0); }
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) { wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(*impl), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc // still draws the label in its own colours, so we need to redraw the text // ourselves if we have a non default fg colour if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour HDC hdc = GetHdcOf(*impl); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); const bool rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft; if ( rtl ) ::SetTextAlign(hdc, TA_RTLREADING | TA_RIGHT); // Get dimensions of the label const wxString label = GetLabel(); // choose the correct font AutoHFONT font; SelectInHDC selFont; if ( m_hasFont ) { selFont.Init(hdc, GetHfontOf(GetFont())); } else // no font set, use the one set by the theme { wxUxThemeHandle hTheme(this, L"BUTTON"); if ( hTheme ) { wxUxThemeFont themeFont; if ( wxUxThemeEngine::Get()->GetThemeFont ( hTheme, hdc, BP_GROUPBOX, GBS_NORMAL, TMT_FONT, themeFont.GetPtr() ) == S_OK ) { font.Init(themeFont.GetLOGFONT()); if ( font ) selFont.Init(hdc, font); } } } // Get the font extent int width, height; dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics), &width, &height); int x; int y = height; // first we need to correctly paint the background of the label // as Windows ignores the brush offset when doing it // // FIXME: value of x is hardcoded as this is what it is on my system, // no idea if it's true everywhere RECT dimensions = {0, 0, 0, y}; if ( !rtl ) { x = 9; dimensions.left = x; dimensions.right = x + width; } else { x = rc.right - 7; dimensions.left = x - width; dimensions.right = x; } // need to adjust the rectangle to cover all the label background dimensions.left -= 2; dimensions.right += 2; dimensions.bottom += 2; if ( UseBgCol() ) { // our own background colour should be used for the background of // the label: this is consistent with the behaviour under pre-XP // systems (i.e. without visual themes) and generally makes sense wxBrush brush = wxBrush(GetBackgroundColour()); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); ::FillRect(GetHdcOf(*impl), &dimensions, GetHbrushOf(brush)); } else // paint parent background { PaintBackground(dc, dimensions); } UINT drawTextFlags = DT_SINGLELINE | DT_VCENTER; // determine the state of UI queues to draw the text correctly under XP // and later systems static const bool isXPorLater = wxGetWinVersion() >= wxWinVersion_XP; if ( isXPorLater ) { if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) & UISF_HIDEACCEL ) { drawTextFlags |= DT_HIDEPREFIX; } } // now draw the text if ( !rtl ) { RECT rc2 = { x, 0, x + width, y }; ::DrawText(hdc, label.t_str(), label.length(), &rc2, drawTextFlags); } else // RTL { RECT rc2 = { x, 0, x - width, y }; ::DrawText(hdc, label.t_str(), label.length(), &rc2, drawTextFlags | DT_RTLREADING); } } }
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) { wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(*impl), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc // still draws the label in its own colours, so we need to redraw the text // ourselves if we have a non default fg colour if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour HDC hdc = GetHdcOf(*impl); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); const bool rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft; if ( rtl ) ::SetTextAlign(hdc, TA_RTLREADING | TA_RIGHT); // Get dimensions of the label const wxString label = GetLabel(); // choose the correct font AutoHFONT font; SelectInHDC selFont; if ( m_hasFont ) { selFont.Init(hdc, GetHfontOf(GetFont())); } else // no font set, use the one set by the theme { wxUxThemeHandle hTheme(this, L"BUTTON"); if ( hTheme ) { // GetThemeFont() expects its parameter to be LOGFONTW and not // LOGFONTA even in ANSI programs and will happily corrupt // memory after the struct end if we pass a LOGFONTA (which is // smaller) to it! LOGFONTW lfw; if ( wxUxThemeEngine::Get()->GetThemeFont ( hTheme, hdc, BP_GROUPBOX, GBS_NORMAL, TMT_FONT, (LOGFONT *)&lfw ) == S_OK ) { #if wxUSE_UNICODE // ok, no conversion necessary const LOGFONT& lf = lfw; #else // !wxUSE_UNICODE // most of the fields are the same in LOGFONTA and LOGFONTW LOGFONT lf; memcpy(&lf, &lfw, sizeof(lf)); // but the face name must be converted WideCharToMultiByte(CP_ACP, 0, lfw.lfFaceName, -1, lf.lfFaceName, sizeof(lf.lfFaceName), NULL, NULL); #endif // wxUSE_UNICODE/!wxUSE_UNICODE font.Init(lf); if ( font ) selFont.Init(hdc, font); } } } // Get the font extent int width, height; dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics), &width, &height); int x; int y = height; // first we need to correctly paint the background of the label // as Windows ignores the brush offset when doing it // // FIXME: value of x is hardcoded as this is what it is on my system, // no idea if it's true everywhere RECT dimensions = {0, 0, 0, y}; if ( !rtl ) { x = 9; dimensions.left = x; dimensions.right = x + width; } else { x = rc.right - 7; dimensions.left = x - width; dimensions.right = x; } // need to adjust the rectangle to cover all the label background dimensions.left -= 2; dimensions.right += 2; dimensions.bottom += 2; if ( UseBgCol() ) { // our own background colour should be used for the background of // the label: this is consistent with the behaviour under pre-XP // systems (i.e. without visual themes) and generally makes sense wxBrush brush = wxBrush(GetBackgroundColour()); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); ::FillRect(GetHdcOf(*impl), &dimensions, GetHbrushOf(brush)); } else // paint parent background { PaintBackground(dc, dimensions); } // now draw the text if ( !rtl ) { RECT rc2 = { x, 0, x + width, y }; ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER); } else // RTL { RECT rc2 = { x, 0, x - width, y }; ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER | DT_RTLREADING); } } }
void CMusikListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxBufferedPaintDC dc(this); MSWDefWindowProc(WM_ERASEBKGND, (WPARAM) (HDC) dc.GetHDC(), 0); MSWDefWindowProc(WM_PAINT, (WPARAM) (HDC) dc.GetHDC(), 0); /* copied from original wxwindows code */ // Reset the device origin since it may have been set dc.SetDeviceOrigin(0, 0); bool drawHRules = ((GetWindowStyle() & wxLC_HRULES) != 0); bool drawVRules = ((GetWindowStyle() & wxLC_VRULES) != 0); if (!drawHRules && !drawVRules) return; if ((GetWindowStyle() & wxLC_REPORT) == 0) return; wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); dc.SetPen(pen); dc.SetBrush(* wxTRANSPARENT_BRUSH); wxSize clientSize = GetClientSize(); wxRect itemRect; int cy=0; int itemCount = GetItemCount(); int i; if (drawHRules) { long top = GetTopItem(); for (i = top; i < top + GetCountPerPage() + 1; i++) { if (GetItemRect(i, itemRect)) { cy = itemRect.GetTop(); if (i != 0) // Don't draw the first one { dc.DrawLine(0, cy, clientSize.x, cy); } // Draw last line if (i == itemCount - 1) { cy = itemRect.GetBottom(); dc.DrawLine(0, cy, clientSize.x, cy); } } } } i = itemCount - 1; if (drawVRules && (i > -1)) { wxRect firstItemRect; GetItemRect(0, firstItemRect); if (GetItemRect(i, itemRect)) { int col; int x = itemRect.GetX(); for (col = 0; col < GetColumnCount(); col++) { int colWidth = GetColumnWidth(col); x += colWidth ; dc.DrawLine(x-1, firstItemRect.GetY() - 2, x-1, itemRect.GetBottom()); } } } }