Beispiel #1
0
/*****************************************************************************
 * VideoWindow::_SetToSettings
 *****************************************************************************/
void
VideoWindow::_SetToSettings()
{
    // adjust dimensions
    uint32_t mode = RESIZE_100;
    switch (fSettings->VideoSize())
    {
        case VideoSettings::SIZE_50:
            mode = RESIZE_50;
            break;
        case VideoSettings::SIZE_200:
            mode = RESIZE_200;
            break;
        case VideoSettings::SIZE_100:
        case VideoSettings::SIZE_OTHER:
        default:
            break;
    }
    bool fullscreen = IsFullScreen();    // remember settings
    _SetVideoSize(mode);                // because this will reset settings
    // the fullscreen status is reflected in the settings,
    // but not yet in the windows state
    if (fullscreen)
        SetFullScreen(true);
    if (fSettings->HasFlags(VideoSettings::FLAG_ON_TOP_ALL))
        fCachedFeel = B_FLOATING_ALL_WINDOW_FEEL;
    else
        fCachedFeel = B_NORMAL_WINDOW_FEEL;
    SetFeel(fCachedFeel);
}
Beispiel #2
0
void
TimedAlert::Show()
{
	fRunner = new BMessageRunner(this, new BMessage(TIMEDALERT_UPDATE), 60000000);
	SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	BAlert::Show();
}
Beispiel #3
0
HDialog::HDialog(BRect frame, const char *name, window_type type,
	int flags, BWindow *owner, BPositionIO* data)
	: BWindow(frame, name, type, flags)
	, fOwner(owner)
	, fPlacement(H_PLACE_LAST_POS)
{
	frame.OffsetTo(0, 0);

	AddChild(fMainView = new HDlogView(frame, "main"));

	if (data)
		_BuildIt(*data);

	AddCommonFilter(new BMessageFilter(B_KEY_DOWN,KeyDownFilter));

	if (fOwner)
	{
		BMessage m(msg_AddDialog);
		m.AddPointer("dialog", this);
		fOwner->PostMessage(&m);

		// [zooey]: let dialog float above owner:
		SetFeel(B_FLOATING_SUBSET_WINDOW_FEEL);
		AddToSubset(fOwner);
	}
} /* HDialog::HDialog */
PulseWindow::PulseWindow(BRect rect)
	:
	BWindow(rect, B_TRANSLATE_SYSTEM_NAME("Pulse"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	SetPulseRate(200000);
	
	PulseApp *pulseapp = (PulseApp *)be_app;
	BRect bounds = Bounds();
	fNormalPulseView = new NormalPulseView(bounds);
	AddChild(fNormalPulseView);

	fMiniPulseView = new MiniPulseView(bounds, "MiniPulseView", 
		pulseapp->prefs);
	AddChild(fMiniPulseView);

	fMode = pulseapp->prefs->window_mode;
	if (fMode == MINI_WINDOW_MODE) {
		SetLook(B_MODAL_WINDOW_LOOK);
		SetFeel(B_NORMAL_WINDOW_FEEL);
		SetFlags(B_NOT_ZOOMABLE);
		fNormalPulseView->Hide();
		SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096);
		ResizeTo(rect.Width(), rect.Height());
	} else
		fMiniPulseView->Hide();

	fPrefsWindow = NULL;
}
void
MainWin::ToggleAlwaysOnTop()
{
	printf("ToggleAlwaysOnTop enter\n");
	fAlwaysOnTop = !fAlwaysOnTop;
	SetFeel(fAlwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
	printf("ToggleAlwaysOnTop leave\n");
}
Beispiel #6
0
// ----------------------------------------------------------------------------------- RHTML_Tag_Menu - Stop -
void RHTMLTagMenu::Stop()
{
 Lock();
 fListView->SetEventMask(B_NO_POINTER_HISTORY);
 MoveTo(-Bounds().right-5,-Bounds().bottom-5);
 SetFeel(B_FLOATING_APP_WINDOW_FEEL);
 Activate(false);
 Unlock();
}
void
PulseWindow::SetMode(int newmode)
{
	PulseApp *pulseapp = (PulseApp *)be_app;

	switch (newmode) {
		case PV_NORMAL_MODE:
			if (fMode == MINI_WINDOW_MODE) {
				pulseapp->prefs->mini_window_rect = Frame();
				pulseapp->prefs->window_mode = NORMAL_WINDOW_MODE;
				pulseapp->prefs->Save();
			}
			fMiniPulseView->Hide();
			fNormalPulseView->Show();
			fMode = NORMAL_WINDOW_MODE;
			SetType(B_TITLED_WINDOW);
			SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE);
			ResizeTo(pulseapp->prefs->normal_window_rect.IntegerWidth(),
				pulseapp->prefs->normal_window_rect.IntegerHeight());
			MoveTo(pulseapp->prefs->normal_window_rect.left,
				pulseapp->prefs->normal_window_rect.top);
			MoveOnScreen();
			break;

		case PV_MINI_MODE:
			if (fMode == NORMAL_WINDOW_MODE) {
				pulseapp->prefs->normal_window_rect = Frame();
				pulseapp->prefs->window_mode = MINI_WINDOW_MODE;
				pulseapp->prefs->Save();
			}
			fNormalPulseView->Hide();
			fMiniPulseView->Show();
			fMode = MINI_WINDOW_MODE;
			SetLook(B_MODAL_WINDOW_LOOK);
			SetFeel(B_NORMAL_WINDOW_FEEL);
			SetFlags(B_NOT_ZOOMABLE);
			SetSizeLimits(GetMinimumViewWidth() - 1, 4096, 2, 4096);
			ResizeTo(pulseapp->prefs->mini_window_rect.IntegerWidth(),
				pulseapp->prefs->mini_window_rect.IntegerHeight());
			MoveTo(pulseapp->prefs->mini_window_rect.left,
				pulseapp->prefs->mini_window_rect.top);
			MoveOnScreen();
			break;

		case PV_DESKBAR_MODE:
			// Do not set window's mode to DESKBAR_MODE because the
			// destructor needs to save the correct BRect. ~PulseApp()
			// will handle launching the replicant after our prefs are saved.
			pulseapp->prefs->window_mode = DESKBAR_MODE;
			PostMessage(B_QUIT_REQUESTED);
			break;
	}
}
Beispiel #8
0
LoginAlert::LoginAlert(nserror (*callback)(const char *username,
						const char *password,
						void *pw),
				void *callbackpw,
				nsurl *url, 
				const char *host, 
				const char *realm, 
				const char *text)
	: BAlert("Login", text, "Cancel", "Ok", NULL, 
		B_WIDTH_AS_USUAL, B_WARNING_ALERT)
{
	fCallback = callback;
	fCallbackPw = callbackpw;
	fUrl = url;
	fHost = host;
	fRealm = realm;

	SetFeel(B_MODAL_SUBSET_WINDOW_FEEL);
	/*
	// XXX: can't do that anymore
	nsbeos_scaffolding *s = nsbeos_get_scaffold(bw->window);
	if (s) {
		NSBrowserWindow *w = nsbeos_get_bwindow_for_scaffolding(s);
		if (w)
			AddToSubset(w);
	}*/

	// make space for controls
	ResizeBy(0, 2 * TC_H);
	MoveTo(AlertPosition(Frame().Width() + 1, 
		Frame().Height() + 1));


	BTextView *tv = TextView();
	BRect r(TC_MARGIN, tv->Bounds().bottom - 2 * TC_H, 
		tv->Bounds().right - TC_MARGIN, tv->Bounds().bottom - TC_H);

	fUserControl = new BTextControl(r, "user", "Username", "", 
		new BMessage(), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
	fUserControl->SetDivider(60);
	tv->AddChild(fUserControl);

	r.OffsetBySelf(0, TC_H);

	fPassControl = new BTextControl(r, "pass", "Password", "", 
		new BMessage(), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
	fPassControl->TextView()->HideTyping(true);
	fPassControl->SetDivider(60);
	tv->AddChild(fPassControl);
	
	SetShortcut(0, B_ESCAPE);
}
Beispiel #9
0
/*****************************************************************************
 * VideoWindow::SetInterfaceShowing
 *****************************************************************************/
void
VideoWindow::SetInterfaceShowing(bool showIt)
{
    BWindow* window = get_interface_window();
    if (window)
    {
        if (showIt)
        {
            if (fCachedFeel != B_NORMAL_WINDOW_FEEL)
                SetFeel(B_NORMAL_WINDOW_FEEL);
            window->Activate(true);
            SendBehind(window);
        }
        else
        {
            SetFeel(fCachedFeel);
            Activate(true);
            window->SendBehind(this);
        }
        fInterfaceShowing = showIt;
    }
}
void
ActivityWindow::_SetAlwaysOnTop(bool alwaysOnTop)
{
    SetFeel(alwaysOnTop ? B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
    fAlwaysOnTop->SetMarked(alwaysOnTop);
    if (fSettingsWindow.IsValid() && alwaysOnTop) {
        // Change the settings window feel to modal (via scripting)
        BMessage toFront(B_SET_PROPERTY);
        toFront.AddSpecifier("Feel");
        toFront.AddInt32("data", B_MODAL_ALL_WINDOW_FEEL);
        fSettingsWindow.SendMessage(&toFront);
    }
}
Beispiel #11
0
//===========================PrefsWindow======================================
PrefsWindow::PrefsWindow(BRect frame, BMessenger *messenger) 
				:	BWindow(frame, "Preferences", B_FLOATING_WINDOW, B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_NOT_CLOSABLE|B_ASYNCHRONOUS_CONTROLS),
					m_msgr(messenger),
					m_colourPrefsChanged(false),
					m_fontSizeChanged(false),
					m_toolbarChanged(false)
{	
	SetFeel(B_NORMAL_WINDOW_FEEL);
	
	m_parent = new BView(Bounds(), "parent", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	m_parent->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(m_parent);
	
	prefsLock.Lock();	
	BFont font(be_fixed_font);
	float fontSize = 10.0f;
	if (preferences.FindFloat(K_FONT_SIZE, &fontSize) == B_OK)
		font.SetSize(fontSize);
	prefsLock.Unlock();
		
	float prefsListWidth = 80.0f;		
	BRect prefsListFrame(10.0f, 10.0f, 10.0f + prefsListWidth, Bounds().bottom - 10.0f);	
	PrefsListView *prefsListView = new PrefsListView(prefsListFrame, m_parent);
	BScrollView *prefsListScroll = new BScrollView("ScrollView", prefsListView, B_FOLLOW_LEFT | B_FOLLOW_TOP,B_WILL_DRAW,false,false);
	m_parent->AddChild(prefsListScroll);
		
	float 	bwidth = 80.0f,
			bheight = 30.0f,
			bspacing = 10.0f
			;
	
	BRect okButtonFrame(Bounds().right - bspacing - bwidth, Bounds().bottom - bspacing - bheight, Bounds().right - bspacing,Bounds().bottom - bspacing);
	BButton *okButton = new BButton(okButtonFrame, "okButton", "Ok", new BMessage(PrefsConstants::K_PREFS_VIEW_OK));
	m_parent->AddChild(okButton);
	okButton->MakeDefault(true);
	
	BRect cancelButtonFrame = okButtonFrame;
	cancelButtonFrame.OffsetBy(-(bwidth + 2.0f * bspacing), 0.0f);
	BButton *cancelButton = new BButton(cancelButtonFrame,"cancelButton","Cancel",new BMessage(PrefsConstants::K_PREFS_VIEW_CANCEL));
	m_parent->AddChild(cancelButton);
	
	float respiteWidth = 41.0f;
	BRect boxRect(10.0f + prefsListWidth + 10.0f , 2.0f, Bounds().right - 7.0f , Bounds().bottom - 10.0f - respiteWidth);	
	prefsListView->AddItem(new PrefsListItem(constructGeneralBox(boxRect), m_parent, "General"));
	prefsListView->AddItem(new PrefsListItem(constructCommandBox(boxRect), m_parent, "Commands"));
	prefsListView->AddItem(new PrefsListItem(constructColourBox(boxRect), m_parent, "TexView"));
	prefsListView->AddItem(new PrefsListItem(constructToolbarBox(boxRect), m_parent, "Toolbars"));	
	prefsListView->Select(0);
	prefsListView->MakeFocus(true);	
}
Beispiel #12
0
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color,
								   SelectedColorMode mode,
								   BWindow* window,
								   BMessage* message, BHandler* target)
	: Panel(frame, "Pick a color",
			B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
			B_ASYNCHRONOUS_CONTROLS |
			B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE
			| B_AUTO_UPDATE_SIZE_LIMITS),
	  fWindow(window),
	  fMessage(message),
	  fTarget(target)
{
	SetTitle(B_TRANSLATE("Pick a color"));

	fColorPickerView = new ColorPickerView("color picker", color, mode);

	SetLayout(new BGroupLayout(B_VERTICAL));
		
	BButton* defaultButton = new BButton("ok button",
		B_TRANSLATE("OK"),
		new BMessage(MSG_DONE));
	BButton* cancelButton = new BButton("cancel button",
		B_TRANSLATE("Cancel"),
		new BMessage(MSG_CANCEL));

	BView* topView = new BGroupView(B_VERTICAL);

	const float inset = be_control_look->DefaultLabelSpacing();

	BLayoutBuilder::Group<>(topView, B_VERTICAL, 0.0f)
		.Add(fColorPickerView)
		.Add(new BSeparatorView(B_HORIZONTAL))
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(cancelButton)
			.Add(defaultButton)
			.SetInsets(inset, inset, inset, inset)
		.End()
	;

	SetDefaultButton(defaultButton);

	if (fWindow != NULL)
		AddToSubset(fWindow);
	else
		SetFeel(B_FLOATING_APP_WINDOW_FEEL);

	AddChild(topView);
}
Beispiel #13
0
// ---------------------------------------------------------------------------------- RHTML_Tag_Menu - Start -
void RHTMLTagMenu::Start(BPoint point, int32 offset, MenuType _menutype, std::vector<BString> &_tags, BString _tag, BString _param)
{
 menutype=_menutype;
 tag=_tag;
 tags=_tags;
 param=_param;
 tag.ToLower();
 param.ToLower();
 Lock();

 if (_menutype==R_TAG_MENU)
  fListView->str = "<";
 if (_menutype==R_PARAM_MENU)
  fListView->str = " ";
 if (_menutype==R_VALUE_MENU)
  fListView->str = "";
 
 LoadList();
 if (fListView->CountItems()>0)
 {
  fListView->sel1=offset-1;
  fListView->sel2=offset;
  
  if (_menutype==R_VALUE_MENU)
   fListView->sel1++;

  SetFeel(B_MODAL_APP_WINDOW_FEEL);
  Activate(true);
  fListView->MakeFocus(true);
  fListView->SetEventMask(B_POINTER_EVENTS);
  float left,top;
  BScreen screen;

  if (screen.Frame().bottom>point.y+221)
   top=point.y+20;
  else
   top=point.y-210;

  if (screen.Frame().right>point.x+Bounds().right+1)
   left=point.x;
  else
   left=point.x-Bounds().right;

  MoveTo(left,top);
 }
 Unlock();
}
Beispiel #14
0
SLoadingModules::SLoadingModules(int32 modules_count)
	: BWindow(BRect(-100, -100, -10, -10), "BeCJK Loading Moudles", B_BORDERED_WINDOW, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FOCUS, B_ALL_WORKSPACES)
{
	count = 0;
	nmodules = modules_count;
	SetPulseRate(500000);
	SetSizeLimits(0, 10000, 0, 10000);

	BString str;
	str << "BeCJK " << _("Loading Modules: ");

	bar = new BStatusBar(BRect(0, 0, 10, 10), NULL, str.String(), NULL);
	rgb_color bar_color = {255, 203, 0, 255};
	bar->SetBarColor(bar_color);
	bar->SetMaxValue(nmodules);
	bar->SetFont(be_plain_font);
	bar->SetFontSize(10);
	bar->SetBarHeight(10);
	float w = 0, h = 0;
	bar->GetPreferredSize(&w, &h);


	BScreen screen(this);
	BRect rect = screen.Frame();
	rect.OffsetTo(B_ORIGIN);
	rect.top = rect.bottom - SLoadingModulesView::GetHeightByChild(bar);
	ResizeTo(rect.Width(), rect.Height());
	MoveTo(rect.LeftTop());

	SLoadingModulesView *main_view = new SLoadingModulesView(Bounds());
	main_view->AddChild(bar);
	bar->ResizeTo(main_view->ContainerBounds().Width(), main_view->ContainerBounds().Height());
	bar->MoveTo(main_view->ContainerBounds().LeftTop());

	AddChild(main_view);

	RemoveShortcut((uint32)'W', (uint32)B_COMMAND_KEY);
	RemoveShortcut((uint32)'Q', (uint32)B_COMMAND_KEY);

	SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	SetLook(B_NO_BORDER_WINDOW_LOOK);

	Run();
}
Beispiel #15
0
TBarWindow::TBarWindow()
	:
	BWindow(BRect(-1000.0f, -1000.0f, -1000.0f, -1000.0f),
		B_TRANSLATE_SYSTEM_NAME("Deskbar"), B_BORDERED_WINDOW,
		B_WILL_ACCEPT_FIRST_CLICK | B_NOT_ZOOMABLE | B_NOT_CLOSABLE
		| B_NOT_MINIMIZABLE | B_NOT_MOVABLE | B_NOT_RESIZABLE
		| B_AVOID_FRONT | B_ASYNCHRONOUS_CONTROLS,
		B_ALL_WORKSPACES)
{
	desk_settings* settings = ((TBarApp*)be_app)->Settings();
	if (settings->alwaysOnTop)
		SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	fBarView = new TBarView(Bounds(), settings->vertical, settings->left,
		settings->top, settings->state, settings->width);
	AddChild(fBarView);

	RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY);
	AddShortcut('F', B_COMMAND_KEY, new BMessage(kFindButton));
}
Beispiel #16
0
WorkspacesWindow::WorkspacesWindow(WorkspacesSettings *settings)
	: BWindow(settings->WindowFrame(), "Workspaces", B_TITLED_WINDOW_LOOK,
 			B_NORMAL_WINDOW_FEEL, B_AVOID_FRONT | B_WILL_ACCEPT_FIRST_CLICK,
 			B_ALL_WORKSPACES),
 	fSettings(settings),
 	fAutoRaising(false)
{
	AddChild(new WorkspacesView(Bounds()));

	if (!fSettings->HasBorder())
		SetLook(B_NO_BORDER_WINDOW_LOOK);
	else if (!fSettings->HasTitle())
		SetLook(B_MODAL_WINDOW_LOOK);

	if (fSettings->AlwaysOnTop())
		SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	else
		SetAutoRaise(fSettings->AutoRaising());
}
ToolSelectionWindow::ToolSelectionWindow(BRect frame)
    : BWindow(frame, StringServer::ReturnString(TOOLS_STRING),
              B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_H_RESIZABLE |
              B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FRONT)
{
    int32 pictureSize = LARGE_TOOL_ICON_SIZE + 4.0;

    window_feel feel = B_NORMAL_WINDOW_FEEL;
    if (SettingsServer* server = SettingsServer::Instance()) {
        server->SetValue(SettingsServer::Application, skSelectToolWindowVisible,
                         true);

        BMessage settings;
        server->GetApplicationSettings(&settings);
        settings.FindInt32(skSelectToolWindowFeel, (int32*)&feel);
    }

    fMatrixView = new MatrixView(pictureSize, pictureSize, kExtraEdge);

    _AddTool(ToolManager::Instance().ReturnTool(FREE_LINE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(STRAIGHT_LINE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(RECTANGLE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(ELLIPSE_TOOL));

    // Here we could add a separator to the tool window.

    _AddTool(ToolManager::Instance().ReturnTool(BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(HAIRY_BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(AIR_BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(BLUR_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(FILL_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(TEXT_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(TRANSPARENCY_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(ERASER_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(SELECTOR_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(COLOR_SELECTOR_TOOL));

    ToolMap::iterator it = gToolMap.find(ToolManager::Instance().ReturnActiveToolType());
    if (it != gToolMap.end())
        it->second->SetValue(B_CONTROL_ON);

    AddChild(fMatrixView);
    fMatrixView->ResizeTo(Bounds().Width(), Bounds().Height());

    SetFeel(feel);
    if (feel == B_NORMAL_WINDOW_FEEL)
        SetLook(B_TITLED_WINDOW_LOOK);
    else
        SetLook(B_FLOATING_WINDOW_LOOK);

    float minDimension = 2 * kExtraEdge + pictureSize;
    float maxDimension = 1 + kExtraEdge + fMatrixView->CountChildren() *
                         (pictureSize + kExtraEdge);
    SetSizeLimits(minDimension, maxDimension, minDimension, maxDimension);

    if (Lock()) {
        AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE,
                                           B_MOUSE_DOWN, window_activation_filter));
        AddCommonFilter(new BMessageFilter(B_KEY_DOWN, AppKeyFilterFunction));
        Unlock();
    }

    Show();

    // NOTE: this is broken/ not implemented in Haiku, so the tools window
    //		 will not show up horizontal as it should be, enable if implemented
    //SetWindowAlignment(B_PIXEL_ALIGNMENT, 0, 0, picture_size + kExtraEdge,
    //	kExtraEdge + 1, 0, 0, picture_size + kExtraEdge, kExtraEdge + 1);

    // remove this if SetWindowAlignment is implemented
    ResizeBy(0.0, maxDimension - pictureSize);

    fSelectionWindow = this;
    FloaterManager::AddFloater(this);
}
Beispiel #18
0
SelectionWindow::SelectionWindow(BContainerWindow *window)
	:	BWindow(BRect(0, 0, 270, 0),
			"Select", B_TITLED_WINDOW,
			B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
			| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
			| B_NOT_ANCHORED_ON_ACTIVATE),
		fParentWindow(window)
{
	if (window->Feel() & kPrivateDesktopWindowFeel)
		// The window will not show up if we have B_FLOATING_SUBSET_WINDOW_FEEL
		// and use it with the desktop window since it's never in front.
		SetFeel(B_NORMAL_WINDOW_FEEL);
	
	AddToSubset(fParentWindow);

	BRect backgroundRect = Bounds();
	backgroundRect.InsetBy(-1, -1);
	BView *backgroundView = new BBox(backgroundRect, "bgView", B_FOLLOW_ALL);
	AddChild(backgroundView);

	BMenu *menu = new BPopUpMenu("");
	
	menu->AddItem(new BMenuItem("starts with", NULL));
	menu->AddItem(new BMenuItem("ends with", NULL));
	menu->AddItem(new BMenuItem("contains", NULL));
	menu->AddItem(new BMenuItem("matches wildcard expression", NULL));
	menu->AddItem(new BMenuItem("matches regular expression", NULL));

	menu->SetLabelFromMarked(true);
	menu->ItemAt(3)->SetMarked(true);
		// Set wildcard matching to default.
	
	// Set up the menu field
	fMatchingTypeMenuField = new BMenuField(BRect(7, 6, Bounds().right - 5, 0),
		NULL, "Name", menu);
	backgroundView->AddChild(fMatchingTypeMenuField);
	fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth("Name") + 8);
	fMatchingTypeMenuField->ResizeToPreferred();
	
	// Set up the expression text control
	fExpressionTextControl = new BTextControl(BRect(7, fMatchingTypeMenuField->
		Bounds().bottom + 11, Bounds().right - 6, 0), NULL, NULL, NULL, NULL,
		B_FOLLOW_LEFT_RIGHT);
	backgroundView->AddChild(fExpressionTextControl);
	fExpressionTextControl->ResizeToPreferred();
	fExpressionTextControl->MakeFocus(true);
	
	// Set up the Invert checkbox
	fInverseCheckBox = new BCheckBox(BRect(7, fExpressionTextControl->Frame().bottom
		+ 6, 6, 6), NULL, "Invert", NULL);
	backgroundView->AddChild(fInverseCheckBox);
	fInverseCheckBox->ResizeToPreferred();
	
	// Set up the Ignore Case checkbox
	fIgnoreCaseCheckBox = new BCheckBox(BRect(fInverseCheckBox->Frame().right + 10,
		fInverseCheckBox->Frame().top, 6, 6), NULL, "Ignore case", NULL);
	fIgnoreCaseCheckBox->SetValue(1);
	backgroundView->AddChild(fIgnoreCaseCheckBox);
	fIgnoreCaseCheckBox->ResizeToPreferred();

	// Set up the Select button
	fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL, "Select",
		new BMessage(kSelectButtonPressed), B_FOLLOW_RIGHT);
		
	backgroundView->AddChild(fSelectButton);
	fSelectButton->ResizeToPreferred();
	fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right,
		fExpressionTextControl->Frame().bottom + 9);
	fSelectButton->MakeDefault(true);
	#if !B_BEOS_VERSION_DANO
	fSelectButton->SetLowColor(backgroundView->ViewColor());
	fSelectButton->SetViewColor(B_TRANSPARENT_COLOR);
	#endif
	
	font_height fh;
	be_plain_font->GetHeight(&fh);
	// Center the checkboxes vertically to the button
	float topMiddleButton =
		(fSelectButton->Bounds().Height() / 2 -
		(fh.ascent + fh.descent + fh.leading + 4) / 2) + fSelectButton->Frame().top;
	fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton);
	fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left, topMiddleButton);

	float bottomMinWidth = 32 + fSelectButton->Bounds().Width() +
		fInverseCheckBox->Bounds().Width() + fIgnoreCaseCheckBox->Bounds().Width();
	float topMinWidth = be_plain_font->StringWidth("Name matches wildcard expression:###");
	float minWidth = bottomMinWidth > topMinWidth ? bottomMinWidth : topMinWidth;

	Run();

	Lock();
	ResizeTo(minWidth, fSelectButton->Frame().bottom + 6);

	SetSizeLimits(
		/* Minimum Width */ minWidth,
		/* Maximum Width */ 1280,
		/* Minimum Height */ Bounds().bottom,
		/* Maximum Height */ Bounds().bottom);

	MoveCloseToMouse();	
	Unlock();
}
Beispiel #19
0
void BoardWindow::MessageReceived(BMessage* message)
{
    if (_MessageFilter(message) == true)
        return;

	switch (message->what) {
		case REPLYCODE_ENGINE:
		{
            if (fEngineCanWrite == false)
                break;

            PostMessage(message, fEngineOutput);
			break;
		}

        case MSG_ENGINEMOVE:
            fEngineIsRunning = false;
            PostMessage(message, fChessBoard);
            break;

        case REPLYCODE_ICS:
		{
			break;
		}


        case REPLYCODE_TIMEVIEW:
            int32  value;
            message->FindInt32("time", &value);
            break;

        case MSG_SKILLCHANGED:
        {
            BString str = "Engine Skill: ";
            str << fSkillSlider->Value();
            fSkillSlider->SetToolTip(str);

            BMessage msg(MSG_SKILLCHANGED);
            msg.AddInt32("val", fSkillSlider->Value());

            if (fEngine != NULL)
                fEngine->PostMessage(&msg);

            break;
        }

		//case 10:
		//	be_roster->Launch( "application/x-vnd.cipri.Puri" );
		//	break;

        case MENU_VIEW_3D:
            f3DMI->SetMarked(!f3DMI->IsMarked());
            fChessBoard->SetViewMode3D(f3DMI->IsMarked());
            break;

		case MSG_MOVEFIRST:
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveFirst();
            fMovesView ->MoveFirst();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

		case MSG_MOVEBACK:

			fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveBack();
            fMovesView ->MoveBack();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

		case MSG_MOVENEXT:
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveNext();
            fMovesView ->MoveNext();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

		case MSG_MOVELAST:
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            fTimeView->Stop();
			fChessBoard->MoveLast();
            fMovesView ->MoveLast();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            fChessBoard->SetUserCanMove();
			break;

        case MSG_GOTO_MOVE:
        {
            fEngineCanWrite = false;
            _EngineStop();
            fEngineIsRunning = false;
            fEngineOutput->SetOn(false);
            uint32  idx = 0;
            message->FindUInt32("move_idx", &idx);
            fTimeView->Stop();
            fChessBoard->GotoMove(idx);
            fMovesView ->GotoMove(idx);
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
            break;
        }

		case MENU_APP_QUIT:
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;

        case MSG_QUIT:
            fICSMainWindow = NULL;

            QuitRequested();
            break;

        case MENU_VIEW_SHOW_WINDOW:
        {
            Show();
            break;
        }

        case MENU_VIEW_FLIPBOARD:
        {
            if (fFlipBoardMI->IsMarked())
                fFlipBoardMI->SetMarked(false);
            else
                fFlipBoardMI->SetMarked(true);

            fChessBoard->FlipBoard();
            break;
        }

		case MENU_VIEW_MININTERFACE:
			if (fMinIfMenuItem->IsMarked()) {
				if (!fShowborderMenuItem->IsMarked())
					PostMessage( MENU_VIEW_SHOWBORDER);

				if (!fSidebarMenuItem->IsMarked())
					PostMessage(MENU_VIEW_SIDEBAR);

				if (!fShowMBarMenuItem->IsMarked())
					PostMessage(MENU_VIEW_SHOWMENU);

                if (fAlwaysOnTopMenuItem->IsMarked())
					PostMessage(MENU_VIEW_ALWAYSONTOP);

				fMinIfMenuItem->SetMarked(false);
			} else {
				if (fShowborderMenuItem->IsMarked())
					PostMessage (MENU_VIEW_SHOWBORDER);

				if (fSidebarMenuItem->IsMarked())
					PostMessage (MENU_VIEW_SIDEBAR);

				if (fShowMBarMenuItem->IsMarked())
					PostMessage(MENU_VIEW_SHOWMENU);

                if (!fAlwaysOnTopMenuItem->IsMarked())
					PostMessage(MENU_VIEW_ALWAYSONTOP);

				fMinIfMenuItem->SetMarked(true);
			}

			break;

        case MENU_VIEW_FULLSCREEN:
        {
            if (fFullScrMI->IsMarked()) {
                fFullScrMI->SetMarked(false);
                Hide();
                MoveTo(fSavedFrame.left, fSavedFrame.top);
                ResizeTo(fSavedFrame.Width(), fSavedFrame.Height());
                Show();
            } else {
                fFullScrMI->SetMarked(true);
                fSavedFrame = Frame();
                BScreen screen(this);
                BRect rect(screen.Frame());
                Hide();
                MoveTo(rect.left, rect.top);
                ResizeTo(rect.Width(), rect.Height());
                Show();
            }

            break;
        }

		case MENU_VIEW_SIDEBAR:
        	if (fSidebarMenuItem->IsMarked() == false) {
        		fSidebarMenuItem->SetMarked(true);
                fSidebarView->Show();
        	} else {
				fSidebarMenuItem->SetMarked(false);
                fSidebarView->Hide();
			}

			break;

		case MENU_VIEW_SHOWBORDER:
			if (fShowborderMenuItem->IsMarked()) {
				SetLook(B_BORDERED_WINDOW_LOOK);
				fShowborderMenuItem->SetMarked(false);
			} else {
				SetLook(B_DOCUMENT_WINDOW_LOOK);
				fShowborderMenuItem->SetMarked(true);
			}

			break;

		case MENU_VIEW_AUTOHIDING:
        	if (fAutohidingMenuItem->IsMarked()) {
        		fAutohidingMenuItem->SetMarked(false);
        		fSidebarView->SetAutohiding(false);
                fNavigationView->SetAutohiding(false);
        	} else {
				fAutohidingMenuItem->SetMarked(true);
                fSidebarView->SetAutohiding(true);
                fNavigationView->SetAutohiding(true);
			}

			break;

		case MENU_VIEW_SHOWCLOCK:
			if (fShowClockMenuItem->IsMarked() == false) {
				fTimeView->Show();
				fShowClockMenuItem->SetMarked(true);
			} else {
				fTimeView->Hide();
				fShowClockMenuItem->SetMarked(false);
			}

			break;

        case MENU_VIEW_SHOWMENU:
			if (fShowMBarMenuItem->IsMarked() == false) {
				fMenuBar->Show();
				fShowMBarMenuItem->SetMarked(true);
			} else {
				fMenuBar->Hide();
				fShowMBarMenuItem->SetMarked(false);
			}

			break;

        case MENU_VIEW_ALWAYSONTOP:
            fAlwaysOnTopMenuItem->SetMarked(!fAlwaysOnTopMenuItem->IsMarked());
            SetFeel(fAlwaysOnTopMenuItem->IsMarked() ?
                             B_FLOATING_ALL_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
            break;

        // TODO: after the game, ask for isready,
        // and wait till the engine is ready.
		case MENU_GAME_NEWGAME:
            fEngineCanWrite = false;
            fChessBoard->NewGame();
			fTimeView->Init(300);
            fMovesView->Clear();
            fMaterialView->Clear();
            fChessBoard->SetUserCanMove(true);

            if (fEngine != NULL) {
                fEngine->PostMessage(MSG_UNLOCK);
                fEngine->PostMessage(MSG_ENG_NEWGAME);
			}
            fEngineCanWrite = true;
            fEngineIsRunning = false;
			break;

        case MENU_GAME_MOVENOW:
            if (fEngineOffMenuItem->IsMarked())
                fEngineOffMenuItem->SetMarked(false);

            if (fTimeView->IsStarted() == false)
                fTimeView->Start();

            if (fEngineIsRunning)
                _EngineStop();
            else
                _EngineGo();

            break;

		case MENU_ENGINE_SOENGINE:
            if (fEngineOffMenuItem->IsMarked()) {
                fEngineOffMenuItem->SetMarked(false);
            } else {
                fEngineCanWrite = false;
                _EngineStop();
                fEngineOffMenuItem->SetMarked(true);
                fChessBoard->SetUserCanMove(true);
            }

			break;

        case ICS_DISCONNECTED:
          //  fICSConnectMI->SetMarked(false);
           // fChessBoard->SetUserCanMove(false);
            break;

        case MSG_SEND_ICS_CMD:
            if (fICSMainWindow != NULL) {
                fICSMainWindow->PostMessage(message);
            }
            break;

        case MENU_HELP_MOVEASSISTANT:
            fMoveAssistantMenuItem->SetMarked(
                                           !fMoveAssistantMenuItem->IsMarked());
            fChessBoard->ShowValidMoves(fMoveAssistantMenuItem->IsMarked());
            break;

		case MENU_HELP_HINT:
            break;

		case MENU_HELP_HELP:
        {
            BString str = "file://";
            str << Tools::AppPath() << "/data/Help/Help.html";
            char const* args[] = {str.String(), 0};
            be_roster->Launch("text/html", 1, const_cast<char **>(args));
			break;
        }

		case MENU_HELP_ABOUT:
        {
            BString str;
            str << "Puri is a Chess GUI\n\twritten by\n";
            str << "Ciprian Nedisan\n\n\n";
            str << "Version: " << (float)VERSION << "\n";
            str << "License: MIT\n\n";
            str << "Many thanks to:\n";
            str << "\talexd\n";
            str << "\tingo\n";
            str << "\tstippi\n";
            str << "\tZuMi\n\n";

            fChessBoard->CancelSelection();
			(new BAlert("About Puri", str, "Ok"))->Go();
			break;
        }

        case MSG_BOARDSTATE:
        {
            int32 state;
            message->FindInt32("val", &state);

            if (state > 1) {
                fTimeView->Stop();
                if (fEngineOutput != NULL)
                	fEngineOutput->SetOn(false);
            }

            break;
        }

        case ICS_GAME_INFO:
        {
            BString str;
            message->FindString("info", &str);
            // The ics protocol is wrongly  implemented. it= , i=
            vector<BString> timeW = Tools::Split(Tools::Find(str, "it="), ',');
            vector<BString> timeB = Tools::Split(Tools::Find(str, "i="), ',');
            fTimeView->SetTimeWhite(atoi(timeW[0]));
            fTimeView->SetTimeBlack(atoi(timeB[0]));
            fTimeView->Stop();

            vector<BString> elo = Tools::Split(Tools::Find(str, "rt=").RemoveSet("PE "), ',');
            BString title;
            title << fPlayerName[0] << " (" << elo[0] << ")  -  ";
            title << fPlayerName[1] << " (" << elo[1] << ")    [ ";
            title << atoi(timeW[0]) / 60 << " +" << atoi(timeW[1]);

            if (Tools::Find(str, "r=") == "1")
                title << "  rated ]";
            else
                title << "  unrated ]";

            SetTitle(title);

            break;
        }

        case ICS_MADE_MOVE:
        {
            BString move;
            message->FindString("info", &move);
            std::vector<BString> vec = Tools::Split(move);
            fTimeView->SetTimeMS(atoi(vec[5]), atoi(vec[1])%2 == 1);
            fChessBoard->DoICSMove(vec[3]);
            break;
        }

        case ICS_FORFEIT_ON_TIME:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            BString str;
            message->FindString("info", &str);
            str << "\nforfeits on time";
            (new BAlert("Time", str, "OK"))->Go();

            break;
        }

        case ICS_FORFEIT_BY_DISCONNECTION:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            BString str;
            message->FindString("info", &str);
            str << "\nforfeits by disconnection";

            (new BAlert("Disconnection", str, "OK"))->Go();

            break;
        }

        case ICS_RESIGN:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            (new BAlert("Resign", "Game was resigned", "OK"))->Go();

            break;
        }

        case ICS_NOTPLAYING:
        {
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
         //   (new BAlert("Not Playing", "Game not active", "OK"))->Go();

            break;
        }

        case ICS_GAME_DRAWN:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            (new BAlert("Draw", "Game was drawn", "OK"))->Go();

            break;
        }

        case ICS_OFFERED_INFO:
        case ICS_TELL:
        case ICS_SHOUT:
            PostMessage(message, fChatView);
            break;


        case ICS_GAME_ABORTED:
        {
            fChessBoard->CancelSelection();
            fTimeView->Stop();
            fChessBoard->SetUserCanMove(true);
            (new BAlert("Abort", "Game was aborted", "OK"))->Go();

            break;
        }

        case ICS_NEW_GAME:
        {
            fChessBoard->NewGame();
			fTimeView->Init(0);
            fMovesView->Clear();
            fMaterialView->Clear();

            BString wuser, buser;
            bool isWhite;
            message->FindString("wuser", &wuser);
            message->FindString("buser", &buser);
            message->FindBool("iswhite", & isWhite);

            fChessBoard->SetBoardTurned(!isWhite);

            if (isWhite)
                fChessBoard->SetUserCanMove(true);
            else
                fChessBoard->SetUserCanMove(false);

            Activate();
            break;
        }

        case MSG_ICS_MOVE_DONE:
        {
            BString move;
            message->FindString("move", &move);
            fMovesView->AddMove(move, !fChessBoard->IsWhiteTurn());
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
			fTimeView->Switch();
            fChessBoard->SetUserCanMove(true);
            break;
        }

		case USER_MADE_MOVE:
        {
            BString move;
            message->FindString("move", &move);
            fMovesView->AddMove(move, !fChessBoard->IsWhiteTurn());
			fTimeView->Switch();
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());

            if (fICSConnectMI->IsMarked()) {
                BMessage msg(USER_MADE_MOVE);
                BString str;
                str << BLK_GAME_MOVE << " " << fChessBoard->LastMoveICSF();
                SendICS(str, fICSMainWindow);
                fChessBoard->SetUserCanMove(false);
            } else if (fEngineOffMenuItem->IsMarked() == false)
            {
                _EngineGo();
            }

			break;
        }

        case ENGINE_MADE_MOVE:
        {
            BString move;
            message->FindString("move", &move);
            fMovesView->AddMove(move, !fChessBoard->IsWhiteTurn());
            fMaterialView->SetMaterial(fChessBoard->GetMaterial());
			fTimeView->Switch();
            fChessBoard->SetUserCanMove(true);
			break;
        }

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
Beispiel #20
0
SNewFolderWindow::SNewFolderWindow(SeekerWindow *mainWindow,
			 	 					const SFile *parentFile)
 : BWindow(BRect(50, 50, 0, 0), "New Folder", 
 			B_FLOATING_WINDOW,
			B_WILL_DRAW | B_NOT_ZOOMABLE | 
			B_NOT_MINIMIZABLE | B_NOT_RESIZABLE),
   iMainWindow(mainWindow),
   iView(0),
   iParentTextControl(0),
   iNameTextControl(0),
   iOkButton(0),
   iCancelButton(0)
{
	char *parentLabel="Parent";
	char *nameLabel="New Folder";

	iParentFile=new SFile(parentFile);

	// set window feel
	SetFeel(B_MODAL_APP_WINDOW_FEEL);

	// create view
	iView=new BView(Bounds(), "NewFolderWindow::View", B_FOLLOW_ALL, 
					   B_WILL_DRAW);
	iView->SetViewColor(BeBackgroundGrey);
	AddChild(iView);

	// parent label/text
	BRect rect;
	rect.left=10;
	rect.top=10;
	iParentTextControl=new BTextControl(rect, "NewFolderWindow::ParentTextControl",
										   parentLabel, iParentFile->Name(), NULL);
	iParentTextControl->ResizeToPreferred();
	iView->AddChild(iParentTextControl);

	// new folder name label/text
	rect.top +=10 + iParentTextControl->Bounds().Height();
	iNameTextControl=new BTextControl(rect, "NewFolderWindow::NameTextControl",
										 nameLabel, "", NULL);
	iNameTextControl->ResizeToPreferred();
	iView->AddChild(iNameTextControl);

	// align fields
	float parentStringWidth=be_plain_font->StringWidth(parentLabel);
	float nameStringWidth=be_plain_font->StringWidth(nameLabel);
	float maxWidth=MAX(parentStringWidth, nameStringWidth) + 10;
	
	iNameTextControl->SetDivider(maxWidth);
	iNameTextControl->ResizeTo(MAX(iNameTextControl->Bounds().Width(), 200),
								iNameTextControl->Bounds().Height());

	iParentTextControl->SetDivider(maxWidth);
	iParentTextControl->ResizeTo(iNameTextControl->Bounds().Width(), 
								  iParentTextControl->Bounds().Height()); 

	// cancel button
	iCancelButton=new BButton(BRect(), "NewFolderWindow::CancelButton",
								 "Cancel",  new BMessage(MSG_NEWFOLDER_WINDOW_CANCEL));
	iCancelButton->ResizeToPreferred();
	iCancelButton->MoveTo(iNameTextControl->Frame().right - iCancelButton->Bounds().Width(),
						   iNameTextControl->Frame().bottom + 10);			
	
	// ok button
	iOkButton=new BButton(BRect(), "NewFolderWindow::OkButton",
							 "OK",  new BMessage(MSG_NEWFOLDER_WINDOW_OK));
	iOkButton->ResizeToPreferred();
	iOkButton->MoveTo(iCancelButton->Frame().left - 10 - iOkButton->Bounds().Width(),
					   iCancelButton->Frame().top);	
	iOkButton->MakeDefault(true);
	
	// add window in tab-order
	iView->AddChild(iOkButton);
	iView->AddChild(iCancelButton);

	// re-size window
	rect.right=iCancelButton->Frame().right + 10;
	rect.bottom=iCancelButton->Frame().bottom + 10;
	ResizeTo(rect.right, rect.bottom);
	
	// disable editing of parent name
	iParentTextControl->TextView()->MakeEditable(false);
	iParentTextControl->TextView()->MakeSelectable(false);
	iParentTextControl->TextView()->SetViewColor(BeBackgroundGrey);
	iParentTextControl->SetViewColor(BeBackgroundGrey);

	// Prevent goofs by changing the folder location
	iNameTextControl->TextView()->DisallowChar('/');
	
	// set focus to name field
	iNameTextControl->MakeFocus();
}			 	  
Beispiel #21
0
SelectionWindow::SelectionWindow(BContainerWindow* window)
	:
	BWindow(BRect(0, 0, 270, 0), B_TRANSLATE("Select"),	B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
			| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
			| B_NOT_ANCHORED_ON_ACTIVATE),
	fParentWindow(window)
{
	if (window->Feel() & kDesktopWindowFeel) {
		// The window will not show up if we have
		// B_FLOATING_SUBSET_WINDOW_FEEL and use it with the desktop window
		// since it's never in front.
		SetFeel(B_NORMAL_WINDOW_FEEL);
	}

	AddToSubset(fParentWindow);

	BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL,
		B_WILL_DRAW);
	backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(backgroundView);

	BMenu* menu = new BPopUpMenu("");
	menu->AddItem(new BMenuItem(B_TRANSLATE("starts with"),	NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("ends with"), NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("contains"), NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("matches wildcard expression"),
		NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("matches regular expression"),
		NULL));

	menu->SetLabelFromMarked(true);
	menu->ItemAt(3)->SetMarked(true);
		// Set wildcard matching to default.

	// Set up the menu field
	fMatchingTypeMenuField = new BMenuField(BRect(7, 6,
		Bounds().right - 5, 0), NULL, B_TRANSLATE("Name"), menu);
	backgroundView->AddChild(fMatchingTypeMenuField);
	fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth(
		B_TRANSLATE("Name")) + 8);
	fMatchingTypeMenuField->ResizeToPreferred();

	// Set up the expression text control
	fExpressionTextControl = new BTextControl(BRect(7,
			fMatchingTypeMenuField->Bounds().bottom + 11,
			Bounds().right - 6, 0),
		NULL, NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT);
	backgroundView->AddChild(fExpressionTextControl);
	fExpressionTextControl->ResizeToPreferred();
	fExpressionTextControl->MakeFocus(true);

	// Set up the Invert checkbox
	fInverseCheckBox = new BCheckBox(
		BRect(7, fExpressionTextControl->Frame().bottom + 6, 6, 6), NULL,
		B_TRANSLATE("Invert"), NULL);
	backgroundView->AddChild(fInverseCheckBox);
	fInverseCheckBox->ResizeToPreferred();

	// Set up the Ignore Case checkbox
	fIgnoreCaseCheckBox = new BCheckBox(
		BRect(fInverseCheckBox->Frame().right + 10,
			fInverseCheckBox->Frame().top, 6, 6),
		NULL, B_TRANSLATE("Ignore case"), NULL);
	fIgnoreCaseCheckBox->SetValue(1);
	backgroundView->AddChild(fIgnoreCaseCheckBox);
	fIgnoreCaseCheckBox->ResizeToPreferred();

	// Set up the Select button
	fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL,
		B_TRANSLATE("Select"), new BMessage(kSelectButtonPressed),
		B_FOLLOW_RIGHT);

	backgroundView->AddChild(fSelectButton);
	fSelectButton->ResizeToPreferred();
	fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right,
		fExpressionTextControl->Frame().bottom + 9);
	fSelectButton->MakeDefault(true);
#if !B_BEOS_VERSION_DANO
	fSelectButton->SetLowColor(backgroundView->ViewColor());
	fSelectButton->SetViewColor(B_TRANSPARENT_COLOR);
#endif

	font_height fh;
	be_plain_font->GetHeight(&fh);
	// Center the checkboxes vertically to the button
	float topMiddleButton =
		(fSelectButton->Bounds().Height() / 2 -
		(fh.ascent + fh.descent + fh.leading + 4) / 2)
		+ fSelectButton->Frame().top;
	fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton);
	fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left,
		topMiddleButton);

	float bottomMinWidth = 32 + fSelectButton->Bounds().Width()
		+ fInverseCheckBox->Bounds().Width()
		+ fIgnoreCaseCheckBox->Bounds().Width();
	float topMinWidth = be_plain_font->StringWidth(
		B_TRANSLATE("Name matches wildcard expression:###"));
	float minWidth = bottomMinWidth > topMinWidth
		? bottomMinWidth : topMinWidth;

	class EscapeFilter : public BMessageFilter {
	public:
		EscapeFilter(BWindow* target)
			:
			BMessageFilter(B_KEY_DOWN),
			fTarget(target)
		{
		}

		virtual filter_result Filter(BMessage* message, BHandler** _target)
		{
			int8 byte;
			if (message->what == B_KEY_DOWN
				&& message->FindInt8("byte", &byte) == B_OK
				&& byte == B_ESCAPE) {
				fTarget->Hide();
				return B_SKIP_MESSAGE;
			}
			return B_DISPATCH_MESSAGE;
		}

	private:
		BWindow* fTarget;
	};
	AddCommonFilter(new(std::nothrow) EscapeFilter(this));

	Run();

	Lock();
	ResizeTo(minWidth, fSelectButton->Frame().bottom + 6);

	SetSizeLimits(minWidth, 1280, Bounds().bottom, Bounds().bottom);

	MoveCloseToMouse();
	Unlock();
}
Beispiel #22
0
SRenameWindow::SRenameWindow(SeekerWindow *mainWindow, const SFile *file, bool multiple, int32 offset)
	: BWindow(BRect(50+offset, 50+offset, 0, 0), "Rename", B_FLOATING_WINDOW, B_WILL_DRAW | 
//	B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE),
	B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE),
	iMainWindow(mainWindow),
	iView(0),
	iOldNameTextControl(0),
	iNewNameTextControl(0),
	iOkButton(0),
	iCancelAllButton(0),
	iCancelButton(0)
{
	char *oldNameLabel="Old Name";
	char *newNameLabel="New Name";

	iFile=new SFile(file);

	// set window feel
	SetFeel(B_MODAL_APP_WINDOW_FEEL);

	// create view
	iView=new BView(Bounds(), "RenameWindow::View", B_FOLLOW_ALL, 
					   B_WILL_DRAW);
	iView->SetViewColor(BeBackgroundGrey);
	AddChild(iView);

	// old-name label/text
	BRect rect;
	rect.left=10;
	rect.top=10;
	iOldNameTextControl=new BTextControl(rect, "RenameWindow::OldNameTextControl",
										    oldNameLabel, iFile->Name(), NULL);
	iOldNameTextControl->ResizeToPreferred();
	iView->AddChild(iOldNameTextControl);

	// new folder name label/text
	rect.top +=10 + iOldNameTextControl->Bounds().Height();
	iNewNameTextControl=new BTextControl(rect, "RenameWindow::NewNameTextControl",
										 	newNameLabel, iFile->Name(), NULL);
	iNewNameTextControl->ResizeToPreferred();
	iView->AddChild(iNewNameTextControl);

	// align fields
	float oldNameStringWidth=be_plain_font->StringWidth(oldNameLabel);
	float newNameStringWidth=be_plain_font->StringWidth(newNameLabel);
	float maxWidth=MAX(oldNameStringWidth, newNameStringWidth) + 10;
	
	iNewNameTextControl->SetDivider(maxWidth);
	if(iNewNameTextControl->Bounds().Width()<200)
		iNewNameTextControl->ResizeBy(200-iNewNameTextControl->Bounds().Width(),0);

	iOldNameTextControl->SetDivider(maxWidth);
	iOldNameTextControl->ResizeTo(iNewNameTextControl->Bounds().Width(), 
								   iOldNameTextControl->Bounds().Height()); 


	// OK button
	iOkButton=new BButton(BRect(), "RenameWindow::OKButton",
			"OK", new BMessage(MSG_RENAME_WINDOW_OK));
	iOkButton->ResizeToPreferred();
	iOkButton->MoveTo(iNewNameTextControl->Frame().left,iNewNameTextControl->Frame().bottom+10);
	iView->AddChild(iOkButton);
	iOkButton->MakeDefault(true);

	// Cancel All button
	iCancelAllButton=new BButton(BRect(), "RenameWindow::CancelAllButton",
			"Cancel All", new BMessage(MSG_RENAME_WINDOW_CANCEL_ALL));
	iCancelAllButton->ResizeToPreferred();
	iCancelAllButton->MoveTo(iOkButton->Frame().right+10,iOkButton->Frame().top);
	iView->AddChild(iCancelAllButton);
	if(!multiple)
		iCancelAllButton->SetEnabled(false);

	// Cancel button
	iCancelButton=new BButton(BRect(), "RenameWindow::CancelButton",
			"Cancel", new BMessage(MSG_RENAME_WINDOW_CANCEL));
	iCancelButton->ResizeToPreferred();
	iCancelButton->MoveTo(iCancelAllButton->Frame().right+10,iCancelAllButton->Frame().top);
	iView->AddChild(iCancelButton);
	
	// add window in tab-order
	iCancelAllButton->SetTarget(be_app);
	
	// re-size window
	rect.right=iCancelButton->Frame().right + 10;
	rect.bottom=iCancelButton->Frame().bottom + 10;
	ResizeTo(rect.right, rect.bottom);
	
	// disable editing of old-name
	iOldNameTextControl->TextView()->MakeEditable(false);
	iOldNameTextControl->TextView()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	// set focus to name field
	iNewNameTextControl->MakeFocus();
	iNewNameTextControl->TextView()->DisallowChar('/');
}			 	  
Beispiel #23
0
WorkspacesWindow::WorkspacesWindow(WorkspacesSettings *settings)
	:
	BWindow(settings->WindowFrame(), B_TRANSLATE_SYSTEM_NAME("Workspaces"),
		B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_AVOID_FRONT | B_WILL_ACCEPT_FIRST_CLICK | B_CLOSE_ON_ESCAPE,
		B_ALL_WORKSPACES),
	fSettings(settings),
	fSwitchOnWheel(false)
{
	// Turn window decor on to grab decor widths.
	BMessage windowSettings;
	float borderWidth = 0;

	SetLook(B_TITLED_WINDOW_LOOK);
	if (GetDecoratorSettings(&windowSettings) == B_OK) {
		BRect tabFrame = windowSettings.FindRect("tab frame");
		borderWidth = windowSettings.FindFloat("border width");
		fTabHeight = tabFrame.Height();
		fBorderWidth = borderWidth;
	}

	if (!fSettings->SettingsLoaded()) {
		// No settings, compute a reasonable default frame.
		// We aim for previews at 10% of actual screen size, and matching the
		// aspect ratio. We then scale that down, until it fits the screen.
		// Finally, we put the window on the bottom right of the screen so the
		// auto-raise mode can be used.

		BScreen screen;

		float screenWidth = screen.Frame().Width();
		float screenHeight = screen.Frame().Height();
		float aspectRatio = screenWidth / screenHeight;

		uint32 columns, rows;
		BPrivate::get_workspaces_layout(&columns, &rows);

		// default size of ~1/10 of screen width
		float workspaceWidth = screenWidth / 10;
		float workspaceHeight = workspaceWidth / aspectRatio;

		float width = floor(workspaceWidth * columns);
		float height = floor(workspaceHeight * rows);

		// If you have too many workspaces to fit on the screen, shrink until
		// they fit.
		while (width + 2 * borderWidth > screenWidth
				|| height + 2 * borderWidth + GetTabHeight() > screenHeight) {
			width = floor(0.95 * width);
			height = floor(0.95 * height);
		}

		BRect frame = fSettings->ScreenFrame();
		frame.OffsetBy(-2.0 * borderWidth, -2.0 * borderWidth);
		frame.left = frame.right - width;
		frame.top = frame.bottom - height;
		ResizeTo(frame.Width(), frame.Height());

		// Put it in bottom corner by default.
		MoveTo(screenWidth - frame.Width() - borderWidth,
			screenHeight - frame.Height() - borderWidth);

		fSettings->SetWindowFrame(frame);
	}

	if (!fSettings->HasBorder())
		SetLook(B_NO_BORDER_WINDOW_LOOK);
	else if (!fSettings->HasTitle())
		SetLook(B_MODAL_WINDOW_LOOK);

	AddChild(new WorkspacesView(Bounds()));

	if (fSettings->AlwaysOnTop())
		SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
	else
		SetAutoRaise(fSettings->AutoRaising());

	SetSwitchOnWheel(fSettings->SwitchOnWheel());
}
// constructor
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color,
                                   selected_color_mode mode,
                                   BWindow* window,
                                   BMessage* message, BHandler* target)
    : Panel(frame, "Pick Color",
            B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
            B_ASYNCHRONOUS_CONTROLS |
            B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE),
      fWindow(window),
      fMessage(message),
      fTarget(target)
{
    SetTitle(B_TRANSLATE("Pick a color"));

    fColorPickerView = new ColorPickerView("color picker", color, mode);

#if LIB_LAYOUT
    MButton* defaultButton = new MButton(B_TRANSLATE("OK"),
                                         new BMessage(MSG_DONE), this);

    // interface layout
    BView* topView = new VGroup (
        fColorPickerView,
        new MBorder (
            M_RAISED_BORDER, 5, "buttons",
            new HGroup (
                new Space(minimax(0.0, 0.0, 10000.0, 10000.0, 5.0)),
                new MButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL),
                            this),
                new Space(minimax(5.0, 0.0, 10.0, 10000.0, 1.0)),
                defaultButton,
                new Space(minimax(2.0, 0.0, 2.0, 10000.0, 0.0)),
                0
            )
        ),
        0
    );
