KeyboardWindow::KeyboardWindow()
	:
	BWindow(BRect(0, 0, 200, 200), B_TRANSLATE_SYSTEM_NAME("Keyboard"),
		B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
		| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	MoveTo(fSettings.WindowCorner());

	// Add the main settings view
	fSettingsView = new KeyboardView();
	BBox* fSettingsBox = new BBox("keyboard_box");
	fSettingsBox->AddChild(fSettingsView);

	// Add the "Default" button..
	fDefaultsButton = new BButton(B_TRANSLATE("Defaults"), new BMessage(BUTTON_DEFAULTS));

	// Add the "Revert" button...
	fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(BUTTON_REVERT));
	fRevertButton->SetEnabled(false);

	// Build the layout
	SetLayout(new BGroupLayout(B_VERTICAL));

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
		.Add(fSettingsBox)
		.AddGroup(B_HORIZONTAL, 7)
			.Add(fDefaultsButton)
			.Add(fRevertButton)
			.AddGlue()
		.End()
		.SetInsets(10, 10, 10, 10)
	);

	BSlider* slider = (BSlider* )FindView("key_repeat_rate");
	if (slider !=NULL)
		slider->SetValue(fSettings.KeyboardRepeatRate());

	slider = (BSlider* )FindView("delay_until_key_repeat");
	if (slider !=NULL)
		slider->SetValue(fSettings.KeyboardRepeatDelay());

	fDefaultsButton->SetEnabled(fSettings.IsDefaultable());

	// center window if it would be off-screen
	BScreen screen;
	if (screen.Frame().right < Frame().right
		|| screen.Frame().bottom < Frame().bottom) {
		CenterOnScreen();
	}

#ifdef DEBUG
	fSettings.Dump();
