Пример #1
0
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;
}
Пример #2
0
void
TTimeWindow::_InitWindow()
{
	SetPulseRate(500000);

	fDateTimeView = new DateTimeView(B_TRANSLATE("Date and time"));
	fTimeZoneView = new TimeZoneView(B_TRANSLATE("Time zone"));
	fNetworkTimeView = new NetworkTimeView(B_TRANSLATE("Network time"));
	fClockView = new ClockView(B_TRANSLATE("Clock"));

	fBaseView = new TTimeBaseView("baseView");
	fBaseView->StartWatchingAll(fDateTimeView);
	fBaseView->StartWatchingAll(fTimeZoneView);

	fTabView = new BTabView("tabView", B_WIDTH_FROM_WIDEST);
	fTabView->AddTab(fDateTimeView);
	fTabView->AddTab(fTimeZoneView);
	fTabView->AddTab(fNetworkTimeView);
	fTabView->AddTab(fClockView);

	fBaseView->AddChild(fTabView);

	fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
		new BMessage(kMsgRevert));
	fRevertButton->SetEnabled(false);
	fRevertButton->SetTarget(this);
	fRevertButton->SetExplicitAlignment(
		BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(fBaseView)
		.Add(fRevertButton);
}
Пример #3
0
TTracker::TTracker()
	:	BApplication(kTrackerSignature),
	fSettingsWindow(NULL)
{
	// set the cwd to /boot/home, anything that's launched 
	// from Tracker will automatically inherit this 
	BPath homePath;
	
	if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK)
		chdir(homePath.Path());
	
	_kset_fd_limit_(512);
		// ask for a bunch more file descriptors so that nested copying
		// works well
	
	fNodeMonitorCount = DEFAULT_MON_NUM;

#ifdef CHECK_OPEN_MODEL_LEAKS
	InitOpenModelDumping();
#endif

	InitIconPreloader();

#ifdef LEAK_CHECKING
	SetNewLeakChecking(true);
	SetMallocLeakChecking(true);
