void KeyItem::DrawItem(BView *view, BRect rect, bool all) { BFont font; view->GetFont(&font); if (m_id == -1) { // Draw the Outline if (IsSelected()) view->SetLowColor(150,190,230); else view->SetLowColor(255,255,255); view->FillRect(rect, B_SOLID_LOW); view->SetHighColor(0,0,0); view->SetFont(be_bold_font); view->DrawString( Label(), BPoint( rect.left +5, rect.top +font.Size() )); view->SetFont(&font); return; } const char *key; StringItem::DrawItem(view, rect, all); view->SetHighColor(240,240,240); view->StrokeLine( BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom)); view->SetHighColor(0,0,0); float x = rect.left + rect.Width()/2 +(font.Size()+4)*3; // max 3 combinations DrawMods(view, BRect( x - font.Size() - 6, rect.top+1, x -4, rect.bottom-1), m_mod); if (m_key >' ' && m_key < 'a') { view->DrawChar( m_key, BPoint( x, rect.top +font.Size() )); } else if (m_key) { key = _KeyLabel(m_key); DrawKey(view, BRect(x-2, rect.top+1, x+font.StringWidth(key)+2, rect.bottom-1), key); } x = rect.right - 32; DrawMods(view, BRect( x - font.Size() - 6, rect.top+1, x -4, rect.bottom-1), m_mod2); if (m_key2 >' ' && m_key2 < 'a') { view->DrawChar( m_key2, BPoint( x, rect.top +font.Size() )); } else if (m_key2) { key = _KeyLabel(m_key2); DrawKey(view, BRect(x-2, rect.top+1, x+font.StringWidth(key)+2, rect.bottom-1), key); } }
void KeyControl::Draw(BRect r) { BFont font; GetFont(&font); font_height fh; font.GetHeight(&fh); float y = Bounds().bottom - (float)ceil(fh.descent); const char* key; SetHighColor(0,0,0); DrawString( Label(), BPoint(2.0, y)); r = Bounds(); r.left = Divider(); if (IsFocus()) SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); else SetHighColor(0,0,0); StrokeRect(r); r.InsetBy(1,1); SetHighColor( 255,255,255 ); FillRect(r); SetHighColor(0,0,0); r.InsetBy(1,1); float x = DrawMods( BRect(r.left, r.top+1, r.left+font.Size()+6, r.bottom-1), fMod); if (fKey >' ' && fKey < 'a') DrawChar( fKey, BPoint( x, r.bottom - (float)ceil(fh.descent))); else if (fKey) { key = _KeyLabel(fKey); DrawKey(BRect(x-2, r.top+1, x+font.StringWidth(key)+2, r.bottom-1), key); } }