Exemple #1
0
void MainView::getSelBounds(BRect& bounds)
{
	BPoint upper_left, lower_right;
	
	upper_left.x = upper_left.y = 999999;
	lower_right.x = lower_right.y = 0;
	
	for(int i = 0; i < selected_fields.CountItems(); i++) {
		BView *field = (BView *)selected_fields.ItemAt(i);
		BRect frame = field->Frame();
		BPoint tl = frame.LeftTop();
		BPoint br = frame.RightBottom();
		
		if(tl.x < upper_left.x) {
			upper_left.x = tl.x;
		}
		if(br.x > lower_right.x) {
			lower_right.x = br.x;
		}
		if(tl.y < upper_left.y) {
			upper_left.y = tl.y;
		}
		if(br.y > lower_right.y) {
			lower_right.y = br.y;
		}
	}
	
	bounds.SetLeftTop(upper_left);
	bounds.SetRightBottom(lower_right);
}
Exemple #2
0
void AnalogView::UpdateNeedle(short cpuTime)
{
	BRect	updateRect;
	BRect	rt;

	if(cpuTime != oldCPUTime)
	{
		rt.SetRightBottom(param.meterCenter);
		rt.SetLeftTop(angle[oldCPUTime].arry);
		if(rt.left > rt.right)
		{
			double tmp = rt.left;
			rt.left = rt.right;
			rt.right = tmp;
		}

		DrawBitmap(panel, rt, rt);

		const rgb_color kNeedleColor = {0,0,0,0};
		//const rgb_color kNeedleColor = {0,255,0,0};
		this->SetHighColor(kNeedleColor);

		StrokeLine(param.meterCenter, angle[cpuTime].arry);
	}
	Sync();
	oldCPUTime = cpuTime;
}
Exemple #3
0
status_t
StyledEditView::GetStyledText(BPositionIO* stream)
{
	fSuppressChanges = true;
	status_t result = BTranslationUtils::GetStyledText(stream, this,
		fEncoding.String());
	fSuppressChanges = false;

	if (result != B_OK)
		return result;

	BNode* node = dynamic_cast<BNode*>(stream);
	if (node != NULL) {
		// get encoding
		if (node->ReadAttrString("be:encoding", &fEncoding) != B_OK) {
			// try to read as "int32"
			int32 encoding;
			ssize_t bytesRead = node->ReadAttr("be:encoding", B_INT32_TYPE, 0,
				&encoding, sizeof(encoding));
			if (bytesRead == (ssize_t)sizeof(encoding)) {
				if (encoding == 65535) {
					fEncoding = "UTF-8";
				} else {
					const BCharacterSet* characterSet
						= BCharacterSetRoster::GetCharacterSetByConversionID(encoding);
					if (characterSet != NULL)
						fEncoding = characterSet->GetName();
				}
			}
		}

		// TODO: move those into BTranslationUtils::GetStyledText() as well?

		// restore alignment
		int32 align;
		ssize_t bytesRead = node->ReadAttr("alignment", 0, 0, &align, sizeof(align));
		if (bytesRead == (ssize_t)sizeof(align))
			SetAlignment((alignment)align);

		// restore wrapping
		bool wrap;
		bytesRead = node->ReadAttr("wrap", 0, 0, &wrap, sizeof(wrap));
		if (bytesRead == (ssize_t)sizeof(wrap)) {
			SetWordWrap(wrap);
			if (wrap == false) {
				BRect textRect;
				textRect = Bounds();
				textRect.OffsetTo(B_ORIGIN);
				textRect.InsetBy(TEXT_INSET, TEXT_INSET);
					// the width comes from stylededit R5. TODO: find a better way
				textRect.SetRightBottom(BPoint(1500.0, textRect.RightBottom().y));
				SetTextRect(textRect);
			}
		}
	}

	return result;
}
_MediaBar_::_MediaBar_(
	BRect		frame,
	MediaView	*owner)
		: BView(frame, B_EMPTY_STRING, B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW)
{
	fOwner = owner;

	BRect buttonRect;
	buttonRect.SetLeftTop(BPoint(kMediaBarInset, kMediaBarInset + 1.0));
	buttonRect.SetRightBottom(buttonRect.LeftTop() + kPlayButtonSize);
	
	fPlayPauseButton = new PlayPauseButton(buttonRect,
										   B_EMPTY_STRING,
										   kPlayButtonBitmapBits, 
										   kPressedPlayButtonBitmapBits, 
										   kDisabledPlayButtonBitmapBits,
										   kPlayingPlayButtonBitmapBits, 
										   kPressedPlayingPlayButtonBitmapBits,
										   kPausedPlayButtonBitmapBits, 
										   kPressedPausedPlayButtonBitmapBits,
										   new BMessage(msg_PlayPause), 
										   ' ', 
										   0, 
										   B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	AddChild(fPlayPauseButton);
	fPlayPauseButton->SetPaused();

	BRect sliderRect = Bounds();
	sliderRect.left = buttonRect.right;
	sliderRect.InsetBy(kMediaBarInset * 4, kMediaBarInset);	

	fMediaSlider = new _MediaSlider_(sliderRect, fOwner);
	AddChild(fMediaSlider);

	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
Exemple #5
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);
}