#endif

	//This is how often it should update the free space bar on the volume icons
	SetPulseRate(1000000);
}
Пример #4
0
DTipWindow::DTipWindow(void)
	:	BWindow(BRect(0,0,1,1),"DToolTipWindow",B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
	                B_NOT_MOVABLE | B_AVOID_FOCUS)
{
	fView = new DTipWatcherView();
	AddChild(fView);
	SetPulseRate(100000);
}
Пример #5
0
App::App()
	:
	BApplication("application/x-vnd.Haiku-LaunchBox"),
	fSettingsChanged(false),
	fNamePanelSize(200, 50),
	fAutoStart(false)
{
	SetPulseRate(3000000);
}
Пример #6
0
MixerWindow::MixerWindow(	BRect r,
							const char* inTitle,
							ulong inFlags,
							MixerView *mv)
	: BWindow( r, inTitle, B_TITLED_WINDOW, inFlags )
{
	AddChild(mv);
	SetPulseRate(100000);
}
Пример #7
0
MainWindow::MainWindow(BRect frame) 
	: BWindow(frame, "Torrentor!", B_DOCUMENT_WINDOW, 
			  B_AUTO_UPDATE_SIZE_LIMITS |
			  B_ASYNCHRONOUS_CONTROLS | 
			  B_NOT_ZOOMABLE )
{
	SetPulseRate(1000000);
	
	//
	//
	//
	SetLayout(new BGroupLayout(B_VERTICAL, 0.0));
	
	CreateMenuBar();
	
	
	fDownloadView 	= new DownloadView;
	
	
//	BStringView* fStatusText = new BStringView("status", "Laralala");
//	fStatusText->SetAlignment(B_ALIGN_LEFT);
//	fStatusText->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
///	fStatusText->SetExplicitMinSize(BSize(150, 12));

	
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
		.Add(fMenuBar)
		.Add(fDownloadView->ScrollView())
/*
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
			.AddGlue()
			.Add(fRemoveMissingButton)
			.Add(fRemoveFinishedButton)
			.SetInsets(12, 5, 12, 5)
		)*/
	);


	//
	//
	//
	fOpenPanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_FILE_NODE, true, NULL, 
								new TorrentRefFilter);
								
	//
	//
	//
	fPreferencesWindow = new PreferencesWindow();




	//
	CenterOnScreen();
}
Пример #8
0
void
DjVuApp::StartPulse()
{
	if (!fPulseStarted) {
		// Tell the app to begin checking
		// for the number of open windows
		fPulseStarted = true;
		SetPulseRate(250000);
			// Set pulse to every 1/4 second
	}
}
Пример #9
0
WorkWindow::WorkWindow(BRect rect)
	: BWindow(rect, "Work Window", B_TITLED_WINDOW, B_WILL_DRAW)
{
	SetPulseRate(1000000); // pulse once every 2 seconds
	
	WorkView *pView;
	BRect viewrect(Bounds());
	pView = new WorkView(viewrect);
	
	AddChild(pView);
}
Пример #10
0
TWindow::TWindow(ERect frame, const char *title, e_window_type type, euint32 flags, euint32 workspace)
	: EWindow(frame, title, type, flags, workspace)
{
	EView *view = new TView(frame.OffsetToCopy(E_ORIGIN), NULL, E_FOLLOW_ALL, E_WILL_DRAW | E_FRAME_EVENTS);
	AddChild(view);

	SetBackgroundColor(view->ViewColor());

#if TEST_STATUSBAR
	SetPulseRate(100000);
#endif
}
Пример #11
0
MouseWindow::MouseWindow(BRect _rect)
	: 
		BWindow(_rect, TR("Mouse"), B_TITLED_WINDOW, 
			B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
				B_AUTO_UPDATE_SIZE_LIMITS)
{
	// Add the main settings view
	fSettingsView = new SettingsView(fSettings);
	fSettingsBox = new BBox("main box");
	fSettingsBox->AddChild(fSettingsView);

	// Add the "Default" button
	fDefaultsButton = new BButton(TR("Defaults"), new BMessage(kMsgDefaults));
	fDefaultsButton->SetEnabled(fSettings.IsDefaultable());

	// Add the "Revert" button
	fRevertButton = new BButton(TR("Revert"), new BMessage(kMsgRevert));
	fRevertButton->SetEnabled(false);

	SetPulseRate(100000);
		// we are using the pulse rate to scan pressed mouse
		// buttons and draw the selected imagery

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

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

	// check if the window is on screen
	BRect rect = BScreen().Frame();
	rect.InsetBySelf(20, 20);

	BPoint position = fSettings.WindowPosition();
	BRect windowFrame = Frame().OffsetToSelf(position);
	if (!rect.Contains(windowFrame)) {
		// center window on screen as it doesn't fit on the saved position
		position.x = (rect.Width() - windowFrame.Width()) / 2;
		position.y = (rect.Height() - windowFrame.Height()) / 2;
		if (position.x < 0)
			position.x = 0;
		if (position.y < 0)
			position.y = 15;
	}
	MoveTo(position);
}
Пример #12
0
void 
TTimeWindow::_InitWindow()
{
	SetPulseRate(500000);

	fDateTimeView = new DateTimeView(Bounds());
	
	BRect bounds = fDateTimeView->Bounds();
	fTimeZoneView = new TimeZoneView(bounds);

	fBaseView = new TTimeBaseView(bounds, "baseView");
	AddChild(fBaseView);
	
	fBaseView->StartWatchingAll(fDateTimeView);
	fBaseView->StartWatchingAll(fTimeZoneView);

	bounds.OffsetBy(10.0, 10.0);
	BTabView *tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
		"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
	
	BTab *tab = new BTab();
	tabView->AddTab(fDateTimeView, tab);
	tab->SetLabel("Date & Time");

	tab = new BTab();
	tabView->AddTab(fTimeZoneView, tab);
	tab->SetLabel("Time zone");

	fBaseView->AddChild(tabView);
	tabView->ResizeBy(0.0, tabView->TabHeight());

	BRect rect = Bounds();

	rect.left = 10;
	rect.top = rect.bottom - 10;

	fRevertButton = new BButton(rect, "revert", "Revert",
		new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	
	fRevertButton->ResizeToPreferred();
	fRevertButton->SetEnabled(false);
	float buttonHeight = fRevertButton->Bounds().Height();
	fRevertButton->MoveBy(0, -buttonHeight);
	fBaseView->AddChild(fRevertButton);
	fRevertButton->SetTarget(this);

	fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0, 
		tabView->Bounds().Height() + buttonHeight + 30.0);

	ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
}
ApplicationWindow::ApplicationWindow(BRect frame, bool visible)
	:
	BWindow(frame, B_TRANSLATE_SYSTEM_NAME("PackageManager"),
		B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fMinimizeOnClose(false)
{
	SetPulseRate(1000000);

	SetLayout(new BGroupLayout(B_VERTICAL, 0.0));

	ApplicationsContainerView* downloadsGroupView = new ApplicationsContainerView();
	fApplicationViewsLayout = downloadsGroupView->GroupLayout();

	BMenuBar* menuBar = new BMenuBar("Menu bar");
	BMenu* menu = new BMenu("Actions");
	menu->AddItem(new BMenuItem("Apply changes",
		new BMessage('NADA')));
	menu->AddItem(new BMenuItem("Exit", new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(menu);

	fApplicationsScrollView = new ApplicationContainerScrollView(downloadsGroupView);

	fDiscardButton = new BButton("Revert",
		new BMessage('NADA'));
	fDiscardButton->SetEnabled(false);

	fApplyChangesButton = new BButton("Apply",
		new BMessage('NADA'));
	fApplyChangesButton->SetEnabled(false);

	const float spacing = be_control_look->DefaultItemSpacing();

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
		.Add(menuBar)
		.Add(fApplicationsScrollView)
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
			.AddGlue()
			.Add(fApplyChangesButton)
			.Add(fDiscardButton)
			.SetInsets(12, 5, 12, 5)
		)
	);

	PostMessage(INIT);

	if (!visible)
		Hide();
	Show();
}
Пример #14
0
ProtocolWindow::ProtocolWindow(BRect frame, const char *title, window_type type, int stream)
			:BWindow(frame, title, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_PULSE_NEEDED|B_ASYNCHRONOUS_CONTROLS) {
	SetSizeLimits(300, 10000, 150, 10000);
	fStream=stream;
	mb=new BMenuBar(BRect(0,0,frame.Width(),1), _T("File")); // "TMI_FILE"
	mainM=new BMenu(_T("File")); // "TMI_FILE"
	clearMI=new BMenuItem(_T("Clear"), new BMessage(LOG_CLEAR), 'C'); // "TMI_CLEAR"
	closeMI=new BMenuItem(_T("Close"), new BMessage(B_QUIT_REQUESTED), 'W'); // ""TMI_CLOSE"
	
	logfileM=new BMenu(_T("Log file")); // "TMI_LOG_FILE"
	enablefileloggingMI=new BMenuItem(_T("Log to file"), // "TMI_ENABLE_LOG_FILE"
				new BMessage(ENABLE_LOG_FILE_MSG),'L');
				
	BString tmpstring;
	tmpstring << _T("Set file") << B_UTF8_ELLIPSIS; // "TMI_SETLOGFILENAME"
	setlognameMI=new BMenuItem( tmpstring.String(), new BMessage(SETLOGFILE_MSG));
	tmpstring = "";
	tmpstring << _T("Log settings") << B_UTF8_ELLIPSIS; // "TMI_SETLOGFILENAME"
	logsettingsMI=new BMenuItem( tmpstring.String(),
				new BMessage(LOGSETTINGS_MSG));
	
	contentView=new ProtocolView(BRect(0,0,frame.Width()-B_V_SCROLL_BAR_WIDTH, frame.Height()-(B_H_SCROLL_BAR_HEIGHT)), "contentView", BRect(1,1,2000,1000),B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_PULSE_NEEDED, fStream);
	scrollView=new BScrollView("scrollView", contentView, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, 0, true, true, B_NO_BORDER);
	AddChild(scrollView);
	AddChild(mb);
	mb->AddItem(mainM);
	mainM->AddItem(clearMI);
	mainM->AddItem(closeMI);
	
	mb->AddItem(logfileM);
	logfileM->AddItem(enablefileloggingMI);
	logfileM->AddItem(setlognameMI);
	////////////////////////////////////////////////
	//logfileM->AddItem(logsettingsMI);
	
	logfileF=new BFile();
	logfilenameS="";
	datewritten=false;

//	contentView=new BTextView(BRect(0,0,frame.Width()-B_V_SCROLL_BAR_WIDTH, frame.Height()-B_H_SCROLL_BAR_HEIGHT), "contentView", frame,B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
//	scrollView=new BScrollView("scrollView", contentView, B_FOLLOW_ALL_SIDES, 0, true, true);
	SetPulseRate(0);
//	reader_sem=create_sem(1, "ProtocolWindow(): reader_sem");
	SetLook(B_DOCUMENT_WINDOW_LOOK);
	contentView->MakeEditable(false);
	contentView->MakeResizable(false);
	contentView->SetStylable(true);
	
	MoveTo(40,40);
	contentView->MakeFocus(true);	
}
Пример #15
0
Window::Window()
	:
	BWindow(BRect(100, 100, 520, 430), "ToolTip-Test",
		B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
	BView* simple = new BStringView("1", "Simple Tool Tip");
	simple->SetToolTip("This is a really\nsimple tool tip!");

	BView* custom = new BStringView("2", "Custom Tool Tip");
	custom->SetToolTip(new CustomToolTip("Custom tool tip!"));

	BView* changing = new BStringView("3", "Changing Tool Tip");
	changing->SetToolTip(new ChangingToolTip());

	BView* mouse = new BStringView("4", "Mouse Tool Tip (sticky)");
	mouse->SetToolTip(new MouseToolTip());

	BView* immediate = new ImmediateView("5", "Immediate Tool Tip (sticky)");

	BView* pulseString = new PulseStringView("pulseString",
		"Periodically changing tool tip text");

	BView* pulseToolTip = new PulseToolTipView("pulseToolTip",
		"Periodically changing tool tip");

	BGroupView* nested = new BGroupView();
	nested->SetViewColor(50, 50, 90);
	nested->GroupLayout()->SetInsets(30);
	nested->SetToolTip("The outer view has a tool tip,\n"
		"the inner one doesn't.");
	nested->AddChild(new BGroupView("inner"));

	BLayoutBuilder::Group<>(this, B_HORIZONTAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL)
			.Add(simple)
			.Add(custom)
			.Add(changing)
			.Add(mouse)
			.Add(immediate)
			.End()
		.AddGroup(B_VERTICAL)
			.Add(pulseString)
			.Add(pulseToolTip)
			.Add(nested);

	SetPulseRate(1000000LL);
}
Пример #16
0
bool ProtocolWindow::QuitRequested() {
	if (IsHidden()) { MoveTo(100000,100000);Show();Hide();}
	while (!IsHidden()) Hide();
	SetPulseRate(0);
	
	// Wait until the app deals with this message before closing down.
	// This is to allow GUI updates, etc.
#if defined(_BEOS_R5_BUILD_) || defined(_BEOS_HAIKU_BUILD_)
	BMessenger(be_app).SendMessage(PROTOCOL_WINDOW_CLOSED_MSG);
#else
	BMessage protocolWindowClosed(PROTOCOL_WINDOW_CLOSED_MSG);
	BMessenger(be_app).SendMessage(protocolWindowClosed);
#endif
	BWindow::QuitRequested();
	return false;
}
Пример #17
0
MagWindow::MagWindow (BRect frame, const char *name, CanvasView *_myView)
: BWindow (frame, name, B_DOCUMENT_WINDOW, 0, 0)
{
	BRect viewFrame, hFrame, vFrame, menubarFrame;
	menubarFrame.Set (0, 0, 0, 0);
	menubar = new BMenuBar (menubarFrame, "Magnify Menubar");
	BPopUpMenu *zoomMenu = new BPopUpMenu ("");
	zoomMenu->AddItem (new BMenuItem ("1:2", new BMessage ('zm2')));
	zoomMenu->AddItem (new BMenuItem ("1:4", new BMessage ('zm4')));
	zoomMenu->AddItem (new BMenuItem ("1:8", new BMessage ('zm8')));
	zoomMenu->AddItem (new BMenuItem ("1:16", new BMessage ('zm16')));
	zoomMenu->FindItem('zm8')->SetMarked (true);
	menubar->AddItem (zoomMenu);
	BPopUpMenu *gridMenu = new BPopUpMenu ("");
	gridMenu->AddItem (new BMenuItem (lstring (410, "Grid off"), new BMessage ('grd0')));
	gridMenu->AddItem (new BMenuItem (lstring (411, "Grid B"), new BMessage ('grdB')));
	gridMenu->AddItem (new BMenuItem (lstring (412, "Grid W"), new BMessage ('grdW')));
	gridMenu->FindItem('grdB')->SetMarked (true);
	menubar->AddItem (gridMenu);
	editMenu = new BMenu (lstring (60, ""));
	editMenu->AddItem (new BMenuItem (lstring (61, "Undo"), new BMessage (B_UNDO), 'Z'));
	editMenu->AddItem (new BMenuItem (lstring (62, "Redo"), new BMessage ('redo'), 'Z', B_SHIFT_KEY));
	menubar->AddItem (editMenu);
	AddChild (menubar);
	menubar->ResizeToPreferred();
	menubarFrame = menubar->Frame();
	menubarheight = menubarFrame.Height();
	viewFrame.Set (0, menubarheight + 1,
		frame.Width() - B_V_SCROLL_BAR_WIDTH,
		frame.Height() - B_H_SCROLL_BAR_HEIGHT);
	magView = new MagView (viewFrame, "Magnify View", _myView);
	hFrame.Set (0, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1,
		frame.Width() - B_V_SCROLL_BAR_WIDTH + 1,
		frame.Height() + 1);
	h = new BScrollBar (hFrame, NULL, magView, 0, 0, B_HORIZONTAL);
	vFrame.Set (frame.Width() - B_V_SCROLL_BAR_WIDTH + 1,
		menubarFrame.Height(), frame.Width() + 1,
		frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1);
	v = new BScrollBar (vFrame, NULL, magView, 0, 0, B_VERTICAL);
	AddChild (h);
	AddChild (v);
	magView->setScrollBars (h, v);
	AddChild (magView);
	myWindow = _myView->Window();
	SetPulseRate (50000);
}
Пример #18
0
	Application()
		: BApplication("application/x-vnd.stippi-async.drawing")
		, fDelay(true)
	{
		BWindow* window = new BWindow(BRect(50, 50, 350, 250),
			"Test Window", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
			B_QUIT_ON_WINDOW_CLOSE);
		fView = new View(window->Bounds(), 255, 80, 155, 128);
		window->AddChild(fView);
		window->Show();

		window = new BWindow(BRect(150, 150, 450, 350),
			"Drag Window", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
			B_QUIT_ON_WINDOW_CLOSE);
		window->Show();

		SetPulseRate(100000);
	}
BStatusWindow::BStatusWindow()
	:
	BWindow(kStatusRect, B_TRANSLATE("Tracker status"),	B_TITLED_WINDOW,
		B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES),
	fRetainDesktopFocus(false)
{
	SetSizeLimits(0, 100000, 0, 100000);
	fMouseDownFilter = new BStatusMouseFilter();
	AddCommonFilter(fMouseDownFilter);

	BView* view = new StatusBackgroundView(Bounds());
	AddChild(view);

	SetPulseRate(1000000);

	Hide();
	Show();
}
Пример #20
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();
}
Пример #21
0
TTracker::TTracker()
    :	BApplication(kTrackerSignature),
      fSettingsWindow(NULL)
{
    // set the cwd to /boot/home, anything that's launched
    // from Tracker will automatically inherit this
    BPath homePath;

    if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK)
        chdir(homePath.Path());

    // ask for a bunch more file descriptors so that nested copying works well
    struct rlimit rl;
    rl.rlim_cur = 512;
    rl.rlim_max = RLIM_SAVED_MAX;
    setrlimit(RLIMIT_NOFILE, &rl);

    fNodeMonitorCount = DEFAULT_MON_NUM;

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