#else // LIB_LAYOUT
    frame = BRect(0, 0, 40, 15);
    BButton* defaultButton = new BButton(frame, "ok button",
                                         B_TRANSLATE("OK"), new BMessage(MSG_DONE),
                                         B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    defaultButton->ResizeToPreferred();
    BButton* cancelButton = new BButton(frame, "cancel button",
                                        B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL),
                                        B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    cancelButton->ResizeToPreferred();

    frame.bottom = frame.top + (defaultButton->Frame().Height() + 16);
    frame.right = frame.left + fColorPickerView->Frame().Width();
    BBox* buttonBox = new BBox(frame, "button group",
                               B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM,
                               B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
                               B_PLAIN_BORDER);

    ResizeTo(frame.Width(),
             fColorPickerView->Frame().Height() + frame.Height() + 1);

    frame = Bounds();
    BView* topView = new BView(frame, "bg", B_FOLLOW_ALL, 0);
    topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    buttonBox->MoveTo(frame.left, frame.bottom - buttonBox->Frame().Height());

    defaultButton->MoveTo(frame.right - defaultButton->Frame().Width() - 10,
                          frame.top + 8);
    buttonBox->AddChild(defaultButton);

    cancelButton->MoveTo(defaultButton->Frame().left - 10
                         - cancelButton->Frame().Width(),
                         frame.top + 8);
    buttonBox->AddChild(cancelButton);

    topView->AddChild(fColorPickerView);
    topView->AddChild(buttonBox);
#endif // LIB_LAYOUT

    SetDefaultButton(defaultButton);

    if (fWindow)
        AddToSubset(fWindow);
    else
        SetFeel(B_FLOATING_APP_WINDOW_FEEL);

    AddChild(topView);
}
Beispiel #25
0
AboutWindow::AboutWindow ()
	: BWindow (BRect (0, 0, 300, 200), "About", B_MODAL_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE)
{
	PRINT (("AboutWindow::AboutWindow ()\n"));
	SetFeel (B_MODAL_APP_WINDOW_FEEL);
	SetLook (B_MODAL_WINDOW_LOOK);

	/* Create the BBitmap objects and set its data with error checking */
	BBitmap *appIcon = new BBitmap (BRect (0, 0, kLargeIconWidth - 1, kLargeIconHeight - 1), B_COLOR_8_BIT);
	appIcon->SetBits (iconBits, 32 * 32 * 8, 0, B_COLOR_8_BIT);
	BBitmap *bmp = BTranslationUtils::GetBitmap ('PNG ', "Image:AboutTitle");
	if (bmp == NULL)
	{
		BAlert *err = new BAlert ("Error", "An error was encountered while "
							"trying to load the resource element \"Image:AboutTitle\"\n", "Hmm..",
							NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT);
		err->Go();
		Hide();
		Quit();
		QuitRequested();
		return;
	}
	
	/* Yet another annoying control rendering section :( */
	BRect bounds (Bounds());
	backView = new BView (bounds.InsetBySelf (1, 1), "AboutWindow:BackView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
	AddChild (backView);

	iconView = new BView (BRect (1.5 * DialogMargin + 3, 1.5 * DialogMargin,
					1.5 * DialogMargin + kLargeIconWidth - 1 + 3, 1.5 * DialogMargin + kLargeIconWidth - 1),
					"AboutWindow:IconView", B_FOLLOW_LEFT, B_WILL_DRAW);
	backView->AddChild (iconView);
	iconView->SetViewBitmap (appIcon);
	
	float left = DialogMargin + kLargeIconWidth + 1.5 * ButtonSpacing - 3;
	float top = DialogMargin / 2.0;
	titleView = new BView (BRect (left, top, 214 + left, 58 + top), "AboutWindow:TitleView",
						B_FOLLOW_LEFT, B_WILL_DRAW);
	backView->AddChild (titleView);
	titleView->SetViewBitmap (bmp);
	
	lineView = new BView (BRect (0, titleView->Frame().bottom + 3, bounds.right, titleView->Frame().bottom + 3),
						"AboutWindow:LineView", B_FOLLOW_LEFT, B_WILL_DRAW);
	lineView->SetViewColor (128, 128, 128);
	backView->AddChild (lineView);
	
	textView = new MarqueeView (BRect (2, lineView->Frame().bottom + ButtonSpacing / 2 + 2,
									bounds.right - DialogMargin - 1, bounds.bottom - 2 - ButtonSpacing / 2),
									"AboutWindow:CreditsView", BRect (0, 0, bounds.right - DialogMargin, 0),
									B_FOLLOW_LEFT, B_WILL_DRAW);
	backView->AddChild (textView);
	textView->SetStylable (true);
	textView->MakeSelectable (false);
	textView->MakeEditable (false);
	textView->SetAlignment (B_ALIGN_CENTER);
	textView->SetViewColor (BePureWhite);
	backView->SetViewColor (BePureWhite);
	textView->SetFontAndColor (be_plain_font, B_FONT_ALL, &BeJetBlack);
	
	/* Calculate no of '\n's to leave to make the text go to the bottom, calculate the no. of lines */
	font_height fntHt;
	textView->GetFontHeight (&fntHt);
	int32 noOfLines = (int32)(textView->Frame().Height() / fntHt.ascent) - 1;
	for (int32 i = 1; i < (int32)noOfLines; i++)
		lineFeeds << "\n";

	creditsText =
		"Freeware, Version " AppVersion "\n"
		"Copyright " B_UTF8_COPYRIGHT " 2002 Ramshankar\n\n\n"
		CODING "\nRamshankar\n([email protected])\n\n* * *\n\n\n\n\n\n\n\n\n"

		THANKS_TO "\n\n"
		BUBBLEHELP "\nMarco Nelissen\n\n"
		BESHARE "\nJeremy Friesner\n\n"
		"Thank you all for your\n"
		"contributions with the code...\n\n* * *\n\n\n\n\n\n\n\n\n"
		"Also thanks to\n\n"
		"John Trujillo\nSebastian Benner\nM Floro\n\n"
		"for your support and contributions...\n\n* * *\n\n\n\n\n\n\n\n\n"
		"A special round of applause\n"
		"to BeShare members (in no\n"
		"particular order) :\n\n"
		"lillo\nshatty\nProcton\n"
		"Bryan\nPahtz\nmmu_man\nBeMikko\nNeil\nskiBUM\nand "
		"others\n\n"
		"for being so good... :)\n\n* * *\n\n\n\n\n\n\n\n\n"
		
		LEGAL_MUMBO_JUMBO "\n\n"
		"This program is distributed under\n"
		"its own license, and the gist of\n"
		"the license is attached to each\n"
		"source file of this program\n\n"
		
		"For third party code, the license's\n"
		"terms and conditions are explicitly\n"
		"stated and the author disclaimed of\n"
		"any and all liabilities\n\n"
		
		"For the full license read the\n"
		"file \"License.txt\" and for\n"
		"information on how to use this\n"
		"program read \"Readme.txt\"\n\n* * *\n\n\n\n\n\n\n\n\n"
		
		DISCLAIMER "\n\n"
		"Because the software is licensed\n"
		"free of charge, there is no warranty\n"
		"for the software. The copyright\n"
		"holders and/or other parties provide\n"
		"the software \"AS IS\" without warranty\n"
		"of any kind, either expressed or\n"
		"implied, including, but not limited to,\n"
		"the implied warranties of merchantability\n"
		"and fitness for a particular purpose.\n"
		"The entire risk as to the quality and\n"
		"performance of the software is with you.\n"
		"Should the software prove defective, you\n"
		"assume the cost of all necessary\n"
		"servicing, repair or correction.\n\n"
		
		"In no event will the copyright holder,\n"
		"or any other party who may modify and/or\n"
		"redistribute the software as permitted\n"
		"above, be liable to you for damages,\n"
		"including any general, special, incidental\n"
		"or consequential damages arising out of\n"
		"the use or inability to use the software\n"
		"(including but not limited to the loss of\n"
		"data or data being rendered inaccurate or\n"
		"losses sustained by you or third parties\n"
		"or a failure of the software to operate\n"
		"with any other programs), even if such\n"
		"holder or other party has been advised\n"
		"of the possibility of such damages.\n\n\n\n\n\n\n\n\n"
		
		FINAL_THANKS "\n\n"
		"Be, Inc., for making this OS\n"
		"in the first place\n\n"
		"OpenBeOS for their efforts to\n"
		"keep BeOS alive\n\n"
		"BeBits.com, BeGroovy.com, BeZip.de and\n"
		"other BeOS related sites for their\n"
		"continued enthusiasm and effort!\n\n"
		"BeOS programmers, designers, artists for\n"
		"their contributions to the OS' growth\n\n"
		"and a big applause goes to the Be\n"
		"community (it includes me too :)\n\n* * *\n\n\n\n\n\n\n\n\n"
		"OK... you can close this window now :)\n\n\n\n\n\n";
		
	textView->SetText (lineFeeds.String());
	textView->Insert (lineFeeds.Length(), creditsText, strlen(creditsText));
	
	int32 nSubHeadings = 4;
	BString subHeadings[] =
	{
		CODING,				// 0
		BUBBLEHELP,			// 2
		BESHARE,			// 3
		DISCLAIMER			// 4
	};

	int32 nMainHeadings = 3;
	BString mainHeadings[] =
	{
		THANKS_TO,			// 0
		LEGAL_MUMBO_JUMBO,	// 1
		FINAL_THANKS		// 2
	};
	
	/* Search and color sub headings */
	BString temp = textView->Text();
	int32 strt;
	for (int32 i = 0; i < nSubHeadings; i++)
	{
		if ((strt = temp.FindFirst (subHeadings[i].String())) != B_ERROR)
		{
			textView->SetFontAndColor (strt, strt + strlen(subHeadings[i].String()),
							be_plain_font, B_FONT_ALL, &TreeLabelColor);
		}
	}
	
	/* Search and color main headings */
	for (int32 i = 0; i < nMainHeadings; i++)
	{
		if ((strt = temp.FindFirst (mainHeadings[i].String())) != B_ERROR)
		{
			textView->SetFontAndColor (strt, strt + strlen(mainHeadings[i].String()),
							be_plain_font, B_FONT_ALL, &(rgb_color){0, 0, 200});
		}
	}
	
	/* Center window on-screen */
	BRect screen_rect (BScreen().Frame());
	MoveTo (screen_rect.Width() / 2 - Frame().Width() / 2, screen_rect.Height() / 2 - Frame().Height() / 2);

	/* Delete unwanted stuff */
	delete appIcon;
	delete bmp;

	/* Spawn & resume the scroller thread now */
	PRINT ((" >> spawning_thread: Magic_Scroll\n"));
	thread_id tid = spawn_thread (ScrollIt, "Magic_Scroll", B_NORMAL_PRIORITY, (void*)this);
	resume_thread (tid);
}
Beispiel #26
0
/*****************************************************************************
 * VideoWindow::MessageReceived
 *****************************************************************************/
void
VideoWindow::MessageReceived( BMessage *p_message )
{
    switch( p_message->what )
    {
        case SHOW_INTERFACE:
            SetInterfaceShowing( true );
            break;
        case TOGGLE_FULL_SCREEN:
            BWindow::Zoom();
            break;
        case RESIZE_50:
        case RESIZE_100:
        case RESIZE_200:
            if (IsFullScreen())
                BWindow::Zoom();
            _SetVideoSize(p_message->what);
            break;
        case VERT_SYNC:
            SetSyncToRetrace(!IsSyncedToRetrace());
            break;
        case WINDOW_FEEL:
            {
                window_feel winFeel;
                if (p_message->FindInt32("WinFeel", (int32*)&winFeel) == B_OK)
                {
                    SetFeel(winFeel);
                    fCachedFeel = winFeel;
                    if (winFeel == B_FLOATING_ALL_WINDOW_FEEL)
                        fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL);
                    else
                        fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL);
                }
            }
            break;
        case ASPECT_CORRECT:
            SetCorrectAspectRatio(!CorrectAspectRatio());
            break;

        case B_KEY_DOWN:
        case B_UNMAPPED_KEY_DOWN:
        case B_KEY_UP:
        case B_UNMAPPED_KEY_UP:
        {
            key_map * keys;
            char    * chars;
            int32     key, modifiers;

            if( p_message->FindInt32( "key", &key ) != B_OK ||
                p_message->FindInt32( "modifiers", &modifiers ) != B_OK )
            {
                /* Shouldn't happen */
                break;
            }

            if( ( p_message->what == B_KEY_UP ||
                  p_message->what == B_UNMAPPED_KEY_UP ) &&
                !( modifiers & B_COMMAND_KEY ) )
            {
                /* We only use the KEY_UP messages to detect Alt+X
                   shortcuts (because the KEY_DOWN messages aren't
                   sent when Alt is pressed) */
                break;
            }

            /* Special case for Alt+1, Alt+2 and Alt+3 shortcuts: since
               the character depends on the keymap, we use the key codes
               directly (18, 19, 20) */
            if( ( modifiers & B_COMMAND_KEY ) &&
                key >= 18 && key <= 20 )
            {
                if( key == 18 )
                    PostMessage( RESIZE_50 );
                else if( key == 19 )
                    PostMessage( RESIZE_100 );
                else
                    PostMessage( RESIZE_200 );

                break;
            }

            /* Get the current keymap */
            get_key_map( &keys, &chars );

            if( key >= 128 || chars[keys->normal_map[key]] != 1 )
            {
                /* Weird key or Unicode character */
                free( keys );
                free( chars );
                break;
            }

            vlc_value_t val;
            val.i_int = ConvertKeyToVLC( chars[keys->normal_map[key]+1] );

            if( modifiers & B_COMMAND_KEY )
            {
                val.i_int |= KEY_MODIFIER_ALT;
            }
            if( modifiers & B_SHIFT_KEY )
            {
                val.i_int |= KEY_MODIFIER_SHIFT;
            }
            if( modifiers & B_CONTROL_KEY )
            {
                val.i_int |= KEY_MODIFIER_CTRL;
            }
            var_Set( p_vout->p_libvlc, "key-pressed", val );

            free( keys );
            free( chars );
            break;
        }

        default:
            BWindow::MessageReceived( p_message );
            break;
    }
}
Beispiel #27
0
void
WorkspacesWindow::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case B_SIMPLE_DATA:
		{
			// Drop from Tracker
			entry_ref ref;
			for (int i = 0; (message->FindRef("refs", i, &ref) == B_OK); i++)
				be_roster->Launch(&ref);
			break;
		}

		case B_ABOUT_REQUESTED:
			PostMessage(message, ChildAt(0));
			break;

		case kMsgToggleBorder:
		{
			bool enable = false;
			if (Look() == B_NO_BORDER_WINDOW_LOOK)
				enable = true;

			if (enable)
				if (fSettings->HasTitle())
					SetLook(B_TITLED_WINDOW_LOOK);
				else
					SetLook(B_MODAL_WINDOW_LOOK);
			else
				SetLook(B_NO_BORDER_WINDOW_LOOK);

			fSettings->SetHasBorder(enable);
			break;
		}

		case kMsgToggleTitle:
		{
			bool enable = false;
			if (Look() == B_MODAL_WINDOW_LOOK
				|| Look() == B_NO_BORDER_WINDOW_LOOK)
				enable = true;

			if (enable)
				SetLook(B_TITLED_WINDOW_LOOK);
			else
				SetLook(B_MODAL_WINDOW_LOOK);

			// No matter what the setting for title, we must force the border on
			fSettings->SetHasBorder(true);
			fSettings->SetHasTitle(enable);
			break;
		}

		case kMsgToggleAutoRaise:
			SetAutoRaise(!IsAutoRaising());
			SetFeel(B_NORMAL_WINDOW_FEEL);
			break;

		case kMsgToggleAlwaysOnTop:
		{
			bool enable = false;
			if (Feel() != B_FLOATING_ALL_WINDOW_FEEL)
				enable = true;

			if (enable)
				SetFeel(B_FLOATING_ALL_WINDOW_FEEL);
			else
				SetFeel(B_NORMAL_WINDOW_FEEL);

			fSettings->SetAlwaysOnTop(enable);
			break;
		}

		default:
			BWindow::MessageReceived(message);
			break;
	}
}
GenesisCopyWindow::GenesisCopyWindow(CustomListView *list, PanelView *destpanel, const char *destination, BLooper* looper, BWindow *mainwindow) :
	BWindow(BRect(0,0,320,140), "Copy...", B_TITLED_WINDOW , B_WILL_DRAW)
