Ejemplo n.º 1
0
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);
	}
}
Ejemplo n.º 2
0
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);
	}
}
Ejemplo n.º 3
0
void KeyControl::Draw(BRect r)
{
	BFont font;
	GetFont(&font);
	font_height fh;
	font.GetHeight(&fh);
	float y = Bounds().bottom - 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), m_mod);
	if (m_key >' ' && m_key < 'a'){
		DrawChar( m_key, BPoint( x, r.bottom - ceil(fh.descent)));
	}else if (m_key){
		switch(m_key){
		case ' ':	key = "   ";	break;
		case 1:		key = "Home";	break;
		case 4:		key = "End";	break;
		case 5:		key = "Ins";	break;
		case 8:		key = "BS ";	break;
		case 9:		key = "Tab";	break;
		case 10:	key = "Return";	break;
		case 11:	key = "PgUp";	break;
		case 12:	key = "PgDown";	break;
		case 14:	key = "F1";		break;
		case 15:	key = "F2";		break;
		case 16:	key = "F3";		break;
		case 17:	key = "F4";		break;
		case 18:	key = "F5";		break;
		case 19:	key = "F6";		break;
		case 20:	key = "F7";		break;
		case 21:	key = "F8";		break;
		case 22:	key = "F9";		break;
		case 23:	key = "F10";	break;
		case 24:	key = "F11";	break;
		case 25:	key = "F12";	break;
		case 27:	key = "Esc";	break;
		case 28:	key = "Left";	break;
		case 29:	key = "Right";	break;
		case 30:	key = "Up";		break;
		case 31:	key = "Down";	break;
		case 127:	key = "Del";	break;
		default:	key = "???";	break;
		}

		DrawKey(BRect(x-2, r.top+1, x+font.StringWidth(key)+2, r.bottom-1), key);
	}
}
Ejemplo n.º 4
0
void KeyItem::DrawItem(BView *view, BRect rect, bool all)
{
	BFont font;
	view->GetFont(&font);

	if (m_id == -1){				// Draw the Outline
		rgb_color bgColor;

		if (IsSelected())
			bgColor = ui_color(B_LIST_SELECTED_BACKGROUND_COLOR);
		else
			bgColor = ui_color(B_LIST_BACKGROUND_COLOR);

		view->SetHighColor(bgColor);
		view->SetLowColor(bgColor);
		view->FillRect(rect, B_SOLID_LOW);

		if (IsSelected())
			view->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
		else
			view->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));

		view->SetFont(be_bold_font);
		view->DrawString( Text(), BPoint( rect.left +5, rect.top +font.Size() +3 ));
		view->SetFont(&font);
		return;
	}

	const char *key;

	BStringItem::DrawItem(view, rect, all);

	view->SetHighColor(240,240,240);
	view->StrokeLine( BPoint(rect.left, rect.bottom), BPoint(rect.right, rect.bottom));
	if (IsSelected()) {
		view->SetHighColor(ui_color(B_LIST_SELECTED_ITEM_TEXT_COLOR));
		view->SetLowColor(ui_color(B_LIST_SELECTED_BACKGROUND_COLOR));
	}
	else {
		view->SetHighColor(ui_color(B_LIST_ITEM_TEXT_COLOR));
		view->SetLowColor(ui_color(B_LIST_BACKGROUND_COLOR));
	}

	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){
		switch(m_key){
		case ' ':	key = "   ";	break;
		case 1:		key = "Home";	break;
		case 4:		key = "End";	break;
		case 5:		key = "Ins";	break;
		case 8:		key = "BS ";	break;
		case 9:		key = "Tab";	break;
		case 10:	key = "Return";	break;
		case 11:	key = "PgUp";	break;
		case 12:	key = "PgDown";	break;
		case 14:	key = "F1";		break;
		case 15:	key = "F2";		break;
		case 16:	key = "F3";		break;
		case 17:	key = "F4";		break;
		case 18:	key = "F5";		break;
		case 19:	key = "F6";		break;
		case 20:	key = "F7";		break;
		case 21:	key = "F8";		break;
		case 22:	key = "F9";		break;
		case 23:	key = "F10";	break;
		case 24:	key = "F11";	break;
		case 25:	key = "F12";	break;
		case 27:	key = "Esc";	break;
		case 28:	key = "Left";	break;
		case 29:	key = "Right";	break;
		case 30:	key = "Up";		break;
		case 31:	key = "Down";	break;
		case 127:	key = "Del";	break;
		default:	key = "???";	break;
		}

		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){
		switch(m_key2){
		case ' ':	key = " ";		break;
		case 1:		key = "Home";	break;
		case 4:		key = "End";	break;
		case 5:		key = "Ins";	break;
		case 8:		key = "BS ";	break;
		case 9:		key = "Tab";	break;
		case 10:	key = "Return";	break;
		case 11:	key = "PgUp";	break;
		case 12:	key = "PgDown";	break;
		case 14:	key = "F1";		break;
		case 15:	key = "F2";		break;
		case 16:	key = "F3";		break;
		case 17:	key = "F4";		break;
		case 18:	key = "F5";		break;
		case 19:	key = "F6";		break;
		case 20:	key = "F7";		break;
		case 21:	key = "F8";		break;
		case 22:	key = "F9";		break;
		case 23:	key = "F10";	break;
		case 24:	key = "F11";	break;
		case 25:	key = "F12";	break;
		case 27:	key = "Esc";	break;
		case 28:	key = "Left";	break;
		case 29:	key = "Right";	break;
		case 30:	key = "Up";		break;
		case 31:	key = "Down";	break;
		case 127:	key = "Del";	break;
		default:	key = "???";	break;
		}

		DrawKey(view, BRect(x-2, rect.top+1, x+font.StringWidth(key)+2, rect.bottom-1), key);
	}
}