Exemple #1
0
SettingsView::SettingsView(Core* core)
	:
	BView("SettingsView", B_WILL_DRAW, 0),
	fCore(core)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// Engines entry
	BBox* audioBox = new BBox("audiobox");
	audioBox->SetLabel("Engines");

	BGroupLayout* audioLayout = new BGroupLayout(B_VERTICAL);
	audioLayout->SetInsets(10, audioBox->TopBorderOffset() * 2 + 10, 10, 10);
	audioBox->SetLayout(audioLayout);

	fEngines[0] = new BRadioButton("sine", "Sine",
		_ButtonMsg(CRONO_SINE_ENGINE));
	audioLayout->AddView(fEngines[0]);

	fEngines[1] = new BRadioButton("triangle", "Triangle",
		_ButtonMsg(CRONO_TRIANGLE_ENGINE));
	audioLayout->AddView(fEngines[1]);

	fEngines[2] = new BRadioButton("sawtooth", "Sawtooth",
		_ButtonMsg(CRONO_SAWTOOTH_ENGINE));
	audioLayout->AddView(fEngines[2]);

	fEngines[3] = new BRadioButton("file", "File Engine",
		_ButtonMsg(CRONO_FILE_ENGINE));
	audioLayout->AddView(fEngines[3]);

	fSoundEntry = new BTextControl("Soundfile", "Soundfile",
		gCronoSettings.SoundFileLocation, new BMessage(MSG_SET), B_WILL_DRAW);
	fSoundEntry->SetDivider(70);
	fSoundEntry->SetAlignment(B_ALIGN_CENTER, B_ALIGN_CENTER);
	audioLayout->AddView(fSoundEntry);
	fSoundEntry->SetEnabled(false);

	fDefaultsButton = new BButton("Defaults", new BMessage(MSG_DEFAULTS));

	BLayoutBuilder::Group<>(this, B_VERTICAL, 5)
		.AddGroup(B_VERTICAL)
			.Add(audioBox, 0)
		.End()
		.AddGroup(B_HORIZONTAL)
			.Add(fDefaultsButton, 0)
		.End();

	_SetEngine(fCore->Engine());
}
Exemple #2
0
	void _AddSpaces(BPartition* partition, PartitionView* parentView)
	{
		// add any available space on the partition
		BPartitioningInfo info;
		if (partition->GetPartitioningInfo(&info) >= B_OK) {
			off_t parentSize = partition->Size();
			off_t offset;
			off_t size;
			for (int32 i = 0;
					info.GetPartitionableSpaceAt(i, &offset, &size) >= B_OK;
					i++) {
				// TODO: remove again once Disk Device API is fixed
				if (!is_valid_partitionable_space(size))
					continue;
				//
				double scale = (double)size / parentSize;
				partition_id id
					= fSpaceIDMap.SpaceIDFor(partition->ID(), offset);
				PartitionView* view = new PartitionView(B_TRANSLATE("<empty>"),
					scale, offset, parentView->Level() + 1, id);

				fViewMap.Put(id, view);
				BGroupLayout* layout = parentView->GroupLayout();
				layout->AddView(_FindInsertIndex(view, layout), view, scale);
			}
		}
	}
Exemple #3
0
CookieWindow::CookieWindow(BRect frame, BNetworkCookieJar& jar)
	:
	BWindow(frame, B_TRANSLATE("Cookie manager"), B_TITLED_WINDOW,
		B_NORMAL_WINDOW_FEEL,
		B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fCookieJar(jar)
{
	BGroupLayout* root = new BGroupLayout(B_HORIZONTAL, 0.0);
	SetLayout(root);

	fDomains = new BOutlineListView("domain list");
	root->AddView(new BScrollView("scroll", fDomains, 0, false, true), 1);

	fHeaderView = new BStringView("label",
		B_TRANSLATE("The cookie jar is empty!"));
	fCookies = new BColumnListView("cookie list", B_WILL_DRAW, B_FANCY_BORDER,
		false);

	int em = fCookies->StringWidth("M");
	int flagsLength = fCookies->StringWidth("Mhttps hostOnly" B_UTF8_ELLIPSIS);

	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Name"),
		20 * em, 10 * em, 50 * em, 0), 0);
	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Path"),
		10 * em, 10 * em, 50 * em, 0), 1);
	fCookies->AddColumn(new CookieDateColumn(B_TRANSLATE("Expiration"),
		fCookies->StringWidth("88/88/8888 88:88:88 AM")), 2);
	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Value"),
		20 * em, 10 * em, 50 * em, 0), 3);
	fCookies->AddColumn(new BStringColumn(B_TRANSLATE("Flags"),
		flagsLength, flagsLength, flagsLength, 0), 4);

	root->AddItem(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING)
		.SetInsets(5, 5, 5, 5)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.Add(fHeaderView)
			.AddGlue()
		.End()
		.Add(fCookies)
		.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
			.SetInsets(5, 5, 5, 5)
#if 0
			.Add(new BButton("import", B_TRANSLATE("Import" B_UTF8_ELLIPSIS),
				NULL))
			.Add(new BButton("export", B_TRANSLATE("Export" B_UTF8_ELLIPSIS),
				NULL))
#endif
			.AddGlue()
			.Add(new BButton("delete", B_TRANSLATE("Delete"),
				new BMessage(COOKIE_DELETE))), 3);

	fDomains->SetSelectionMessage(new BMessage(DOMAIN_SELECTED));
}
NotificationView::NotificationView(NotificationWindow* win,
	BNotification* notification, bigtime_t timeout)
	:
	BView("NotificationView", B_WILL_DRAW),
	fParent(win),
	fNotification(notification),
	fTimeout(timeout),
	fRunner(NULL),
	fBitmap(NULL),
	fCloseClicked(false)
{
	if (fNotification->Icon() != NULL)
		fBitmap = new BBitmap(fNotification->Icon());

	if (fTimeout <= 0)
		fTimeout = fParent->Timeout() * 1000000;

	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	SetLayout(layout);

	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	switch (fNotification->Type()) {
		case B_IMPORTANT_NOTIFICATION:
			fStripeColor = ui_color(B_CONTROL_HIGHLIGHT_COLOR);
			break;
		case B_ERROR_NOTIFICATION:
			fStripeColor = ui_color(B_FAILURE_COLOR);
			break;
		case B_PROGRESS_NOTIFICATION:
		{
			BStatusBar* progress = new BStatusBar("progress");
			progress->SetBarHeight(12.0f);
			progress->SetMaxValue(1.0f);
			progress->Update(fNotification->Progress());

			BString label = "";
			label << (int)(fNotification->Progress() * 100) << " %";
			progress->SetTrailingText(label);

			layout->AddView(progress);
		}
		// fall through.
		case B_INFORMATION_NOTIFICATION:
			fStripeColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
				B_DARKEN_1_TINT);
			break;
	}
}
/*!	
 *	\brief			Default constructor
 *	\param[in]	frame	The rectangle enclosing the view
 *	\param[in]	name	Name of the view. Will be passed to BView's constructor.
 *
 */
CalendarModulePreferencesView::CalendarModulePreferencesView( BRect frame )
	:
	BView( BRect( frame.left, frame.top, frame.right, frame.bottom-10 ), 
		 "Calendar Module Preferences",
		 B_FOLLOW_LEFT | B_FOLLOW_TOP,
		 B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS )
{
	BRect tempFrame = this->Bounds();	// Got the boundaries
	
	this->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	tempFrame.InsetBySelf( 5, 5 );
	tempFrame.bottom -= 10;
	
	/* Add the chooser for the calendar modules */
	BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
	if ( !groupLayout ) {
		/* Panic! */
		exit( 1 );
	}
	groupLayout->SetSpacing( 2 );
	this->SetLayout( groupLayout );
	
	// Create the menu with all supported calendar modules
	calendarModules = PopulateModulesMenu();
	if ( ! calendarModules ) {
		/* Panic! */
		exit ( 1 );
	}
	
	calendarModuleSelector = new BMenuField( BRect( 0, 0, this->Bounds().Width() - 10, 1 ),
											 "Calendar Modules selector",
											 "Calendar module:",
											 calendarModules,
											 B_FOLLOW_H_CENTER | B_FOLLOW_TOP );
	if ( !calendarModuleSelector ) {
		/* Panic! */
		exit ( 1 );
	}
	
	calendarModuleSelector->ResizeToPreferred();
	
	// Add the menu with all calendar modules to the layout
	BLayoutItem* layoutItem = groupLayout->AddView( 0, calendarModuleSelector, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
	}
	
	// Relayout
	groupLayout->Relayout();
}	// <-- end of constructor for CalendarModulePreferencesView
Exemple #6
0
DiskView::DiskView(const BRect& frame, uint32 resizeMode,
		SpaceIDMap& spaceIDMap)
	:
	Inherited(frame, "diskview", resizeMode,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
	fDiskCount(0),
	fDisk(NULL),
	fSpaceIDMap(spaceIDMap),
	fPartitionLayout(new PartitionLayout(this, fSpaceIDMap))
{
	BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL, kLayoutInset);
	SetLayout(layout);

	SetViewColor(B_TRANSPARENT_COLOR);
	SetHighUIColor(B_PANEL_BACKGROUND_COLOR, B_DARKEN_2_TINT);
	SetLowUIColor(B_PANEL_BACKGROUND_COLOR, 1.221f);

#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
	PartitionView* view;
	float scale = 1.0;
	view = new PartitionView("Disk", scale, 0, 0, -1);
	layout->AddView(view, scale);

	layout = view->GroupLayout();

	scale = 0.3;
	view = new PartitionView("Primary", scale, 1, 50, -1);
	layout->AddView(view, scale);
	scale = 0.7;
	view = new PartitionView("Extended", scale, 1, 100, -1);
	layout->AddView(view, scale);

	layout = view->GroupLayout();

	scale = 0.2;
	view = new PartitionView("Logical", scale, 2, 200, -1);
	layout->AddView(view, scale);

	scale = 0.5;
	view = new PartitionView("Logical", scale, 2, 250, -1);
	layout->AddView(view, scale);

	scale = 0.005;
	view = new PartitionView("Logical", scale, 2, 290, -1);
	layout->AddView(view, scale);

	scale = 0.295;
	view = new PartitionView("Logical", scale, 2, 420, -1);
	layout->AddView(view, scale);
#endif
}
Exemple #7
0
void
add_status_bars(BGridLayout* layout, int32& row)
{
	BBox* box = new BBox(B_FANCY_BORDER, NULL);
	box->SetLabel("Info");

	BGroupLayout* boxLayout = new BGroupLayout(B_VERTICAL, kInset);
	boxLayout->SetInsets(kInset, kInset + box->TopBorderOffset(), kInset,
		kInset);
	box->SetLayout(boxLayout);

	BStatusBar* statusBar = new BStatusBar("status bar", "Status",
		"Completed");
	statusBar->SetMaxValue(100);
	statusBar->SetTo(0);
	statusBar->SetBarHeight(12);
	boxLayout->AddView(statusBar);

	statusBar = new BStatusBar("status bar", "Progress",
		"Completed");
	statusBar->SetMaxValue(100);
	statusBar->SetTo(40);
	statusBar->SetBarHeight(12);
	boxLayout->AddView(statusBar);

	statusBar = new BStatusBar("status bar", "Lifespan of capitalism",
		"Completed");
	statusBar->SetMaxValue(100);
	statusBar->SetTo(100);
	statusBar->SetBarHeight(12);
	boxLayout->AddView(statusBar);

	layout->AddView(box, 0, row, 4);

	row++;
}
Exemple #8
0
NetworkView::NetworkView()
	:
	BView("NetworkView", 0, NULL)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));


	// build the GUI
	BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL);
	SetLayout(rootLayout);

	//BGridView* controlsGroup = new BGridView();
	//BGridLayout* layout = controlsGroup->GridLayout();

	// insets
	/*
	float inset = ceilf(be_plain_font->Size() * 0.7);
	rootLayout->SetInsets(inset, inset, inset, inset);
	rootLayout->SetSpacing(inset);
	layout->SetSpacing(inset, inset);
	*/
	// available network lists



	// button group
	BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL);

	fRefreshButton = new BButton(B_TRANSLATE("Refresh"),
		new BMessage(kMsgRefresh));
	fRefreshButton->SetEnabled(false);
	buttonGroup->GroupLayout()->AddView(fRefreshButton);

	buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

	fNewNetworkButton = new BButton(B_TRANSLATE("New Network"), new BMessage(kMsgNewNetwork));
	fNewNetworkButton->SetEnabled(false);
	buttonGroup->GroupLayout()->AddView(fNewNetworkButton);

	//rootLayout->AddView(controlsGroup);
	rootLayout->AddView(buttonGroup);
}
Exemple #9
0
	virtual bool Visit(BPartition* partition, int32 level)
	{
		if (!partition->Parent()
			|| !fViewMap.ContainsKey(partition->Parent()->ID()))
			return false;

		// calculate size factor within parent frame
		off_t offset = partition->Offset();
//		off_t parentOffset = partition->Parent()->Offset();
		off_t size = partition->Size();
		off_t parentSize = partition->Parent()->Size();
		double scale = (double)size / parentSize;

		BString name = partition->ContentName();
		if (name.Length() == 0) {
			if (partition->CountChildren() > 0)
				name << partition->Type();
			else {
				char buffer[64];
				snprintf(buffer, 64, B_TRANSLATE("Partition %ld"),
					partition->ID());
				name << buffer;
			}
		}
		partition_id id = partition->ID();
		PartitionView* view = new PartitionView(name.String(), scale, offset,
			level, id);
		view->SetSelected(id == fSelectedPartition);
		PartitionView* parent = fViewMap.Get(partition->Parent()->ID());
		BGroupLayout* layout = parent->GroupLayout();
		layout->AddView(_FindInsertIndex(view, layout), view, scale);

		fViewMap.Put(partition->ID(), view);
		_AddSpaces(partition, view);

		return false;
	}