////////////////////////////////////////////////////////////////////////
{
	BRect rect;

	m_CustomListView = list;
	m_DestPanel = destpanel;
	m_DestPath.SetTo(destination);
	m_Looper = looper;
	m_Window = mainwindow;

	m_SingleCopy = false;
	m_Paused = false;
	m_SkipAllCopyError = false;
	m_OverwriteAll = false;
	m_SkipSymLinkCreationError = false;

	// After the delete process we have to select an item if no item selected...
	m_Selection = GetFirstSelection();

	// First we have to remove the parent selection if selected...
//	RemoveParentSelection();

	m_FileCount = m_CustomListView->CountSelectedEntries(CT_WITHOUTPARENT);			

	if (m_FileCount == 1)
		m_SingleCopy = true;

	SetType(B_FLOATING_WINDOW);
	SetFeel(B_MODAL_SUBSET_WINDOW_FEEL);
	SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE);

	AddToSubset(mainwindow);

	m_View = new BView(Bounds(), "copyview", B_FOLLOW_ALL, B_WILL_DRAW);
	m_View->SetViewColor(216, 216, 216, 0);
	AddChild(m_View);

	// Bottom View	
	rect = Bounds();
	rect.top = rect.bottom-44;
	BView *BottomView = new BView(rect, "infobottomview", B_FOLLOW_BOTTOM, B_WILL_DRAW);
	BottomView->SetViewColor(180, 190, 200, 0);
	m_View->AddChild(BottomView);	
