Example #1
0
void
FileTypesWindow::_ShowSnifferRule(bool show)
{
	if (fRuleControl->IsHidden() == !show)
		return;

	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);

	float diff = fRuleControl->Bounds().Height() + 8.0f;

	if (!show) {
		fRuleControl->Hide();
		diff = -diff;
	}

	// adjust other controls to make space or take it again

	fIconBox->ResizeBy(0.0f, diff);
	fRecognitionBox->ResizeBy(0.0f, diff);
	fDescriptionBox->MoveBy(0.0f, diff);
	fPreferredBox->MoveBy(0.0f, diff);
	fAttributeBox->MoveBy(0.0f, diff);
	fAttributeBox->ResizeBy(0.0f, -diff);

	if (show)
		fRuleControl->Show();

	SetSizeLimits(minWidth, maxWidth, minHeight + diff, maxHeight);
}
void
ExpanderWindow::_UpdateWindowSize(bool showContents)
{
	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);

	float bottom = fSizeLimit;

	if (showContents) {
		if (fPreviousHeight < 0.0) {
			BFont font;
			font_height fontHeight;
			fListingText->GetFont(&font);
			font.GetHeight(&fontHeight);
			fLineHeight = ceilf(fontHeight.ascent + fontHeight.descent
				+ fontHeight.leading);
			fPreviousHeight = bottom + 10.0 * fLineHeight;
		}
		minHeight = bottom + 5.0 * fLineHeight;
		maxHeight = 32767.0;

		bottom = max_c(fPreviousHeight, minHeight);
	} else {
		minHeight = fSizeLimit;
		maxHeight = fSizeLimit;
		fPreviousHeight = Frame().Height();
	}

	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
	ResizeTo(Frame().Width(), bottom);
}
Example #3
0
void
ScreenshotWindow::_ResizeToFitAndCenter()
{
	// Find out dimensions of the largest screenshot of this package
	ScreenshotInfoList screenshotInfos;
	if (fPackage.Get() != NULL)
		screenshotInfos = fPackage->ScreenshotInfos();

	int32 largestScreenshotWidth = 0;
	int32 largestScreenshotHeight = 0;

	const uint32 numScreenshots = fPackage->ScreenshotInfos().CountItems();
	for (uint32 i = 0; i < numScreenshots; i++) {
		const ScreenshotInfo& info = screenshotInfos.ItemAtFast(i);
		if (info.Width() > largestScreenshotWidth)
			largestScreenshotWidth = info.Width();
		if (info.Height() > largestScreenshotHeight)
			largestScreenshotHeight = info.Height();
	}

	fScreenshotView->SetExplicitMinSize(
		BSize(largestScreenshotWidth, largestScreenshotHeight));
	Layout(false);

	// TODO: Limit window size to screen size (with a little margin),
	//       the image should then become scrollable.

	float minWidth;
	float minHeight;
	GetSizeLimits(&minWidth, NULL, &minHeight, NULL);
	ResizeTo(minWidth, minHeight);
	CenterOnScreen();
}
void
ExpanderWindow::_ExpandListingText()
{
	float delta = fLongestLine - fListingText->Frame().Width();

	if (delta > 0) {
		BScreen screen;
		BRect screenFrame = screen.Frame();

		if (Frame().right + delta > screenFrame.right)
			delta = screenFrame.right - Frame().right - 4.0f;

		ResizeBy(delta, 0.0f);
	}

	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);

	if (minWidth < Frame().Width() + delta) {
		// set the Zoom limit as the minimal required size
		SetZoomLimits(Frame().Width() + delta,
			min_c(fSizeLimit + fListingText->TextRect().Height()
				+ fLineHeight + B_H_SCROLL_BAR_HEIGHT + 1.0f,
				maxHeight));
	} else {
		// set the zoom limit based on minimal window size allowed
		SetZoomLimits(minWidth,
			min_c(fSizeLimit + fListingText->TextRect().Height()
				+ fLineHeight + B_H_SCROLL_BAR_HEIGHT + 1.0f,
				maxHeight));
	}
}
Example #5
0
void
ScreenshotWindow::_ResizeToFitAndCenter()
{
	float minWidth;
	float minHeight;
	GetSizeLimits(&minWidth, NULL, &minHeight, NULL);
	ResizeTo(minWidth, minHeight);
	CenterOnScreen();
}
Example #6
0
DevicesWindow::DevicesWindow()
	:
	BWindow(BRect(50, 50, 750, 550), "Devices", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
			| B_QUIT_ON_WINDOW_CLOSE)
{
	float minWidth;
	float maxWidth;
	float minHeight;
	float maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	minWidth = 600;
	minHeight = 300;
	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
	fDevicesView = new DevicesView(Bounds());
	AddChild(fDevicesView);
}
Example #7
0
BootManagerWindow::BootManagerWindow()
	: BWindow(BRect(100, 100, 500, 400), "Boot Manager", B_TITLED_WINDOW, 
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{
	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	SetSizeLimits(250, maxWidth, 250, maxHeight);
	
	fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL);
	AddChild(fWizardView);
	
	fController.Initialize(fWizardView);
	
	AddShortcut('A', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));

	CenterOnScreen();
}
Example #8
0
void
ShowImageWindow::_ResizeWindowToImage()
{
	BBitmap* bitmap = fImageView->Bitmap();
	BScreen screen;
	if (bitmap == NULL || !screen.IsValid())
		return;

	// TODO: use View::GetPreferredSize() instead?
	BRect r(bitmap->Bounds());
	float width = r.Width() + B_V_SCROLL_BAR_WIDTH;
	float height = r.Height() + 1 + fBar->Frame().Height()
		+ B_H_SCROLL_BAR_HEIGHT;

	BRect frame = screen.Frame();
	const float windowBorder = 5;
	// dimensions so that window does not reach outside of screen
	float maxWidth = frame.Width() + 1 - windowBorder - Frame().left;
	float maxHeight = frame.Height() + 1 - windowBorder - Frame().top;

	// We have to check size limits manually, otherwise
	// menu bar will be too short for small images.

	float minW, maxW, minH, maxH;
	GetSizeLimits(&minW, &maxW, &minH, &maxH);
	if (maxWidth > maxW)
		maxWidth = maxW;
	if (maxHeight > maxH)
		maxHeight = maxH;
	if (width < minW)
		width = minW;
	if (height < minH)
		height = minH;

	if (width > maxWidth)
		width = maxWidth;
	if (height > maxHeight)
		height = maxHeight;

	ResizeTo(width, height);
}
Example #9
0
void
ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
{
	BScreen screen;
	if (!screen.IsValid())
		return;

	BRect r(pbitmap->Bounds());
	float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
	float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
		B_H_SCROLL_BAR_HEIGHT;

	BRect frame = screen.Frame();
	const float windowBorder = 5;
	// dimensions so that window does not reach outside of screen
	float maxWidth = frame.Width() + 1 - windowBorder - Frame().left;
	float maxHeight = frame.Height() + 1 - windowBorder - Frame().top;

	// We have to check size limits manually, otherwise
	// menu bar will be too short for small images.

	float minW, maxW, minH, maxH;
	GetSizeLimits(&minW, &maxW, &minH, &maxH);
	if (maxWidth > maxW)
		maxWidth = maxW;
	if (maxHeight > maxH)
		maxHeight = maxH;
	if (width < minW)
		width = minW;
	if (height < minH)
		height = minH;

	if (width > maxWidth)
		width = maxWidth;
	if (height > maxHeight)
		height = maxHeight;

	ResizeTo(width, height);
}
BootManagerWindow::BootManagerWindow()
	:
	BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_SYSTEM_NAME("BootManager"),
		B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE
		| B_AUTO_UPDATE_SIZE_LIMITS)
{
	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	SetSizeLimits(250, maxWidth, 250, maxHeight);

	fWizardView = new WizardView("wizard");
	BLayoutBuilder::Group<>(this)
		.Add(fWizardView);

	fController.Initialize(fWizardView);

	CenterOnScreen();

	// Prevent minimizing this window if the user would have no way to
	// get back to it. (For example when only the Installer runs.)
	if (!be_roster->IsRunning(kDeskbarSignature))
		SetFlags(Flags() | B_NOT_MINIMIZABLE);
}
Example #11
0
SampleGLWindow::SampleGLWindow(BRect frame, uint32 type)
    : BDirectWindow(frame, "GLDirectMode", B_TITLED_WINDOW, 0)
{
    float minWidth = 0.0f;
    float maxWidth = 0.0f;
    float minHeight = 0.0f;
    float maxHeight = 0.0f;

    GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
    SetSizeLimits(50.0f, maxWidth, 50.0f, maxHeight);

    BRect r = Bounds();

    r.InsetBy(10, 10);
    theView = new SampleGLView(r, type);
    AddChild(theView);
    Show();

    updateRunner = new BMessageRunner(BMessenger(theView),
                                      new BMessage(REDRAW_MSG), 1000000/60 /* 60 fps */);

    theView->Render();
}
void
EBePrivateWin::DispatchMessage(BMessage *bMsg, BHandler *handler)
{
	bool handled = true;

	if(bMsg->what == 'etk_')
	{
		int32 what = 0;
		bMsg->FindInt32("etk:what", &what);

		switch(what)
		{
			case ETK_BEOS_QUIT:
				doQuit = true;
				PostMessage(B_QUIT_REQUESTED);
				break;

			case ETK_BEOS_CONTACT_TO:
				{
					fContactor = EMessenger();
					const char *buffer = NULL;
					ssize_t size = -1;
					if(bMsg->FindData("etk:messenger", B_ANY_TYPE, (const void**)&buffer, &size) != B_OK) break;
					if(buffer == NULL || size <= 0) break;
					fContactor.Unflatten(buffer, (size_t)size);
				}
				break;

			case ETK_BEOS_SET_BACKGROUND:
				{
					rgb_color bkColor;
					if(bMsg->FindInt32("background", (int32*)&bkColor) != B_OK) break;
					fTopView->SetViewColor(bkColor);
					fTopView->Invalidate();
				}
				break;

			case ETK_BEOS_SET_LOOK:
				{
					int8 look;
					if(bMsg->FindInt8("look", &look) != B_OK) break;
					switch((e_window_look)look)
					{
						case E_BORDERED_WINDOW_LOOK:
							SetLook(B_BORDERED_WINDOW_LOOK);
							break;

						case E_NO_BORDER_WINDOW_LOOK:
							SetLook(B_NO_BORDER_WINDOW_LOOK);
							break;

						case E_TITLED_WINDOW_LOOK:
							SetLook(B_TITLED_WINDOW_LOOK);
							break;

						case E_DOCUMENT_WINDOW_LOOK:
							SetLook(B_DOCUMENT_WINDOW_LOOK);
							break;

						case E_MODAL_WINDOW_LOOK:
							SetLook(B_MODAL_WINDOW_LOOK);
							break;

						case E_FLOATING_WINDOW_LOOK:
							SetLook(B_FLOATING_WINDOW_LOOK);
							break;

						default:
							break;
					}
				}
				break;

			case ETK_BEOS_SET_TITLE:
				{
					const char *title = NULL;
					if(bMsg->FindString("title", &title) != B_OK) break;
					SetTitle(title);
				}
				break;

			case ETK_BEOS_SET_WORKSPACES:
				{
					uint32 workspaces = 0;
					if(bMsg->FindInt32("workspaces", (int32*)&workspaces) != B_OK) break;
					if(workspaces == 0) workspaces = current_workspace() + 1;
					SetWorkspaces(workspaces);
				}
				break;

			case ETK_BEOS_GET_WORKSPACES:
				{
					uint32 workspaces = Workspaces();
					bMsg->AddInt32("workspaces", *((int32*)&workspaces));
				}
				break;

			case ETK_BEOS_ICONIFY:
				if(!IsMinimized()) Minimize(true);
				break;

			case ETK_BEOS_SHOW:
				if(IsHidden())
				{
					uint32 oldFlags = Flags();
					SetFlags(oldFlags | B_AVOID_FOCUS);
					Show();
					if(Look() != B_NO_BORDER_WINDOW_LOOK) SetFlags(oldFlags);
				}
				break;

			case ETK_BEOS_HIDE:
				if(!IsHidden()) Hide();
				break;

			case ETK_BEOS_RAISE:
				if(!IsFront())
				{
					uint32 oldFlags = Flags();
					SetFlags(oldFlags | B_AVOID_FOCUS);
					Activate(true);
					if(Look() != B_NO_BORDER_WINDOW_LOOK) SetFlags(oldFlags);
				}
				break;

			case ETK_BEOS_LOWER:
				{
					BHandler *_frontWin = NULL;
					if(bMsg->FindPointer("front", (void**)&_frontWin) != B_OK) break;
					BWindow *frontWin = e_cast_as(_frontWin, BWindow);
					if(frontWin == NULL) break;
					SendBehind(frontWin);
					bMsg->AddBool("done", true);
				}
				break;

			case ETK_BEOS_ACTIVATE:
				{
					bool state;
					if(bMsg->FindBool("state", &state) != B_OK || state == IsActive()) break;
					Activate(state);
				}
				break;

			case ETK_BEOS_GET_ACTIVATED_STATE:
				bMsg->AddBool("state", IsActive());
				break;

			case ETK_BEOS_MOVE_RESIZE:
				{
					if(bMsg->HasPoint("where"))
					{
						BPoint pt;
						if(bMsg->FindPoint("where", &pt) == B_OK) MoveTo(pt);
					}

					if(bMsg->HasFloat("width") && bMsg->HasFloat("height"))
					{
						float w = -1, h = -1;
						bMsg->FindFloat("width", &w);
						bMsg->FindFloat("height", &h);
						if(w < 0 || h < 0) break;
						ResizeTo(w, h);
					}
				}
				break;

			case ETK_BEOS_DRAW_BITMAP:
				{
					BBitmap *bitmap = NULL;
					BRect srcRect, destRect;
					const ERegion *clipping = NULL;

					if(bMsg->FindPointer("bitmap", (void**)&bitmap) != B_OK || bitmap == NULL) break;
					bMsg->FindRect("src", &srcRect);
					bMsg->FindRect("dest", &destRect);
					if(srcRect.IsValid() == false || destRect.IsValid() == false) break;
					bMsg->FindPointer("clipping", (void**)&clipping); 

					BRegion beRegion;
					__etk_convert_region(clipping, &beRegion, fTopView->Bounds());
					fTopView->ConstrainClippingRegion(&beRegion);
					fTopView->DrawBitmap(bitmap, srcRect, destRect);
				}
				break;

			case ETK_BEOS_GRAB_MOUSE:
			case ETK_BEOS_UNGRAB_MOUSE:
				{
					uint32 options = (what == ETK_BEOS_GRAB_MOUSE ? B_LOCK_WINDOW_FOCUS : 0);
					if(fTopView->SetEventMask(B_POINTER_EVENTS, options) != B_OK) break;
					bMsg->AddBool("state", what == ETK_BEOS_GRAB_MOUSE);
				}
				break;

			case ETK_BEOS_GRAB_KEYBOARD:
			case ETK_BEOS_UNGRAB_KEYBOARD:
				{
					uint32 options = (what == ETK_BEOS_GRAB_KEYBOARD ? B_LOCK_WINDOW_FOCUS : 0);
					if(fTopView->SetEventMask(B_KEYBOARD_EVENTS, options) != B_OK) break;
					bMsg->AddBool("state", what == ETK_BEOS_GRAB_KEYBOARD);
				}
				break;

			case ETK_BEOS_QUERY_MOUSE:
				{
					BPoint pt;
					uint32 btns = 0;
					fTopView->GetMouse(&pt, &btns, false);
					bMsg->AddInt32("x", (int32)pt.x);
					bMsg->AddInt32("y", (int32)pt.y);
					bMsg->AddInt32("buttons", (int32)btns);
				}
				break;

			case ETK_BEOS_SET_SIZE_LIMITS:
				{
					BRect r;
					if(bMsg->FindRect("limits", &r) != B_OK) break;
					SetSizeLimits(r.left, r.right, r.top, r.bottom);
					bMsg->AddBool("done", true);
				}
				break;

			case ETK_BEOS_GET_SIZE_LIMITS:
				{
					BRect r(-1, -1, -1, -1);
					GetSizeLimits(&(r.left), &(r.right), &(r.top), &(r.bottom));
					bMsg->AddRect("limits", r);
				}
				break;

			default:
				handled = false;
				break;
		}

		if(handled)
		{
			BMessage aMsg(*bMsg);
			bMsg->SendReply(&aMsg);
			return;
		}
	}

	switch(bMsg->what)
	{
		case B_WINDOW_ACTIVATED:
			{
				handled = false;

				if(fContactor.IsValid() == false) break;
				EMessage message(E_WINDOW_ACTIVATED);
				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				fContactor.SendMessage(&message);
			}
			break;

		case B_MOUSE_DOWN:
		case B_MOUSE_UP:
		case B_MOUSE_MOVED:
			{
				if(fContactor.IsValid() == false) break;

				BPoint where;
				int32 buttons = 0;

				bMsg->FindPoint("where", &where);
				if(bMsg->what != B_MOUSE_UP) bMsg->FindInt32("buttons", &buttons);

				int32 clicks = 1;
				if(bMsg->what == B_MOUSE_DOWN)
				{
#if 0
					bMsg->FindInt32("clicks", &clicks);
#else
					bigtime_t eventTime;
					if(bMsg->FindInt64("when", &eventTime) == B_OK)
					{
						if(eventTime - fPrevMouseDownTime <= CLICK_TIMEOUT)
							clicks = (fPrevMouseDownCount += 1);
						else
							clicks = fPrevMouseDownCount = 1;
						fPrevMouseDownTime = eventTime;
					}
#endif
				}

				EMessage message;
				if(bMsg->what == B_MOUSE_DOWN) message.what = E_MOUSE_DOWN;
				else if(bMsg->what == B_MOUSE_UP) message.what = E_MOUSE_UP;
				else message.what = E_MOUSE_MOVED;

				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				if(bMsg->what != B_MOUSE_UP) message.AddInt32("buttons", buttons);
				if(bMsg->what == B_MOUSE_DOWN) message.AddInt32("clicks", clicks);
				message.AddPoint("where", EPoint(where.x, where.y));
				ConvertToScreen(&where);
				message.AddPoint("screen_where", EPoint(where.x, where.y));

				// TODO: modifiers

				message.AddMessenger("etk:msg_for_target", fContactor);

				etk_app->PostMessage(&message);
			}
			break;

		case B_KEY_DOWN:
		case B_KEY_UP:
		case B_UNMAPPED_KEY_DOWN:
		case B_UNMAPPED_KEY_UP:
			{
				if(fContactor.IsValid() == false) break;

				int8 byte[4];
				const char *bytes = NULL;
				int32 numBytes = 0;
				int32 key = 0;
				int32 key_repeat = 0;
				int32 beModifiers = 0;
				eint32 modifiers = 0;

				bMsg->FindInt32("key", &key);
				bMsg->FindInt32("modifiers", &beModifiers);
				bzero(byte, sizeof(int8) * 4);

				if(bMsg->what == B_KEY_DOWN || bMsg->what == B_KEY_UP)
				{
					for(int32 i = 0; i < 3; i++) bMsg->FindInt8("byte", i, &byte[i]);
					if(bMsg->FindString("bytes", &bytes) == B_OK) numBytes = strlen(bytes);
//					if(bMsg->what == B_KEY_DOWN) bMsg->FindInt32("be:key_repeat", &key_repeat);
				}
				else
				{
					etk_beos_get_byte(beModifiers, key, (char*)byte);
				}

				if(beModifiers & B_SHIFT_KEY) modifiers |= E_SHIFT_KEY;
				if(beModifiers & B_CONTROL_KEY) modifiers |= E_CONTROL_KEY;
				if(beModifiers & B_COMMAND_KEY) modifiers |= E_COMMAND_KEY;

				EMessage message;
				if(bMsg->what == B_KEY_DOWN) message.what = E_KEY_DOWN;
				else if(bMsg->what == B_KEY_UP) message.what = E_KEY_UP;
				else if(bMsg->what == B_UNMAPPED_KEY_DOWN) message.what = E_UNMAPPED_KEY_DOWN;
				else message.what = E_UNMAPPED_KEY_UP;

				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				message.AddInt32("key", key);
				message.AddInt32("modifiers", modifiers);

				if(bMsg->what == B_KEY_DOWN || bMsg->what == B_KEY_UP)
				{
					if(bMsg->what == B_KEY_DOWN) message.AddInt32("etk:key_repeat", key_repeat);
					for(int32 i = 0; i < 3; i++) message.AddInt8("byte", byte[i]);
					if(!(numBytes != 1 || *bytes != byte[0]))
					{
						etk_beos_get_byte(beModifiers, key, (char*)byte);
						message.AddString("bytes", (char*)byte);
					}
					else if(numBytes > 0)
					{
						message.AddString("bytes", bytes);
					}
				}
				else if(byte[0] != 0)
				{
					message.AddInt8("byte", byte[0]);
					message.AddString("bytes", (char*)byte);
				}

				message.AddMessenger("etk:msg_for_target", fContactor);

				etk_app->PostMessage(&message);
			}
			break;

		case B_MODIFIERS_CHANGED:
			{
				if(fContactor.IsValid() == false) break;

				eint32 modifiers = 0;
				eint32 old_modifiers = 0;
				int32 beModifiers = 0;
				int32 old_beModifiers = 0;

				bMsg->FindInt32("modifiers", &beModifiers);
				bMsg->FindInt32("be:old_modifiers", &old_beModifiers);

				if(beModifiers & B_SHIFT_KEY) modifiers |= E_SHIFT_KEY;
				if(beModifiers & B_CONTROL_KEY) modifiers |= E_CONTROL_KEY;
				if(beModifiers & B_COMMAND_KEY) modifiers |= E_COMMAND_KEY;

				if(old_beModifiers & B_SHIFT_KEY) old_modifiers |= E_SHIFT_KEY;
				if(old_beModifiers & B_CONTROL_KEY) old_modifiers |= E_CONTROL_KEY;
				if(old_beModifiers & B_COMMAND_KEY) old_modifiers |= E_COMMAND_KEY;

				EMessage message(E_MODIFIERS_CHANGED);

				message.AddBool("etk:msg_from_gui", true);
				message.AddInt64("when", e_real_time_clock_usecs());
				message.AddInt32("modifiers", modifiers);
				message.AddInt32("etk:old_modifiers", old_modifiers);

				message.AddMessenger("etk:msg_for_target", fContactor);

				etk_app->PostMessage(&message);
			}
			break;

		default:
			handled = false;
			break;
	}

	if(!handled) BWindow::DispatchMessage(bMsg, handler);
}
Example #13
0
RouteWindow::RouteWindow(RouteAppNodeManager* manager)
	:
	BWindow(s_initFrame, s_windowName, B_DOCUMENT_WINDOW, 0),
	m_hScrollBar(0),
	m_vScrollBar(0),
	m_transportWindow(0),
	m_dormantNodeWindow(0),
	m_selectedGroupID(0),
	m_zoomed(false),
	m_zooming(false)
{
	BRect b = Bounds();

	// initialize the menu bar: add all menus that target this window
	BMenuBar* pMenuBar = new BMenuBar(b, "menuBar");
	BMenu* pFileMenu = new BMenu("File");
	BMenuItem* item = new BMenuItem("Open" B_UTF8_ELLIPSIS,
		new BMessage(RouteApp::M_SHOW_OPEN_PANEL), 'O');
	item->SetTarget(be_app);
	pFileMenu->AddItem(item);
	pFileMenu->AddItem(new BSeparatorItem());
	item = new BMenuItem("Save nodes" B_UTF8_ELLIPSIS,
		new BMessage(RouteApp::M_SHOW_SAVE_PANEL), 'S');
	item->SetTarget(be_app);
	pFileMenu->AddItem(item);
	pFileMenu->AddItem(new BSeparatorItem());
	pFileMenu->AddItem(new BMenuItem("About Cortex/Route" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));
	pFileMenu->AddItem(new BSeparatorItem());
	pFileMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
	pMenuBar->AddItem(pFileMenu);
	AddChild(pMenuBar);

	// build the routing view
	BRect rvBounds = b;
	rvBounds.top = pMenuBar->Frame().bottom+1;
	rvBounds.right -= B_V_SCROLL_BAR_WIDTH;
	rvBounds.bottom -= B_H_SCROLL_BAR_HEIGHT;
	m_routingView = new MediaRoutingView(manager, rvBounds, "routingView");

	BRect hsBounds = rvBounds;
	hsBounds.left = rvBounds.left + 199;
	hsBounds.top = hsBounds.bottom + 1;
	hsBounds.right++;
	hsBounds.bottom = b.bottom + 1;

	m_hScrollBar = new BScrollBar(hsBounds, "hScrollBar", m_routingView,
		0, 0, B_HORIZONTAL);
	AddChild(m_hScrollBar);

	BRect vsBounds = rvBounds;
	vsBounds.left = vsBounds.right + 1;
	vsBounds.top--;
	vsBounds.right = b.right + 1;
	vsBounds.bottom++;

	m_vScrollBar = new BScrollBar(vsBounds, "vScrollBar", m_routingView,
		0, 0, B_VERTICAL);
	AddChild(m_vScrollBar);

	BRect svBounds = rvBounds;
	svBounds.left -= 1;
	svBounds.right = hsBounds.left - 1;
	svBounds.top = svBounds.bottom + 1;
	svBounds.bottom = b.bottom + 1;

	m_statusView = new StatusView(svBounds, manager, m_hScrollBar);
	AddChild(m_statusView);

	AddChild(m_routingView);

	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	minWidth = m_statusView->Frame().Width() + 6 * B_V_SCROLL_BAR_WIDTH;
	minHeight = 6 * B_H_SCROLL_BAR_HEIGHT;
	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);

	// construct the Window menu
	BMenu* windowMenu = new BMenu("Window");
	m_transportWindowItem = new BMenuItem(
		"Show transport",
		new BMessage(M_TOGGLE_TRANSPORT_WINDOW));
	windowMenu->AddItem(m_transportWindowItem);

	m_dormantNodeWindowItem = new BMenuItem(
		"Show add-ons",
		new BMessage(M_TOGGLE_DORMANT_NODE_WINDOW));
	windowMenu->AddItem(m_dormantNodeWindowItem);

	windowMenu->AddItem(new BSeparatorItem());

	m_pullPalettesItem = new BMenuItem(
		"Pull palettes",
		new BMessage(M_TOGGLE_PULLING_PALETTES));
	windowMenu->AddItem(m_pullPalettesItem);

	pMenuBar->AddItem(windowMenu);

	// create the dormant-nodes palette
	_toggleDormantNodeWindow();

	// display group inspector
	_toggleTransportWindow();
}
// Vanilla constructor, just give me a size.
InexactMatchWindow::InexactMatchWindow(BMessage *message) : BWindow(message)
{
	//	Locate views
	
	BRect boundsRect = frame;
	boundsRect.OffsetTo(B_ORIGIN);
	BView *mainView = new BView(boundsRect,"mainView",B_FOLLOW_ALL,B_WILL_DRAW);
	mainView->SetViewColor(220,220,220);
	AddChild(mainView);
	const BFont *font = be_plain_font;
	const char* theString = "Please select the closest match:";
	font_height fh;
	font->GetHeight(&fh);
	float btn_height = fh.leading+20;
	float btn_width = font->StringWidth("No Match")+20;
	float text_width = font->StringWidth(theString);
	
	boundsRect = frame;
	boundsRect.OffsetTo(B_ORIGIN);
	boundsRect.top +=4;
	boundsRect.bottom =boundsRect.top+btn_height;
	boundsRect.left += 8;
	boundsRect.right = boundsRect.left + text_width;
	
	titleString = new BStringView(boundsRect,"titleString",theString,B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW);
	mainView->AddChild(titleString);
	
	boundsRect = frame;
	boundsRect.OffsetTo(B_ORIGIN);
	boundsRect.bottom -= 12;
	boundsRect.top = boundsRect.bottom-btn_height;
	boundsRect.right -= 8;
	boundsRect.left = boundsRect.right -btn_width;
	
	btnNoMatch = new BButton(boundsRect,"CancelButton","No Match",new BMessage(CANCEL_B),B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT,B_WILL_DRAW);
	mainView->AddChild(btnNoMatch);
	
	boundsRect = frame;
	boundsRect.OffsetTo(B_ORIGIN);
	boundsRect.bottom -= 12;
	boundsRect.top = boundsRect.bottom-btn_height;
	boundsRect.left += 8;
	boundsRect.right = boundsRect.left+btn_width;
	btnSave = new BButton(boundsRect,"SaveButton","Ok",new BMessage(SAVE_B),B_FOLLOW_BOTTOM|B_FOLLOW_LEFT,B_WILL_DRAW);
	mainView->AddChild(btnSave);
	SetDefaultButton(btnSave);
		
	boundsRect = frame;
	boundsRect.OffsetTo(B_ORIGIN);
	boundsRect.left += 8;
	boundsRect.top += 8+btn_height;
	boundsRect.right -= 20;
	boundsRect.bottom -= 18+btn_height;
	
	cdList = new BListView(boundsRect,"cdList",B_SINGLE_SELECTION_LIST,B_FOLLOW_ALL,B_WILL_DRAW);
	
	aView = new BScrollView("",(BView *)cdList,B_FOLLOW_ALL,B_WILL_DRAW,false,true, B_FANCY_BORDER);
	mainView->AddChild(aView);

	// Set the minimum window size
	float minWidth,maxWidth,minHeight,maxHeight;
	GetSizeLimits(&minWidth,&maxWidth,&minHeight,&maxHeight);
	minWidth = 3*btn_width;
	minHeight = 6*btn_height;
	SetSizeLimits(minWidth,maxWidth,minHeight,maxHeight);
}
Example #15
0
// constructor
NavigationInfoPanel::NavigationInfoPanel(BWindow* parent,
		const BMessage& message, const BMessenger& target)
	: BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK,
		B_FLOATING_SUBSET_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE)
	, fMessage(message)
	, fTarget(target)
{
	// create the interface and resize to fit

	BRect frame = Bounds();
	frame.InsetBy(5, 5);
	frame.bottom = frame.top + 15;

	// label string view
	fLabelView = new BStringView(frame, "label", kLabel,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fLabelView->ResizeToPreferred();
	frame = fLabelView->Frame();

	// target clip text control
	frame.OffsetBy(0, frame.Height() + 5);
	fTargetClipTC = new BTextControl(frame, "clip id",
		"Target Playlist ID", "", new BMessage(MSG_INVOKE),
		B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fTargetClipTC->ResizeToPreferred();
	frame = fTargetClipTC->Frame();

	// help string view
	frame.OffsetBy(0, frame.Height() + 5);
	BStringView* helpView = new BStringView(frame, "help",
		"Drag and drop a playlist clip here.",
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	BFont font;
	helpView->GetFont(&font);
	font.SetFace(B_ITALIC_FACE);
	font.SetSize(font.Size() * 0.9);
	helpView->SetFont(&font);
	helpView->SetAlignment(B_ALIGN_CENTER);
	helpView->ResizeToPreferred();

	// parent view
	frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame();
	frame.InsetBy(-5, -5);
	fInfoView = new InfoView(frame, this);
	fInfoView->AddChild(fLabelView);
	fInfoView->AddChild(fTargetClipTC);
	fInfoView->AddChild(helpView);

	// resize to fit and adjust size limits
	ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height());
	AddChild(fInfoView);
	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	minWidth = Frame().Width();
	minHeight = maxHeight = Frame().Height();
	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);

	// modify the high color after the help view is attached to a window
	helpView->SetHighColor(tint_color(helpView->LowColor(),
		B_DISABLED_LABEL_TINT));
	helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE);
		// help the buggy BeOS BStringView (when text alignment != left...)

	fInfoView->SetEventMask(B_POINTER_EVENTS);

	// resize controls to the same (maximum) width
	float maxControlWidth = fLabelView->Frame().Width();
	maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width());
	maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width());
	fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height());
	fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height());
	helpView->ResizeTo(maxControlWidth, helpView->Frame().Height());

	// center above parent window
	BAutolock _(parent);
	frame = Frame();
	BRect parentFrame = parent->Frame();
	MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2,
		(parentFrame.top + parentFrame.bottom - frame.Height()) / 2);

	AddToSubset(parent);
}
Example #16
0
PeepsWindow::PeepsWindow(BMessenger target)
	: BWindow(BRect(50,50,600,470), "Mr. Peeps!", B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE)
{
	float wmin,wmax,hmin,hmax;
	
	GetSizeLimits(&wmin,&wmax,&hmin,&hmax);
	wmin=500;
	hmin=400;
	
	SetSizeLimits(wmin,wmax,hmin,hmax);
		
	ReadLocaleSettings();
	if(fLocale.CountChars()>0)
	{
		locale_roster->SetLocale(fLocale.String());
		gCurrentLocale=locale_roster->GetLocale();
	}
	
	BRect r(Bounds());
	BMessage *msg;
	
	r.bottom=20;
	BMenuBar *mb=new BMenuBar(r,"menubar");
	AddChild(mb);
	
	fPeopleMenu=new BMenu(TRANSLATE("Person"));
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("New"),new BMessage(M_ADD_PERSON),'N'));
	fPeopleMenu->AddSeparatorItem();
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("Previous"),new BMessage(M_PREV_ITEM),B_UP_ARROW));
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("Next"),new BMessage(M_NEXT_ITEM),B_DOWN_ARROW));
	fPeopleMenu->AddSeparatorItem();
	
	fActionsMenu=new BMenu(TRANSLATE("Actions"));
		
	// Submenu for sending e-mail
	BMenu *emailmenu=new BMenu(TRANSLATE("Send E-Mail to"));
	
	fEmailPersonalItem=new BMenuItem(TRANSLATE("Personal Address"),new BMessage(M_SEND_PERSONAL_EMAIL));
	emailmenu->AddItem(fEmailPersonalItem);
	
	fEmailWorkItem=new BMenuItem(TRANSLATE("Work Address"),new BMessage(M_SEND_WORK_EMAIL));
	emailmenu->AddItem(fEmailWorkItem);
	
	fEmailAltItem=new BMenuItem(TRANSLATE("Alternate Address"),new BMessage(M_SEND_ALT_EMAIL));
	emailmenu->AddItem(fEmailAltItem);
	fActionsMenu->AddItem(emailmenu);
	
	// Submenu for sending e-mail
	BMenu *browsermenu=new BMenu(TRANSLATE("Go to Web Page"));
	
	fBrowseHomeItem=new BMenuItem(TRANSLATE("Personal Web Address"),new BMessage(M_BROWSE_WWW_HOME));
	browsermenu->AddItem(fBrowseHomeItem);
	
	fBrowseWorkItem=new BMenuItem(TRANSLATE("Work Web Address"),new BMessage(M_BROWSE_WWW_WORK));
	browsermenu->AddItem(fBrowseWorkItem);
	
	fBrowseAltItem=new BMenuItem(TRANSLATE("Alternate Web Address"),new BMessage(M_BROWSE_WWW_ALT));
	browsermenu->AddItem(fBrowseAltItem);
	fActionsMenu->AddItem(browsermenu);
	
	fActionsMenu->AddSeparatorItem();
	fPastePhotoItem=new BMenuItem(TRANSLATE("Paste Photo from Clipboard"),new BMessage(M_PASTE_IMAGE));
	fActionsMenu->AddItem(fPastePhotoItem);
	fRemovePhotoItem=new BMenuItem(TRANSLATE("Remove Photo"),new BMessage(M_REMOVE_IMAGE));
	fActionsMenu->AddItem(fRemovePhotoItem);
	fActionsMenu->AddSeparatorItem();
	fActionsMenu->AddItem(new BMenuItem(TRANSLATE("Move To Trash"),new BMessage(M_DELETE_PERSON),'T'));
	fPeopleMenu->AddItem(fActionsMenu);
	fActionsMenu->SetEnabled(false);
	
	
	fPeopleMenu->AddSeparatorItem();
	fPeopleMenu->AddItem(new BMenuItem(TRANSLATE("About..."),new BMessage(B_ABOUT_REQUESTED)));
	mb->AddItem(fPeopleMenu);

	fEditMenu=new BMenu(TRANSLATE("Edit"));
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Undo"),new BMessage(M_UNDO),'Z'));
	fEditMenu->AddSeparatorItem();
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Cut"),new BMessage(M_CUT),'X'));
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Copy"),new BMessage(M_COPY),'C'));
	fEditMenu->AddItem(new BMenuItem(TRANSLATE("Paste"),new BMessage(M_PASTE),'V'));
	mb->AddItem(fEditMenu);
	fEditMenu->SetEnabled(false);
	
	fTabMenu=new BMenu(TRANSLATE("Tab"));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Main"),new BMessage(M_TAB_1),'1'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Personal"),new BMessage(M_TAB_2),'2'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Work"),new BMessage(M_TAB_3),'3'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Instant Message"),new BMessage(M_TAB_4),'4'));
	fTabMenu->AddItem(new BMenuItem(TRANSLATE("Notes"),new BMessage(M_TAB_5),'5'));
	mb->AddItem(fTabMenu);
	fTabMenu->SetEnabled(false);
	
	BMessage *menumsg;
	BEntry toolentry;
	
	// Note that I don't just simply have a way to iterate over whatever's in a folder
	// because I want to control what tools are officially supported by Mr. Peeps!
	// It's not that I don't want anyone helping -- I just want quality control with
	// tool usability.
	
	fToolMenu=new BMenu(TRANSLATE("Tools"));
	
	toolentry.SetTo("/boot/home/config/settings/MrPeeps/PeopleMover");
	if(toolentry.Exists())
	{
		menumsg=new BMessage(M_RUN_TOOL);
		menumsg->AddString("signature","application/x-vnd.wgp-PeopleMover");
		fToolPeopleMover=new BMenuItem(TRANSLATE("People Mover"),menumsg);
		fToolMenu->AddItem(fToolPeopleMover);
	}
	else
		fToolPeopleMover=NULL;
	
	toolentry.SetTo("/boot/home/config/settings/MrPeeps/PersonAtAGlance");
	if(toolentry.Exists())
	{
		menumsg=new BMessage(M_RUN_TOOL);
		menumsg->AddString("signature","application/x-vnd.wgp-PersonAtAGlance");
		fToolPeopleAtAGlance=new BMenuItem(TRANSLATE("Person at a Glance"),menumsg);
		fToolPeopleAtAGlance->SetEnabled(false);
		fToolMenu->AddItem(fToolPeopleAtAGlance);
	}
	else
		fToolPeopleAtAGlance=NULL;
	
	toolentry.SetTo("/boot/home/config/settings/MrPeeps/VCardExport");
	if(toolentry.Exists())
	{
		menumsg=new BMessage(M_RUN_TOOL);
		menumsg->AddString("signature","application/x-vnd.wgp-VCardExport");
		fToolVCardExport=new BMenuItem(TRANSLATE("Export Person to VCard"),menumsg);
		fToolVCardExport->SetEnabled(false);
		fToolMenu->AddItem(fToolVCardExport);
	}
	else
		fToolVCardExport=NULL;
	
	if(fToolMenu->CountItems()>0)
	{
		// PeopleMover does not require a selection, so if it is installed, allow the
		// user to select it.
		if(!fToolPeopleMover)
			fToolMenu->SetEnabled(false);
		mb->AddItem(fToolMenu);
	}
	else
	{
		delete fToolMenu;
		fToolMenu=NULL;
	}
	
	if(locale_roster->CountLocales()>1)
	{
		fLanguageMenu=new BMenu(TRANSLATE("Language"));
		fLanguageMenu->SetRadioMode(true);
		for(int32 i=0; i<locale_roster->CountLocales(); i++)
		{
			Locale *locale=locale_roster->LocaleAt(i);
			BMessage *langmsg=new BMessage(M_SET_LANGUAGE);
			langmsg->AddInt32("index",i);
			fLanguageMenu->AddItem(new BMenuItem(locale->Name(),langmsg));
		}
		mb->AddItem(fLanguageMenu);
		
		BMenuItem *markeditem=fLanguageMenu->FindItem(fLocale.String());
		if(markeditem)
			markeditem->SetMarked(true);
	}
	else
		fLanguageMenu=NULL;
	
	// set up left frame
	r.top+=mb->Bounds().bottom+1;
	r.bottom=Bounds().bottom;
	r.right=200;
	left_view=new BView(r, "left_view", B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW);
	AddChild(left_view);
	
	// Check to see that all of the tabs will fit
	float tabwidth=left_view->StringWidth(TRANSLATE("Main"))+
		left_view->StringWidth(TRANSLATE("Personal"))+
		left_view->StringWidth(TRANSLATE("Work"))+
		left_view->StringWidth(TRANSLATE("Instant Message"))+
		left_view->StringWidth(TRANSLATE("Notes"))+120;
	
	r.left=201;

	if(tabwidth+r.left>Bounds().right)
		ResizeTo(tabwidth+r.left, Bounds().Height());
	
	r.right=Bounds().right;
	
	fIntroView=new IntroView(r);
	AddChild(fIntroView);
	
	
	dataview=new DataView(fIntroView->Bounds());
	fIntroView->AddChild(dataview);
	dataview->Hide();
	
	
	// create list for left frame
	BRect tmp_rect=left_view->Bounds();
	tmp_rect.right -= B_V_SCROLL_BAR_WIDTH;
	fPeopleList=new PeopleList(tmp_rect, "fPeopleList",dataview);
	
	// put scrolled list in left_view
	BScrollView *my_scroll=new BScrollView("scroll_people", fPeopleList,
			B_FOLLOW_TOP_BOTTOM, 0, false, true);
	left_view->AddChild(my_scroll);


	// open directory of people
	BDirectory people_dir(PEOPLE_FOLDER);
	
	msg=new BMessage(M_SET_STATUS);
	int32 refcount=people_dir.CountEntries();
	msg->AddInt32("refcount",refcount);
	target.SendMessage(msg);
	
	if(refcount==0)
		fIntroView->SetNoPeopleMsg(true);
	
	// our variables for instantiation and garbage collection later
	entry_ref tmp_ref;
	BFile tmp_file;
	BString filename;
		
	while (people_dir.GetNextRef(&tmp_ref)==B_OK)
	{
		// variables for use here
		tmp_file.SetTo(&tmp_ref, B_READ_WRITE);
		
		if(tmp_file.ReadAttrString(PERSON_NAME,&filename)==B_OK)
			AddPerson(tmp_ref, false);
		
		target.SendMessage(new BMessage(M_UPDATE_STATUS));
	}

	SortList();
	fPeopleList->MakeFocus(true);

	node_ref nref;
	people_dir.GetNodeRef(&nref);
	watch_node(&nref, B_WATCH_NAME | B_WATCH_ATTR | B_WATCH_DIRECTORY,this);
}