#ifdef CHECK_OPEN_MODEL_LEAKS
    InitOpenModelDumping();
#endif

    InitIconPreloader();

#ifdef LEAK_CHECKING
    SetNewLeakChecking(true);
    SetMallocLeakChecking(true);
#endif

    // This is how often it should update the free space bar on the
    // volume icons
    SetPulseRate(1000000);

    gLaunchLooper = new LaunchLooper();
    gLaunchLooper->Run();
}
Пример #22
0
CSumItApplication::CSumItApplication()
	  : BApplication(kOpenSumItSignature)
{
#if PRERELEASE
//	{
//		time_t now, expire;
//		time(&now);
//		expire = parsedate("nov 1, 1997", now);
//		printf("expire at %08x\n", expire);
//		expire = 0x345a62f0;

//		if (difftime(now, expire) > 0) {
//			MAlert *a = new MWarningAlert("This version of sum-it has expired");
//			a->Go();
//			exit(1);
//		}
//		TimeLimit limit;
//	}
#endif

	try
	{
		gApp = this;
		
		app_info ai;
		GetAppInfo(&ai);
		
		BEntry entry(&ai.ref);
		entry.GetPath(&gAppName);
		
		BPath dir;
		gAppName.GetParent(&dir);
		gAppDir = new BDirectory(dir.Path());
		gCWD = new BDirectory(*gAppDir);
			
		gResourceManager.SetTo( &gAppName ) ;
		InitFunctions();
		srand((int)(system_time() % INT_MAX));
			
		try
		{
			gPrefs = new CPreferences("Sum-It.Prefs");
			gPrefs->ReadPrefFile();
		}
		catch (CErr& e)
		{
			CATCHED;
			if (e != errIOOpen)
			{
				e.DoError();
				exit(1);
			}
		}
	
		gErrorNan = Nan(1);
		gRefNan = Nan(3);
		gCircleNan = Nan(4);
		gSqrtNan = Nan(5);
		gPowerNan = Nan(6);
		gValueNan = Nan(7);
		gDivNan = Nan(8);
		gAddNan = Nan(9);
		gFinanceNan = Nan(10);
		gEvalNan = Nan(11);
		gInvTrigNan = Nan(12);
		gLogNan = Nan(13);
		gMulNan = Nan(14);
		gNANan = Nan(15);
		gDateNan = Nan(16);
		gTimeNan = Nan(17);
//		gCellNan = Nan(18);
		gFuncNan = Nan(19);
		gNameNan = Nan(20);
		
		font_family fam;
		font_style sty;
		float siz;
		
		be_plain_font->GetFamilyAndStyle(&fam, &sty);
		siz = be_plain_font->Size();
		
		gFontSizeTable.GetFontID(
			gPrefs->GetPrefString("defdoc font family", fam),
			gPrefs->GetPrefString("defdoc font style", sty),
			gPrefs->GetPrefDouble("defdoc font size", siz),
			kBlack);
		
		InitFormatter();
		
		fOpenPanel = NULL;
		
		gClipboard = new CClipboard;
		gClipboard->Run();

		fFindDialog = CFindDialog::Construct();
		fFindDialog->Run();
		
		gWithEqualSign = gPrefs->GetPrefInt("formula starts with equal", 0);
		gGridColor = gPrefs->GetPrefInt("dark gridlines") ? 10 : 6;
		
		InstallMimeType();
		
		SetPulseRate(1000000);
	}
	
	catch (CErr& e)
	{
		CATCHED;
		e.DoError();
		exit(1);
	}
	
	catch (...)
	{
		CATCHED;
		ASSERT(false);
	}
}
Пример #23
0
void TCueSheetWindow::Init()
{
	// Init Undo Engine
	fUndoEngine = new TUndoEngine();

	// Member file used for saves
	fFile = NULL;

	// Dialog box state
	fPanelOpen = false;

	// Create the stage window
	BRect stageRect(0,0,420,340);
	fStageWindow = new TStageWindow(stageRect, this);
	CenterWindow(fStageWindow);

	// Set up menu bar
	BRect mbarRect = Bounds();
	mbarRect.bottom = mbarRect.top+kMenuHeight;
	BMenuBar* mbar = new BMenuBar(mbarRect, "MuseumMenu");

	// Set up application menus.
	// Create a new TMuseumMenu object and pass the  BMenuBar object in to the constructor.
	// Then add the individual menu items with the TMuseumMenu object
	fAppMenu = new TMuseumMenus(mbar);

	AddChild(mbar);

	//      Set the channel length to an hour duration in milliseconds
	float channelLength = TimeToPixels( 60 * 60 * 1000L, B_TIMECODE_24, 3);

	//      Create Toolbar.  It is always at the top of the window, below the menu.
	BRect toolRect = Bounds();
	toolRect.Set(toolRect.left, kMenuHeight, toolRect.right, kMenuHeight+kToolbarHeight);
	fToolbar = new TToolbar(toolRect, this);
	AddChild(fToolbar);
	fToolbar->Show();

	//      Create ExportTimeView.  It is always located below the toolbar and to the
	//      very left of the cue sheet.  It is as wide as the cue sheet headers.
	BRect exportTimeRect;
	exportTimeRect.left             = fToolbar->Frame().left;
	exportTimeRect.top              = fToolbar->Frame().bottom+1;
	exportTimeRect.right    = exportTimeRect.left + kHeaderWidth;
	exportTimeRect.bottom   = exportTimeRect.top + kExportZoneHeight + 11;
	fExportTimeView = new TExportTimeView(this, exportTimeRect);
	AddChild(fExportTimeView);
	fExportTimeView->Show();

	//      Create CueSheet Time Zone.  It is always located below the toolbar and to the
	//      very left of the cue sheet.  It is as wide as the cue sheet headers.
	BRect zoneRect;
	zoneRect.left   = exportTimeRect.left;
	zoneRect.top    = exportTimeRect.bottom+1;
	zoneRect.right  = zoneRect.left+kHeaderWidth;
	zoneRect.bottom = zoneRect.top + kTimelineHeight - 11;
	fTimeZone = new TCueSheetTimeView(this, zoneRect);
	AddChild(fTimeZone);
	fTimeZone->Show();

	//	Create ExportZone.  It is always located below the toolbar and to the right
	//	of the TimeZone.  This is where the user determines the span of the cue sheet
	//	to preview or export
	BRect exportRect;
	exportRect.left         = zoneRect.right + 1;
	exportRect.top          = fToolbar->Frame().bottom+1;
	exportRect.right        = Bounds().right;
	exportRect.bottom   = exportRect.top + kExportZoneHeight;
	fExportZone = new TExportZone(exportRect, this);
	AddChild(fExportZone);
	fExportZone->Show();

	//      Create Timeline.  It is always located below the toolbar and to the right
	//	of the TimeZone.  This is where the time is indicated and the playback head resides
	BRect timeRect;
	timeRect.left   = exportRect.left;
	timeRect.top    = exportRect.bottom + 1;
	timeRect.right  = Bounds().right;
	timeRect.bottom = timeRect.top + kTimelineHeight;
	fTimeline = new TTimelineView(timeRect, this);
	AddChild(fTimeline);
	fTimeline->Show();

	// Create Header Container View
	BRect containerRect  = Bounds();
	containerRect.top    = fTimeline->Frame().bottom;
	containerRect.right  = containerRect.left + kHeaderWidth;
	containerRect.bottom -= kScrollHeight+1;
	fHeaderContainer = new THeaderContainerView(containerRect);
	AddChild(fHeaderContainer);
	fHeaderContainer->SetViewColor(kMediumGrey);


	// Create cue sheet view.  Add one pixel to left to fix drawing bug with header...
	BRect bounds = fTimeline->Frame();
	bounds.Set(bounds.left, bounds.bottom+1, Bounds().right-(kScrollWidth+1), Bounds().bottom - (kScrollHeight+1));
	fCueSheetView = new TCueSheetView(bounds, this);
	fCueSheetView->SetViewColor(kGrey);


	//
	// Create scroll bars
	//

	// Horizontal
	BRect scrollRect = Bounds();
	scrollRect.Set(scrollRect.left+kTimeScalerWidth, scrollRect.bottom-kScrollHeight, scrollRect.right-kScrollWidth, scrollRect.bottom);
	fHScroll = new TCueSheetScrollBarH(this, scrollRect, NULL, 0, channelLength);
	AddChild(fHScroll);
	fHScroll->SetSteps(kTickSpacing, kTickSpacing*4);

	// Vertical
	scrollRect = Bounds();
	scrollRect.Set(scrollRect.right-kScrollWidth, scrollRect.top + (fTimeline->Frame().bottom+1), scrollRect.right, scrollRect.bottom-kScrollHeight);
	fVScroll = new TCueSheetScrollBarV(this, scrollRect, fCueSheetView, 0, channelLength);
	AddChild(fVScroll);
	fVScroll->SetSteps(kTickSpacing, kTickSpacing*4);

	// Create TimeScaler
	BRect scalerRect(0, Bounds().bottom-14,kTimeScalerWidth, Bounds().bottom);
	fTimeScaler = new TTimeScalerView(scalerRect, fCueSheetView);
	AddChild(fTimeScaler);

	// Limit the window size
	SetSizeLimits( 280, 1500, 280, 1500);

	// Add CueSheetView to frame
	AddChild(fCueSheetView);

	// Adjust the scroll bars
	AdjustScrollBars();

	// Add ourself to cue sheet list
	static_cast<MuseumApp*>(be_app)->GetCueSheetList()->AddItem(this);

	// Create the video engine
	fVideoEngine = new TVideoEngine(fCueSheetView);
	ASSERT(fVideoEngine);

	//	Create audio engine
	fAudioEngine = new TAudioEngine();

	// Set Pulse rate for views that need it
	SetPulseRate(5000);
}
Пример #24
0
void ProtocolWindow::Start(int stream) {
	contentView->Start(stream);
	SetPulseRate(1000000);
}
Пример #25
0
TTracker::TTracker()
	:
	BApplication(kTrackerSignature),
	fMimeTypeList(NULL),
	fClipboardRefsWatcher(NULL),
	fTrashWatcher(NULL),
	fTaskLoop(NULL),
	fNodeMonitorCount(-1),
	fWatchingInterface(new WatchingInterface),
	fSettingsWindow(NULL)
{
	BPathMonitor::SetWatchingInterface(fWatchingInterface);

	// set the cwd to /boot/home, anything that's launched
	// from Tracker will automatically inherit this
	BPath homePath;

	if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK)
		chdir(homePath.Path());

	// ask for a bunch more file descriptors so that nested copying works well
	struct rlimit rl;
	rl.rlim_cur = 512;
	rl.rlim_max = RLIM_SAVED_MAX;
	setrlimit(RLIMIT_NOFILE, &rl);

	fNodeMonitorCount = DEFAULT_MON_NUM;

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

