void CListBox::Draw() const { CWindow::Draw(); if (m_pSDLSurface) { CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE); Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_DARKGRAY); int iStartIndex = m_pVScrollbar->GetValue(); for (unsigned int i = iStartIndex; i < m_Items.size(); ++i) { CRect ItemRect(m_ClientRect.Left(), m_ClientRect.Top() + (i - iStartIndex) * m_iItemHeight, m_ClientRect.Right(), m_ClientRect.Top() + (i - iStartIndex + 1) * m_iItemHeight - 1); if (ItemRect.Overlaps(m_ClientRect)) { ItemRect.ClipTo(m_ClientRect); ItemRect.SetBottom(ItemRect.Bottom() - 1); if (m_SelectedItems.at(i)) { Painter.DrawRect(ItemRect, true, CApplication::Instance()->GetDefaultSelectionColor(), CApplication::Instance()->GetDefaultSelectionColor()); } if (i == m_iFocusedItem && HasFocus()) { ItemRect.Grow(1); Painter.DrawRect(ItemRect, false, COLOR_DARKGRAY); ItemRect.Grow(-1); } ItemRect.Grow(-1); m_RenderedStrings.at(i).Draw(m_pSDLSurface, ItemRect, ItemRect.TopLeft() + CPoint(0, 1), m_Items[i].ItemColor); } } } m_pVScrollbar->Draw(); }
int MenuBar::GetPointItem(cpoint p) { for (int i = 0; i<list.count(); i++) if (ItemRect(i).In(p)) return i; return -1; }
void MenuBar::DrawItem(GC &gc, int n) { if (n<0 || n>=list.count()) return; UiCondList ucl; if (n == select && InFocus()) ucl.Set(uiCurrentItem, true); int color_text = UiGetColor(uiColor, uiItem, &ucl, 0x0); int color_bg = UiGetColor(uiBackground, uiItem, &ucl, 0xFFFFFF); gc.Set(GetFont()); crect itemRect = ItemRect(n); gc.SetFillColor(color_bg); if (n == select && InFocus()) gc.FillRect(itemRect); if (n == select) { DrawBorder(gc, itemRect, UiGetColor(uiCurrentItemFrame, uiItem, &ucl, 0xFFFFFF)); } gc.SetTextColor( color_text ); const unicode_t *text = list[n].text.ptr(); cpoint tsize = gc.GetTextExtents(text); int x = itemRect.left + (itemRect.Width()-tsize.x)/2; int y = itemRect.top + (itemRect.Height()-tsize.y)/2; #ifdef _WIN32 gc.TextOut(x,y,text); #else gc.TextOutF(x,y,text); #endif }
void MenuBar::OpenSub() { ReleaseCapture(); sub = 0; if (select>=0 && select<list.count()) { crect rect = ScreenRect(); crect itemRect = ItemRect(select); int x = rect.left+itemRect.left; int y = rect.top+itemRect.bottom; sub = new PopupMenu(0, this, list[select].data, x, y, this ); //Parent() ? Parent() : 0); sub->Show(Win::SHOW_INACTIVE); sub->Enable(true); SetCapture(); } }
void ConfigDlg::OnBnClickedButton3() { if( m_EditCtrl.IsWindowVisible()) { return; } int nitemCount = m_List.GetItemCount(); m_List.InsertItem( nitemCount, _T("")); m_List.EnsureVisible( nitemCount, FALSE ); CRect ItemRect(0,0,0,0); m_List.GetItemRect( nitemCount , ItemRect, LVIR_BOUNDS ); m_EditCtrl.MoveWindow( ItemRect ); m_EditCtrl.SetWindowText( _T("SRV*c:\\Windows\\Symbols*http://msdl.microsoft.com/download/symbols")); m_EditCtrl.ShowWindow( SW_SHOW ); m_EditCtrl.SetFocus(); }
void CNavigationBar::Draw(void) const { CWindow::Draw(); if (m_pSDLSurface) { CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE); Painter.Draw3DLoweredRect(m_WindowRect.SizeRect(), DEFAULT_BACKGROUND_COLOR); SDL_Rect PictureSourceRect = CRect(CPoint(0, 0), 30, 30).SDLRect(); for (unsigned int i = 0; i < m_Items.size(); ++i) { CRect ItemRect(CPoint(m_ClientRect.Left() + i*m_iItemWidth, m_ClientRect.Top()), m_iItemWidth , m_iItemHeight); if (ItemRect.Overlaps(m_ClientRect)) { ItemRect.ClipTo(m_ClientRect); ItemRect.SetBottom(ItemRect.Bottom() - 1); ItemRect.SetRight(ItemRect.Right() - 1); if (i == m_iSelectedItem) { Painter.DrawRect(ItemRect, true, CApplication::Instance()->GetDefaultSelectionColor(), CApplication::Instance()->GetDefaultSelectionColor()); } if (i == m_iFocusedItem && HasFocus()) { ItemRect.Grow(1); Painter.DrawRect(ItemRect, false, CApplication::Instance()->GetDefaultSelectionColor() * 0.7); ItemRect.Grow(-1); } ItemRect.Grow(-1); // '- CPoint(0,1)' is to move the reference point one pixel up (otherwise the lowest pixels of p,g,q,y // etc. are not fully visible. m_RenderedStrings.at(i).Draw(m_pSDLSurface, ItemRect, ItemRect.BottomLeft() - CPoint(0, 1) + CPoint(ItemRect.Width()/2, 0), m_Items[i].ItemColor); // Draw the picture (if available): if (m_Bitmaps.at(i) != nullptr) { SDL_Rect DestRect = ItemRect.Move(9, 1).SDLRect(); SDL_BlitSurface(m_Bitmaps.at(i)->Bitmap(), &PictureSourceRect, m_pSDLSurface, &DestRect); } } } } }