TransportControlGroup::TransportControlGroup(BRect frame,
		bool usePlaybackFrame, bool useSkipButtons, bool usePeakView,
		bool useWindButtons, bool useSeekSlider)
	:
	BGroupView(B_VERTICAL, 0),
	fSeekSlider(NULL),
	fPeakView(NULL),
	fPlaybackFrame(NULL),
	fVolumeSlider(NULL),
	fSkipBack(NULL),
	fSkipForward(NULL),
	fRewind(NULL),
	fForward(NULL),
	fPlayPause(NULL),
	fStop(NULL),
	fMute(NULL),
	fSeekLayout(NULL),
	fControlLayout(NULL),
	fSymbolScale(0.0f)
{
    // Seek slider
	if (useSeekSlider) {
		BGroupView* seekGroup = new BGroupView(B_HORIZONTAL, 0);
		fSeekLayout = seekGroup->GroupLayout();
		GroupLayout()->AddView(seekGroup);

		fSeekSlider = new SeekSlider("seek slider", new BMessage(MSG_SEEK),
			0, 10000);
		fSeekLayout->AddView(fSeekSlider);
	}

    // Buttons

	uint32 topBottomBorder = BControlLook::B_TOP_BORDER
		| BControlLook::B_BOTTOM_BORDER;

	if (useSkipButtons) {
		// Skip Back
		fSkipBack = new SymbolButton(B_EMPTY_STRING, NULL,
			new BMessage(MSG_SKIP_BACKWARDS),
			BControlLook::B_LEFT_BORDER | topBottomBorder);
		// Skip Foward
		fSkipForward = new SymbolButton(B_EMPTY_STRING, NULL,
			new BMessage(MSG_SKIP_FORWARD),
			BControlLook::B_RIGHT_BORDER | topBottomBorder);
	}

	if (useWindButtons) {
		// Rewind
		fRewind = new SymbolButton(B_EMPTY_STRING, NULL,
			new BMessage(MSG_REWIND), useSkipButtons ? topBottomBorder
				: BControlLook::B_LEFT_BORDER | topBottomBorder);
		// Forward
		fForward = new SymbolButton(B_EMPTY_STRING, NULL,
			new BMessage(MSG_FORWARD), useSkipButtons ? topBottomBorder
				: BControlLook::B_RIGHT_BORDER | topBottomBorder);
	}

	// Play Pause
	fPlayPause = new PlayPauseButton(B_EMPTY_STRING, NULL, NULL,
		new BMessage(MSG_PLAY), useWindButtons || useSkipButtons
			? topBottomBorder
			: topBottomBorder | BControlLook::B_LEFT_BORDER);

	// Stop
	fStop = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_STOP),
		useWindButtons || useSkipButtons ? topBottomBorder
			: topBottomBorder | BControlLook::B_RIGHT_BORDER);

	// Mute
	fMute = new SymbolButton(B_EMPTY_STRING, NULL, new BMessage(MSG_SET_MUTE),
		0);

	// Volume Slider
	fVolumeSlider = new VolumeSlider("volume slider",
		0, VIRTUAL_MAX_VOLUME, SNAP_VOLUME, new BMessage(MSG_SET_VOLUME));
	fVolumeSlider->SetValue(100);

	// Peak view
	if (usePeakView)
		fPeakView = new PeakView("peak view", false, false);

	// Playback Frame
	if (usePlaybackFrame)
	    fPlaybackFrame = new PlaybackFrameView();

	// Layout the controls

	BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL, 0);
	BGroupLayout* buttonLayout = buttonGroup->GroupLayout();

	if (fSkipBack != NULL)
		buttonLayout->AddView(fSkipBack);
	if (fRewind != NULL)
		buttonLayout->AddView(fRewind);
	buttonLayout->AddView(fPlayPause);
	buttonLayout->AddView(fStop);
	if (fForward != NULL)
		buttonLayout->AddView(fForward);
	if (fSkipForward != NULL)
		buttonLayout->AddView(fSkipForward);

	BGroupView* controlGroup = new BGroupView(B_HORIZONTAL, 0);
	GroupLayout()->AddView(controlGroup);
	fControlLayout = controlGroup->GroupLayout();
	fControlLayout->AddView(buttonGroup, 0.6f);
	fControlLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(5));
	fControlLayout->AddView(fMute);
	fControlLayout->AddView(fVolumeSlider);
	if (fPeakView != NULL)
		fControlLayout->AddView(fPeakView, 0.6f);
	if (fPlaybackFrame != NULL) {
		fControlLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(5));
		fControlLayout->AddView(fPlaybackFrame, 0.0f);
	}

	BSize size = fControlLayout->MinSize();
	size.width *= 3;
	size.height = B_SIZE_UNSET;
	fControlLayout->SetExplicitMaxSize(size);
	fControlLayout->SetExplicitAlignment(BAlignment(B_ALIGN_CENTER,
		B_ALIGN_TOP));

	SetSymbolScale(1.0f);
}
TeamMonitorWindow::TeamMonitorWindow()
	:
	BWindow(BRect(0, 0, 350, 400), B_TRANSLATE("Team monitor"),
		B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
		B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
			| B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS,
		B_ALL_WORKSPACES),
	fQuitting(false),
	fUpdateRunner(NULL)
{
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	float inset = 10;
	layout->SetInsets(inset, inset, inset, inset);
	layout->SetSpacing(inset);
	SetLayout(layout);

	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fListView = new BListView("teams");
	fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM));

	BScrollView* scrollView = new BScrollView("scroll_teams", fListView,
		0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER);
	layout->AddView(scrollView);

	BGroupView* groupView = new BGroupView(B_HORIZONTAL);
	layout->AddView(groupView);

	fKillButton = new BButton("kill", B_TRANSLATE("Kill application"),
		new BMessage(TM_KILL_APPLICATION));
	groupView->AddChild(fKillButton);
	fKillButton->SetEnabled(false);
	
	fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"),
		new BMessage(TM_QUIT_APPLICATION));
	groupView->AddChild(fQuitButton);
	fQuitButton->SetEnabled(false);

	groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

	fDescriptionView = new TeamDescriptionView;
	layout->AddView(fDescriptionView);

	groupView = new BGroupView(B_HORIZONTAL);
	layout->AddView(groupView);

	BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"),
		new BMessage(TM_FORCE_REBOOT));
	groupView->GroupLayout()->AddView(forceReboot);

	BSpaceLayoutItem* glue = BSpaceLayoutItem::CreateGlue();
	glue->SetExplicitMinSize(BSize(inset, -1));
	groupView->GroupLayout()->AddItem(glue);

	fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"),
		new BMessage(TM_RESTART_DESKTOP));
	SetDefaultButton(fRestartButton);
	groupView->GroupLayout()->AddView(fRestartButton);

	glue = BSpaceLayoutItem::CreateGlue();
	glue->SetExplicitMinSize(BSize(inset, -1));
	groupView->GroupLayout()->AddItem(glue);

	fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
		new BMessage(TM_CANCEL));
	SetDefaultButton(fCancelButton);
	groupView->GroupLayout()->AddView(fCancelButton);

	BSize preferredSize = layout->View()->PreferredSize();
	if (preferredSize.width > Bounds().Width())
		ResizeTo(preferredSize.width, Bounds().Height());
	if (preferredSize.height > Bounds().Height())
		ResizeTo(Bounds().Width(), preferredSize.height);

	BRect screenFrame = BScreen(this).Frame();
	BPoint point;
	point.x = (screenFrame.Width() - Bounds().Width()) / 2;
	point.y = (screenFrame.Height() - Bounds().Height()) / 2;

	if (screenFrame.Contains(point))
		MoveTo(point);

	SetSizeLimits(Bounds().Width(), Bounds().Width() * 2,
		Bounds().Height(), screenFrame.Height());

	fRestartButton->Hide();

	AddShortcut('T', B_COMMAND_KEY | B_OPTION_KEY,
		new BMessage(kMsgLaunchTerminal));
	AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));

	gLocalizedNamePreferred
		= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();

	gTeamMonitorWindow = this;

	if (be_app->Lock()) {
		be_app->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY,
			B_ANY_SOURCE, B_LOCALE_CHANGED, FilterLocaleChanged));
		be_app->Unlock();
	}
}
ActivityWindow::ActivityWindow()
	:
	BWindow(BRect(100, 100, 500, 350), B_TRANSLATE_SYSTEM_NAME("ActivityMonitor"),
	B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{
	BMessage settings;
	_LoadSettings(settings);

	BRect frame;
	if (settings.FindRect("window frame", &frame) == B_OK) {
		MoveTo(frame.LeftTop());
		ResizeTo(frame.Width(), frame.Height());
	}

#ifdef __HAIKU__
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
	SetLayout(layout);

	// create GUI

	BMenuBar* menuBar = new BMenuBar("menu");
	layout->AddView(menuBar);

	fLayout = new BGroupLayout(B_VERTICAL);
	float inset = ceilf(be_plain_font->Size() * 0.7);
	fLayout->SetInsets(inset, inset, inset, inset);
	fLayout->SetSpacing(inset);

	BView* top = new BView("top", 0, fLayout);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	layout->AddView(top);

	BMessage viewState;
	int32 count = 0;
	for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
			== B_OK; i++) {
		ActivityView* view = new ActivityView("ActivityMonitor", &viewState);
		fLayout->AddItem(view->CreateHistoryLayoutItem());
		fLayout->AddItem(view->CreateLegendLayoutItem());
		count++;
	}
	if (count == 0) {
		// Add default views (memory & CPU usage)
		_AddDefaultView();
		_AddDefaultView();
	}
#else	// !__HAIKU__
	BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0);
	AddChild(layout);

	// create GUI
	BRect mbRect(Bounds());
	mbRect.bottom = 10;
	BMenuBar* menuBar = new BMenuBar(mbRect, "menu");
	layout->AddChild(menuBar);

	BRect topRect(Bounds());
	topRect.top = menuBar->Bounds().bottom + 1;

	BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	layout->AddChild(top);

	BMessage viewState;
	int32 count = 0;
	ActivityView *aview;
	BRect rect;
	for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
			== B_OK; i++) {
		aview = new ActivityView("ActivityMonitor", &viewState);
		if (!rect.IsValid())
			rect = aview->Bounds();
		else
			rect.OffsetBySelf(0.0, aview->Bounds().Height());
		top->AddChild(aview);
		count++;
	}
	if (count == 0)
		top->AddChild(new ActivityView("ActivityMonitor", NULL));

#endif
	// add menu

	// "File" menu
	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Add graph"),
		new BMessage(kMsgAddView)));
	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q'));
	menu->SetTargetForItems(this);
	menuBar->AddItem(menu);

	// "Settings" menu
	menu = new BMenu(B_TRANSLATE("Settings"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
		new BMessage(kMsgShowSettings)));
	menu->SetTargetForItems(this);
	menuBar->AddItem(menu);
}
/*!	\brief		Constructor.
 *		\param[in]	frame		The rectangle of the View. Passed unmodified to
 *									constructor of BView.
 *		\param[in]	data		Data of the Event.
 *		\details		The user must check \c InitCheck() value. If it's not B_OK,
 *						the class did not initialize properly.
 */
