Ejemplo n.º 1
0
void
ImageView::AttachedToWindow()
{
	if (Parent() != NULL)
		SetViewColor(Parent()->ViewColor());
	else
		SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fEditor.StartWatching(this);
	if (fScaleSlider != NULL)
		fScaleSlider->SetTarget(this);

	_UpdateImage();
}
Ejemplo n.º 2
0
PopUpSlider*
PopUpSlider::Instantiate(const BMessenger& target, BMessage* message,
	int32 minRange, int32 maxRange)
{
	BSlider* slider = new BSlider(BRect(0.0, 0.0, 200.0, 0.0),
		"popUpSlider", NULL, message, minRange, maxRange, B_TRIANGLE_THUMB);

	slider->SetTarget(target);
	slider->ResizeToPreferred();
	slider->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	PopUpSlider* popUpSlider = new PopUpSlider(slider->Bounds());
	popUpSlider->fSlider = slider;
	popUpSlider->AddChild(slider);

	return popUpSlider;
}
Ejemplo n.º 3
0
void
JobSetupView::AddDoubleSlider(const DriverSpecificCap* capability,
	BGridLayout* gridLayout, int& row)
{
	PrinterCap::CapID category = static_cast<PrinterCap::CapID>(
		capability->ID());
	const DoubleRangeCap* range = fPrinterCap->FindDoubleRangeCap(category);
	if (range == NULL) {
		fprintf(stderr, "Internal error: DoubleRangeCap for '%s' not found!\n",
			capability->Label());
		return;
	}

	const char* label = capability->Label();
	const char* key = capability->Key();
	BString name;
	name << "pds_" << key;
	BMessage* message = new BMessage(kMsgDoubleSliderChanged);
	message->AddInt32(kCategoryID, category);
	BSlider* slider = new BSlider(name.String(), label,
		message, 0, 1000, B_HORIZONTAL);
	slider->SetModificationMessage(new BMessage(*message));
	slider->SetTarget(this);

	double value = range->DefaultValue();
	if (fJobData->Settings().HasDouble(key))
		value = fJobData->Settings().GetDouble(key);
	float position = static_cast<float>((value - range->Lower()) /
		(range->Upper() - range->Lower()));
	slider->SetPosition(position);

	gridLayout->AddView(slider, 0, row, 2);
	row ++;

	DoubleRange doubleRange(label, key, range, slider);
	fDriverSpecificDoubleSliders[category] = doubleRange;
	doubleRange.UpdateLabel();
}
Ejemplo n.º 4
0
VolumeWindow::VolumeWindow(BRect frame, bool dontBeep, int32 volumeWhich)
	: BWindow(frame, "VolumeWindow", B_BORDERED_WINDOW_LOOK,
		B_FLOATING_ALL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK
		| B_AUTO_UPDATE_SIZE_LIMITS, 0),
	fUpdatedCount(0)
{
	SetLayout(new BGroupLayout(B_HORIZONTAL));

	BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL);
	layout->SetInsets(5, 5, 5, 5);

	BBox* box = new BBox("sliderbox");
	box->SetLayout(layout);
	box->SetBorder(B_PLAIN_BORDER);
	AddChild(box);

	BSlider* slider = new VolumeControl(volumeWhich, !dontBeep,
		new BMessage(kMsgVolumeChanged));
	slider->SetModificationMessage(new BMessage(kMsgVolumeUpdate));
	box->AddChild(slider);

	slider->SetTarget(this);
	ResizeTo(300, 50);

	// Make sure it's not outside the screen.
	const int32 kMargin = 3;
	BRect windowRect = Frame();
	BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame());
	if (screenFrame.right < windowRect.right + kMargin)
		MoveBy(- kMargin - windowRect.right + screenFrame.right, 0);
	if (screenFrame.bottom < windowRect.bottom + kMargin)
		MoveBy(0, - kMargin - windowRect.bottom + screenFrame.bottom);
	if (screenFrame.left > windowRect.left - kMargin)
		MoveBy(kMargin + screenFrame.left - windowRect.left, 0);
	if (screenFrame.top > windowRect.top - kMargin)
		MoveBy(0, kMargin + screenFrame.top - windowRect.top);
}