/*
	// More checkbox
	rect = BottomView->Bounds();
	rect.top = rect.bottom-30;
	rect.bottom = rect.bottom-14;
	rect.left = 20;
	rect.right = rect.left+40;	
	m_MoreCB = new BCheckBox(rect,"more","Show more",new BMessage(COPY_MORE), B_FOLLOW_BOTTOM, B_WILL_DRAW);
	m_MoreCB->ResizeToPreferred();
	BottomView->AddChild(m_MoreCB);
*/	
	// OK Button	
	rect = BottomView->Bounds();
	rect.top = rect.bottom-34;
	rect.bottom = rect.bottom-14;
	rect.left = rect.right-80;
	rect.right = rect.right-20;	
	m_CopyButton = new BButton(rect,"copy","Copy",new BMessage(BUTTON_MSG_COPY),B_FOLLOW_BOTTOM,B_WILL_DRAW);
	BottomView->AddChild(m_CopyButton);

	//Cancel Button
	rect = BottomView->Bounds();
	rect.top = rect.bottom-34;
	rect.bottom = rect.bottom-14;
	rect.left = rect.right-160;
	rect.right = rect.right-100;	
	m_CancelButton = new BButton(rect,"cancel","Cancel",new BMessage(BUTTON_MSG_CANCELCOPY),B_FOLLOW_BOTTOM,B_WILL_DRAW);
	BottomView->AddChild(m_CancelButton);

	SetDefaultButton(m_CopyButton);

	// Info string
	rect = Bounds();
	rect.left += 24;
	rect.right -= 24;
	if (m_SingleCopy)
		rect.top += 8;
	else
		rect.top += 16;
	rect.bottom = rect.top+20;
	m_Label = new BStringView(rect,"filename","Copy");
	m_Label->SetAlignment(B_ALIGN_CENTER);
	m_Label->SetViewColor(216,216,216);
	m_Label->SetLowColor(216,216,216);
	m_Label->SetHighColor(0,0,0);
	AddChild(m_Label);

	// Edit field
	rect = BottomView->Bounds();
	if (m_SingleCopy)
		rect.top = rect.top+36;
	else
		rect.top = rect.top+56;
	rect.bottom = rect.top+32;
	rect.left += 20;
	rect.right -= 20;
	m_DirName = new BTextControl( rect, "destname", "to", "", NULL );
	m_DirName->SetDivider(m_View->StringWidth("to")+4);
	m_DirName->SetModificationMessage(new BMessage(COPYNAME_CHANGED));
	m_DirName->SetText(m_DestPath.String());
	m_View->AddChild(m_DirName);

	// "as" field
	if (m_SingleCopy)
	{
		rect = BottomView->Bounds();
		rect.top = rect.top+64;
		rect.bottom = rect.top+32;
		rect.left += 20;
		rect.right -= 20;

		m_FileAsName = new BTextControl( rect, "destfilename", "as", "", NULL );
		m_FileAsName->SetDivider(m_View->StringWidth("to")+4);
		m_FileAsName->SetModificationMessage(new BMessage(COPYNAME_CHANGED));

		if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT)
			m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName.String() );
		else
			m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName.String() );
		
		m_View->AddChild(m_FileAsName);
	}

	m_DirName->MakeFocus(true);	
	
	// Ctrl + Q closes the window...
	AddShortcut('Q', 0, new BMessage(BUTTON_MSG_CANCELCOPY));

	// Set copy label...
	if (m_SingleCopy)
	{
		BString text;
		text.SetTo("Copy '");
		if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT)
			text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName;
		else
			text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName;
		text << "'";
	
		m_Label->SetText(text.String());
	}
	else
	{
		BString text;
		text.SetTo("Copy ");
		text << m_FileCount << " files";
		
		m_Label->SetText(text.String());
	}
	
	AddCommonFilter(new EscapeFilter(this, new BMessage(BUTTON_MSG_CANCELCOPY)));
	
	// If there is a given window, let's align our window to its center...
	if (mainwindow)
	{
		BRect myrect = Bounds();
		
		rect = mainwindow->Frame();
		float w = rect.right - rect.left;
		float h = rect.bottom - rect.top;
		MoveTo(rect.left + w/2 - (myrect.right-myrect.left)/2, rect.top + h/2 - (myrect.bottom-myrect.top)/2);
	}
}