void Switcher::paintEvent(QPaintEvent *e) { QPainter p(this); p.fillRect(rect(), _st.bgColor->b); if (!_buttons.isEmpty()) { p.setFont(_st.font->f); float64 btnWidth = float64(width()) / _buttons.size(); for (int i = 0; i < _buttons.size(); ++i) { QRect btnRect(qRound(i * btnWidth), 0, qRound((i + 1) * btnWidth) - qRound(i * btnWidth), height()); if (i == _selected) { p.fillRect(btnRect, _st.bgActive->b); } else if (i == _over) { p.fillRect(btnRect, a_bgOver.current()); } else if (i == _wasOver) { p.fillRect(btnRect, a_bgWasOver.current()); } p.setPen((i == _selected ? _st.activeColor : _st.textColor)->p); p.drawText(btnRect, _buttons[i], style::al_center); } } if (_st.border) { p.fillRect(0, 0, width() - _st.border, _st.border, _st.borderColor->b); p.fillRect(width() - _st.border, 0, _st.border, height() - _st.border, _st.borderColor->b); p.fillRect(_st.border, height() - _st.border, width() - _st.border, _st.border, _st.borderColor->b); p.fillRect(0, _st.border, _st.border, height() - _st.border, _st.borderColor->b); } }
//! constructor CNrpGuiFlick::CNrpGuiFlick( IGUIEnvironment* guienv, IGUIElement* parent, core::recti rectangle, u32 column, s32 id ) : IGUIWindow( guienv, parent, id, rectangle ), _column( column ) { core::recti btnRect( 0, 0, 1, 1 ); _btnUp = new CNrpButton( guienv, this, -1, btnRect ); _btnUp->setText( L"up" ); _btnDown = new CNrpButton( guienv, this, -1, btnRect ); _btnDown->setText( L"down" ); _starty = 0; updateAbsolutePosition(); }
bool CPetQuit::setup(CPetControl *petControl, CPetGlyphs *owner) { CPetGlyph::setup(petControl, owner); Rect tempRect(0, 0, 280, 16); tempRect.moveTo(322, 407); _text.setBounds(tempRect); _text.resize(3); _text.setHasBorder(false); _text.setup(); Rect btnRect(0, 0, 68, 52); btnRect.moveTo(496, 388); _btnYes.setBounds(btnRect); return true; }
void AboutConstruction::_setWorkingVisible(bool show) { if( !_btnToggleWorking && _lbBlackFrame() ) { Rect btnRect( Point( _lbBlackFrame()->width() - 110, (_lbBlackFrame()->height() - 25)/2 ), Size( 100, 25 ) ); _btnToggleWorking = new PushButton( _lbBlackFrame(), btnRect, "", -1, false, PushButton::blackBorderUp ); _btnToggleWorking->setFont( Font::create( FONT_1 ) ); _updateWorkingText(); CONNECT( _btnToggleWorking, onClicked(), this, AboutConstruction::_resolveToggleWorking ); } if( _btnToggleWorking ) { _btnToggleWorking->setVisible( show ); } }
CRect SourceWindow::PaintEdge(CDC& dcPaint, int y, int w, CDibSection* image, bool top) { // Create a bitmap to draw into CDC dc; dc.CreateCompatibleDC(&dcPaint); CDibSection bitmap; CSize sz = image->GetSize(); if (bitmap.CreateBitmap(dc.GetSafeHdc(),w,sz.cy) == FALSE) return CRect(0,0,0,0); bitmap.FillSolid(::GetSysColor(COLOR_BTNFACE)); // Draw the torn edge int x = 0; while (x < w) { bitmap.AlphaBlend(image,x,0); x += sz.cx; } // Draw the arrow button CDibSection* btn = theApp.GetCachedImage("TearArrow"); CRect btnRect(CPoint(w/2,sz.cy/2),CSize(0,0)); CSize btnSize(btn->GetSize()); btnRect.InflateRect(btnSize.cx/2,btnSize.cy/2); bitmap.AlphaBlend(btn,btnRect.left,btnRect.top,!top); // Copy the bitmap to the device context CBitmap* oldBitmap = CDibSection::SelectDibSection(dc,&bitmap); dcPaint.BitBlt(0,y,w,sz.cy,&dc,0,0,SRCCOPY); dc.SelectObject(oldBitmap); // Return a rectangle around the arrow button btnRect.InflateRect(btnSize.cx/2,btnSize.cy/2); btnRect.OffsetRect(0,y); return btnRect; }
SettingsWindow::SettingsWindow(BRect frame) : BWindow(frame, "MediaPlayer settings", B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE #ifdef __ANTARES__ | B_AUTO_UPDATE_SIZE_LIMITS) #else ) #endif { #ifdef __ANTARES__ BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, 5); settingsBox->SetLayout(settingsLayout); BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5); buttonBox->SetLayout(buttonLayout); BStringView* playModeLabel = new BStringView("stringViewPlayMode", "Play mode"); BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions", "View options"); BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg", "Play background clips at"); BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER); playModeLabel->SetExplicitAlignment(alignment); playModeLabel->SetFont(be_bold_font); viewOptionsLabel->SetExplicitAlignment(alignment); viewOptionsLabel->SetFont(be_bold_font); bgMoviesModeLabel->SetExplicitAlignment(alignment); bgMoviesModeLabel->SetFont(be_bold_font); fAutostartCB = new BCheckBox("chkboxAutostart", "Automatically start playing", new BMessage(M_AUTOSTART)); fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies", "Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE)); fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds", "Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS)); fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie", "Loop movies by default", new BMessage(M_LOOP_MOVIE)); fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds", "Loop sounds by default", new BMessage(M_LOOP_SOUND)); fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays", "Use hardware video overlays if available", new BMessage(M_USE_OVERLAYS)); fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)", new BMessage(M_SCALE_BILINEAR)); fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", "Full volume", new BMessage(M_START_FULL_VOLUME)); fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume", "Low volume", new BMessage(M_START_HALF_VOLUME)); fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", "Muted", new BMessage(M_START_MUTE_VOLUME)); fRevertB = new BButton("revert", "Revert", new BMessage(M_SETTINGS_REVERT)); BButton* cancelButton = new BButton("cancel", "Cancel", new BMessage(M_SETTINGS_CANCEL)); BButton* okButton = new BButton("ok", "OK", new BMessage(M_SETTINGS_SAVE)); okButton->MakeDefault(true); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(BGroupLayoutBuilder(settingsLayout) .Add(playModeLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fAutostartCB) .Add(BGridLayoutBuilder(5, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 0) .Add(fCloseWindowMoviesCB, 1, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1) .Add(fCloseWindowSoundsCB, 1, 1) ) .Add(fLoopMoviesCB) .Add(fLoopSoundsCB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(viewOptionsLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fUseOverlaysCB) .Add(fScaleBilinearCB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(bgMoviesModeLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fFullVolumeBGMoviesRB) .Add(fHalfVolumeBGMoviesRB) .Add(fMutedVolumeBGMoviesRB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .SetInsets(5, 5, 15, 5) ) .Add(BGroupLayoutBuilder(buttonLayout) .Add(fRevertB) .AddGlue() .Add(cancelButton) .Add(okButton) .SetInsets(5, 5, 5, 5) ) ); #else frame = Bounds(); BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW); view->SetViewColor(216, 216, 216); BRect btnRect(80.00, frame.bottom - (SPACE + BUTTONHEIGHT), 145.00, frame.bottom-SPACE); fRevertB = new BButton(btnRect, "revert", "Revert", new BMessage(M_SETTINGS_REVERT)); view->AddChild(fRevertB); btnRect.OffsetBy(btnRect.Width() + SPACE, 0); BButton* btn = new BButton(btnRect, "btnCancel", "Cancel", new BMessage(M_SETTINGS_CANCEL)); view->AddChild(btn); btnRect.OffsetBy(btnRect.Width() + SPACE, 0); btn = new BButton(btnRect, "btnOK", "OK", new BMessage(M_SETTINGS_SAVE)); view->AddChild(btn); BRect rectBox(frame.left + SPACE, frame.top + SPACE, frame.right - SPACE, btnRect.top- SPACE); BBox* bbox = new BBox(rectBox, "box1", B_FOLLOW_ALL_SIDES,B_WILL_DRAW | B_NAVIGABLE, B_FANCY_BORDER); bbox->SetLabel("MediaPlayer Settings"); BFont font; font_height fh1; font.GetHeight(&fh1); BString str("Play Mode:"); BRect rect(rectBox.left, rectBox.top + SPACE, rectBox.right - (12*2), rectBox.top + fh1.leading + fh1.ascent + 10); bbox->AddChild(new BStringView(rect, "stringViewPlayMode", str.String())); rect.OffsetBy(0, rect.Height()); bbox->AddChild(fAutostartCB = new BCheckBox(rect, "chkboxAutostart", "Automatically start playing", new BMessage(M_AUTOSTART))); rect.OffsetBy(SPACE, rect.Height() + SPACEING); bbox->AddChild(fCloseWindowMoviesCB = new BCheckBox(rect, "chkBoxCloseWindowMovies", "Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fCloseWindowSoundsCB = new BCheckBox(rect, "chkBoxCloseWindowSounds", "Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS))); rect.OffsetBy(-SPACE, rect.Height() + SPACEING); bbox->AddChild(fLoopMoviesCB = new BCheckBox(rect, "chkBoxLoopMovie", "Loop movies by default", new BMessage(M_LOOP_MOVIE))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fLoopSoundsCB = new BCheckBox(rect, "chkBoxLoopSounds", "Loop sounds by default", new BMessage(M_LOOP_SOUND))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fUseOverlaysCB = new BCheckBox(rect, "chkBoxUseOverlays", "Use hardware video overlays if available", new BMessage(M_USE_OVERLAYS))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fScaleBilinearCB = new BCheckBox(rect, "chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)", new BMessage(M_SCALE_BILINEAR))); rect.OffsetBy(0, rect.Height() + SPACE + SPACEING); bbox->AddChild(new BStringView(rect, "stringViewPlayBackg", "Play backgrounds clips at:")); rect.OffsetBy(SPACE, rect.Height() + SPACEING); fFullVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Full Volume", new BMessage(M_START_FULL_VOLUME)); bbox->AddChild(fFullVolumeBGMoviesRB); rect.OffsetBy(0, rect.Height() + SPACEING); fHalfVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnhalfvolume", "Low Volume", new BMessage(M_START_HALF_VOLUME)); bbox->AddChild(fHalfVolumeBGMoviesRB); rect.OffsetBy(0, rect.Height() + SPACEING); fMutedVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Muted", new BMessage(M_START_MUTE_VOLUME)); bbox->AddChild(fMutedVolumeBGMoviesRB); view->AddChild(bbox); AddChild(view); #endif // disable currently unsupported features fLoopMoviesCB->SetEnabled(false); fLoopSoundsCB->SetEnabled(false); }
int wxStdRenderer::HitTestFrame(const wxRect& rect, const wxPoint& pt, int flags) const { wxRect client = GetFrameClientArea(rect, flags); if ( client.Contains(pt) ) return wxHT_TOPLEVEL_CLIENT_AREA; if ( flags & wxTOPLEVEL_TITLEBAR ) { wxRect client = GetFrameClientArea(rect, flags & ~wxTOPLEVEL_TITLEBAR); if ( flags & wxTOPLEVEL_ICON ) { if ( wxRect(client.GetPosition(), GetFrameIconSize()).Contains(pt) ) return wxHT_TOPLEVEL_ICON; } wxRect btnRect(client.GetRight() - 2 - FRAME_BUTTON_WIDTH, client.GetTop() + (FRAME_TITLEBAR_HEIGHT-FRAME_BUTTON_HEIGHT)/2, FRAME_BUTTON_WIDTH, FRAME_BUTTON_HEIGHT); if ( flags & wxTOPLEVEL_BUTTON_CLOSE ) { if ( btnRect.Contains(pt) ) return wxHT_TOPLEVEL_BUTTON_CLOSE; btnRect.x -= FRAME_BUTTON_WIDTH + 2; } if ( flags & wxTOPLEVEL_BUTTON_MAXIMIZE ) { if ( btnRect.Contains(pt) ) return wxHT_TOPLEVEL_BUTTON_MAXIMIZE; btnRect.x -= FRAME_BUTTON_WIDTH; } if ( flags & wxTOPLEVEL_BUTTON_RESTORE ) { if ( btnRect.Contains(pt) ) return wxHT_TOPLEVEL_BUTTON_RESTORE; btnRect.x -= FRAME_BUTTON_WIDTH; } if ( flags & wxTOPLEVEL_BUTTON_ICONIZE ) { if ( btnRect.Contains(pt) ) return wxHT_TOPLEVEL_BUTTON_ICONIZE; btnRect.x -= FRAME_BUTTON_WIDTH; } if ( flags & wxTOPLEVEL_BUTTON_HELP ) { if ( btnRect.Contains(pt) ) return wxHT_TOPLEVEL_BUTTON_HELP; btnRect.x -= FRAME_BUTTON_WIDTH; } if ( pt.y >= client.y && pt.y < client.y + FRAME_TITLEBAR_HEIGHT ) return wxHT_TOPLEVEL_TITLEBAR; } if ( (flags & wxTOPLEVEL_BORDER) && !(flags & wxTOPLEVEL_MAXIMIZED) ) { // we are certainly at one of borders, let's decide which one: int border = 0; // dirty trick, relies on the way wxHT_TOPLEVEL_XXX are defined! if ( pt.x < client.x ) border |= wxHT_TOPLEVEL_BORDER_W; else if ( pt.x >= client.width + client.x ) border |= wxHT_TOPLEVEL_BORDER_E; if ( pt.y < client.y ) border |= wxHT_TOPLEVEL_BORDER_N; else if ( pt.y >= client.height + client.y ) border |= wxHT_TOPLEVEL_BORDER_S; return border; } return wxHT_NOWHERE; }
//////////////////////////////////////////////////////////////////////////////// // // FUNCTION: DrawItem // // DESCRIPTION: Called in response to draw the button // // NOTES: // // MAINTENANCE: // Name: Date: Version: Notes: // NT ALMOND 210100 1.0 Origin // //////////////////////////////////////////////////////////////////////////////// void CCoolBtn::DrawItem(DRAWITEMSTRUCT* lpDIS) { if (lpDIS->CtlType != ODT_BUTTON) return; CFont *pFont = CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT)); CDC dcMem; CBitmap bmp; CRect btnRect(lpDIS->rcItem); CRect trueRect(btnRect); CDC *pDC = CDC::FromHandle(lpDIS->hDC); //////////////////////////////////////// // Button Background // //////////////////////////////////////// pDC->FillRect(trueRect,&CBrush(GetSysColor(COLOR_BTNFACE))); BOOL bDisabled = ODS_DISABLED & lpDIS->itemState; if (m_bDefaultBtn) btnRect.DeflateRect(1,1); CRect rectFocus(btnRect); rectFocus.DeflateRect(4,4); if (!m_bMenuPushed) rectFocus.OffsetRect(m_bPushed,m_bPushed); rectFocus.right -= nDropBtnWidth; //////////////////////////////////////// // Button in a normal state // //////////////////////////////////////// if (!m_bPushed || m_bMenuPushed) { #ifdef _VISUALSTYLE_XP_H_ if (g_xpStyle.IsAppThemed()) { HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON"); g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(), BP_PUSHBUTTON, PBS_NORMAL, &btnRect, 0); g_xpStyle.CloseThemeData(hTheme); } else { #endif pDC->DrawFrameControl(&btnRect,DFC_BUTTON,DFCS_BUTTONPUSH); #ifdef _VISUALSTYLE_XP_H_ } #endif } //////////////////////////////////////// // Default Button State // //////////////////////////////////////// if ((m_bDefaultBtn || m_bPushed) && !bDisabled) { if (m_bPushed && !m_bMenuPushed) { #ifdef _VISUALSTYLE_XP_H_ if (g_xpStyle.IsAppThemed()) { HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON"); g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(), BP_PUSHBUTTON, PBS_PRESSED, &btnRect, 0); g_xpStyle.CloseThemeData(hTheme); } else { #endif pDC->FrameRect(&lpDIS->rcItem,CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH))); pDC->FrameRect(&btnRect,CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH))); #ifdef _VISUALSTYLE_XP_H_ } #endif } } //////////////////////////////////////// // State Hover // //////////////////////////////////////// if (m_bOverControl /*lpDIS->itemState & ODS_HOTLIGHT*/) if (!m_bMenuPushed) { #ifdef _VISUALSTYLE_XP_H_ if (g_xpStyle.IsAppThemed()) { HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON"); g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(), BP_PUSHBUTTON, PBS_HOT, &btnRect, 0); g_xpStyle.CloseThemeData(hTheme); } #endif } //////////////////////////////////////// // State Focus // //////////////////////////////////////// if (lpDIS->itemState & ODS_FOCUS || m_bPushed) if (!m_bMenuPushed) pDC->DrawFocusRect(&rectFocus); //////////////////////////////////////// // Action Focus // //////////////////////////////////////// if ((lpDIS->itemAction & ODA_FOCUS)) if (!m_bMenuPushed) pDC->DrawFocusRect(&rectFocus); //////////////////////////////////////// // Draw out bitmap // //////////////////////////////////////// // Draw out bitmap if (m_bLoaded) { if (!bDisabled) { m_IL.DrawIndirect(pDC,0,CPoint(6+m_bPushed,6+m_bPushed), CSize(m_bm.bmWidth, m_bm.bmHeight), CPoint(0,0),ILD_NORMAL); } else { pDC->DrawState(CPoint(6+m_bPushed,6+m_bPushed), CSize(m_bm.bmWidth, m_bm.bmHeight), m_hbmpDisabled, DST_BITMAP | DSS_DISABLED); } } //////////////////////////////////////// // Draw out text // //////////////////////////////////////// pDC->SelectObject(pFont); CRect rectText(rectFocus); rectFocus.left += m_bm.bmWidth + 2; CString strCaption; GetWindowText(strCaption); pDC->SetBkMode(TRANSPARENT); pDC->SetBkColor(GetSysColor(COLOR_BTNFACE)); if (ODS_DISABLED & lpDIS->itemState) { rectFocus.OffsetRect(1,1); pDC->SetTextColor(GetSysColor(COLOR_WINDOW)); pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER); rectFocus.OffsetRect(-1,-1); pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT)); pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER); } else { pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER); } CRect rectSplit(btnRect); rectSplit.DeflateRect(2,2); rectSplit.right -= nDropBtnWidth; //////////////////////////////////////// // Drop down split // //////////////////////////////////////// CPen brFace(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW)); pDC->SelectObject(&brFace); pDC->MoveTo(rectSplit.right, rectSplit.top); pDC->LineTo(rectSplit.right, rectSplit.bottom); CPen brLite(PS_SOLID,1,GetSysColor(COLOR_3DHILIGHT)); pDC->SelectObject(&brLite); pDC->MoveTo(rectSplit.right+1 , rectSplit.top); pDC->LineTo(rectSplit.right+1, rectSplit.bottom); rectSplit.left = rectSplit.right; rectSplit.right += nDropBtnWidth; CPoint pt(rectSplit.CenterPoint()); pt += CPoint(m_bPushed,m_bPushed); CPen penBlack(PS_SOLID, 1, bDisabled ? GetSysColor(COLOR_GRAYTEXT) : GetSysColor(COLOR_WINDOWTEXT)); pDC->SelectObject(&penBlack); DrawArrow(pDC,pt); //////////////////////////////////////// // Drop down state // //////////////////////////////////////// if (m_bMenuPushed && !bDisabled) { #ifdef _VISUALSTYLE_XP_H_ rectSplit.DeflateRect(1,1); #else rectSplit.InflateRect(1,1); #endif pDC->DrawEdge(rectSplit,BDR_SUNKENOUTER, BF_RECT); } }
void wxAuiMSWTabArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxRect& in_rect, int bitmap_id, int button_state, int orientation, wxRect* out_rect) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawButton(dc, wnd, in_rect, bitmap_id, button_state, orientation, out_rect); return; } const wchar_t* themeId = NULL; int part = 0; switch (bitmap_id) { case wxAUI_BUTTON_CLOSE: themeId = L"Window"; part = WP_CLOSEBUTTON; break; case wxAUI_BUTTON_LEFT: themeId = L"Spin"; part = SPNP_DOWNHORZ; break; case wxAUI_BUTTON_RIGHT: themeId = L"Spin"; part = SPNP_UPHORZ; break; case wxAUI_BUTTON_WINDOWLIST: themeId = L"Combobox"; part = CP_DROPDOWNBUTTON; break; } wxRect rect = in_rect; if ( orientation == wxLEFT ) { rect.SetX(in_rect.x); rect.SetY(((in_rect.y + in_rect.height) / 2) - (m_closeBtnSize.GetHeight() / 2)); rect.SetWidth(m_closeBtnSize.GetWidth()); rect.SetHeight(m_closeBtnSize.GetHeight()); } else { rect = wxRect(in_rect.x + in_rect.width - m_closeBtnSize.GetWidth(), ((in_rect.y + in_rect.height) / 2) - (m_closeBtnSize.GetHeight() / 2), m_closeBtnSize.GetWidth(), m_closeBtnSize.GetHeight()); } if ( bitmap_id == wxAUI_BUTTON_LEFT || bitmap_id == wxAUI_BUTTON_RIGHT ) { rect.y = in_rect.y; rect.height = in_rect.height - wnd->FromDIP(7); } dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(m_baseColour)); dc.DrawRectangle(rect); int btnState; if ( button_state == wxAUI_BUTTON_STATE_DISABLED ) btnState = TTCS_PRESSED + 1; else if ( button_state == wxAUI_BUTTON_STATE_HOVER ) btnState = TTCS_HOT; else if ( button_state == wxAUI_BUTTON_STATE_PRESSED ) btnState = TTCS_PRESSED; else btnState = TTCS_NORMAL; wxUxThemeHandle hTheme(wnd, themeId); wxRect btnRect(rect); btnRect.width -= wnd->FromDIP(1); RECT btnR; wxCopyRectToRECT(btnRect, btnR); ::DrawThemeBackground(hTheme, GetHdcOf(dc.GetTempHDC()), part, btnState, &btnR, NULL); if ( out_rect ) *out_rect = rect; }
void TranscriptWindow::OnDraw(CDC* pDC) { CRect clientRect; GetClientRect(clientRect); CDC dc; dc.CreateCompatibleDC(pDC); // Create an off-screen bitmap for drawing CDibSection bitmap; if (bitmap.CreateBitmap(pDC->GetSafeHdc(),clientRect.Width(),clientRect.Height()) == FALSE) return; CBitmap* oldBitmap = CDibSection::SelectDibSection(dc,&bitmap); dc.SetBkMode(TRANSPARENT); dc.FillSolidRect(clientRect,theApp.GetColour(InformApp::ColourBack)); if (m_skein->IsActive()) { CFont* oldFont = dc.SelectObject(theApp.GetFont(InformApp::FontDisplay)); CPen linePen(PS_SOLID,1,theApp.GetColour(InformApp::ColourBorder)); CPen* oldPen = dc.SelectObject(&linePen); int y = 0; int yinput = m_layout.fontSize.cy+(2*m_layout.margin.cy); // If the transcript is taller than the window, work out the drawing origin if (GetHeight() > clientRect.Height()) { SCROLLINFO scroll; ::ZeroMemory(&scroll,sizeof scroll); scroll.cbSize = sizeof scroll; GetScrollInfo(SB_VERT,&scroll); y -= scroll.nPos; } // Clear the map of visible buttons and expected texts m_buttons.clear(); m_expecteds.clear(); // Loop over the transcript nodes std::deque<NodeLayout>::const_iterator nodeIt; for (nodeIt = m_layout.nodes.begin(); nodeIt != m_layout.nodes.end(); ++nodeIt) { const NodeLayout& nl = *nodeIt; // Is this node visible? CRect nodeRect(0,y,1,y+m_layout.fontSize.cy+nl.height+(4*m_layout.margin.cy)+1); CRect intersection; if (intersection.IntersectRect(nodeRect,clientRect) == FALSE) { // Not visible, so increase the y position and try the next node y += yinput+nl.height+(2*m_layout.margin.cy); continue; } // Get the text associated with the node const CStringW& transcript = nl.node->GetTranscriptText(); const CStringW& expected = nl.node->GetExpectedText(); const CStringW& line = nl.node->GetLine(); // Fill in the background of the input line dc.FillSolidRect(0,y+1,clientRect.Width(),yinput, theApp.GetColour(InformApp::ColourTransInput)); // Fill in the background of the transcript text COLORREF back; if (transcript.IsEmpty()) back = theApp.GetColour(InformApp::ColourTransUnset); else { back = theApp.GetColour(nl.node->GetChanged() ? InformApp::ColourTransDiffers : InformApp::ColourTransSame); } CRect backRect(0,y+yinput,m_layout.columnWidth, y+m_layout.fontSize.cy+nl.height+(4*m_layout.margin.cy)); dc.FillSolidRect(backRect,back); // Fill in the background of the expected text if (expected.IsEmpty()) back = theApp.GetColour(InformApp::ColourTransUnset); else { switch (nl.node->GetDiffers()) { case Skein::Node::ExpectedSame: back = theApp.GetColour(InformApp::ColourTransSame); break; case Skein::Node::ExpectedNearlySame: back = RGB(255,255,127); break; case Skein::Node::ExpectedDifferent: back = theApp.GetColour(InformApp::ColourTransDiffers); break; default: ASSERT(FALSE); back = theApp.GetColour(InformApp::ColourTransDiffers); break; } } backRect.OffsetRect(m_layout.columnWidth+1,0); dc.FillSolidRect(backRect,Brighter(back)); // If this is the first node in the transcript, draw a horizontal line at the top if (nl.node == m_skein->GetRoot()) { dc.MoveTo(0,y); dc.LineTo(clientRect.Width(),y); } // Draw a horizontal line below the node's input dc.MoveTo(0,y+yinput); dc.LineTo(clientRect.Width(),y+yinput); // Draw a final horizontal line below the text boxes dc.MoveTo(0,y+yinput+nl.height+(2*m_layout.margin.cy)); dc.LineTo(clientRect.Width(),y+yinput+nl.height+(2*m_layout.margin.cy)); // Draw a dividing line between the two text boxes dc.MoveTo(m_layout.columnWidth,y+yinput); dc.LineTo(m_layout.columnWidth,y+yinput+nl.height+(2*m_layout.margin.cy)); // If this is the last played knot in the skein, draw a yellow border around it if (nl.node == m_skeinPlayed) { CRect backRect(0,y,clientRect.Width(), y+m_layout.fontSize.cy+nl.height+(4*m_layout.margin.cy)); DrawInsideRect(dc,backRect,CSize(m_layout.margin.cx*3/4,m_layout.margin.cy*7/8), theApp.GetColour(InformApp::ColourTransPlayed)); } // If this is the knot selected in the skein, draw a blue border around it if (nl.node == m_skeinSelected) { CRect backRect(0,y,clientRect.Width(), y+m_layout.fontSize.cy+nl.height+(4*m_layout.margin.cy)); DrawInsideRect(dc,backRect,CSize(m_layout.margin.cx*3/8,m_layout.margin.cy*7/16), theApp.GetColour(InformApp::ColourTransSelect)); } // Draw the buttons at the end of the input line, and store their positions int btnHeight = m_layout.fontSize.cy+m_layout.margin.cy; CRect btnRect( CPoint(clientRect.Width()-(m_layout.margin.cy/2),y+(m_layout.margin.cy/2)), CSize(0,btnHeight)); btnRect = DrawButton(dc,btnRect,false,"Show knot",Button(nl.node,ButtonShow),true); btnRect.right = btnRect.left-(m_layout.margin.cy/2); DrawButton(dc,btnRect,false,"Play to here",Button(nl.node,ButtonPlay),true); // Write the node's input dc.SetTextColor(theApp.GetColour(InformApp::ColourText)); CRect textRect(m_layout.margin.cx,y+m_layout.margin.cy, btnRect.left-m_layout.margin.cx,y+yinput); theOS.DrawText(&dc,line,line.GetLength(),textRect,DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS); // Draw the 'bless' button, and store its position y += yinput; btnRect.right = m_layout.columnWidth; btnRect.top = y+(((nl.height+(2*m_layout.margin.cy))-btnHeight)/2); btnRect.bottom = btnRect.top+btnHeight; DrawButton(dc,btnRect,true,"Bless",Button(nl.node,ButtonBless),nl.node->CanBless()); // Write the text in the text boxes textRect = CRect(m_layout.margin.cx,y+m_layout.margin.cy, m_layout.columnWidth-m_layout.centreMargin,y+m_layout.margin.cy+nl.height); DrawText(dc,textRect,transcript,nl.node->GetTranscriptDiffs()); textRect.OffsetRect(m_layout.columnWidth+m_layout.centreMargin-m_layout.margin.cx,0); DrawText(dc,textRect,expected,nl.node->GetExpectedDiffs()); textRect.InflateRect(theApp.MeasureFont(m_edit.GetFont()).cx/4,0); m_expecteds.push_back(std::make_pair(backRect,Expected(nl.node,textRect))); // Advance the y position y += nl.height+(2*m_layout.margin.cy); } dc.SelectObject(oldPen); dc.SelectObject(oldFont); // If the edit window is visible, exclude the area under it to reduce flicker if (m_edit.IsWindowVisible()) { CRect editRect; m_edit.GetWindowRect(&editRect); ScreenToClient(&editRect); pDC->ExcludeClipRect(editRect); } } // Copy to the on-screen device context pDC->BitBlt(0,0,clientRect.Width(),clientRect.Height(),&dc,0,0,SRCCOPY); dc.SelectObject(oldBitmap); }