#ifdef CHECK_OPEN_MODEL_LEAKS
	InitOpenModelDumping();
#endif

	InitIconPreloader();

#ifdef LEAK_CHECKING
	SetNewLeakChecking(true);
	SetMallocLeakChecking(true);
#endif

	// This is how often it should update the free space bar on the
	// volume icons
	SetPulseRate(1000000);

	gLaunchLooper = new LaunchLooper();
	gLaunchLooper->Run();

	// open desktop window
	BContainerWindow* deskWindow = NULL;
	BDirectory deskDir;
	if (FSGetDeskDir(&deskDir) == B_OK) {
		// create desktop
		BEntry entry;
		deskDir.GetEntry(&entry);
		Model* model = new Model(&entry, true);
		if (model->InitCheck() == B_OK) {
			AutoLock<WindowList> lock(&fWindowList);
			deskWindow = new BDeskWindow(&fWindowList);
			AutoLock<BWindow> windowLock(deskWindow);
			deskWindow->CreatePoseView(model);
			deskWindow->Init();

			if (TrackerSettings().ShowDisksIcon()) {
				// create model for root of everything
				BEntry entry("/");
				Model model(&entry);
				if (model.InitCheck() == B_OK) {
					// add the root icon to desktop window
					BMessage message;
					message.what = B_NODE_MONITOR;
					message.AddInt32("opcode", B_ENTRY_CREATED);
					message.AddInt32("device", model.NodeRef()->device);
					message.AddInt64("node", model.NodeRef()->node);
					message.AddInt64("directory",
						model.EntryRef()->directory);
					message.AddString("name", model.EntryRef()->name);
					deskWindow->PostMessage(&message, deskWindow->PoseView());
				}
			}
		} else
			delete model;
	}
}
Пример #26
0
AddTorrentWindow::AddTorrentWindow(TorrentObject* torrent)
	:	BWindow(BRect(),
				"Add torrent", 
				B_TITLED_WINDOW_LOOK,
				B_NORMAL_WINDOW_FEEL, 
				B_AUTO_UPDATE_SIZE_LIMITS |
				B_ASYNCHRONOUS_CONTROLS |
				B_NOT_ZOOMABLE |
				B_NOT_RESIZABLE |
				B_PULSE_NEEDED ),
		fTorrent(torrent),
		fCancelAdd(true)
{
	SetPulseRate(1000000);
	SetLayout(new BGroupLayout(B_VERTICAL));	
	
	float spacing = be_control_look->DefaultItemSpacing();
	
	//
	//
	//
	fInfoHeaderView = new InfoHeaderView(fTorrent);
	fFileList		= new BColumnListView("FileList", 0, B_PLAIN_BORDER, true);
	fStartCheckBox 	= new BCheckBox("", "Start when added", NULL);
	fCancelButton	= new BButton("Cancel", new BMessage(B_QUIT_REQUESTED));
	fAddButton		= new BButton("Add", new BMessage(MSG_BUTTON_ADD));
	fLoadingView	= new BStatusBar("", "Downloading Metadata");
	fLoadingView->SetBarHeight(12);
	fLoadingView->SetMaxValue(1.0);
	
	if( !fTorrent->IsMagnet() )
		fLoadingView->Hide();
	
	fStartCheckBox->SetValue(B_CONTROL_ON);
	
	//
	//
	//
	fFileList->SetColumnFlags(B_ALLOW_COLUMN_RESIZE);
	fFileList->SetSortingEnabled(false);
	fFileList->SetExplicitMinSize(BSize(550, FILE_COLUMN_HEIGHT * 5));
	
	fFileList->AddColumn(new FileColumn("Name", 400, 400, 500), COLUMN_FILE_NAME);
	fFileList->AddColumn(new CheckBoxColumn("DL", 40, 40, 40), COLUMN_FILE_DOWNLOAD);
	
	//
	// We're a magnet or a complete torrent file?
	//
	if( fTorrent->IsMagnet() )
	{
		fTorrent->SetMetadataCallbackHandler(this);
		//const_cast<TorrentObject*>(fTorrent)->StartTransfer();
	}
	else
		UpdateFileList();

	
	AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.Add(fInfoHeaderView)
		.AddGlue()
		.Add(fFileList)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
			.SetInsets(spacing, spacing, spacing, spacing)
			.Add(fStartCheckBox)
			.AddGlue()
			.Add(fCancelButton)
			.Add(fAddButton)
			.Add(fLoadingView)
		)
		.SetInsets(spacing, spacing, spacing, spacing)
	);
	
	CenterOnScreen();
	Run();
}
Пример #27
0
int ProtocolWindow::Stop() {
	SetPulseRate(0);
	return contentView->Stop();
}
Пример #28
0
ShowImageWindow::ShowImageWindow(const entry_ref *ref,
	const BMessenger& trackerMessenger)
	:
	BWindow(BRect(5, 24, 250, 100), "", B_DOCUMENT_WINDOW, 0),
	fSavePanel(NULL),
	fBar(NULL),
	fOpenMenu(NULL),
	fBrowseMenu(NULL),
	fGoToPageMenu(NULL),
	fSlideShowDelay(NULL),
	fImageView(NULL),
	fStatusView(NULL),
	fModified(false),
	fFullScreen(false),
	fShowCaption(true),
	fPrintSettings(NULL),
	fResizerWindowMessenger(NULL),
	fResizeItem(NULL),
	fHeight(0),
	fWidth(0)
{
	_LoadSettings();

	// create menu bar
	fBar = new BMenuBar(BRect(0, 0, Bounds().right, 1), "menu_bar");
	AddMenus(fBar);
	AddChild(fBar);

	BRect viewFrame = Bounds();
	viewFrame.top = fBar->Bounds().Height() + 1;
	viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
	viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;

	// create the image view
	fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED);
	// wrap a scroll view around the view
	BScrollView *scrollView = new BScrollView("image_scroller", fImageView,
		B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER);
	AddChild(scrollView);

	const int32 kstatusWidth = 190;
	BRect rect;
	rect = Bounds();
	rect.top	= viewFrame.bottom + 1;
	rect.left 	= viewFrame.left + kstatusWidth;
	rect.right	= viewFrame.right + 1;
	rect.bottom += 1;
	BScrollBar *horizontalScrollBar = new BScrollBar(rect, "hscroll",
		fImageView, 0, 150, B_HORIZONTAL);
	AddChild(horizontalScrollBar);

	rect.left = 0;
	rect.right = kstatusWidth - 1;
	rect.bottom -= 1;
	fStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM,
		B_WILL_DRAW);
	AddChild(fStatusView);

	rect = Bounds();
	rect.top	= viewFrame.top - 1;
	rect.left	= viewFrame.right + 1;
	rect.bottom	= viewFrame.bottom + 1;
	rect.right	+= 1;
	BScrollBar *verticalScrollBar = new BScrollBar(rect, "vscroll", fImageView,
		0, 150, B_VERTICAL);
	AddChild(verticalScrollBar);

	SetSizeLimits(250, 100000, 100, 100000);

	// finish creating the window
	fImageView->SetImage(ref);
	fImageView->SetTrackerMessenger(trackerMessenger);

	if (InitCheck() != B_OK) {
		BAlert* alert;
		alert = new BAlert("ShowImage",
			"Could not load image! Either the file or an image translator for "
			"it does not exist.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
		alert->Go();

		// quit if file could not be opened
		Quit();
		return;
	}

	// add View menu here so it can access ShowImageView methods
	BMenu* menu = new BMenu("View");
	_BuildViewMenu(menu, false);
	fBar->AddItem(menu);
	_MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither());
	UpdateTitle();

	SetPulseRate(100000);
		// every 1/10 second; ShowImageView needs it for marching ants

	WindowRedimension(fImageView->GetBitmap());
	fImageView->MakeFocus(true); // to receive KeyDown messages
	Show();

	// Tell application object to query the clipboard
	// and tell this window if it contains interesting data or not
	be_app_messenger.SendMessage(B_CLIPBOARD_CHANGED);
}
Пример #29
0
ShowImageWindow::ShowImageWindow(BRect frame, const entry_ref& ref,
	const BMessenger& trackerMessenger)
	:
	BWindow(frame, "", B_DOCUMENT_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
	fNavigator(ref, trackerMessenger),
	fSavePanel(NULL),
	fBar(NULL),
	fBrowseMenu(NULL),
	fGoToPageMenu(NULL),
	fSlideShowDelayMenu(NULL),
	fToolBar(NULL),
	fImageView(NULL),
	fStatusView(NULL),
	fProgressWindow(new ProgressWindow()),
	fModified(false),
	fFullScreen(false),
	fShowCaption(true),
	fShowToolBar(true),
	fPrintSettings(NULL),
	fSlideShowRunner(NULL),
	fSlideShowDelay(kDefaultSlideShowDelay)
{
	_ApplySettings();

	SetLayout(new BGroupLayout(B_VERTICAL, 0));

	// create menu bar
	fBar = new BMenuBar("menu_bar");
	_AddMenus(fBar);
	float menuBarMinWidth = fBar->MinSize().width;
	AddChild(fBar);

	// Add a content view so the tool bar can be moved outside of the
	// visible portion without colliding with the menu bar.

	BView* contentView = new BView(BRect(), "content", B_FOLLOW_NONE, 0);
	contentView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	contentView->SetExplicitMinSize(BSize(250, 100));
	AddChild(contentView);

	// Create the tool bar
	BRect viewFrame = contentView->Bounds();
	viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
	fToolBar = new BToolBar(viewFrame);

	// Add the tool icons.

//	fToolBar->AddAction(MSG_FILE_OPEN, be_app,
//		tool_bar_icon(kIconDocumentOpen), B_TRANSLATE("Open" B_UTF8_ELLIPSIS));
	fToolBar->AddAction(MSG_FILE_PREV, this,
		tool_bar_icon(kIconGoPrevious), B_TRANSLATE("Previous file"), false);
	fToolBar->AddAction(MSG_FILE_NEXT, this, tool_bar_icon(kIconGoNext),
		B_TRANSLATE("Next file"), false);
	BMessage* fullScreenSlideShow = new BMessage(MSG_SLIDE_SHOW);
	fullScreenSlideShow->AddBool("full screen", true);
	fToolBar->AddAction(fullScreenSlideShow, this,
		tool_bar_icon(kIconMediaMovieLibrary), B_TRANSLATE("Slide show"),
		false);
	fToolBar->AddSeparator();
	fToolBar->AddAction(MSG_SELECTION_MODE, this,
		tool_bar_icon(kIconDrawRectangularSelection),
		B_TRANSLATE("Selection mode"), false);
	fToolBar->AddSeparator();
	fToolBar->AddAction(kMsgOriginalSize, this,
		tool_bar_icon(kIconZoomOriginal), B_TRANSLATE("Original size"), true);
	fToolBar->AddAction(kMsgFitToWindow, this,
		tool_bar_icon(kIconZoomFitBest), B_TRANSLATE("Fit to window"), false);
	fToolBar->AddAction(MSG_ZOOM_IN, this, tool_bar_icon(kIconZoomIn),
		B_TRANSLATE("Zoom in"), false);
	fToolBar->AddAction(MSG_ZOOM_OUT, this, tool_bar_icon(kIconZoomOut),
		B_TRANSLATE("Zoom out"), false);
	fToolBar->AddSeparator();
	fToolBar->AddAction(MSG_PAGE_PREV, this, tool_bar_icon(kIconPagePrevious),
		B_TRANSLATE("Previous page"), false);
	fToolBar->AddAction(MSG_PAGE_NEXT, this, tool_bar_icon(kIconPageNext),
		B_TRANSLATE("Next page"), false);
	fToolBar->AddGlue();
	fToolBar->AddAction(MSG_FULL_SCREEN, this,
		tool_bar_icon(kIconViewWindowed), B_TRANSLATE("Leave full screen"),
		false);
	fToolBar->SetActionVisible(MSG_FULL_SCREEN, false);

	fToolBar->ResizeTo(viewFrame.Width(), fToolBar->MinSize().height);

	contentView->AddChild(fToolBar);

	if (fShowToolBar)
		viewFrame.top = fToolBar->Frame().bottom + 1;
	else
		fToolBar->Hide();

	fToolBarVisible = fShowToolBar;

	viewFrame.bottom = contentView->Bounds().bottom;
	viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;

	// create the image view
	fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED
			| B_FRAME_EVENTS);
	// wrap a scroll view around the view
	fScrollView = new BScrollView("image_scroller", fImageView,
		B_FOLLOW_ALL, 0, true, true, B_PLAIN_BORDER);
	contentView->AddChild(fScrollView);

	fStatusView = new ShowImageStatusView(fScrollView);
	fScrollView->AddChild(fStatusView);

	// Update minimum window size
	float toolBarMinWidth = fToolBar->MinSize().width;
	SetSizeLimits(std::max(menuBarMinWidth, toolBarMinWidth), 100000, 100,
		100000);

	// finish creating the window
	if (_LoadImage() != B_OK) {
		_LoadError(ref);
		Quit();
		return;
	}

	// add View menu here so it can access ShowImageView methods
	BMenu* menu = new BMenu(B_TRANSLATE_CONTEXT("View", "Menus"));
	_BuildViewMenu(menu, false);
	fBar->AddItem(menu);

	fBar->AddItem(_BuildRatingMenu());

	SetPulseRate(100000);
		// every 1/10 second; ShowImageView needs it for marching ants

	_MarkMenuItem(menu, MSG_SELECTION_MODE,
		fImageView->IsSelectionModeEnabled());

	// Tell application object to query the clipboard
	// and tell this window if it contains interesting data or not
	be_app_messenger.SendMessage(B_CLIPBOARD_CHANGED);

	// The window will be shown on screen automatically
	Run();
}
DownloadWindow::DownloadWindow(BRect frame, bool visible,
		SettingsMessage* settings)
	: BWindow(frame, B_TRANSLATE("Downloads"),
		B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fMinimizeOnClose(false)
{
	SetPulseRate(1000000);

	settings->AddListener(BMessenger(this));
	BPath downloadPath;
	if (find_directory(B_DESKTOP_DIRECTORY, &downloadPath) != B_OK)
		downloadPath.SetTo("/boot/home/Desktop");
	fDownloadPath = settings->GetValue(kSettingsKeyDownloadPath,
		downloadPath.Path());
	settings->SetValue(kSettingsKeyDownloadPath, fDownloadPath);

	SetLayout(new BGroupLayout(B_VERTICAL, 0.0));

	DownloadsContainerView* downloadsGroupView = new DownloadsContainerView();
	fDownloadViewsLayout = downloadsGroupView->GroupLayout();

	BMenuBar* menuBar = new BMenuBar("Menu bar");
	BMenu* menu = new BMenu(B_TRANSLATE("Downloads"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Open downloads folder"),
		new BMessage(OPEN_DOWNLOADS_FOLDER)));
	BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
	newWindowMessage->AddString("url", "");
	BMenuItem* newWindowItem = new BMenuItem(B_TRANSLATE("New browser window"),
		newWindowMessage, 'N');
	menu->AddItem(newWindowItem);
	newWindowItem->SetTarget(be_app);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Hide"),
		new BMessage(B_QUIT_REQUESTED), 'D'));
	menuBar->AddItem(menu);

	fDownloadsScrollView = new DownloadContainerScrollView(downloadsGroupView);

	fRemoveFinishedButton = new BButton(B_TRANSLATE("Remove finished"),
		new BMessage(REMOVE_FINISHED_DOWNLOADS));
	fRemoveFinishedButton->SetEnabled(false);

	fRemoveMissingButton = new BButton(B_TRANSLATE("Remove missing"),
		new BMessage(REMOVE_MISSING_DOWNLOADS));
	fRemoveMissingButton->SetEnabled(false);

	const float spacing = be_control_look->DefaultItemSpacing();

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
		.Add(menuBar)
		.Add(fDownloadsScrollView)
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
			.AddGlue()
			.Add(fRemoveMissingButton)
			.Add(fRemoveFinishedButton)
			.SetInsets(12, 5, 12, 5)
		)
	);

	PostMessage(INIT);

	if (!visible)
		Hide();
	Show();
}