EventEditor_ReminderView::EventEditor_ReminderView( BRect rect, EventData* data )
	:
	BView( rect,
			 "Reminder Activity",
			 B_FOLLOW_ALL,
			 B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED ),
	fData( data ),
	fLastError( B_OK ),
	fReminderEnabler( NULL ),
	fExplanation( NULL ),
	fExplanation2( NULL ),
	fHourMinControl( NULL ),
	fActivityView( NULL )
{	
	// Sanity check
	if ( !data ) {
		/* Panic! */
		fLastError = B_BAD_VALUE;
		return;
	}
	
	// Create the layout
	BGroupLayout* layout = new BGroupLayout( B_VERTICAL );
	if ( !layout ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	this->SetLayout( layout );
	layout->SetInsets( 5, 5, 5, 5 );
	
	// Get the preferences
	TimePreferences*	pref = pref_GetTimePreferences();	
	
	// Construct the checkbox
	BMessage* toSend = new BMessage( kReminderEnabled );
	if ( !toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fReminderEnabler = new BCheckBox( BRect( 0, 0, 1, 1 ),
												 "Enable or disable the reminder",
												 "Remind me about this Event",
												 toSend );
	if( !fReminderEnabler ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fReminderEnabler->ResizeToPreferred();
	BLayoutItem* layoutItem = layout->AddView( fReminderEnabler );
	
	// Construct the explanation string
	fExplanation = new BStringView( BRect( 0, 0, 1, 1 ),
											  "Explanation",
											  "Reminder will not work if it's set up to start at" );
	fExplanation2 = new BStringView( BRect( 0, 0, 1, 1 ),
											  "Explanation2",
											  "the time of the Event itself. (Don't choose 00:00)!" );
	if ( !fExplanation || !fExplanation2 ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fExplanation->ResizeToPreferred();
	fExplanation2->ResizeToPreferred();
	fExplanation->SetFont( be_bold_font );
	fExplanation2->SetFont( be_bold_font );
	layoutItem = layout->AddView( fExplanation );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_BOTTOM ) );
	}
	layoutItem = layout->AddView( fExplanation2 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
	}
	
	// Construct the time control
	toSend = new BMessage( kReminderTimeUpdated );
	if ( !toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	
	fHourMinControl = new GeneralHourMinControl( BRect ( 0, 0, 1, 1 ),
																"Reminder time",
																BString( "Reminder is set" ),
																BString( "before the Event" ),
																toSend );
	if ( !fHourMinControl ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fHourMinControl->ResizeToPreferred();
	fHourMinControl->SetHoursLimit( 71 );
	fHourMinControl->SetMinutesLimit( 55 );
	
	layoutItem = layout->AddView( fHourMinControl );
	
	// Activity control
	fActivityView = new ActivityView( BRect( 0, 0, 1, 1 ),
												 "Reminder activity",
												 fData->GetReminderActivity() );
	if ( !fActivityView ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fActivityView->ResizeToPreferred();
	layoutItem = layout->AddView( fActivityView );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
	}
	
	// Set up options
	bool beforeEvent = true;
	time_t fOffset = fData->GetReminderOffset( &beforeEvent );
	int seconds = ( int )( fOffset % 60 );
	fOffset /= 60;
	fMinutes = ( int )( fOffset % 60 );
	fHours = ( int )( fOffset / 60 );
	
	if ( fOffset == 0 && pref ) {		// First usage
		pref->GetDefaultReminderTime( ( int* )&fHours, ( int* )&fMinutes );
	}
	
	fHourMinControl->SetCurrentTime( fHours, fMinutes );
	fHourMinControl->SetCheckBoxValue( beforeEvent );
	
	// Initial enable / disable of the items	
	fReminderEnabler->SetValue( ( fOffset != 0 ) );
	fActivityView->SetEnabled( ( fOffset != 0 ) );
	fHourMinControl->SetEnabled( ( fOffset != 0 ) );

}	// <-- end of constructor
Exemple #14
0
/**
 * _ConstructGUI()
 *
 * Creates the GUI for the View. MUST be called AFTER the View is attached to
 *	the Window, or will crash and/or create strange behaviour
 *
 * @param none
 * @return void
 */
void
MarginView::_ConstructGUI()
{
	fPage = new PageView();
	fPage->SetViewColor(ViewColor());

	fPageSize = new BStringView("pageSize", "?x?");

	BString str;
	// Create text fields

	// top
	str << fMargins.top/fUnitValue;
	fTop = new BTextControl("top", "Top:", str.String(), NULL);

	fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
	fTop->SetTarget(this);
	_AllowOnlyNumbers(fTop, kNumCount);

	//left
    str = "";
	str << fMargins.left/fUnitValue;
	fLeft = new BTextControl("left", "Left:", str.String(), NULL);

	fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
	fLeft->SetTarget(this);
	_AllowOnlyNumbers(fLeft, kNumCount);

	//bottom
    str = "";
	str << fMargins.bottom/fUnitValue;
	fBottom = new BTextControl("bottom", "Bottom:", str.String(), NULL);

	fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
	fBottom->SetTarget(this);
	_AllowOnlyNumbers(fBottom, kNumCount);

	//right
    str = "";
	str << fMargins.right/fUnitValue;
	fRight = new BTextControl("right", "Right:", str.String(), NULL);

	fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
	fRight->SetTarget(this);
	_AllowOnlyNumbers(fRight, kNumCount);

	// Create Units popup

	BPopUpMenu *menu = new BPopUpMenu("units");
	BMenuField *units = new BMenuField("units", "Units:", menu);

	BMenuItem *item;
	// Construct menu items
	for (int32 i = 0; kUnitNames[i] != NULL; i++) {
		BMessage *msg = new BMessage(MARGIN_UNIT_CHANGED);
		msg->AddInt32("marginUnit", kUnitMsg[i]);
		menu->AddItem(item = new BMenuItem(kUnitNames[i], msg));
		item->SetTarget(this);
		if (fMarginUnit == kUnitMsg[i])
			item->SetMarked(true);
	}

	BGridView* settings = new BGridView();
	BGridLayout* settingsLayout = settings->GridLayout();
	settingsLayout->AddItem(fTop->CreateLabelLayoutItem(), 0, 0);
	settingsLayout->AddItem(fTop->CreateTextViewLayoutItem(), 1, 0);
	settingsLayout->AddItem(fLeft->CreateLabelLayoutItem(), 0, 1);
	settingsLayout->AddItem(fLeft->CreateTextViewLayoutItem(), 1, 1);
	settingsLayout->AddItem(fBottom->CreateLabelLayoutItem(), 0, 2);
	settingsLayout->AddItem(fBottom->CreateTextViewLayoutItem(), 1, 2);
	settingsLayout->AddItem(fRight->CreateLabelLayoutItem(), 0, 3);
	settingsLayout->AddItem(fRight->CreateTextViewLayoutItem(), 1, 3);
	settingsLayout->AddItem(units->CreateLabelLayoutItem(), 0, 4);
	settingsLayout->AddItem(units->CreateMenuBarLayoutItem(), 1, 4);
	settingsLayout->SetSpacing(0, 0);

	BGroupView* groupView = new BGroupView(B_HORIZONTAL, 10);
	BGroupLayout* groupLayout = groupView->GroupLayout();
	groupLayout->AddView(BGroupLayoutBuilder(B_VERTICAL, 0)
		.Add(fPage)
		.Add(fPageSize)
		.SetInsets(0, 0, 0, 0)
		.TopView()
	);
	groupLayout->AddView(settings);
	groupLayout->SetInsets(5, 5, 5, 5);

	AddChild(groupView);

	UpdateView(MARGIN_CHANGED);
}
Exemple #15
0
void
MainWindow::_CreateGUI()
{
    SetLayout(new BGroupLayout(B_HORIZONTAL));

    BGridLayout* layout = new BGridLayout();
    layout->SetSpacing(0, 0);
    BView* rootView = new BView("root view", 0, layout);
    AddChild(rootView);
    rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    BGroupView* leftTopView = new BGroupView(B_VERTICAL, 0);
    layout->AddView(leftTopView, 0, 0);

    // views along the left side
    leftTopView->AddChild(_CreateMenuBar());

    float splitWidth = 13 * be_plain_font->Size();
    BSize minSize = leftTopView->MinSize();
    splitWidth = std::max(splitWidth, minSize.width);
    leftTopView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));
    leftTopView->SetExplicitMinSize(BSize(splitWidth, B_SIZE_UNSET));

    BGroupView* iconPreviews = new BGroupView(B_HORIZONTAL);
    iconPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    iconPreviews->GroupLayout()->SetSpacing(5);

    // icon previews
    fIconPreview16Folder = new IconView(BRect(0, 0, 15, 15),
                                        "icon preview 16 folder");
    fIconPreview16Menu = new IconView(BRect(0, 0, 15, 15),
                                      "icon preview 16 menu");
    fIconPreview16Menu->SetLowColor(ui_color(B_MENU_BACKGROUND_COLOR));

    fIconPreview32Folder = new IconView(BRect(0, 0, 31, 31),
                                        "icon preview 32 folder");
    fIconPreview32Desktop = new IconView(BRect(0, 0, 31, 31),
                                         "icon preview 32 desktop");
    fIconPreview32Desktop->SetLowColor(ui_color(B_DESKTOP_COLOR));

    fIconPreview64 = new IconView(BRect(0, 0, 63, 63), "icon preview 64");
    fIconPreview64->SetLowColor(ui_color(B_DESKTOP_COLOR));


    BGroupView* smallPreviews = new BGroupView(B_VERTICAL);
    smallPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    smallPreviews->GroupLayout()->SetSpacing(5);

    smallPreviews->AddChild(fIconPreview16Folder);
    smallPreviews->AddChild(fIconPreview16Menu);

    BGroupView* mediumPreviews = new BGroupView(B_VERTICAL);
    mediumPreviews->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    mediumPreviews->GroupLayout()->SetSpacing(5);

    mediumPreviews->AddChild(fIconPreview32Folder);
    mediumPreviews->AddChild(fIconPreview32Desktop);

//	iconPreviews->AddChild(fIconPreview48);

    iconPreviews->AddChild(smallPreviews);
    iconPreviews->AddChild(mediumPreviews);
    iconPreviews->AddChild(fIconPreview64);
    iconPreviews->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));

    leftTopView->AddChild(iconPreviews);


    BGroupView* leftSideView = new BGroupView(B_VERTICAL, 0);
    layout->AddView(leftSideView, 0, 1);
    leftSideView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNSET));

    // path menu and list view
    BMenuBar* menuBar = new BMenuBar("path menu bar");
    menuBar->AddItem(fPathMenu);
    leftSideView->AddChild(menuBar);

    fPathListView = new PathListView(BRect(0, 0, splitWidth, 100),
                                     "path list view", new BMessage(MSG_PATH_SELECTED), this);

    BView* scrollView = new BScrollView("path list scroll view",
                                        fPathListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // shape list view
    menuBar = new BMenuBar("shape menu bar");
    menuBar->AddItem(fShapeMenu);
    leftSideView->AddChild(menuBar);

    fShapeListView = new ShapeListView(BRect(0, 0, splitWidth, 100),
                                       "shape list view", new BMessage(MSG_SHAPE_SELECTED), this);
    scrollView = new BScrollView("shape list scroll view",
                                 fShapeListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // transformer list view
    menuBar = new BMenuBar("transformer menu bar");
    menuBar->AddItem(fTransformerMenu);
    leftSideView->AddChild(menuBar);

    fTransformerListView = new TransformerListView(BRect(0, 0, splitWidth, 100),
            "transformer list view");
    scrollView = new BScrollView("transformer list scroll view",
                                 fTransformerListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    leftSideView->AddChild(scrollView);

    // property list view
    menuBar = new BMenuBar("property menu bar");
    menuBar->AddItem(fPropertyMenu);
    leftSideView->AddChild(menuBar);

    fPropertyListView = new IconObjectListView();

    // scroll view around property list view
    ScrollView* propScrollView = new ScrollView(fPropertyListView,
            SCROLL_VERTICAL, BRect(0, 0, splitWidth, 100), "property scroll view",
            B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER,
            BORDER_RIGHT);
    leftSideView->AddChild(propScrollView);

    BGroupLayout* topSide = new BGroupLayout(B_HORIZONTAL);
    topSide->SetSpacing(0);
    BView* topSideView = new BView("top side view", 0, topSide);
    layout->AddView(topSideView, 1, 0);

    // canvas view
    BRect canvasBounds = BRect(0, 0, 200, 200);
    fCanvasView = new CanvasView(canvasBounds);

    // scroll view around canvas view
    canvasBounds.bottom += B_H_SCROLL_BAR_HEIGHT;
    canvasBounds.right += B_V_SCROLL_BAR_WIDTH;
    ScrollView* canvasScrollView = new ScrollView(fCanvasView, SCROLL_VERTICAL
            | SCROLL_HORIZONTAL | SCROLL_VISIBLE_RECT_IS_CHILD_BOUNDS,
            canvasBounds, "canvas scroll view", B_FOLLOW_NONE,
            B_WILL_DRAW | B_FRAME_EVENTS, B_NO_BORDER);
    layout->AddView(canvasScrollView, 1, 1);

    // views along the top

    BGroupLayout* styleGroup = new BGroupLayout(B_VERTICAL, 0);
    BView* styleGroupView = new BView("style group", 0, styleGroup);
    topSide->AddView(styleGroupView);

    // style list view
    menuBar = new BMenuBar("style menu bar");
    menuBar->AddItem(fStyleMenu);
    styleGroup->AddView(menuBar);

    fStyleListView = new StyleListView(BRect(0, 0, splitWidth, 100),
                                       "style list view", new BMessage(MSG_STYLE_SELECTED), this);
    scrollView = new BScrollView("style list scroll view", fStyleListView,
                                 B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
    scrollView->SetExplicitMaxSize(BSize(splitWidth, B_SIZE_UNLIMITED));
    styleGroup->AddView(scrollView);

    // style view
    fStyleView = new StyleView(BRect(0, 0, 200, 100));
    topSide->AddView(fStyleView);

    // swatch group
    BGroupLayout* swatchGroup = new BGroupLayout(B_VERTICAL);
    swatchGroup->SetSpacing(0);
    BView* swatchGroupView = new BView("swatch group", 0, swatchGroup);
    topSide->AddView(swatchGroupView);

    menuBar = new BMenuBar("swatches menu bar");
    menuBar->AddItem(fSwatchMenu);
    swatchGroup->AddView(menuBar);

    fSwatchGroup = new SwatchGroup(BRect(0, 0, 100, 100));
    swatchGroup->AddView(fSwatchGroup);

    swatchGroupView->SetExplicitMaxSize(swatchGroupView->MinSize());

    // make sure the top side has fixed height
    topSideView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
                                          swatchGroupView->MinSize().height));
}
Exemple #16
0
bool
DownloadProgressView::Init(BMessage* archive)
{
	fCurrentSize = 0;
	fExpectedSize = 0;
	fLastUpdateTime = 0;
	fBytesPerSecond = 0.0;
	for (size_t i = 0; i < kBytesPerSecondSlots; i++)
		fBytesPerSecondSlot[i] = 0.0;
	fCurrentBytesPerSecondSlot = 0;
	fLastSpeedReferenceSize = 0;
	fEstimatedFinishReferenceSize = 0;

	fProcessStartTime = fLastSpeedReferenceTime = fEstimatedFinishReferenceTime
		= system_time();

	SetViewColor(245, 245, 245);
	SetFlags(Flags() | B_FULL_UPDATE_ON_RESIZE | B_WILL_DRAW);

	if (archive) {
		fStatusBar = new BStatusBar("download progress", fPath.Leaf());
		float value;
		if (archive->FindFloat("value", &value) == B_OK)
			fStatusBar->SetTo(value);
	} else
		fStatusBar = new BStatusBar("download progress", "Download");
	fStatusBar->SetMaxValue(100);
	fStatusBar->SetBarHeight(12);

	// fPath is only valid when constructed from archive (fDownload == NULL)
	BEntry entry(fPath.Path());

	if (archive) {
		if (!entry.Exists())
			fIconView = new IconView(archive);
		else
			fIconView = new IconView(entry);
	} else
		fIconView = new IconView();

	if (!fDownload && (fStatusBar->CurrentValue() < 100 || !entry.Exists()))
		fTopButton = new SmallButton("Restart", new BMessage(RESTART_DOWNLOAD));
	else {
		fTopButton = new SmallButton("Open", new BMessage(OPEN_DOWNLOAD));
		fTopButton->SetEnabled(fDownload == NULL);
	}
	if (fDownload)
		fBottomButton = new SmallButton("Cancel", new BMessage(CANCEL_DOWNLOAD));
	else {
		fBottomButton = new SmallButton("Remove", new BMessage(REMOVE_DOWNLOAD));
		fBottomButton->SetEnabled(fDownload == NULL);
	}

	fInfoView = new BStringView("info view", "");

	BGroupLayout* layout = GroupLayout();
	layout->SetInsets(8, 5, 5, 6);
	layout->AddView(fIconView);
	BView* verticalGroup = BGroupLayoutBuilder(B_VERTICAL, 3)
		.Add(fStatusBar)
		.Add(fInfoView)
		.TopView()
	;
	verticalGroup->SetViewColor(ViewColor());
	layout->AddView(verticalGroup);
	verticalGroup = BGroupLayoutBuilder(B_VERTICAL, 3)
		.Add(fTopButton)
		.Add(fBottomButton)
		.TopView()
	;
	verticalGroup->SetViewColor(ViewColor());
	layout->AddView(verticalGroup);

	BFont font;
	fInfoView->GetFont(&font);
	float fontSize = font.Size() * 0.8f;
	font.SetSize(max_c(8.0f, fontSize));
	fInfoView->SetFont(&font, B_FONT_SIZE);
	fInfoView->SetHighColor(tint_color(fInfoView->LowColor(),
		B_DARKEN_4_TINT));
	fInfoView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	return true;
}
ExtendedInfoWindow::ExtendedInfoWindow(PowerStatusDriverInterface* interface)
	:
	BWindow(BRect(100, 150, 500, 500), "Extended battery info", B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AVOID_FRONT |
		B_ASYNCHRONOUS_CONTROLS),
	fDriverInterface(interface),
	fSelectedView(NULL)
{
	fDriverInterface->AcquireReference();

	BView *view = new BView(Bounds(), "view", B_FOLLOW_ALL, 0);
	view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(view);

	BGroupLayout* mainLayout = new BGroupLayout(B_VERTICAL);
	mainLayout->SetSpacing(10);
	mainLayout->SetInsets(10, 10, 10, 10);
	view->SetLayout(mainLayout);

	BRect rect = Bounds();
	rect.InsetBy(5, 5);
	BBox *infoBox = new BBox(rect, "Power status box");
	infoBox->SetLabel("Battery info");
	BGroupLayout* infoLayout = new BGroupLayout(B_HORIZONTAL);
	infoLayout->SetInsets(10, infoBox->TopBorderOffset() * 2 + 10, 10, 10);
	infoLayout->SetSpacing(10);
	infoBox->SetLayout(infoLayout);
	mainLayout->AddView(infoBox);

	BGroupView* batteryView = new BGroupView(B_VERTICAL);
	batteryView->GroupLayout()->SetSpacing(10);
	infoLayout->AddView(batteryView);

	// create before the battery views
	fBatteryInfoView = new BatteryInfoView();

	BGroupLayout* batteryLayout = batteryView->GroupLayout();
	BRect batteryRect(0, 0, 50, 30);
	for (int i = 0; i < interface->GetBatteryCount(); i++) {
		ExtPowerStatusView* view = new ExtPowerStatusView(interface,
			batteryRect, B_FOLLOW_NONE, i, this);
		view->SetExplicitMaxSize(BSize(70, 80));
		view->SetExplicitMinSize(BSize(70, 80));

		batteryLayout->AddView(view);
		fBatteryViewList.AddItem(view);
		fDriverInterface->StartWatching(view);
		if (!view->IsCritical())
			fSelectedView = view;
	}

	batteryLayout->AddItem(BSpaceLayoutItem::CreateGlue());

	infoLayout->AddView(fBatteryInfoView);

	if (!fSelectedView && fBatteryViewList.CountItems() > 0)
		fSelectedView = fBatteryViewList.ItemAt(0);
	fSelectedView->Select();

	BSize size = mainLayout->PreferredSize();
	ResizeTo(size.width, size.height);
}
Exemple #18
0
void 
JobSetupView::AttachedToWindow()
{
	// quality
	BBox* qualityBox = new BBox("quality");
	qualityBox->SetLabel("Quality");

	// color
	fColorType = new BPopUpMenu("color");
	fColorType->SetRadioMode(true);
	FillCapabilityMenu(fColorType, kMsgQuality, PrinterCap::kColor,
		fJobData->GetColor());
	BMenuField* colorMenuField = new BMenuField("color", "Color:", fColorType);
	fColorType->SetTargetForItems(this);
	
	if (IsHalftoneConfigurationNeeded())
		CreateHalftoneConfigurationUI();

	// page range

	BBox* pageRangeBox = new BBox("pageRange");
	pageRangeBox->SetLabel("Page Range");

	fAll = new BRadioButton("all", "Print all Pages", new BMessage(kMsgRangeAll));

	BRadioButton *range = new BRadioButton("selection", "Print selected Pages:",
		new BMessage(kMsgRangeSelection));

	fFromPage = new BTextControl("from", "From:", "", NULL);
	fFromPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	AllowOnlyDigits(fFromPage->TextView(), 6);

	fToPage = new BTextControl("to", "To:", "", NULL);
	fToPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	AllowOnlyDigits(fToPage->TextView(), 6);

	int first_page = fJobData->GetFirstPage();
	int last_page  = fJobData->GetLastPage();

	if (first_page <= 1 && last_page <= 0) {
		fAll->SetValue(B_CONTROL_ON);
	} else {
		range->SetValue(B_CONTROL_ON);
		if (first_page < 1)
			first_page = 1;
		if (first_page > last_page)
			last_page = -1;

		BString oss1;
		oss1 << first_page;
		fFromPage->SetText(oss1.String());

		BString oss2;
		oss2 << last_page;
		fToPage->SetText(oss2.String());
	}

	fAll->SetTarget(this);
	range->SetTarget(this);

	// paper source
	fPaperFeed = new BPopUpMenu("");
	fPaperFeed->SetRadioMode(true);
	FillCapabilityMenu(fPaperFeed, kMsgNone, PrinterCap::kPaperSource,
		fJobData->GetPaperSource());
	BMenuField* paperSourceMenufield = new BMenuField("paperSource",
		"Paper Source:", fPaperFeed);

	// Pages per sheet
	fNup = new BPopUpMenu("");
	fNup->SetRadioMode(true);
	FillCapabilityMenu(fNup, kMsgNone, gNups,
		sizeof(gNups) / sizeof(gNups[0]), (int)fJobData->GetNup());
	BMenuField* pagesPerSheet = new BMenuField("pagesPerSheet",
		"Pages Per Sheet:", fNup);

	// duplex
	if (fPrinterCap->Supports(PrinterCap::kPrintStyle)) {
		fDuplex = new BCheckBox("duplex", "Duplex",
			new BMessage(kMsgDuplexChanged));
		if (fJobData->GetPrintStyle() != JobData::kSimplex) {
			fDuplex->SetValue(B_CONTROL_ON);
		}
		fDuplex->SetTarget(this);
	} else {
		fDuplex = NULL;
	}

	// copies
	fCopies = new BTextControl("copies", "Number of Copies:", "", NULL);
	AllowOnlyDigits(fCopies->TextView(), 3);

	BString copies;
	copies << fJobData->GetCopies();
	fCopies->SetText(copies.String());

	// collate
	fCollate = new BCheckBox("collate", "Collate",
		new BMessage(kMsgCollateChanged));
	if (fJobData->GetCollate()) {
		fCollate->SetValue(B_CONTROL_ON);
	}
	fCollate->SetTarget(this);

	// reverse
	fReverse = new BCheckBox("reverse", "Reverse Order",
		new BMessage(kMsgReverseChanged));
	if (fJobData->GetReverse()) {
		fReverse->SetValue(B_CONTROL_ON);
	}
	fReverse->SetTarget(this);

	// pages view
	// TODO make layout API compatible
	fPages = new PagesView(BRect(0, 0, 150, 40), "pages", B_FOLLOW_ALL,
		B_WILL_DRAW);
	fPages->SetCollate(fJobData->GetCollate());
	fPages->SetReverse(fJobData->GetReverse());
	fPages->SetExplicitMinSize(BSize(150, 40));
	fPages->SetExplicitMaxSize(BSize(150, 40));
	
	// page selection
	BBox* pageSelectionBox = new BBox("pageSelection");
	pageSelectionBox->SetLabel("Page Selection");
	
	fAllPages = CreatePageSelectionItem("allPages", "All Pages",
		JobData::kAllPages);
	fOddNumberedPages = CreatePageSelectionItem("oddPages",
		"Odd-Numbered Pages", JobData::kOddNumberedPages);
	fEvenNumberedPages = CreatePageSelectionItem("evenPages",
		"Even-Numbered Pages", JobData::kEvenNumberedPages);

	fPreview = new BCheckBox("preview", "Show preview before printing", NULL);
	if (fJobData->GetShowPreview())
		fPreview->SetValue(B_CONTROL_ON);

	// separator line
	BBox *separator = new BBox("separator");
	separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

	// buttons
	BButton* cancel = new BButton("cancel", "Cancel",
		new BMessage(kMsgCancel));
	BButton* ok = new BButton("ok", "OK", new BMessage(kMsgOK));
	ok->MakeDefault(true);
	
	if (IsHalftoneConfigurationNeeded()) {
		BGroupView* halftoneGroup = new BGroupView(B_VERTICAL, 0);
		BGroupLayout* halftoneLayout = halftoneGroup->GroupLayout();
		halftoneLayout->AddView(fHalftone);
		fHalftoneBox->AddChild(halftoneGroup);
	}

	BGridView* qualityGrid = new BGridView();
	BGridLayout* qualityGridLayout = qualityGrid->GridLayout();
	qualityGridLayout->AddItem(colorMenuField->CreateLabelLayoutItem(), 0, 0);
	qualityGridLayout->AddItem(colorMenuField->CreateMenuBarLayoutItem(), 1, 0);
	if (IsHalftoneConfigurationNeeded()) {
		qualityGridLayout->AddItem(fDitherMenuField->CreateLabelLayoutItem(),
			0, 1);
		qualityGridLayout->AddItem(fDitherMenuField->CreateMenuBarLayoutItem(),
			1, 1);
		qualityGridLayout->AddView(fGamma, 0, 2, 2);
		qualityGridLayout->AddView(fInkDensity, 0, 3, 2);
		qualityGridLayout->AddView(fHalftoneBox, 0, 4, 2);
	} else {
		AddDriverSpecificSettings(qualityGridLayout, 1);
	}
	qualityGridLayout->SetSpacing(0, 0);
	qualityGridLayout->SetInsets(5, 5, 5, 5);
	qualityBox->AddChild(qualityGrid);
	// TODO put qualityGrid in a scroll view
	// the layout of the box surrounding the scroll view using the following
	// code is not correct; the box still has the size of the qualityGird;
	// and the scroll view is vertically centered inside the box!
	//BScrollView* qualityScroller = new BScrollView("qualityScroller",
	//	qualityGrid, 0, false, true);
	//qualityScroller->SetExplicitMaxSize(BSize(500, 500));
	//qualityBox->AddChild(qualityScroller);

	BGridView* pageRangeGrid = new BGridView();
	BGridLayout* pageRangeLayout = pageRangeGrid->GridLayout();
	pageRangeLayout->AddItem(fFromPage->CreateLabelLayoutItem(), 0, 0);
	pageRangeLayout->AddItem(fFromPage->CreateTextViewLayoutItem(), 1, 0);
	pageRangeLayout->AddItem(fToPage->CreateLabelLayoutItem(), 0, 1);
	pageRangeLayout->AddItem(fToPage->CreateTextViewLayoutItem(), 1, 1);
	pageRangeLayout->SetInsets(0, 0, 0, 0);
	pageRangeLayout->SetSpacing(0, 0);

	BGroupView* pageRangeGroup = new BGroupView(B_VERTICAL, 0);
	BGroupLayout* pageRangeGroupLayout = pageRangeGroup->GroupLayout();
	pageRangeGroupLayout->AddView(fAll);
	pageRangeGroupLayout->AddView(range);
	pageRangeGroupLayout->AddView(pageRangeGrid);
	pageRangeGroupLayout->SetInsets(5, 5, 5, 5);
	pageRangeBox->AddChild(pageRangeGroup);

	BGridView* settings = new BGridView();
	BGridLayout* settingsLayout = settings->GridLayout();
	settingsLayout->AddItem(paperSourceMenufield->CreateLabelLayoutItem(), 0,
		0);
	settingsLayout->AddItem(paperSourceMenufield->CreateMenuBarLayoutItem(), 1,
		0);
	settingsLayout->AddItem(pagesPerSheet->CreateLabelLayoutItem(), 0, 1);
	settingsLayout->AddItem(pagesPerSheet->CreateMenuBarLayoutItem(), 1, 1);
	int row = 2;
	if (fDuplex != NULL) {
		settingsLayout->AddView(fDuplex, 0, row, 2);
		row ++;
	}
	settingsLayout->AddItem(fCopies->CreateLabelLayoutItem(), 0, row);
	settingsLayout->AddItem(fCopies->CreateTextViewLayoutItem(), 1, row);
	settingsLayout->SetSpacing(0, 0);


	BGroupView* pageSelectionGroup = new BGroupView(B_VERTICAL, 0);
	BGroupLayout* groupLayout = pageSelectionGroup->GroupLayout();
	groupLayout->AddView(fAllPages);
	groupLayout->AddView(fOddNumberedPages);
	groupLayout->AddView(fEvenNumberedPages);
	groupLayout->SetInsets(5, 5, 5, 5);
	pageSelectionBox->AddChild(pageSelectionGroup);

	SetLayout(new BGroupLayout(B_VERTICAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
		.AddGroup(B_HORIZONTAL, 10, 1.0f)
			.AddGroup(B_VERTICAL, 10, 1.0f)
				.Add(qualityBox)
				.Add(pageRangeBox)
				.AddGlue()
			.End()
			.AddGroup(B_VERTICAL, 0, 1.0f)
				.Add(settings)
				.AddStrut(5)
				.Add(fCollate)
				.Add(fReverse)
				.Add(fPages)
				.AddStrut(5)
				.Add(pageSelectionBox)
				.AddGlue()
			.End()
		.End()
		.Add(fPreview)
		.AddGlue()
		.Add(separator)
		.AddGroup(B_HORIZONTAL, 10, 1.0f)
			.AddGlue()
			.Add(cancel)
			.Add(ok)
		.End()
		.SetInsets(0, 0, 0, 0)
	);

	UpdateHalftonePreview();

	UpdateButtonEnabledState();
}
/*!	\brief		Builds the interface for a selected calendar module.
 *	\param[in]		id		Name of the calendar module to build the interface for.
 *	\details	If the interface for a module already exists, this function
 *				deletes it without affecting the already set preferences.
 */
void	CalendarModulePreferencesView::BuildInterfaceForModule( const BString& id )
{
	BGroupLayout* layout = ( BGroupLayout* )( BView::GetLayout() );
	BLayoutItem* 	layoutItem = NULL;
	BBox*		 tempBBox = NULL;
	
	if ( !this->Window() || this->Window()->Lock() )
	{
		// First, clean up old interface items if they existed
		this->ClearOldInterface();
		
		// Prepare the frame for the BBox for weekends selection
		BRect 		 r = this->Bounds();	
		r.InsetBySelf( 5, 5 );
		r.right -= 10;
		r.bottom -= 10;
		if ( calendarModuleSelector )
			r.top += ( calendarModuleSelector->Bounds().Height() + 10 );
		
		// Build weekend selection
		tempBBox = CreateWeekendSelectionBox( r, id );
		if ( tempBBox )
		{
			// After the call, the BBox is resized to minimal required size.
			layoutItem = layout->AddView( 1, tempBBox, 0 );
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
		}
		else
		{
			utl_Deb = new DebuggerPrintout( "Error - Weekend selection box is NULL." );
		}

		// Start day chooser	
		BMenuField* startDayChooser = CreateWeekStartDayChooser( r, id );
		if ( startDayChooser )
		{
			layoutItem = layout->AddView( 2, startDayChooser, 0 );
			if ( layoutItem )
				layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
		}
		
		// Day-month-year order
		BMenuField* dmyChooser = CreateDayMonthYearOrderChooser( r, id );
		if ( dmyChooser )
		{
			layoutItem = layout->AddView( 3, dmyChooser, 0 );
			if ( layoutItem )
				layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
		}
		
		// Colors selection
		tempBBox = BuildColorSelectors( r, id );
		if ( tempBBox ) {
			layoutItem = layout->AddView( 4, tempBBox, 0 );
		}
		
		
		/* At the end, all children are targetted at current window */
		UpdateTargetting();
		
		if ( this->Window() ) { this->Window()->Unlock(); }
	}	// <-- end of lock-only section
	
	
}	// <-- end of function CalendarModulePreferencesView::BuildInterfaceForModule
/*!	\brief		Add the interface for configuring colors.
 *	\param[in]	frame	The frame of the view.
 *	\param[in]	id		The ID of the interface to configure the colors for.
 */
BBox*		CalendarModulePreferencesView::BuildColorSelectors( BRect frame,
															    const BString& id )
{
	BBox* toReturn = NULL;
	BLayoutItem*	layoutItem = NULL;
	BString sb;
	BRect tempRect = frame;
//	tempRect.InsetBySelf( 10, 10 );
	BMessage* toSend = NULL;
	
	// Access the preferences
	CalendarModulePreferences* prefs = pref_GetPreferencesForCalendarModule( id );
	if ( !prefs ) {
		return NULL;
	}
	
	// Prepare the overall BBox
	toReturn = new BBox( frame, "Color selector" );
	if ( ! toReturn )
		return NULL;
		
	toReturn->SetLabel( "Set up colors" );
	
	// Set up the layout for this BBox
	BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
	if ( !groupLayout ) {
		delete toReturn;
		return NULL;
	}
	groupLayout->SetInsets( 10, 15, 10, 5 );
	groupLayout->SetSpacing( 2 );
	toReturn->SetLayout( groupLayout );
	
	// Label over the CategoryListView for the viewer
	BStringView* viewerString = new BStringView( BRect( 0, 0, 1, 1 ),
											   "Colors Changer Explanation",
											   "Double-click the color to edit it." );
	if ( !viewerString )
	{
		delete toReturn;
		return NULL;
	}
	viewerString->ResizeToPreferred();
	layoutItem = groupLayout->AddView( 0, viewerString, 0 );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );

	toSend = new BMessage( kCategoryInvoked );
	if ( !toSend )
	{
		/* Panic! */
		exit( 1 );
	}
	toSend->AddString( "Calendar module", id );
	CategoryListView* menuColors = new CategoryListView( BRect( 0, 
																0,
																tempRect.Width() + B_V_SCROLL_BAR_WIDTH,
																tempRect.Height() + B_H_SCROLL_BAR_HEIGHT ),
														 "Colors list view" );
	if ( !menuColors ) {
//		menuString->RemoveSelf(); delete menuString;
//		viewerString->RemoveSelf(); delete viewerString;
		delete toReturn; return NULL;
	}
	menuColors->SetInvocationMessage( toSend );
	
	// Fill the CategoryListView for the menu colors
	sb.SetTo( "Color for displaying weekdays in the controls" );
	CategoryListItem* toAdd = new CategoryListItem( prefs->GetWeekdaysColor( false ),
													sb );
	if ( toAdd ) {
		menuColors->AddItem( toAdd );
	}
	
	sb.SetTo( "Color for displaying weekends in the controls" );
	toAdd = new CategoryListItem( prefs->GetWeekendsColor( false ),
		 					  	  sb );
	if ( toAdd ) {
		menuColors->AddItem( toAdd );
	}
	sb.SetTo( "Color for displaying weekdays in Viewer" );
	toAdd = new CategoryListItem( prefs->GetWeekdaysColor( true ),
								  sb );
	if ( toAdd ) {
		menuColors->AddItem( toAdd );
	}
	sb.SetTo( "Color for displaying weekends in Viewer" );
	toAdd = new CategoryListItem( prefs->GetWeekendsColor( true ),
		 					  	  sb );
	if ( toAdd ) {
		menuColors->AddItem( toAdd );
	}
	sb.SetTo( "Color for displaying service items in the controls" );
	toAdd = new CategoryListItem( prefs->GetServiceItemsColor( false ),
		 					  	  sb );
	if ( toAdd ) {
		menuColors->AddItem( toAdd );
	}
	sb.SetTo( "Color for displaying service items in the Viewer" );
	toAdd = new CategoryListItem( prefs->GetServiceItemsColor( true ),
		 					  	  sb );
	if ( toAdd ) {
		menuColors->AddItem( toAdd );
	}
	
	menuColors->ResizeToPreferred();	
//	BSize setSize( menuColors->Bounds().Width(), menuColors->Bounds().Height() );
	BSize setSize( frame.Width(), menuColors->Bounds().Height()+5 );
	
	layoutItem = groupLayout->AddView( 1, menuColors, 0 );
	layoutItem->SetExplicitMaxSize( setSize );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
	groupLayout->InvalidateLayout();
		
	return toReturn;
}	// <-- end of function CalendarModulePreferecesView::BuildColorSelectors
/*!	\brief			Constructor of CategoryPreferencesView
 *	\details		It's a descendant of BView.
 *	\param[in]	frame	The frame rectangle of the view.
 */
CategoryPreferencesView::CategoryPreferencesView( BRect frame )
	:
	BView( frame,
		   "Category Preferences",
		   B_FOLLOW_ALL_SIDES,
		   B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE )
{
	BLayoutItem* layoutItem = NULL;
	BMessage* toSend = NULL;
	menuField = NULL;
	
	this->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	
	/*!	\note	Layout of the view
	 *			The view has a grid layout. It's arranged in the following way:
	 *			1)	Left column - list of Categories (CategoryList) that
	 *				contains all categories currently available.
	 *			2) 	Right column - three buttons, from top to bottom:
	 *				2a)	Edit currently selected category - guess what it's doing
	 *				2b) Add a new category
	 *				2c)	Merge a current directory into another one + menu with
	 *					all categories. The category selected in the list is disabled.
	 * \note	Restrictions:
	 *			a) The list of categories is scrolled.
	 *			b) If no category is selected, then
	 *				i) 	"Edit" button is disabled
	 *				ii)	"Merge to" field is disabled
	 *			
	 */
	BGridLayout* gridLayout = new BGridLayout();
	if ( !gridLayout )
	{
		/* Panic! */
		exit( 1 );
	}
	// Margins from the sides of the view and spacing between the elements
	gridLayout->SetInsets( 5, 5, 5, 5 );
	gridLayout->SetHorizontalSpacing( 10 );
	gridLayout->SetVerticalSpacing( 10 );
	this->SetLayout( gridLayout );
	gridLayout->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
	gridLayout->SetExplicitMinSize( BSize( (this->Bounds()).Width(), (this->Bounds()).Height() ) );
	

	BRect rect = gridLayout->Frame();
	printf ( "The frame is %d pixels wide and %d pixels high.\n",
			 (int )rect.Width(),
			 (int )rect.Height() );
	
	
	/* Creating the CategoryListView with its scroller */
	BRect r( this->Bounds() );
	r.InsetBySelf( 5, 10 );	// Margins near the border of the view
	r.right = (int)(r.right / 2) - B_V_SCROLL_BAR_WIDTH;
	r.bottom -= 0;
	
	listView = new CategoryListView( r, "List View" );
	if ( ! listView ) {
		/* Panic! */
		exit( 1 );
	}
	BLooper* looper = this->Looper();
	if ( looper && looper->LockLooper() )
	{
		looper->AddHandler( ( BHandler* )this );
		looper->UnlockLooper();	
	}
	
	scroller = new BScrollView( "Scroller",
								listView,
								B_FOLLOW_LEFT | B_FOLLOW_TOP,
								0, 	// Flags
								true,
								true );
	if ( !scroller )
	{
		/* Panic! */
		exit( 1 );
	}
	layoutItem = gridLayout->AddView( scroller, 0, 0, 1, 3 );
	if ( !layoutItem ) {
		/* Panic! */
		exit( 1 );
	}
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT,
												  B_ALIGN_USE_FULL_HEIGHT ) );
	toSend = new BMessage( kCategoryInvoked );
	if ( !toSend )
	{
		/* Panic! */
		exit( 1 );
	}
	listView->SetInvocationMessage( toSend );
	toSend = new BMessage( kCategorySelected );
	if ( !toSend )
	{
		/* Panic! */
		exit( 1 );
	}
	listView->SetSelectionMessage( toSend );
	
	r = listView->Bounds();	
	r.bottom += B_H_SCROLL_BAR_HEIGHT + 3;
	r.right -= ( B_V_SCROLL_BAR_WIDTH + 10 );
	
	layoutItem->SetExplicitMinSize( BSize( ( B_V_SCROLL_BAR_WIDTH * 2 ), r.Height() ) );
	gridLayout->SetMaxColumnWidth( 0, r.Width()-70 );
	gridLayout->SetMaxColumnWidth( 1, r.Width()-66 );
	
	// Add categories to the list
	PopulateCategoriesView();
	
	/* Creating the buttons */
	// Add new category button
	toSend = new BMessage( kAddNewCategory );
	addButton = new BButton( BRect( 0, 0, 1, 1), 
							 "Add category",
							 "Add category",
							 toSend,
							 B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
	if ( !toSend || !addButton ) {
		/* Panic! */
		exit( 1 );
	}
	addButton->ResizeToPreferred();
	addButton->SetTarget( this );
	layoutItem = gridLayout->AddView( addButton, 1, 0, 1, 1 );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER ) );
	
	// Edit old category button
	toSend = new BMessage( kCategoryInvoked );
	editButton = new BButton( BRect( 0, 0, 1, 1), 
							 "Edit category",
							 "Edit category",
							 toSend,
							 B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
	if ( !toSend || !editButton ) {
		/* Panic! */
		exit( 1 );
	}
	editButton->ResizeToPreferred();
	editButton->SetTarget( this );
	layoutItem = gridLayout->AddView( editButton, 1, 1, 1, 1 );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER ) );
	// Edit category button is disabled by default; 
	// it's enabled when user chooses a category in the list.
	editButton->SetEnabled( false );
	
	/* Creating the menu of merging a category */
	// Create a label
	BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
	if ( !groupLayout )
	{
		/* Panic! */
		exit( 1 );
	}
	gridLayout->AddItem( groupLayout, 1, 2, 1, 1 );
	groupLayout->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
	
	mergeToLabel = new BStringView( BRect( 0, 0, 1, 1 ),
								"Merge to label",
								"Merge selected category into:" );
	if ( !mergeToLabel ) {
		/* Panic! */
		exit( 1 );
	}
	mergeToLabel->ResizeToPreferred();
	layoutItem = groupLayout->AddView( mergeToLabel );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
	
	// Create the menu
	BMessage templateMessage( kMergeIntoCategory );
	listMenu = new CategoryMenu( "Select category to merge to:", true, &templateMessage );
	if ( !listMenu )
	{
		/* Panic! */
		exit( 1 );
	}	
	
	menuField = new BMenuField( mergeToLabel->Bounds(),
								"Merge to field",
								NULL,
								listMenu );
	if ( !menuField ) {
		/* Panic! */
		exit( 1 );
	}
	menuField->SetDivider( 0 );
	// Just like the "Edit" button above, the menu is initially disabled.
	menuField->SetEnabled( false );
	
	layoutItem = groupLayout->AddView( menuField );
	layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
	
	for ( int index = 0; index < gridLayout->CountColumns(); ++index )
	{
		gridLayout->SetColumnWeight( index, 1 );
	}
	for ( int index = 0; index < gridLayout->CountRows(); ++index )
	{
		gridLayout->SetRowWeight( index, 1 );	
	}
	gridLayout->InvalidateLayout();
	
}	// <-- end of constructor of CategoryPreferencesView
MainView::MainView(BRect frame) 
	:
	BView(frame, 
			NULL, 
			B_FOLLOW_TOP|B_FOLLOW_LEFT, 
			B_FRAME_EVENTS|B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE)
{
	this->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BRect tempRect = this->Bounds();
	tempRect.InsetBy(5, 5);
	
	CategoryListView* listView = new CategoryListView( tempRect, "list" );
	if ( !listView )
	{
		/* Panic! */
		exit(1);
	}
	
/*	tempRect.right -= B_V_SCROLL_BAR_WIDTH;
	tempRect.bottom -= B_H_SCROLL_BAR_HEIGHT;
	
	BListView* listView = new BListView(tempRect, "list");
	if (!listView) { exit(1); }
	
*/
	this->scrollView = new BScrollView("scroll",
			listView,
			B_FOLLOW_LEFT | B_FOLLOW_TOP,
			B_FRAME_EVENTS,
			true, true);

	if (!scrollView) { exit(1); }
	
	listView->SetScroller( scrollView );
/*	((BScrollBar*)(scrollView->ScrollBar(B_VERTICAL)))->SetSteps(5, 20);
	((BScrollBar*)(scrollView->ScrollBar(B_HORIZONTAL)))->SetSteps(5, 20);

	 
	BBitmap *icon = NULL;
	icon = CreateIcon(kBlue);
	IconListItem *item = new IconListItem(icon,
										  "Test1",
										  0,
										  false);											  
	if (!item) { exit(1); }
	
	listView->AddItem(item);
	
	icon = CreateIcon(kMagen);
	item = new IconListItem(icon,
						  "Test2",
						  0,
						  false);											  
	if (!item) { exit(1); }
	listView->AddItem(item);
	
	icon = CreateIcon(kWhite);
	item = new IconListItem(icon,
						  "White icon",
						  0,
						  false);											  
	if (!item) { exit(1); }
	listView->AddItem(item);
	
	icon = CreateIcon(kMedGray);
	item = new IconListItem(icon,
						  "Категория на русском",
						  0,
						  false);											  
	if (!item) { exit(1); }
	listView->AddItem(item);

	BString categoryName("Категория с именем из BString");
	icon = CreateIcon(kBlue);	
	item = new IconListItem(icon,
				categoryName.String(),
				0,
				false);
	if (!item) { exit(1); }
	listView->AddItem(item);
*/	
	rgb_color red = { 255, 0, 0, 255 };
	BString catName = "CategoryListItem";
	
	BListItem* listItem = new CategoryListItem( red, catName );
	if ( !listItem ) { exit(1); }
	listView->AddItem( listItem );
	
//	listView->ResizeToPreferred();
	
	
	BGroupLayout* layout = new BGroupLayout( B_VERTICAL );
	if (!layout ) { /* Panic! */  exit(1); }
	this->SetLayout( layout );
	layout->SetInsets( 5, 5, 5, 5 );
	
	layout->AddView( scrollView );
	
	CategoryMenu* catMenu = new CategoryMenu( "CatMenu", NULL );
	
	CategoryMenuItem* item1 = new CategoryMenuItem( catName, red, NULL );
	
	catMenu->AddItem( item1 );
	
	BString menuName("Categories");
	BMenuField* menuField = new BMenuField( BRect( 0, 0, 1, 1),
											"Menu field",
											menuName,
											catMenu );
	menuField->ResizeToPreferred();
	layout->AddView( menuField );
	
	
	// this->AddChild(scrollView);
	// FixupScrollbars();
}
/*!	\brief		Constructor for the ActivityWindow class.
 *		\param[in]	data			The data to be displayed.
 *		\param[in]	target		The process to be notified about user's choise.
 *		\param[in]	name			Name of the Event.
 *		\param[in]	category		Category of the Event.
 *		\param[in]	templateMessage		The message to be sent to the target.
 *										If \c NULL is passed, then a new message is constructed
 *										with \c kActivityWindowRepsonceMessage value in \c what.
 *		\param[in]	reminder		\c true if the window is constructed for a reminder, else
 *										\c false. Actually, it matters only for explanation to user.
 *										Default is \c false (it's not a reminder).
 *		\note			A note on memory management:
 *						\c data (the ActionData) belongs to the caller, but it's used only for
 *						initialization of this window. I. e., if the user makes changes to the
 *						data while an ActivityWindow is open, the changes won't be reflected.
 *						However, \c target and \c templateMessage belong to this object. User
 *						shouldn't free them or do anything else.
 */
