filter_result
MouseDownFilter(BMessage* message, BHandler** handlers, BMessageFilter* filter)
{
	BWindow* window = dynamic_cast<BWindow*> (filter->Looper());
	if (window == NULL)
		return B_DISPATCH_MESSAGE;

	MagStringView* magStringView = dynamic_cast<MagStringView*> (handlers[0]);
	if (magStringView == NULL)
		return B_DISPATCH_MESSAGE;

	BPoint point;
	message->FindPoint("be:view_where", &point);
	BRect bounds(magStringView->Bounds());
	if (!bounds.Contains(point))
		return B_DISPATCH_MESSAGE;

	ImageView* imageView = dynamic_cast<ImageView*>(window->FindView("image_view"));
	if (imageView == NULL)
		return B_DISPATCH_MESSAGE;

	magStringView->SetEventMask(B_POINTER_EVENTS);

	gPopUpSlider = PopUpSlider::Instantiate(BMessenger(imageView, window),
		new BMessage(HS_SET_MAGNIFYING_SCALE), 10, 1600);

	// Convert nonlinear from [0.1,16] -> [10,1600]
	float value = 1590.0 * log10((9.0 * (imageView->getMagScale() - 0.1) / 15.9)
		+ 1.0) + 10.0;

	BSlider* slider = gPopUpSlider->Slider();
	slider->SetValue(int32(value));
	slider->SetModificationMessage(new BMessage(HS_SET_MAGNIFYING_SCALE));

	BRect rect(slider->BarFrame());
	float offset = (slider->Position() * (rect.Width() - 1.0)) + 8.0;

	rect = gPopUpSlider->Bounds();
	bounds = magStringView->ConvertToScreen(bounds);

	message->FindPoint("screen_where", &point);
	gPopUpSlider->MoveTo(point.x - offset, bounds.top - rect.Height());
	gPopUpSlider->Go();

	return B_SKIP_MESSAGE;
}
Esempio n. 2
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);
}
Esempio 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();
}
Esempio n. 4
0
BView* PrefsWindow::constructColourBox(BRect frame)
{
	BBox* colourBox = new BBox(frame);
	colourBox->SetLabel("TexView");

	float	offset = 30.0f,
			texViewWidth = 280.0f,
			texHeight = 200.0f,
			adjust = 5.0f,
			cbheight = 14.0f,
			cbspacing = 10.0f,
			bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f	
			;
			
	BRect bounds = colourBox->Bounds();
	
	float texViewX1 = bounds.right - texViewWidth - (offset * 2.0f / 3.0f);
	float texViewX2 = bounds.right - (offset * 2.0f / 3.0f) - B_V_SCROLL_BAR_WIDTH;
	BRect texViewRect(texViewX1, offset - adjust, texViewX2, offset + texHeight - adjust);	
	BRect texViewTextRect(texViewRect);
		
	/*TexView *texView = new TexView(texViewRect, texViewTextRect, prefs);
	BString sampleText = "Welcome to \\betex!\\\\\n%This is a Comment\n$Phe\\alpha r the Calculus$\n\\subsection{About \\betex}\n\\betex is \\textbf{cool}!\\\\\n``To Be Or Not To Be\'\'\n";
	texView->SetText(sampleText.String(),sampleText.Length());
	texView->MakeEditable(false);
	texView->MakeSelectable(false);
	
	BScrollView *texViewScroll = new BScrollView("textViewScroll", texView, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE, false, true, B_FANCY_BORDER);
	texViewScroll->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	colourBox->AddChild(texViewScroll);	
	texView->SetTextRect(texView->Bounds());*/	
	
	//fg colour button
	BRect ccRect((offset*2/3),offset-adjust,offset+150,offset+cbheight-adjust);	
	rgb_color fgColour;
	ColourButton *fgColourButton = new ColourButton(ccRect, GetPrefsMessage(K_FG_COLOUR), fgColour," Text");
	colourBox->AddChild(fgColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color bgColour;
	ColourButton *bgColourButton = new ColourButton(ccRect, GetPrefsMessage(K_BG_COLOUR), bgColour, "Background");
	colourBox->AddChild(bgColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color genericCmdColour;
	ColourButton *genericCmdColourButton = new ColourButton(ccRect, GetPrefsMessage(K_GEN_CMD_COLOUR), genericCmdColour, "Generic Commands");
	colourBox->AddChild(genericCmdColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color formatCmdColour;
	ColourButton *formatCmdColourButton  = new ColourButton(ccRect, GetPrefsMessage(K_FORMAT_CMD_COLOUR), formatCmdColour, "Formatting Commands");
	colourBox->AddChild(formatCmdColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color specialCmdColour;
	ColourButton *specialCmdColourButton = new ColourButton(ccRect, GetPrefsMessage(K_SPECIAL_CMD_COLOUR), specialCmdColour, "Special Commands");
	colourBox->AddChild(specialCmdColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color mathModeColour;
	ColourButton *mathModeColourButton = new ColourButton(ccRect, GetPrefsMessage(K_MATH_MODE_COLOUR), mathModeColour, "Math Mode");
	colourBox->AddChild(mathModeColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color commaColour;
	ColourButton *commaColourButton = new ColourButton(ccRect, GetPrefsMessage(K_COMMA_COLOUR), commaColour, "Quotation Marks");
	colourBox->AddChild(commaColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color commentColour;
	ColourButton *commentColourButton = new ColourButton(ccRect,GetPrefsMessage(K_COMMENT_COLOUR),commentColour,"Comments");
	colourBox->AddChild(commentColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	rgb_color puncSymbolColour;
	ColourButton *puncSymbolColourButton = new ColourButton(ccRect,GetPrefsMessage(K_PUNC_SYMBOL_COLOUR),puncSymbolColour,"Punctuation / Symbols");
	colourBox->AddChild(puncSymbolColourButton);
	
	ccRect.OffsetBy(0,cbheight+cbspacing);
	//rgb_color htmlColour;
	//ColourButton *htmlColourButton = new ColourButton(ccRect,GetPrefsMessage(K_HTML_COLOUR), htmlColour,"Urls");
	//colourBox->AddChild(htmlColourButton);
	
	BRect cbRect = colourBox->Bounds();
	BRect cbbtnRect(cbRect.right - bspacing - bwidth, cbRect.bottom - bspacing - bheight, cbRect.right - bspacing, cbRect.bottom - bspacing);
	BButton *resetColourDefaults = new BButton(cbbtnRect,"fResetColorDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_COLOUR_DEFAULTS));
	colourBox->AddChild(resetColourDefaults);
	
	float	sliderWidth = 300.0f,
			vertOffset = 50.0f,
			minVal = 5.0f,
			maxVal = 30.0f
			;		
	BRect sliderFrame(ccRect.left, ccRect.top + vertOffset, ccRect.left + sliderWidth, ccRect.top + vertOffset + 100.0f);
	BSlider *fontSizeSlider = new BSlider(sliderFrame, K_FONT_SIZE, "Font Size", GetPrefsMessage(K_FONT_SIZE), minVal, maxVal);
	colourBox->AddChild(fontSizeSlider);
	
	fontSizeSlider->SetBarColor(ui_color(B_WINDOW_TAB_COLOR));
	fontSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fontSizeSlider->SetHashMarkCount(26);
	float fontSize = 12.0f;
	fontSizeSlider->SetValue(fontSize);
	fontSizeSlider->SetLimitLabels("Small","Large");
	fontSizeSlider->SetModificationMessage(GetPrefsMessage(K_FONT_SIZE));
		
	rgb_color fire_r = {223,0,50};
	const rgb_color* fillcolor = &fire_r;
	fontSizeSlider->UseFillColor(true,fillcolor);
	
	return colourBox;
}