예제 #1
0
AgentDockHeader::AgentDockHeader(BRect frame, const char* name, uint32 resize)
	: BView(frame, "AgentDockHeader", resize, B_WILL_DRAW)
{
	SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));

	BRect stringRect(frame);
	stringRect.left = stringRect.left + 3;
	stringRect.right = stringRect.right - 24;

	fHeaderView = new AgentDockHeaderString(stringRect, name);
	AddChild(fHeaderView);
}
예제 #2
0
BamKeysPrefsWindow::BamKeysPrefsWindow()
	: BWindow(BRect(40, 30, 40 + WIDTH, 30 + HEIGHT), "BamKeys",
			B_TITLED_WINDOW, B_NOT_ZOOMABLE)// | B_NOT_RESIZABLE)
{
	fModified = false;
	fRootView = new BBox(BRect(0, 0, WIDTH, HEIGHT), 
						"root_view", B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER);
	
	fRootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(fRootView);
	
	// Screen area selection box
	fScreenBox = new BBox(BRect(10, 10, ((WIDTH / 3) * 2) - 5, (HEIGHT - 50)), 
						"screen_box", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER);
	BRect gridRect = fScreenBox->Frame();
	gridRect.OffsetTo(0, 0);
	gridRect.InsetBy(5, 5);
	fGrid = new BamKeysGridControl(gridRect, "screen_grid", "", new BMessage('grid'));
	fScreenBox->AddChild(fGrid);
	
	// Settings Box
	fSettingBox = new BBox(BRect(((WIDTH / 3) * 2) + 5, 10, WIDTH - 10, (HEIGHT - 50)),
						"settings_box", B_FOLLOW_RIGHT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);
	
	BRect itmRect = fSettingBox->Frame();
	itmRect.Set(5, 10, itmRect.Width() - 5, (itmRect.Height() - 10) / 8);
	
	// Filter Enabled
	fChkEnabled = new BCheckBox(itmRect, "chkGrid", "Enable BamKeys", new BMessage('fltr'), B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fChkEnabled->SetValue(fGrid->IsFiltering() ? B_CONTROL_ON : B_CONTROL_OFF);
	fSettingBox->AddChild(fChkEnabled);
	
	itmRect.OffsetBy(0, itmRect.Height());

	// Rows and Columns
	int32 rows;
	int32 columns;
	fGrid->GetSize(&rows, &columns);
	
	BPopUpMenu *mnuRows = new BPopUpMenu("");
	for (int i = 1; i <= MAX_DIVIDE; i++) {
		BString numb("");
		numb << i;
		BMenuItem *mnuItem = new BMenuItem(numb.String(), new BMessage('rowC'));
		mnuRows->AddItem(mnuItem);
		if (i == rows) {
			mnuItem->SetMarked(true);
		}
	}
	
	fMnuFldRows = new BMenuField(itmRect, "mnuRows", "Rows:", mnuRows, B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fSettingBox->AddChild(fMnuFldRows);
	
	
	itmRect.OffsetBy(0, itmRect.Height());
	
	BPopUpMenu *mnuColumns = new BPopUpMenu("");
	for (int i = 1; i <= MAX_DIVIDE; i++) {
		BString numb("");
		numb << i;
		BMenuItem *mnuItem = new BMenuItem(numb.String(), new BMessage('colC'));
		mnuColumns->AddItem(mnuItem);
		if (i == columns) {
			mnuItem->SetMarked(true);
		}
	}
	
	fMnuFldColumns = new BMenuField(itmRect, "mnuCols", "Columns:", mnuColumns, B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fSettingBox->AddChild(fMnuFldColumns);
	
	itmRect.OffsetBy(0, itmRect.Height());
	// Hotkey
	BRect stringRect(itmRect);
	stringRect.OffsetBy(0, -(itmRect.Height() / 3));
	fStrHotKey = new BStringView(stringRect, "lblModifiers", "Modifiers:", B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fStrHotKey);
	itmRect.OffsetBy(0, itmRect.Height());

	// Caps Lock
	fCapsLock = new BamKeysKeyView(itmRect, "capsLock", B_CAPS_LOCK, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fCapsLock);
	itmRect.OffsetBy(0, itmRect.Height());
	
	// Num Lock
	fNumLock = new BamKeysKeyView(itmRect, "numLock", B_NUM_LOCK, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fNumLock);
	itmRect.OffsetBy(0, itmRect.Height());

	// Scroll Lock
	fScrlLock = new BamKeysKeyView(itmRect, "scrollLock", B_SCROLL_LOCK, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fScrlLock);
	itmRect.OffsetBy(0, itmRect.Height());
	
	BPoint half = itmRect.RightBottom();
	
	half.x = half.x / 2;
	itmRect.SetRightBottom(half);
	
	// Command Keys
	fLeftCommand = new BamKeysKeyView(itmRect, "leftCommand", B_LEFT_COMMAND_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftCommand);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightCommand = new BamKeysKeyView(itmRect, "rightCommand", B_RIGHT_COMMAND_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightCommand);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	// Ctrl Keys
	fLeftControl = new BamKeysKeyView(itmRect, "leftControl", B_LEFT_CONTROL_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftControl);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightControl = new BamKeysKeyView(itmRect, "rightControl", B_RIGHT_CONTROL_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightControl);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	// Option Keys
	fLeftOption = new BamKeysKeyView(itmRect, "leftOption", B_LEFT_OPTION_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftOption);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightOption = new BamKeysKeyView(itmRect, "rightOption", B_RIGHT_OPTION_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightOption);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	// Shift Keys
	fLeftShift = new BamKeysKeyView(itmRect, "leftShift", B_LEFT_SHIFT_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftShift);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightShift = new BamKeysKeyView(itmRect, "rightShift", B_RIGHT_SHIFT_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightShift);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	
	// Buttons that do things!
	fBtnDefaults = new BButton(BRect(10, HEIGHT - 35, 85, HEIGHT - 15), 
							"btn_defaults", "Defaults", new BMessage('deft'),
							B_FOLLOW_BOTTOM | B_FOLLOW_LEFT);
	fBtnRevert = new BButton(BRect(95, HEIGHT - 35, 170, HEIGHT - 15),
							"btn_revert", "Revert", new BMessage('revt'),
							B_FOLLOW_BOTTOM | B_FOLLOW_LEFT);
	
	fRootView->AddChild(fScreenBox);
	fRootView->AddChild(fSettingBox, fScreenBox);
	fRootView->AddChild(fBtnDefaults, fSettingBox);
	fRootView->AddChild(fBtnRevert, fBtnDefaults);
	
	// If the fGrid couldn't load it settings, force our applications' defaults.
	if (fGrid->InitCheck() != B_OK) {
		BMessage *defaults = new BMessage('deft');
		MessageReceived(defaults);
		fGrid->SaveSettings();
		delete defaults;
		fModified = false;
	}
	fBtnRevert->SetEnabled(fModified);
}