ActivityWindow::ActivityWindow( ActivityData* data,
									 BMessenger* target,
									 BString		 name,
									 Category*	 category,
									 BMessage* templateMessage,
									 bool reminder )
	:
	BWindow( BRect( 0, 0, 400, 500 ),
				"Event occurred",
				B_FLOATING_WINDOW_LOOK,
				B_NORMAL_WINDOW_FEEL,
				B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS ),
	fTarget( target ),
	fData( data ),
	fTemplateMessage( templateMessage ),
	bIsReminder( reminder ),
	fLastError( B_OK ),
	fEventName( name ),
	fCategory( category ),
	fTitle( NULL ),
	fEventNameView( NULL ),
	fCategoryView( NULL ),
	fTextScroller( NULL ),
	fSnoozeTime( NULL ),
	fNoteText( NULL ),
	fSnooze( NULL ),
	fOk( NULL )
{
	BFont boldFont( be_bold_font );
	BFont plainFont( be_plain_font );
	BFont font;			// For various font-related activities
	font_height	fh;	// For setting the height of the Text View with notification text
	plainFont.GetHeight( &fh );
	int	numberOfColumnsInLayout = 2;
	
	// Sanity check
	if ( !data || !target ) {
		/* Panic! */
		fLastError = B_BAD_VALUE;
		return;
	}
	
	if ( ! fData->GetNotification( NULL ) &&
		  ! fData->GetSound( NULL ) &&
		  ! fData->GetProgram( NULL, NULL ) )
	{
		// Nothing to do! This is not an error!
		fLastError = B_NO_INIT;
		return;
	}
	BView*	background = new BView( Bounds(),
												"Background view",
												B_FOLLOW_ALL_SIDES,
												B_WILL_DRAW );
	if ( !background ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	this->AddChild( background );
	BGridLayout* gridLayout = new BGridLayout();
	if ( !gridLayout ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	background->SetLayout( gridLayout );
	background->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	gridLayout->SetInsets( 5, 5, 5, 5 );
	
	/*-------------------------------------------------
	 * First line - explaining what's happening here
	 *------------------------------------------------*/
	BStringView* exp = new BStringView( BRect( 0, 0, 1, 1 ),
													"Explanation 1",
													( bIsReminder ? 
															"A Reminder has occured!" : 
															"An Event has occured!" ) );
	if ( ! exp ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;	
	}
	exp->SetFont( &boldFont );
	exp->ResizeToPreferred();
	BLayoutItem* layoutItem = gridLayout->AddView( exp, 0, 0, numberOfColumnsInLayout, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_TOP ) );
	}
	
	/*-----------------------------------------------------------------
	 * Second line - event's name on category's color as background
	 *----------------------------------------------------------------*/
	 
	// Create background
	// Note: the pulse is requested for this Window to receive Pulse notifications.
	fBackground = new BView( BRect( 0, 0, 1, 1 ),
									 "Background",
									 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_V_CENTER | B_PULSE_NEEDED,
									 B_WILL_DRAW );
	if ( !fBackground ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fBackground->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	layoutItem = gridLayout->AddView( fBackground, 0, 1, numberOfColumnsInLayout, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
	}
	
	BGroupLayout* bgLayout = new BGroupLayout( B_VERTICAL );
	if ( !bgLayout ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fBackground->SetLayout( bgLayout	);
	bgLayout->SetInsets( 15, 10, 15, 10 );
	fBackground->SetViewColor( fCategory.categoryColor );
	BString sb = "Category:\n";
	sb << fCategory.categoryName;
	fBackground->SetToolTip( sb.String() );
	
	// Create Event's name view
	fTitle = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Event name",
									  fEventName.String(),
									  B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
	if ( !fTitle ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
		// Use big bold font for Event's name
	fTitle->SetFont( be_bold_font );
	fTitle->GetFont( &font );
	font.SetSize( font.Size() + 2 );
	fTitle->SetFont( &font, B_FONT_SIZE );
	
		// Add the title and set its tooltip
	fTitle->ResizeToPreferred();
	fTitle->SetToolTip( sb.String() );
	bgLayout->AddView( fTitle );
	fTitle->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
	fTitle->SetToolTip( fEventName.String() );
	
	int	nextLineInLayout = 2;
	
	/*================================================================
	 * If the notification was set by the user, display it.
	 *================================================================*/

	BString 	tempString;
	BPath		path;
	float rectHeight = fh.leading + fh.ascent + fh.descent;
	float rectWidth = this->Bounds().Width() - 10;		// Layout insets
	BSize size( rectWidth, rectHeight );
	
	if ( fData->GetNotification( &tempString ) )
	{
		/*-----------------------------------------------------------------
	 	 * Line of explanation
	 	 *----------------------------------------------------------------*/
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Text view explanation",
									  "You set the following notification:" );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );

		/*-----------------------------------------------------------------
	 	 * Text view with notification text
	 	 *----------------------------------------------------------------*/
		BRect tempRect( BPoint( 0, 0 ), size );
		tempRect.right -= B_V_SCROLL_BAR_WIDTH;
		fNoteText = new BTextView( tempRect,
											"Notification text container",
											tempRect.InsetByCopy( 1, 1 ),
											B_FOLLOW_ALL_SIDES,
											B_WILL_DRAW );
		if ( !fNoteText ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		fNoteText->MakeEditable( false );
		fNoteText->SetText( tempString.String() );
		
		/*-----------------------------------------------------------------
	 	 * Scroll view to scroll the notification text
	 	 *----------------------------------------------------------------*/
		fTextScroller = new BScrollView( "Notification text scroller",
													fNoteText,
													B_FOLLOW_ALL_SIDES,
													0,
													false,
													true );
		if ( !fTextScroller ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		layoutItem = gridLayout->AddView( fTextScroller, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
//			layoutItem->SetExplicitMaxSize( size );
			layoutItem->SetExplicitMinSize( size );
			layoutItem->SetExplicitPreferredSize( size );
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
		}
	}	// <-- end of adding information about the notification
	
	/*================================================================
	 * If user wanted to play a sound file, notify him about it.
	 *================================================================*/
	if ( fData->GetSound( &path ) )
	{
		/*-----------------------------------------------------------------
	 	 * Line of explanation
	 	 *----------------------------------------------------------------*/
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Sound file explanation",
									  "You wanted to play the file:",
									  B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}

		/*-----------------------------------------------------------------
	 	 * Display sound file name
	 	 *----------------------------------------------------------------*/
	 	 
	 	// What should we display - full path or just the leaf?
	 	if ( ( size.width - 10 ) > plainFont.StringWidth( path.Path() ) )
	 	{
	 		tempString.SetTo( path.Path() );
	 	}
	 	else
	 	{
	 		tempString.SetTo( path.Leaf() );
	 	}
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Sound file name",
									  tempString.String() );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}
		
	}	// <-- end of displaying information about the sound file
	
	/*================================================================
	 * If user wanted to run a program, notify him about it.
	 *================================================================*/
	if ( fData->GetProgram( &path, &tempString ) )
	{
		/*-----------------------------------------------------------------
	 	 * Line of explanation
	 	 *----------------------------------------------------------------*/
		exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Program explanation",
									  "You wanted to run a program:" );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}

		/*-----------------------------------------------------------------
	 	 * Display path to program file
	 	 *----------------------------------------------------------------*/
	 	 
	 	// What should we display - full path or just the leaf?
	 	exp = new BStringView( BRect( 0, 0, 1, 1 ),
									  "Program file name",
									  ( ( size.width - 10 ) > plainFont.StringWidth( path.Path() ) ) ?
									  		path.Path() :
									  		path.Leaf() );
		if ( !exp ) {
			/* Panic! */
			fLastError = B_NO_MEMORY;
			return;
		}
		exp->ResizeToPreferred();
		layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
		if ( layoutItem ) {
			layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
		}
		
		/*-----------------------------------------------------------------
	 	 * Explanation about the program options
	 	 *----------------------------------------------------------------*/
	 	 
	 	if ( tempString.Length() > 0 ) {
		 	exp = new BStringView( BRect( 0, 0, 1, 1 ),
										  "Program file options explanation",
										  "With the following parameters:" );
			if ( !exp ) {
				/* Panic! */
				fLastError = B_NO_MEMORY;
				return;
			}
			exp->ResizeToPreferred();
			layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
			if ( layoutItem ) {
				layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
			}
			
			/*-----------------------------------------------------------------
		 	 * Display the program options
		 	 *----------------------------------------------------------------*/
		 	 
		 	// What should we display - full path or just the leaf?
		 	exp = new BStringView( BRect( 0, 0, 1, 1 ),
										  "Program file options",
										  tempString.String() );
			if ( !exp ) {
				/* Panic! */
				fLastError = B_NO_MEMORY;
				return;
			}
			exp->ResizeToPreferred();
			layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
			if ( layoutItem ) {
				layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
			}
	 	}	// <-- end of diplaying CLI options		
	}	// <-- end of displaying information about the program to run
	
	/*================================================================
	 * Now it's time to display the Snooze time selector
	 *================================================================*/
	TimePreferences* prefs = pref_GetTimePreferences();
	if ( prefs ) {
		prefs->GetDefaultSnoozeTime( ( int* )&fSnoozeHours, ( int* )&fSnoozeMins );
	} else {
		fSnoozeHours = 0;
		fSnoozeMins = 10;
	}
	
	BMessage* toSend = new BMessage( kSnoozeTimeControlMessage );
	if ( ! toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnoozeTime = new GeneralHourMinControl( BRect( 0, 0, 1, 1 ),
														  "Snooze time selector",
														  "Snooze this Activtiy for:",
														  BString( "" ),	// No check box
														  toSend );
	if ( !fSnoozeTime ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnoozeTime->SetHoursLimit( 23 );	// Max reminder time delay is 23 hours 55 minutes
	fSnoozeTime->SetMinutesLimit( 55 );
	fSnoozeTime->SetCurrentTime( fSnoozeHours, fSnoozeMins );
	
	layoutItem = gridLayout->AddView( fSnoozeTime, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
	}
	

	/*================================================================
	 * Snooze button
	 *================================================================*/
	toSend = new BMessage( kSnoozeButtonPressed );
	if ( !toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnooze = new BButton( BRect( 0, 0, 1, 1 ),
								  "Snooze button",
								  "Snooze",
								  toSend,
								  B_FOLLOW_LEFT | B_FOLLOW_TOP );
	if ( !fSnooze ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnooze->ResizeToPreferred();
	layoutItem = gridLayout->AddView( fSnooze, 0, nextLineInLayout );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
	}

	/*================================================================
	 * Ok button
	 *================================================================*/
	toSend = new BMessage( kDismissButtonPressed );
	if ( !toSend ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fOk = new BButton( BRect( 0, 0, 1, 1 ),
							  "Dismiss button",
							  "Dismiss",
							  toSend,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP );
	if ( !fOk ) {
		/* Panic! */
		fLastError = B_NO_MEMORY;
		return;
	}
	fSnooze->ResizeToPreferred();
	layoutItem = gridLayout->AddView( fOk, 1, nextLineInLayout );
	if ( layoutItem ) {
		layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_TOP ) );
	}

	this->CenterOnScreen();	
}	// <-- end of constructor for ActivityWindow
Exemple #24
0
EthernetSettingsView::EthernetSettingsView()
    :
    BView("EthernetSettingsView", 0, NULL),
    fCurrentSettings(NULL)
{
    SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    fSocket = socket(AF_INET, SOCK_DGRAM, 0);
    _GatherInterfaces();

    // build the GUI
    BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL);
    SetLayout(rootLayout);

    BGridView* controlsGroup = new BGridView();
    BGridLayout* layout = controlsGroup->GridLayout();

    // insets
    float inset = ceilf(be_plain_font->Size() * 0.7);
    rootLayout->SetInsets(inset, inset, inset, inset);
    rootLayout->SetSpacing(inset);
    layout->SetSpacing(inset, inset);

    BPopUpMenu* deviceMenu = new BPopUpMenu(B_TRANSLATE("<no adapter>"));
    for (int32 i = 0; i < fInterfaces.CountItems(); i++) {
        BString& name = *fInterfaces.ItemAt(i);
        BString label = name;
        BMessage* info = new BMessage(kMsgInfo);
        info->AddString("interface", name.String());
        BMenuItem* item = new BMenuItem(label.String(), info);
        deviceMenu->AddItem(item);
    }

    BPopUpMenu* modeMenu = new BPopUpMenu("modes");
    modeMenu->AddItem(new BMenuItem(B_TRANSLATE("Static"),
                                    new BMessage(kMsgStaticMode)));
    modeMenu->AddItem(new BMenuItem(B_TRANSLATE("DHCP"),
                                    new BMessage(kMsgDHCPMode)));
    modeMenu->AddSeparatorItem();
    modeMenu->AddItem(new BMenuItem(B_TRANSLATE("Disabled"),
                                    new BMessage(kMsgDisabledMode)));

    BPopUpMenu* networkMenu = new BPopUpMenu("networks");

    fDeviceMenuField = new BMenuField(B_TRANSLATE("Adapter:"), deviceMenu);
    layout->AddItem(fDeviceMenuField->CreateLabelLayoutItem(), 0, 0);
    layout->AddItem(fDeviceMenuField->CreateMenuBarLayoutItem(), 1, 0);

    fNetworkMenuField = new BMenuField(B_TRANSLATE("Network:"), networkMenu);
    layout->AddItem(fNetworkMenuField->CreateLabelLayoutItem(), 0, 1);
    layout->AddItem(fNetworkMenuField->CreateMenuBarLayoutItem(), 1, 1);

    fTypeMenuField = new BMenuField(B_TRANSLATE("Mode:"), modeMenu);
    layout->AddItem(fTypeMenuField->CreateLabelLayoutItem(), 0, 2);
    layout->AddItem(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 2);

    fIPTextControl = new BTextControl(B_TRANSLATE("IP address:"), "", NULL);
    SetupTextControl(fIPTextControl);

    BLayoutItem* layoutItem = fIPTextControl->CreateTextViewLayoutItem();
    layoutItem->SetExplicitMinSize(BSize(
                                       fIPTextControl->StringWidth("XXX.XXX.XXX.XXX") + inset,
                                       B_SIZE_UNSET));

    layout->AddItem(fIPTextControl->CreateLabelLayoutItem(), 0, 3);
    layout->AddItem(layoutItem, 1, 3);

    fNetMaskTextControl = new BTextControl(B_TRANSLATE("Netmask:"), "", NULL);
    SetupTextControl(fNetMaskTextControl);
    layout->AddItem(fNetMaskTextControl->CreateLabelLayoutItem(), 0, 4);
    layout->AddItem(fNetMaskTextControl->CreateTextViewLayoutItem(), 1, 4);

    fGatewayTextControl = new BTextControl(B_TRANSLATE("Gateway:"), "", NULL);
    SetupTextControl(fGatewayTextControl);
    layout->AddItem(fGatewayTextControl->CreateLabelLayoutItem(), 0, 5);
    layout->AddItem(fGatewayTextControl->CreateTextViewLayoutItem(), 1, 5);

    // TODO: Replace the DNS text controls by a BListView with add/remove
    // functionality and so on...
    fPrimaryDNSTextControl = new BTextControl(B_TRANSLATE("DNS #1:"), "",
            NULL);
    SetupTextControl(fPrimaryDNSTextControl);
    layout->AddItem(fPrimaryDNSTextControl->CreateLabelLayoutItem(), 0, 6);
    layout->AddItem(fPrimaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6);

    fSecondaryDNSTextControl = new BTextControl(B_TRANSLATE("DNS #2:"), "",
            NULL);
    SetupTextControl(fSecondaryDNSTextControl);
    layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 7);
    layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 7);

    fDomainTextControl = new BTextControl(B_TRANSLATE("Domain:"), "", NULL);
    SetupTextControl(fDomainTextControl);
    layout->AddItem(fDomainTextControl->CreateLabelLayoutItem(), 0, 8);
    layout->AddItem(fDomainTextControl->CreateTextViewLayoutItem(), 1, 8);

    fErrorMessage = new BStringView("error", "");
    fErrorMessage->SetAlignment(B_ALIGN_LEFT);
    fErrorMessage->SetFont(be_bold_font);
    fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

    layout->AddView(fErrorMessage, 1, 9);

    // button group (TODO: move to window, but take care of
    // enabling/disabling)
    BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL);

    fRevertButton = new BButton(B_TRANSLATE("Revert"),
                                new BMessage(kMsgRevert));
    fRevertButton->SetEnabled(false);
    buttonGroup->GroupLayout()->AddView(fRevertButton);

    buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

    fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(kMsgApply));
    fApplyButton->SetEnabled(false);
    buttonGroup->GroupLayout()->AddView(fApplyButton);

    rootLayout->AddView(controlsGroup);
    rootLayout->AddView(buttonGroup);
}
Exemple #25
0
void
TouchpadPrefView::SetupView()
{
	SetLayout(new BGroupLayout(B_VERTICAL));
	BBox* scrollBox = new BBox("Touchpad");
	scrollBox->SetLabel(B_TRANSLATE("Scrolling"));

	fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120));
	fTouchpadView->SetExplicitMaxSize(BSize(130, 120));

	// Create the "Mouse Speed" slider...
	fScrollAccelSlider = new BSlider("scroll_accel",
		B_TRANSLATE("Scroll acceleration"),
		new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
	fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fScrollAccelSlider->SetHashMarkCount(7);
	fScrollAccelSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	fScrollStepXSlider = new BSlider("scroll_stepX",
		B_TRANSLATE("Horizontal scroll speed"),
		new BMessage(SCROLL_CONTROL_CHANGED),
		0, 20, B_HORIZONTAL);
	fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fScrollStepXSlider->SetHashMarkCount(7);
	fScrollStepXSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	fScrollStepYSlider = new BSlider("scroll_stepY",
		B_TRANSLATE("Vertical scroll speed"),
		new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
	fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fScrollStepYSlider->SetHashMarkCount(7);
	fScrollStepYSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"),
		new BMessage(SCROLL_CONTROL_CHANGED));
	fTwoFingerHorizontalBox = new BCheckBox(
		B_TRANSLATE("Horizontal scrolling"),
		new BMessage(SCROLL_CONTROL_CHANGED));

	BGroupView* scrollPrefLeftLayout = new BGroupView(B_VERTICAL);
	BLayoutBuilder::Group<>(scrollPrefLeftLayout)
		.Add(fTouchpadView)
		.Add(fTwoFingerBox)
		.AddGroup(B_HORIZONTAL)
			.AddStrut(20)
			.Add(fTwoFingerHorizontalBox);

	BGroupView* scrollPrefRightLayout = new BGroupView(B_VERTICAL);
	scrollPrefRightLayout->AddChild(fScrollAccelSlider);
	scrollPrefRightLayout->AddChild(fScrollStepXSlider);
	scrollPrefRightLayout->AddChild(fScrollStepYSlider);

	BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL);
	scrollPrefLayout->SetSpacing(10);
	scrollPrefLayout->SetInsets(10, scrollBox->TopBorderOffset() * 2 + 10, 10,
		10);
	scrollBox->SetLayout(scrollPrefLayout);

	scrollPrefLayout->AddView(scrollPrefLeftLayout);
	scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(15));
	scrollPrefLayout->AddView(scrollPrefRightLayout);

	BBox* tapBox = new BBox("tapbox");
	tapBox->SetLabel(B_TRANSLATE("Tap gesture"));

	BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL);
	tapPrefLayout->SetInsets(10, tapBox->TopBorderOffset() * 2 + 10, 10, 10);
	tapBox->SetLayout(tapPrefLayout);

	fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Tap click sensitivity"),
		new BMessage(TAP_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
	fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fTapSlider->SetHashMarkCount(7);
	fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High"));

	tapPrefLayout->AddView(fTapSlider);

	BGroupView* buttonView = new BGroupView(B_HORIZONTAL);
	fDefaultButton = new BButton(B_TRANSLATE("Defaults"),
		new BMessage(DEFAULT_SETTINGS));

	buttonView->AddChild(fDefaultButton);
	buttonView->GetLayout()->AddItem(
		BSpaceLayoutItem::CreateHorizontalStrut(7));
	fRevertButton = new BButton(B_TRANSLATE("Revert"),
		new BMessage(REVERT_SETTINGS));
	fRevertButton->SetEnabled(false);
	buttonView->AddChild(fRevertButton);
	buttonView->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	layout->SetInsets(10, 10, 10, 10);
	layout->SetSpacing(10);
	BView* rootView = new BView("root view", 0, layout);
	AddChild(rootView);
	rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	layout->AddView(scrollBox);
	layout->AddView(tapBox);
	layout->AddView(buttonView);

}
Exemple #26
0
	KeyRequestView()
		:
		BView("KeyRequestView", B_WILL_DRAW),
		fPassword(NULL)
	{
		SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

		BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL);
		if (rootLayout == NULL)
			return;

		SetLayout(rootLayout);

		BGridView* controls = new(std::nothrow) BGridView();
		if (controls == NULL)
			return;

		BGridLayout* layout = controls->GridLayout();

		float inset = ceilf(be_plain_font->Size() * 0.7);
		rootLayout->SetInsets(inset, inset, inset, inset);
		rootLayout->SetSpacing(inset);
		layout->SetSpacing(inset, inset);

		BStringView* label = new(std::nothrow) BStringView("keyringLabel",
			B_TRANSLATE("Keyring:"));
		if (label == NULL)
			return;

		int32 row = 0;
		layout->AddView(label, 0, row);

		fKeyringName = new(std::nothrow) BStringView("keyringName", "");
		if (fKeyringName == NULL)
			return;

		layout->AddView(fKeyringName, 1, row++);

		fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"******"", NULL);
		if (fPassword == NULL)
			return;

		BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem();
		layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth(
				"0123456789012345678901234567890123456789") + inset,
			B_SIZE_UNSET));

		layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row);
		layout->AddItem(layoutItem, 1, row++);

		BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL);
		if (buttons == NULL)
			return;

		fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"),
			new BMessage(kMessageCancel));
		buttons->GroupLayout()->AddView(fCancelButton);

		buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());

		fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"),
			new BMessage(kMessageUnlock));
		buttons->GroupLayout()->AddView(fUnlockButton);

		BTextView* message = new(std::nothrow) BTextView("message");
		message->SetText(B_TRANSLATE("An application wants to access the "
			"keyring below, but it is locked with a passphrase. Please enter "
			"the passphrase to unlock the keyring.\n"
			"If you unlock the keyring, it stays unlocked until the system is "
			"shut down or the keyring is manually locked again.\n"
			"If you cancel this dialog the keyring will remain locked."));
		message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
		rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
		message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
		message->MakeEditable(false);
		message->MakeSelectable(false);
		message->SetWordWrap(true);

		rootLayout->AddView(message);
		rootLayout->AddView(controls);
		rootLayout->AddView(buttons);
	}