#endif

	Show();
}
void
Window::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgShowAlert:
		{
			int32 count = fCountSlider->Value();

			BAlert* alert = new BAlert("Test title", "Lorem ipsum dolor sit "
				"amet, consectetur adipiscing elit. Suspendisse vel iaculis "
				"quam. Donec faucibus erat nunc, ac ullamcorper justo sodales.",
				"short 1", count > 1 ? "a bit longer 2" : NULL,
				count > 2 ? "very very long button 3" : NULL,
				_ButtonWidth(), _ButtonSpacing(), _AlertType());
			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			int result = alert->Go();
			if (result < 0) {
				fLastStringView->SetText("Canceled alert");
			} else {
				fLastStringView->SetText(BString().SetToFormat(
					"Pressed button %d", result + 1).String());
			}
			break;
		}
		default:
			BWindow::MessageReceived(message);
	}
}
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;
}
Example #4
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;
}
Example #5
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();
}
Example #6
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);
}
Example #7
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();
}
Example #8
0
//calculate the view positions of all the MatrixLayoutItems
//on the items list with offsets based upon matrixLeft
//and matrixTop
void 
LayoutMatrix	::	Calc(	const float paramMatrixLeft,  
							const float paramMatrixTop,
							sem_id paramSemID) 
{
	int32 numItems = mpItemsList->CountItems();
	if (!numItems) return;
	if (acquire_sem(paramSemID) != B_NO_ERROR)
	{
		warning(myPrefs->FailAqSem);
		return;
	}
	bool hasPopUpMenu = false;
	TextItem *	scratchTextItem;
	for (	int i = 0;
			i < numItems;
			i++)
	{
		((LayoutMatrixItem *)(mpItemsList->ItemAt(i)))->Calc();
	}
	float widest = 0;
	float tallest = 0;
	int32 index = 0;
	for (	int i = 0;
			i < numItems;
			i++)
	{
		LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
		if (lmi->mfWidthPref > widest) 
		{
			widest = lmi->mfWidthPref;
		}
		if (lmi->mfHeightPref > tallest) 
		{
			tallest = lmi->mfHeightPref;
		}
	}
	if (mui32Flags & SAMESIZE) 
	{//SAMESIZE makes all items the same size as the largest
		index = 0;
		//Resize all items to match largest:
		for (	uint32 i = 0;
				i < mui32Rows;
				i++) 
		{
			for (	uint32 j = 0;
					j < mui32Columns;
					j++) 
			{
				LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
				switch (lmi->mui32Kind)
				{
					case KIND_MYSPACER:
					{
						MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
						if (scratchMySpacer->mbSAMEFromWidest)
						{
							scratchMySpacer->ResizeTo(widest, tallest);
						}
					}
					break;
					case KIND_MYBUTTON:
					{
						BButton * scratchMyButton = (BButton *)lmi->mpItem;
						scratchMyButton->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYSLIDER:
					{
						BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
						scratchMySlider->ResizeTo(widest, tallest);
					}
					break;
					case KIND_STRINGDRAWER:
					{
						BStringView * scratchMyStringView = (BStringView *)lmi->mpItem;
						scratchMyStringView->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYCHECKBOX:
					{
						BCheckBox * scratchMyCheckBox = (BCheckBox *)lmi->mpItem;
						scratchMyCheckBox->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYPICTUREBUTTON:
					{
						BPictureButton * scratchMyPictureButton = (BPictureButton *)lmi->mpItem;
						scratchMyPictureButton->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYCOLORCONTROL:
					{
						BColorControl * scratchMyColorControl = (BColorControl *)lmi->mpItem;
						scratchMyColorControl->ResizeTo(widest, tallest);
					}
					break;
					case KIND_MYSTATUSBAR:
					{
						BStatusBar * scratchMyStatusBar = (BStatusBar *)lmi->mpItem;
						scratchMyStatusBar->ResizeTo(widest, tallest);
					}
					break;
					case KIND_UINT32CONTROL:
					{
						UInt32Control * scratchUInt32Control = (UInt32Control *)lmi->mpItem;
						scratchUInt32Control->ResizeTo(widest, tallest);
					}
					break;
					case KIND_FLOATCONTROL:
					{
						FloatControl * scratchFloatControl = (FloatControl *)lmi->mpItem;
						scratchFloatControl->ResizeTo(widest, tallest);
					}
					break;
					case KIND_STRINGCONTROL:
					{
						StringControl * scratchStringControl = (StringControl *)lmi->mpItem;
						scratchStringControl->ResizeTo(widest, tallest);
					}
					break;
				}
			}
		}
	}
	index = 0;
	//move every item based upon size and padding:
	const float hpad = 2;//horizontal spacing between items
	const float vpad = 2;//vertical spacing between items
	float localLeft;
	float localTop = vpad + paramMatrixTop;
	float excessRight = 0, excessRightHold = 0;
	float excessBottom = 0, excessBottomHold = 0;
	for (	uint32 ii = 0;
			ii < mui32Rows;
			ii++) 
	{
		localLeft = paramMatrixLeft + hpad;
		float columnRight = 0;
		excessBottom = 0;
		for (	uint32 jj = 0;
				jj < mui32Columns;
				jj++) 
		{
			excessRight = 0;
			LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
			switch (lmi->mui32Kind) 
			{
				case KIND_MYPOPUPMENU:
				{
					hasPopUpMenu = true;
					MyPopUpMenu * scratchPopUpMenu = (MyPopUpMenu *)lmi->mpItem;
					scratchPopUpMenu->mfLabelLeft = localLeft;
					excessRightHold = lmi->mfWidthPref + scratchPopUpMenu->mfLabelWidth;
					scratchPopUpMenu->SetLeft(localLeft);
					scratchPopUpMenu->mfLabelTop = localTop;
					if ((scratchPopUpMenu->mfHeight + 9) > scratchPopUpMenu->mfLabelHeight)
					{
						excessBottomHold = scratchPopUpMenu->mfHeight + 10;
					}
					else
					{
						excessBottomHold = scratchPopUpMenu->mfLabelHeight + 1;
					}
				}
				break;
				case KIND_MYTEXTVIEW:
				{
					BTextView * scratchTextView = (BTextView *)lmi->mpItem;
					scratchTextView->MoveTo(localLeft, localTop);
					excessRightHold = ((MyTextView *)scratchTextView)->mfWidth;
					excessBottomHold = ((MyTextView *)scratchTextView)->mfHeight;
				}
				break;
				case KIND_MYLISTVIEW:
				{
					BListView * scratchListView = (BListView *)lmi->mpItem;
					scratchListView->MoveTo(localLeft, localTop);
					((BListView *)(lmi->mpItem))->GetPreferredSize(&excessRightHold, &excessBottomHold);
				}
				break;
				case KIND_MYBUTTON:
				{
					BButton * scratchMyButton = (BButton *)lmi->mpItem;
					scratchMyButton->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_MYSLIDER:
				{
					BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
					scratchMySlider->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_MYSPACER:
				{
					MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
					if (	(mui32Flags & SAMESIZE) 
							&& 
							scratchMySpacer->mbSAMEFromWidest)
					{
						excessRightHold = widest;
						excessBottomHold = tallest;
					}
					else
					{
						excessRightHold = scratchMySpacer->mfPreferredWidth;
						excessBottomHold = scratchMySpacer->mfPreferredHeight;
					}
				}
				break;
				case KIND_MYRADIOVIEW:
				{
					MyRadioView * scratchRadioView = (MyRadioView *)lmi->mpItem;
					scratchRadioView->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_STRINGDRAWER:
				{
					BStringView * scratchMyStringView = (BStringView *)lmi->mpItem;
					TextItem * scratchTextItem = ((MyStringDrawer *)lmi->mpItem)->GetTextItem();
					scratchTextItem->mfLeft = localLeft;
					scratchTextItem->mfTop = localTop + lmi->mfHeightPref - ((MyStringDrawer *)lmi->mpItem)->mfDescender - vpad;
					scratchMyStringView->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_MYCHECKBOX:
				{
					BCheckBox * scratchMyCheckBox = (BCheckBox *)lmi->mpItem;
					scratchMyCheckBox->MoveTo(localLeft, localTop + 1);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref + 1;
				}
				break;
				case KIND_MYPICTUREBUTTON:
				{
					BPictureButton * scratchMyPictureButton = (BPictureButton *)lmi->mpItem;
					scratchMyPictureButton->MoveTo(localLeft, localTop);
					excessRightHold = scratchMyPictureButton->Bounds().Width() + 1;
					excessBottomHold = scratchMyPictureButton->Bounds().Height() + 1;
				}
				break;
				case KIND_MYCOLORCONTROL:
				{
					BColorControl * scratchMyColorControl = (BColorControl *)lmi->mpItem;
					scratchMyColorControl->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
					;
				}
				break;
				case KIND_MYSTATUSBAR:
				{
					MyStatusBar * scratchMyStatusBar = (MyStatusBar *)lmi->mpItem;
					scratchMyStatusBar->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_UINT32CONTROL:
				{
					UInt32Control * scratchUInt32Control = (UInt32Control *)lmi->mpItem;
					scratchUInt32Control->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_FLOATCONTROL:
				{
					FloatControl * scratchFloatControl = (FloatControl *)lmi->mpItem;
					scratchFloatControl->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_STRINGCONTROL:
				{
					StringControl * scratchStringControl = (StringControl *)lmi->mpItem;
					scratchStringControl->MoveTo(localLeft, localTop);
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				}
				break;
				case KIND_TEXT:
					scratchTextItem = (TextItem *)lmi->mpItem;
					scratchTextItem->mfLeft = localLeft;
					scratchTextItem->mfTop = localTop + lmi->mfHeightPref;
					excessRightHold = lmi->mfWidthPref;
					excessBottomHold = lmi->mfHeightPref;
				break;
				case KIND_COLORWELL:
					((ColorWell *)lmi->mpItem)->mfLabelLeft = localLeft;
					((ColorWell *)lmi->mpItem)->SetLeft(((ColorWell *)lmi->mpItem)->GetLeft() + localLeft);
					excessRightHold = lmi->mfWidthPref;
					((ColorWell *)lmi->mpItem)->mfLabelTop = localTop;
					((ColorWell *)lmi->mpItem)->SetTop(((ColorWell *)lmi->mpItem)->GetTop() + localTop);
					excessBottomHold = lmi->mfHeightPref;
				break;
				case KIND_INT8GADGET:
				case KIND_UINT8GADGET:
				case KIND_INT16GADGET:
				case KIND_UINT16GADGET:
				case KIND_INT32GADGET:
				case KIND_UINT32GADGET:
				case KIND_INT64GADGET:
				case KIND_UINT64GADGET:
				case KIND_FLOATGADGET:
				case KIND_HEXGADGET:
				case KIND_STRINGGADGET:
					((GadgetBase *)lmi->mpItem)->mfLabelLeft = localLeft;
					((GadgetBase *)lmi->mpItem)->SetLeft(((GadgetBase *)lmi->mpItem)->GetLeft() + localLeft);
					excessRightHold = lmi->mfWidthPref;
					((GadgetBase *)lmi->mpItem)->mfLabelTop = localTop;
					((GadgetBase *)lmi->mpItem)->SetTop(((GadgetBase *)lmi->mpItem)->GetTop() + localTop);
					excessBottomHold = lmi->mfHeightPref + 1;
				break;
			}
			if (mui32Flags & SAMESIZE)
			{
				excessRightHold = widest;
				excessBottomHold = tallest;
			}
			excessRightHold += hpad;
			if (excessRightHold > excessRight)
			{
				excessRight = excessRightHold;
			}
			localLeft += excessRight;
			if (mui32Columns - 1) 
			{
				if (jj != (mui32Columns - 1)) 
				{
					if (localLeft > columnRight) 
					{
						columnRight = localLeft;
					}
				}
				else 
				{
					columnRight = localLeft;
				}
			}
			else 
			{
				if (localLeft > columnRight) 
				{
					columnRight = localLeft;
				}
			}
			//mfRight is stored so that another MatrixLayout
			//can know where a previous one ended up
			if (excessBottomHold > excessBottom)
			{
				excessBottom = excessBottomHold;
			}
		}
		if (columnRight > mfRight)
		{
			mfRight = columnRight;
		}
		excessBottomHold += vpad;
		localTop += excessBottom;
		if (mui32Rows - 1) 
		{
			if (ii != (mui32Rows - 1)) 
			{
				if (localTop > mfBottom) 
				{
					mfBottom = localTop;
				}
			}
			else 
			{
				mfBottom = localTop;
			}
		}
		else 
		{
			if (localTop > mfBottom) 
			{
				mfBottom = localTop;
			}
		}
		//mfBottom is stored so that another MatrixLayout
		//can know where a previous one ended up
	}
	if (hasPopUpMenu)
	{
		mfRight += 30;
	}
	release_sem(paramSemID);
}//end
Example #9
0
void
ImageView::_UpdateImage()
{
	// ToDo: add scroller if necessary?!

	BAutolock locker(fEditor);

	// we need all the data...

	size_t viewSize = fEditor.ViewSize();
	// that may need some more memory...
	if ((off_t)viewSize < fEditor.FileSize())
		fEditor.SetViewSize(fEditor.FileSize());

	const char *data;
	if (fEditor.GetViewBuffer((const uint8 **)&data) != B_OK) {
		fEditor.SetViewSize(viewSize);
		return;
	}

	if (fBitmap != NULL && (fEditor.Type() == B_MINI_ICON_TYPE
			|| fEditor.Type() == B_LARGE_ICON_TYPE)) {
		// optimize icon update...
		fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
		fEditor.SetViewSize(viewSize);
		return;
	}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
	if (fBitmap != NULL && fEditor.Type() == B_VECTOR_ICON_TYPE
		&& fScaleSlider->Value() * 8 - 1 == fBitmap->Bounds().Width()) {
		if (BIconUtils::GetVectorIcon((const uint8 *)data,
				(size_t)fEditor.FileSize(), fBitmap) == B_OK) {
			fEditor.SetViewSize(viewSize);
			return;
		}
	}
#endif

	delete fBitmap;
	fBitmap = NULL;

	switch (fEditor.Type()) {
		case B_MINI_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
			if (fBitmap->InitCheck() == B_OK)
				fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
			break;
		case B_LARGE_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
			if (fBitmap->InitCheck() == B_OK)
				fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
			break;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
		case B_VECTOR_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, fScaleSlider->Value() * 8 - 1,
				fScaleSlider->Value() * 8 - 1), B_RGB32);
			if (fBitmap->InitCheck() != B_OK
				|| BIconUtils::GetVectorIcon((const uint8 *)data,
					(size_t)fEditor.FileSize(), fBitmap) != B_OK) {
				delete fBitmap;
				fBitmap = NULL;
			}
			break;
#endif
		case B_PNG_FORMAT:
		{
			BMemoryIO stream(data, fEditor.FileSize());
			fBitmap = BTranslationUtils::GetBitmap(&stream);
			break;
		}
		case B_MESSAGE_TYPE:
		{
			BMessage message;
			// ToDo: this could be problematic if the data is not large
			//		enough to contain the message...
			if (message.Unflatten(data) == B_OK)
				fBitmap = new BBitmap(&message);
			break;
		}
	}

	// Update the bitmap description. If no image can be displayed,
	// we will show our "unsupported" message

	if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) {
		delete fBitmap;
		fBitmap = NULL;
	}

	if (fBitmap != NULL) {
		char buffer[256];
		const char *type = B_TRANSLATE("Unknown type");
		switch (fEditor.Type()) {
			case B_MINI_ICON_TYPE:
			case B_LARGE_ICON_TYPE:
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
			case B_VECTOR_ICON_TYPE:
#endif
				type = B_TRANSLATE("Icon");
				break;
			case B_PNG_FORMAT:
				type = B_TRANSLATE("PNG format");
				break;
			case B_MESSAGE_TYPE:
				type = B_TRANSLATE("Flattened bitmap");
				break;
			default:
				break;
		}
		const char *colorSpace;
		switch (fBitmap->ColorSpace()) {
			case B_GRAY1:
			case B_GRAY8:
				colorSpace = B_TRANSLATE("Grayscale");
				break;
			case B_CMAP8:
				colorSpace = B_TRANSLATE("8 bit palette");
				break;
			case B_RGB32:
			case B_RGBA32:
			case B_RGB32_BIG:
			case B_RGBA32_BIG:
				colorSpace = B_TRANSLATE("32 bit");
				break;
			case B_RGB15:
			case B_RGBA15:
			case B_RGB15_BIG:
			case B_RGBA15_BIG:
				colorSpace = B_TRANSLATE("15 bit");
				break;
			case B_RGB16:
			case B_RGB16_BIG:
				colorSpace = B_TRANSLATE("16 bit");
				break;
			default:
				colorSpace = B_TRANSLATE("Unknown format");
				break;
		}
		snprintf(buffer, sizeof(buffer), "%s, %g x %g, %s", type,
			fBitmap->Bounds().Width() + 1, fBitmap->Bounds().Height() + 1, 
			colorSpace);
		fDescriptionView->SetText(buffer);
	} else
		fDescriptionView->SetText(B_TRANSLATE_COMMENT("Could not read image", 
			"Image means here a picture file, not a disk image."));

	// Update the view size to match the image and its description

	float width, height;
	fDescriptionView->GetPreferredSize(&width, &height);
	fDescriptionView->ResizeTo(width, height);

	BRect rect = fDescriptionView->Bounds();
	if (fBitmap != NULL) {
		BRect bounds = fBitmap->Bounds();
		rect.bottom += bounds.Height() + 5;

		if (fScaleSlider != NULL && rect.Width() < fScaleSlider->Bounds().Width())
			rect.right = fScaleSlider->Bounds().right;
		if (bounds.Width() > rect.Width())
			rect.right = bounds.right;

		// center description below the bitmap
		fDescriptionView->MoveTo((rect.Width() - fDescriptionView->Bounds().Width()) / 2,
			bounds.Height() + 5);

		if (fScaleSlider != NULL) {
			// center slider below description
			rect.bottom += fScaleSlider->Bounds().Height() + 5;
			fScaleSlider->MoveTo((rect.Width() - fScaleSlider->Bounds().Width()) / 2,
				fDescriptionView->Frame().bottom + 5);

			if (fScaleSlider->IsHidden())
				fScaleSlider->Show();
		}
	} else if (fScaleSlider != NULL && !fScaleSlider->IsHidden())
		fScaleSlider->Hide();

	ResizeTo(rect.Width(), rect.Height());
	if (Parent()) {
		// center within parent view
		BRect parentBounds = Parent()->Bounds();
		MoveTo((parentBounds.Width() - rect.Width()) / 2,
			(parentBounds.Height() - rect.Height()) / 2);
	}

	Invalidate();

	// restore old view size
	fEditor.SetViewSize(viewSize);
}
void
KeyboardWindow::MessageReceived(BMessage* message)
{
	BSlider* slider = NULL;

	switch (message->what) {
		case BUTTON_DEFAULTS:
		{
			fSettings.Defaults();

			slider = (BSlider* )FindView("key_repeat_rate");
			if (slider !=NULL)
				slider->SetValue(fSettings.KeyboardRepeatRate());

			slider = (BSlider* )FindView("delay_until_key_repeat");
			if (slider !=NULL)
				slider->SetValue(fSettings.KeyboardRepeatDelay());

			fDefaultsButton->SetEnabled(false);

  			fRevertButton->SetEnabled(true);
			break;
		}
		case BUTTON_REVERT:
		{
			fSettings.Revert();

			slider = (BSlider* )FindView("key_repeat_rate");
			if (slider !=NULL)
				slider->SetValue(fSettings.KeyboardRepeatRate());

			slider = (BSlider* )FindView("delay_until_key_repeat");
			if (slider !=NULL)
				slider->SetValue(fSettings.KeyboardRepeatDelay());

			fDefaultsButton->SetEnabled(fSettings.IsDefaultable());

  			fRevertButton->SetEnabled(false);
			break;
		}
		case SLIDER_REPEAT_RATE:
		{
			int32 rate;
			if (message->FindInt32("be:value", &rate) != B_OK)
				break;
			fSettings.SetKeyboardRepeatRate(rate);

			fDefaultsButton->SetEnabled(fSettings.IsDefaultable());

			fRevertButton->SetEnabled(true);
			break;
		}
		case SLIDER_DELAY_RATE:
		{
			int32 delay;
			if (message->FindInt32("be:value", &delay) != B_OK)
				break;

			// We need to look at the value from the slider and make it "jump"
			// to the next notch along. Setting the min and max values of the
			// slider to 1 and 4 doesn't work like the real Keyboard app.
			if (delay < 375000)
				delay = 250000;
			if (delay >= 375000 && delay < 625000)
				delay = 500000;
			if (delay >= 625000 && delay < 875000)
				delay = 750000;
			if (delay >= 875000)
				delay = 1000000;

			fSettings.SetKeyboardRepeatDelay(delay);

			slider = (BSlider* )FindView("delay_until_key_repeat");
			if (slider != NULL)
				slider->SetValue(delay);

			fDefaultsButton->SetEnabled(fSettings.IsDefaultable());

			fRevertButton->SetEnabled(true);
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Example #11
0
void YabWindow::MessageReceived(BMessage *message)
{
	// if(message) message->PrintToStream();
	switch(message->what)
	{
		case YABBUTTON:
			{
				BString tmpMessage("");
                        	BButton *myButtonPressed;
                        	message->FindPointer("source",(void **) &myButtonPressed);
				tmpMessage += myButtonPressed->Name();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABMENU:
			{
				BString tmpMessage("");
				BMenuItem *mySelectedMenu;
                        	message->FindPointer("source",(void **) &mySelectedMenu);
				BMenu *myMenu = mySelectedMenu->Menu();
				tmpMessage += ((BMenuBar*)myMenu->Supermenu())->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Name();
				tmpMessage += ":";
                        	tmpMessage += mySelectedMenu->Label(); 
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABSUBMENU:
			{
				BString tmpMessage("");
				BMenuItem *mySelectedMenu;
                        	message->FindPointer("source",(void **) &mySelectedMenu);
				BMenu *myMenu = mySelectedMenu->Menu();
				tmpMessage += ((BMenuBar*)myMenu->Supermenu()->Supermenu())->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Supermenu()->Name();
				tmpMessage += ":";
				tmpMessage += myMenu->Name();
				tmpMessage += ":";
                        	tmpMessage += mySelectedMenu->Label(); 
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABTEXTCONTROL:
			{
				BString tmpMessage("");
				BTextControl *myTextControl;
                        	message->FindPointer("source",(void **) &myTextControl);
				tmpMessage += myTextControl->Name();
				tmpMessage += ":";
				tmpMessage += myTextControl->Text();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABCHECKBOX:
			{
				BString tmpMessage("");
				BCheckBox *myCheckBox;
                        	message->FindPointer("source",(void **) &myCheckBox);
				tmpMessage += myCheckBox->Name();
				tmpMessage += ":";
				if(myCheckBox->Value()==B_CONTROL_ON)
					tmpMessage += "ON|";
				else
					tmpMessage += "OFF|";
				messageString += tmpMessage;
			}
			break;
		case YABRADIOBUTTON:
			{
				BString tmpMessage("");
				BRadioButton *myRadioButton;
                        	message->FindPointer("source",(void **) &myRadioButton);
				tmpMessage += myRadioButton->Name();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABLISTBOXINVOKE:
			{
				BListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->CurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
					tmpMessage << i+1;
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABLISTBOXSELECT:
			{
				BListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->CurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Select:";
					// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
					tmpMessage << i+1;
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABDROPBOX:
			{
				BString tmpMessage("");
				BMenuItem *myMenuItem;
				message->FindPointer("source",(void **) &myMenuItem);
				tmpMessage += (myMenuItem->Menu())->Supermenu()->Parent()->Name();
				tmpMessage += ":";
				tmpMessage += myMenuItem->Label();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABSLIDER:
			{
				BString tmpMessage("");
                        	BSlider *mySlider;
                        	message->FindPointer("source",(void **) &mySlider);
				tmpMessage += mySlider->Name();
				tmpMessage += ":";
				tmpMessage << mySlider->Value();
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABCOLORCONTROL:
			{
				rgb_color col;
				BString tmpMessage("");
                        	BColorControl *myCControl;
                        	message->FindPointer("source",(void **) &myCControl);
				tmpMessage += myCControl->Name();
				tmpMessage += ":";
				col = myCControl->ValueAsColor();
				tmpMessage << col.red << ":" << col.green << ":" << col.blue;
				tmpMessage += "|";
				messageString += tmpMessage;
			}
			break;
		case YABTREEBOXINVOKE:
			{
				BOutlineListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->FullListCurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text();
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					tmpMessage << i+1;
					/*
					int n = tmpMessage.Length();
					BListItem *superitem = myList->Superitem(myList->FullListItemAt(i));
					while(superitem)
					{
						BString t("");
						t << ((BStringItem*)superitem)->Text() << ":";
						tmpMessage.Insert(t,n);
						superitem = myList->Superitem(superitem);
					}
					tmpMessage += txt;*/
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABTREEBOXSELECT:
			{
				BOutlineListView *myList;
				message->FindPointer("source",(void **) &myList);
				int i = myList->FullListCurrentSelection();
				if(i>=0)
				{
					BString tmpMessage("");
					const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text();
					tmpMessage += myList->Name();
					tmpMessage += ":_Select:";
					tmpMessage << i+1;
					/*
					int n = tmpMessage.Length();
					BListItem *superitem = myList->Superitem(myList->FullListItemAt(i));
					while(superitem)
					{
						BString t("");
						t << ((BStringItem*)superitem)->Text() << ":";
						tmpMessage.Insert(t,n);
						superitem = myList->Superitem(superitem);
					}
					tmpMessage += txt;*/
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABFILEBOXSELECT:
			{
				BColumnListView *myList;
				message->FindPointer("source",(void **) &myList);
				BRow *myRow = NULL;
				if(myList) myRow = myList->CurrentSelection();
				if(myRow)
				{
				//	if(!myList->IsFocus()) myList->MakeFocus();
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Select:";
					tmpMessage << myList->IndexOf(myRow)+1; 
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABFILEBOXINVOKE:
			{
				BColumnListView *myList;
				message->FindPointer("source",(void **) &myList);
				BRow *myRow = NULL;
				if(myList) myRow = myList->CurrentSelection();
				if(myRow)
				{
				//	if(!myList->IsFocus()) myList->MakeFocus();
					BString tmpMessage("");
					tmpMessage += myList->Name();
					tmpMessage += ":_Invoke:";
					tmpMessage << myList->IndexOf(myRow)+1; 
					tmpMessage += "|";
					messageString += tmpMessage;
				}
			}
			break;
		case YABSHORTCUT:
			{
				const char* myMsg;
				if(message->FindString("shortcut", &myMsg) == B_OK)
				{
					messageString += myMsg;
					messageString += "|";
				}
			}
			break;
		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Example #12
0
BControl *
DefaultMediaTheme::MakeViewFor(BParameter *parameter, const BRect *hintRect)
{
	BRect rect;
	if (hintRect)
		rect = *hintRect;
	else
		rect.Set(0, 0, 50, 100);

	switch (parameter->Type()) {
		case BParameter::B_NULL_PARAMETER:
			// there is no default view for a null parameter
			return NULL;

		case BParameter::B_DISCRETE_PARAMETER:
		{
			BDiscreteParameter &discrete = static_cast<BDiscreteParameter &>(*parameter);

			if (!strcmp(discrete.Kind(), B_ENABLE)
				|| !strcmp(discrete.Kind(), B_MUTE)
				|| discrete.CountItems() == 0) {
				// create a checkbox item

				BCheckBox *checkBox = new BCheckBox(rect, discrete.Name(),
					discrete.Name(), NULL);
				checkBox->ResizeToPreferred();

				return checkBox;
			} else {
				// create a pop up menu field

				// ToDo: replace BOptionPopUp (or fix it in Antares...)
				// this is a workaround for a bug in BOptionPopUp - you need to
				// know the actual width before creating the object - very nice...

				BFont font;
				float width = 0;
				for (int32 i = 0; i < discrete.CountItems(); i++) {
					float labelWidth = font.StringWidth(discrete.ItemNameAt(i));
					if (labelWidth > width)
						width = labelWidth;
				}
				width += font.StringWidth(discrete.Name()) + 55;
				rect.right = rect.left + width;

				BOptionPopUp *popUp = new BOptionPopUp(rect, discrete.Name(),
					discrete.Name(), NULL);

				for (int32 i = 0; i < discrete.CountItems(); i++) {
					popUp->AddOption(discrete.ItemNameAt(i), discrete.ItemValueAt(i));
				}

				popUp->ResizeToPreferred();

				return popUp;
			}
		}

		case BParameter::B_CONTINUOUS_PARAMETER:
		{
			BContinuousParameter &continuous = static_cast<BContinuousParameter &>(*parameter);

			if (!strcmp(continuous.Kind(), B_MASTER_GAIN)
				|| !strcmp(continuous.Kind(), B_GAIN)) {
				BChannelSlider *slider = new BChannelSlider(rect, continuous.Name(),
					continuous.Name(), NULL, B_VERTICAL, continuous.CountChannels());

				char minLabel[64], maxLabel[64];

				const char *unit = continuous.Unit();
				if (unit[0]) {
					// if we have a unit, print it next to the limit values
					sprintf(minLabel, "%g %s", continuous.MinValue(), continuous.Unit());
					sprintf(maxLabel, "%g %s", continuous.MaxValue(), continuous.Unit());
				} else {
					sprintf(minLabel, "%g", continuous.MinValue());
					sprintf(maxLabel, "%g", continuous.MaxValue());
				}
				slider->SetLimitLabels(minLabel, maxLabel);

				float width, height;
				slider->GetPreferredSize(&width, &height);
				slider->ResizeTo(width, 190);

				// ToDo: take BContinuousParameter::GetResponse() & ValueStep() into account!

				for (int32 i = 0; i < continuous.CountChannels(); i++) {
					slider->SetLimitsFor(i, int32(continuous.MinValue() * 1000),
						int32(continuous.MaxValue() * 1000));
				}

				return slider;
			}

			BSlider *slider = new BSlider(rect, parameter->Name(), parameter->Name(),
				NULL, 0, 100);

			float width, height;
			slider->GetPreferredSize(&width, &height);
			slider->ResizeTo(100, height);

			return slider;
		}

		default:
			ERROR("BMediaTheme: Don't know parameter type: 0x%x\n",
				parameter->Type());
	}
	return NULL;
}
Example #13
0
void PrefsWindow::MessageReceived(BMessage* message)
{
	switch(message->what)
	{
		case PrefsConstants::K_PREFS_VIEW_RESET_COLOUR_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_COLOUR_PREFS);
		}
		break;		
		case PrefsConstants::K_PREFS_VIEW_RESET_COMMAND_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_COMMAND_PREFS);
		}		
		break;
		case PrefsConstants::K_PREFS_VIEW_RESET_TOOLBAR_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_TOOLBAR_PREFS);	
		}
		break;
		case PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS:
		{
			ResetToDefaults(PrefsConstants::K_RESET_GENERAL_PREFS);
		}
		break;
		case PrefsConstants::K_PREFS_UPDATE:
		{			
			//update the preferences message, from view values
			BString prefsID;			
			if (message->FindString(K_PREFS_ID, &prefsID) == B_OK)
			{
				BView *changedView = m_parent->FindView(prefsID.String());
				prefsLock.Lock();
				//different view have different kinds of values
				if (is_instance_of(changedView, BTextControl))
				{
					//a textcontrol value was changed, update preferences with new text
					BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
					preferences.ReplaceString(prefsID.String(), textControl->Text());
				}
				else if (is_instance_of(changedView, BCheckBox))
				{
					//a checkbox value was changed, update preferences with new bool value(on/off)
					BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
					preferences.ReplaceBool(prefsID.String(), checkBox->Value());
				}
				else if (is_instance_of(changedView, BSlider))
				{
					//a slider value was changed, update preferences with new slider value
					BSlider *slider = dynamic_cast<BSlider*>(changedView);
					preferences.ReplaceInt32(prefsID.String(), slider->Value());
				}
				else if (is_instance_of(changedView, ColourButton))
				{
					//a colourcontrol value was changed, update preferences with new colour
					ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
					preferences.ReplaceData(prefsID.String(),B_RGB_COLOR_TYPE, &colourControl->Value(), sizeof(rgb_color));
				}
				prefsLock.Unlock();
			}
		}
		break;
		case PrefsConstants::K_LOAD_PREFERENCES:
		{
			//set preferences view values to values of the preferences message
			BString prefsID;
			if (message->FindString(K_PREFS_ID, &prefsID) == B_OK)
			{
				//find out which view value has to be updated
				BView *changedView = m_parent->FindView(prefsID.String());
				prefsLock.Lock();
				char *name;
				uint32 type;
				int32 count;
				for (int32 i = 0; preferences.GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i++)
				{
					//find out what kind of field we are using
					switch (type)
					{
						case B_INT32_TYPE:
						{
							int32 value;
							preferences.FindInt32(name, &value);
							if (is_instance_of(changedView, BSlider))
							{
								BSlider *slider = dynamic_cast<BSlider*>(changedView);
								slider->SetValue(value);
							}
						}
						break;
						case B_BOOL_TYPE:
						{
							bool value;
							preferences.FindBool(name, &value);
							if (is_instance_of(changedView, BCheckBox))
							{
								BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
								checkBox->SetValue(value);
							}
						}
						break;
						case B_RGB_COLOR_TYPE:
						{
							rgb_color *colour;
							ssize_t size;
							preferences.FindData(name, B_RGB_COLOR_TYPE, (const void**)&colour, &size);
							if (is_instance_of(changedView, ColourButton))
							{
								ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
								colourControl->SetValue(*colour);
							}
						}
						break;
						case B_STRING_TYPE:
						{
							BString string;
							preferences.FindString(name, &string);
							if (is_instance_of(changedView, ColourButton))
							{
								BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
								textControl->SetText(string.String());
							}
						}
						break;
					}
				} 				
				prefsLock.Unlock();
				//make sure the new view values are drawn!
				changedView->Invalidate();
			}
		}
		break;
		default:
			BWindow::MessageReceived(message);
		break;
	}
}
Example #14
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;
}