Exemple #27
0
FindWindow::FindWindow(BString workingDir)
	:	DWindow(BRect(100,100,600,500), B_TRANSLATE("Find in project"), B_TITLED_WINDOW,
				B_CLOSE_ON_ESCAPE),
		fIsRegEx(false),
		fIgnoreCase(true),
		fMatchWord(false),
		fThreadID(-1),
		fThreadMode(0),
		fThreadQuitFlag(0),
		fFileList(20, true),
		fWorkingDir(""),
		fProject(NULL)
{
	SetSizeLimits(650, 30000, 400, 30000);
	
	MakeCenteredOnShow(true);
	fMenuBar = new BMenuBar("menubar");
	
	fFindButton = new BButton("findbutton", B_TRANSLATE("Replace all"),
								new BMessage(M_FIND));
	fFindButton->SetLabel(B_TRANSLATE("Find"));
	fFindButton->SetEnabled(false);
	
	fFindBox = new DTextView("findbox");
	fFindBox->SetFlags(fFindBox->Flags() | B_NAVIGABLE_JUMP);
	
	BScrollView *findBoxScroll = fFindBox->MakeScrollView("findscroll", true, true);
	
	fReplaceBox = new DTextView("replacebox");
	fReplaceBox->SetFlags(fFindBox->Flags() | B_NAVIGABLE_JUMP);	
	BScrollView *replaceBoxScroll = fReplaceBox->MakeScrollView("replacescroll", true, true);
	
	BGroupLayout* hGroup = new BGroupLayout(B_HORIZONTAL,0);
	BView* hView = new BView("hview",0,hGroup);
	
	fReplaceButton = new BButton("replacebutton", B_TRANSLATE("Replace"),
								new BMessage(M_REPLACE));
	fReplaceButton->SetEnabled(false);
	//hGroup->AddView(fReplaceButton);
	// hidden until we decide we need an individual replace in a multi
	//   file dialog box (doubtful - could click on file and do it from
	//   within pe)
	
	fReplaceAllButton = new BButton("replaceallbutton", B_TRANSLATE("Replace all"),
								new BMessage(M_REPLACE_ALL));
	fReplaceAllButton->SetEnabled(false);
	hGroup->AddView(fReplaceAllButton);
	
	BStringView *resultLabel = new BStringView("resultlabel", B_TRANSLATE("Results:"));
	
	fResultList = new DListView("resultlist", B_MULTIPLE_SELECTION_LIST);
	BScrollView* resultsScroll = fResultList->MakeScrollView("resultscroll", true, true);
	resultsScroll->SetExplicitMinSize(BSize(650,150));
	fResultList->SetInvocationMessage(new BMessage(M_SHOW_RESULT));
	
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(fMenuBar)
		.Add(findBoxScroll)
		.Add(fFindButton)
		.Add(replaceBoxScroll)
		.Add(hView)
		.Add(resultLabel)
		.Add(resultsScroll)
	.End();
	
	BMenu *menu = new BMenu(B_TRANSLATE("Search"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Find"), new BMessage(M_FIND), 'F', B_COMMAND_KEY));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Replace"), new BMessage(M_REPLACE), 'R', B_COMMAND_KEY));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Replace all"), new BMessage(M_REPLACE_ALL), 'R',
								B_COMMAND_KEY | B_SHIFT_KEY));
	fMenuBar->AddItem(menu);
	
	menu = new BMenu(B_TRANSLATE("Options"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Regular expression"), new BMessage(M_TOGGLE_REGEX)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Ignore case"), new BMessage(M_TOGGLE_CASE_INSENSITIVE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Match whole word"), new BMessage(M_TOGGLE_MATCH_WORD)));
	fMenuBar->AddItem(menu);
	
	BMenuItem *item = fMenuBar->FindItem(B_TRANSLATE("Ignore case"));
	if (fIgnoreCase)
		item->SetMarked(true);
	
	menu = new BMenu(B_TRANSLATE("Project"));
	menu->SetRadioMode(true);
	gProjectList->Lock();
	for (int32 i = 0; i < gProjectList->CountItems(); i++)
	{
		Project *proj = gProjectList->ItemAt(i);
		BMessage *msg = new BMessage(M_SET_PROJECT);
		msg->AddPointer("project", proj);
		BMenuItem *projItem = new BMenuItem(proj->GetName(), msg);
		menu->AddItem(projItem);
		if (gCurrentProject == proj)
		{
			projItem->SetMarked(true);
			fProject = proj;
		}
	}
	gProjectList->Unlock();
	fMenuBar->AddItem(menu);
	
	SetProject(fProject);
	
	EnableReplace(false);
	
	SetWorkingDirectory(workingDir);
	
	// The search terms box will tell us whenever it has been changed at every keypress
	fFindBox->SetMessage(new BMessage(M_FIND_CHANGED));
	fFindBox->SetTarget(this);
	fFindBox->SetChangeNotifications(true);
	fFindBox->MakeFocus(true);
	
	fReplaceBox->SetMessage(new BMessage(M_REPLACE_CHANGED));
	fReplaceBox->SetTarget(this);
	fReplaceBox->SetChangeNotifications(true);
}
Exemple #28
0
CronoView::CronoView()
	:
	BView("CronoView", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
	fAccentsList(false)
{
    fReplicated = false;

	// Core
	fCore = new Core();

	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	rgb_color barColor = { 0, 200, 0 };
	rgb_color fillColor = { 240, 240, 240 };


	_BuildMenu();

	// Volume slider
	BBox* volBox = new BBox("volbox");
	volBox->SetLabel("Volume");

	BGroupLayout* volLayout = new BGroupLayout(B_VERTICAL);
	volLayout->SetInsets(10, volBox->TopBorderOffset() * 2 + 10, 10, 10);
	volBox->SetLayout(volLayout);
	
	fVolumeSlider = new VolumeSlider("",
		0, 1000, DEFAULT_VOLUME, new BMessage(MSG_VOLUME));

	fVolumeSlider->SetLimitLabels("Min", "Max");
	fVolumeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fVolumeSlider->SetHashMarkCount(20);
	fVolumeSlider->SetValue((int32)fCore->Volume()*10);
	fVolumeSlider->UseFillColor(true, &fillColor);
	fVolumeSlider->SetPosition(gCronoSettings.CronoVolume);
	fVolumeSlider->SetLabel(BString() << gCronoSettings.CronoVolume);
	volLayout->AddView(fVolumeSlider);

	// Speed Slider & TextControl
	BBox* speedBox = new BBox("speedbox");
	speedBox->SetLabel("BPM");
	BGroupLayout* speedLayout = new BGroupLayout(B_HORIZONTAL);
	speedLayout->SetInsets(10, speedBox->TopBorderOffset() * 2 + 10, 10, 10);
	speedBox->SetLayout(speedLayout);

	fSpeedSlider = new VolumeSlider("",
		MIN_SPEED, MAX_SPEED, DEFAULT_SPEED, new BMessage(MSG_SPEED_SLIDER));

	fSpeedSlider->SetLimitLabels(BString() << MIN_SPEED,
		BString() << MAX_SPEED);

	fSpeedSlider->SetKeyIncrementValue(5);
	fSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fSpeedSlider->SetHashMarkCount(15);
	fSpeedSlider->SetValue(fCore->Speed());
	fSpeedSlider->UseFillColor(true, &fillColor);
	_UpdateTempoName(gCronoSettings.Speed);

	fSpeedEntry = new BTextControl("", "", BString() << gCronoSettings.Speed,
		new BMessage(MSG_SPEED_ENTRY), B_WILL_DRAW);

	fSpeedEntry->SetDivider(70);
	fSpeedEntry->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT);
	fSpeedEntry->SetExplicitSize(BSize(35, 20));

	speedLayout->AddView(fSpeedSlider);
	speedLayout->AddView(fSpeedEntry);

	// Meter buttons
	BBox* tempoBox = new BBox("tempoBox");
	tempoBox->SetLabel("Tempo");

	for(int i = 0; i < 5; i++)
		fTempoRadios[i] = new BRadioButton("", "",
			new BMessage(MSG_METER_RADIO));

	fTempoRadios[0]->SetLabel("1/4");
	fTempoRadios[1]->SetLabel("2/4");
	fTempoRadios[2]->SetLabel("3/4");
	fTempoRadios[3]->SetLabel("4/4");
	fTempoRadios[4]->SetLabel("Other");

	fTempoRadios[fCore->Meter()]->SetValue(1);

	fTempoEntry = new BTextControl("", "", "4",
		new BMessage(MSG_METER_ENTRY), B_WILL_DRAW);

	fTempoEntry->SetDivider(70);

	if (fTempoRadios[4]->Value() == 1)
		fTempoEntry->SetEnabled(true);
	else
		fTempoEntry->SetEnabled(false);		

	fAccentsView = new BGroupView(B_HORIZONTAL, 0);

	BLayoutBuilder::Group<>(tempoBox, B_VERTICAL, 0)
		.SetInsets(10, tempoBox->TopBorderOffset() * 2 + 10, 10, 10)
		.AddGroup(B_HORIZONTAL, 0)
			.Add(fTempoRadios[0])
			.Add(fTempoRadios[1])
			.Add(fTempoRadios[2])
			.Add(fTempoRadios[3])
			.Add(fTempoRadios[4])
			.Add(fTempoEntry)
			.AddGlue()
		.End()
		.Add(fAccentsView)
		.AddGlue()
	.End();

	if (gCronoSettings.AccentTable == true)
		_ShowTable(true);

	fStartButton = new BButton("Start", new BMessage(MSG_START));						
	fStartButton->MakeDefault(true);	
	fStopButton = new BButton("Stop", new BMessage(MSG_STOP));							

#ifdef CRONO_REPLICANT_ACTIVE
	// Dragger
	BRect frame(Bounds());
	frame.left = frame.right - 7;
	frame.top = frame.bottom - 7;
	BDragger *dragger = new BDragger(frame, this,
		B_FOLLOW_RIGHT | B_FOLLOW_TOP); 
#endif

	// Create view
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.Add(fMenuBar)
		.Add(volBox)
		.Add(speedBox)
		.Add(tempoBox)
		.AddGroup(B_HORIZONTAL)
			.Add(fStartButton)
			.Add(fStopButton)
		.End()
#ifdef CRONO_REPLICANT_ACTIVE
		.Add(dragger)
#endif
		.End();
}
Exemple #29
0
void
TouchpadPrefView::SetupView()
{
	SetLayout(new BGroupLayout(B_VERTICAL));
	BBox* scrollBox = new BBox("Touchpad");
	scrollBox->SetLabel(B_TRANSLATE("Scrolling"));

	fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120));
	fTouchpadView->SetExplicitMaxSize(BSize(130, 120));

	// Create the "Mouse Speed" slider...
	fScrollAccelSlider = new BSlider("scroll_accel",
		B_TRANSLATE("Acceleration"),
		new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
	fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fScrollAccelSlider->SetHashMarkCount(7);
	fScrollAccelSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));
	fScrollAccelSlider->SetExplicitMinSize(BSize(150, B_SIZE_UNSET));

	fScrollStepXSlider = new BSlider("scroll_stepX",
		B_TRANSLATE("Horizontal"),
		new BMessage(SCROLL_CONTROL_CHANGED),
		0, 20, B_HORIZONTAL);
	fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fScrollStepXSlider->SetHashMarkCount(7);
	fScrollStepXSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	fScrollStepYSlider = new BSlider("scroll_stepY",
		B_TRANSLATE("Vertical"),
		new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
	fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fScrollStepYSlider->SetHashMarkCount(7);
	fScrollStepYSlider->SetLimitLabels(B_TRANSLATE("Slow"),
		B_TRANSLATE("Fast"));

	fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"),
		new BMessage(SCROLL_CONTROL_CHANGED));
	fTwoFingerHorizontalBox = new BCheckBox(
		B_TRANSLATE("Horizontal scrolling"),
		new BMessage(SCROLL_CONTROL_CHANGED));

	float spacing = be_control_look->DefaultItemSpacing();

	BView* scrollPrefLeftLayout
		= BLayoutBuilder::Group<>(B_VERTICAL, 0)
		.Add(fTouchpadView)
		.AddStrut(spacing)
		.Add(fTwoFingerBox)
		.AddGroup(B_HORIZONTAL, 0)
			.AddStrut(spacing * 2)
			.Add(fTwoFingerHorizontalBox)
			.End()
		.AddGlue()
		.View();

	BGroupView* scrollPrefRightLayout = new BGroupView(B_VERTICAL);
	scrollPrefRightLayout->AddChild(fScrollAccelSlider);
	scrollPrefRightLayout->AddChild(fScrollStepXSlider);
	scrollPrefRightLayout->AddChild(fScrollStepYSlider);

	BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL);
	scrollPrefLayout->SetSpacing(spacing);
	scrollPrefLayout->SetInsets(spacing,
		scrollBox->TopBorderOffset() * 2 + spacing, spacing, spacing);
	scrollBox->SetLayout(scrollPrefLayout);

	scrollPrefLayout->AddView(scrollPrefLeftLayout);
	scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(spacing
		* 1.5));
	scrollPrefLayout->AddView(scrollPrefRightLayout);

	BBox* tapBox = new BBox("tapbox");
	tapBox->SetLabel(B_TRANSLATE("Tapping"));

	BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL);
	tapPrefLayout->SetInsets(spacing, tapBox->TopBorderOffset() * 2 + spacing,
		spacing, spacing);
	tapBox->SetLayout(tapPrefLayout);

	fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Sensitivity"),
		new BMessage(TAP_CONTROL_CHANGED), 0, spacing * 2, B_HORIZONTAL);
	fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fTapSlider->SetHashMarkCount(7);
	fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High"));

	tapPrefLayout->AddView(fTapSlider);

	fDefaultButton = new BButton(B_TRANSLATE("Defaults"),
		new BMessage(DEFAULT_SETTINGS));

	fRevertButton = new BButton(B_TRANSLATE("Revert"),
		new BMessage(REVERT_SETTINGS));
	fRevertButton->SetEnabled(false);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_SPACING)
		.Add(scrollBox)
		.Add(tapBox)
		.AddGroup(B_HORIZONTAL)
			.Add(fDefaultButton)
			.Add(fRevertButton)
			.AddGlue()
			.End()
		.End();
}