Beispiel #1
0
static Menu *
add_boot_volume_menu(Directory *bootVolume)
{
    Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Boot Volume");
    MenuItem *item;
    void *cookie;
    int32 count = 0;

    if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
        Directory *volume;
        while (gRoot->GetNextNode(cookie, (Node **)&volume) == B_OK) {
            // only list bootable volumes
            if (!is_bootable(volume))
                continue;

            char name[B_FILE_NAME_LENGTH];
            if (volume->GetName(name, sizeof(name)) == B_OK) {
                menu->AddItem(item = new(nothrow) MenuItem(name));
                item->SetTarget(user_menu_boot_volume);
                item->SetData(volume);

                if (volume == bootVolume) {
                    item->SetMarked(true);
                    item->Select(true);
                }

                count++;
            }
        }
        gRoot->Close(cookie);
    }

    if (count == 0) {
        // no boot volume found yet
        menu->AddItem(item = new(nothrow) MenuItem("<No boot volume found>"));
        item->SetType(MENU_ITEM_NO_CHOICE);
        item->SetEnabled(false);
    }

    menu->AddSeparatorItem();

    menu->AddItem(item = new(nothrow) MenuItem("Rescan volumes"));
    item->SetHelpText("Please insert a Antares CD-ROM or attach a USB disk - "
                      "depending on your system, you can then boot from them.");
    item->SetType(MENU_ITEM_NO_CHOICE);
    if (count == 0)
        item->Select(true);

    menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
    item->SetType(MENU_ITEM_NO_CHOICE);

    if (gKernelArgs.boot_volume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false))
        menu->SetChoiceText("CD-ROM or hard drive");

    return menu;
}
Beispiel #2
0
static Menu*
add_safe_mode_menu()
{
	Menu* safeMenu = new(nothrow) Menu(SAFE_MODE_MENU, "Safe Mode Options");
	MenuItem* item;

	safeMenu->AddItem(item = new(nothrow) MenuItem("Safe mode"));
	item->SetData(B_SAFEMODE_SAFE_MODE);
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetHelpText("Puts the system into safe mode. This can be enabled "
		"independently from the other options.");

	safeMenu->AddItem(item = new(nothrow) MenuItem("Disable user add-ons"));
	item->SetData(B_SAFEMODE_DISABLE_USER_ADD_ONS);
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Prevents all user installed add-ons from being loaded. "
		"Only the add-ons in the system directory will be used.");

	safeMenu->AddItem(item = new(nothrow) MenuItem("Disable IDE DMA"));
	item->SetData(B_SAFEMODE_DISABLE_IDE_DMA);
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Disables IDE DMA, increasing IDE compatibility "
		"at the expense of performance.");

#if B_HAIKU_PHYSICAL_BITS > 32
	// check whether we have memory beyond 4 GB
	bool hasMemoryBeyond4GB = false;
	for (uint32 i = 0; i < gKernelArgs.num_physical_memory_ranges; i++) {
		phys_addr_range& range = gKernelArgs.physical_memory_range[i];
		if (range.start >= (phys_addr_t)1 << 32) {
			hasMemoryBeyond4GB = true;
			break;
		}
	}

	// ... add the menu, if so
	if (hasMemoryBeyond4GB) {
		safeMenu->AddItem(
			item = new(nothrow) MenuItem("Ignore memory beyond 4 GiB"));
		item->SetData(B_SAFEMODE_4_GB_MEMORY_LIMIT);
		item->SetType(MENU_ITEM_MARKABLE);
		item->SetHelpText("Ignores all memory beyond the 4 GiB address limit, "
			"overriding the setting in the kernel settings file.");
	}
#endif

	platform_add_menus(safeMenu);

	safeMenu->AddSeparatorItem();
	safeMenu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));

	return safeMenu;
}
Beispiel #3
0
status_t
user_menu(Directory** _bootVolume)
{
	Menu* menu = new(std::nothrow) Menu(MAIN_MENU);
	Menu* safeModeMenu = NULL;
	Menu* debugMenu = NULL;
	MenuItem* item;

	TRACE(("user_menu: enter\n"));

	// Add boot volume
	menu->AddItem(item = new(std::nothrow) MenuItem("Select boot volume",
		add_boot_volume_menu(*_bootVolume)));

	// Add safe mode
	menu->AddItem(item = new(std::nothrow) MenuItem("Select safe mode options",
		safeModeMenu = add_safe_mode_menu()));

	// add debug menu
	menu->AddItem(item = new(std::nothrow) MenuItem("Select debug options",
		debugMenu = add_debug_menu()));

	// Add platform dependent menus
	platform_add_menus(menu);

	menu->AddSeparatorItem();

	menu->AddItem(item = new(std::nothrow) MenuItem("Reboot"));
	item->SetTarget(user_menu_reboot);
	item->SetShortcut('r');

	menu->AddItem(item = new(std::nothrow) MenuItem("Continue booting"));
	if (*_bootVolume == NULL) {
		item->SetEnabled(false);
		menu->ItemAt(0)->Select(true);
	} else
		item->SetShortcut('b');

	menu->Run();

	// See if a new boot device has been selected, and propagate that back
	if (item->Data() != NULL)
		*_bootVolume = (Directory*)item->Data();

	apply_safe_mode_options(safeModeMenu);
	apply_safe_mode_options(debugMenu);
	delete menu;

	TRACE(("user_menu: leave\n"));

	return B_OK;
}
Beispiel #4
0
void CreateWindowMenu(Window w) {
    //File Menu
    mFile.AddItem(ID_FILE_NEW, "&New");
    mFile.AddItem(ID_FILE_SAVE, "&Save");
    mFile.AddBreak();
    mFile.AddItem(ID_FILE_EXIT, "E&xit");

    //Scale Menu
    mScale.AddItem(ID_SCALE_CONNECT, "&Connect");
    mScale.AddItem(ID_SCALE_ZERO, "&Zero", MF_DISABLED);

    //Add the sub menu's to the title menu
    mTitle.AddSubMenu(mFile, "&File");
    mTitle.AddSubMenu(mScale, "&Scale");

    //Set the window's menu to the title menu
    w.SetWindowMenu(mTitle);
}
Beispiel #5
0
static Menu*
add_debug_menu()
{
	Menu* menu = new(std::nothrow) Menu(STANDARD_MENU, "Debug Options");
	MenuItem* item;

#if DEBUG_SPINLOCK_LATENCIES
	item = new(std::nothrow) MenuItem("Disable latency checks");
	if (item != NULL) {
		item->SetType(MENU_ITEM_MARKABLE);
		item->SetData(B_SAFEMODE_DISABLE_LATENCY_CHECK);
		item->SetHelpText("Disables latency check panics.");
		menu->AddItem(item);
	}
#endif

	menu->AddItem(item
		= new(nothrow) MenuItem("Enable serial debug output"));
	item->SetData("serial_debug_output");
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Turns on forwarding the syslog output to the serial "
		"interface.");

	menu->AddItem(item
		= new(nothrow) MenuItem("Enable on screen debug output"));
	item->SetData("debug_screen");
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Displays debug output on screen while the system "
		"is booting, instead of the normal boot logo.");

	menu->AddItem(item = new(nothrow) MenuItem("Enable debug syslog"));
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetMarked(gKernelArgs.keep_debug_output_buffer);
	item->SetTarget(&debug_menu_toggle_debug_syslog);
    item->SetHelpText("Enables a special in-memory syslog buffer for this "
    	"session that the boot loader will be able to access after rebooting.");

	ring_buffer* syslogBuffer = (ring_buffer*)gKernelArgs.debug_output;
	if (syslogBuffer != NULL && ring_buffer_readable(syslogBuffer) > 0) {
		menu->AddSeparatorItem();

		menu->AddItem(item
			= new(nothrow) MenuItem("Display syslog from previous session"));
		item->SetTarget(&debug_menu_display_syslog);
		item->SetType(MENU_ITEM_NO_CHOICE);
		item->SetHelpText(
			"Displays the syslog from the previous Haiku session.");

		menu->AddItem(item = new(nothrow) MenuItem(
			"Save syslog from previous session", add_save_debug_syslog_menu()));
		item->SetHelpText("Saves the syslog from the previous Haiku session to "
			"disk. Currently only FAT32 volumes are supported.");
	}

	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));

	return menu;
}
Beispiel #6
0
static void
add_boot_volume_item(Menu* menu, Directory* volume, const char* name)
{
	BReference<PackageVolumeInfo> volumeInfo;
	PackageVolumeState* selectedState = NULL;
	if (volume == sBootVolume->RootDirectory()) {
		volumeInfo.SetTo(sBootVolume->GetPackageVolumeInfo());
		selectedState = sBootVolume->GetPackageVolumeState();
	} else {
		volumeInfo.SetTo(new(std::nothrow) PackageVolumeInfo);
		if (volumeInfo->SetTo(volume, "system/packages") == B_OK)
			selectedState = volumeInfo->States().Head();
		else
			volumeInfo.Unset();
	}

	BootVolumeMenuItem* item = new(nothrow) BootVolumeMenuItem(name);
	menu->AddItem(item);

	Menu* subMenu = NULL;

	if (volumeInfo != NULL) {
		subMenu = new(std::nothrow) Menu(CHOICE_MENU, "Select Haiku version");

		for (PackageVolumeStateList::ConstIterator it
				= volumeInfo->States().GetIterator();
			PackageVolumeState* state = it.Next();) {
			PackageVolumeStateMenuItem* stateItem
				= new(nothrow) PackageVolumeStateMenuItem(state->DisplayName(),
					volumeInfo, state);
			subMenu->AddItem(stateItem);
			stateItem->SetTarget(user_menu_boot_volume_state);
			stateItem->SetData(volume);

			if (state == selectedState) {
				stateItem->SetMarked(true);
				stateItem->Select(true);
				item->UpdateStateName(stateItem->VolumeState());
			}
		}
	}

	if (subMenu != NULL && subMenu->CountItems() > 1) {
		item->SetSubmenu(subMenu);
	} else {
		delete subMenu;
		item->SetTarget(user_menu_boot_volume);
		item->SetData(volume);
	}

	if (volume == sBootVolume->RootDirectory()) {
		item->SetMarked(true);
		item->Select(true);
	}
}
Beispiel #7
0
Menu *
video_mode_menu()
{
	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
	MenuItem *item;

	menu->AddItem(item = new(nothrow) MenuItem("Default"));
	item->SetMarked(true);
	item->Select(true);
	item->SetHelpText("The Default video mode is the one currently configured "
		"in the system. If there is no mode configured yet, a viable mode will "
		"be chosen automatically.");


	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
	item->SetType(MENU_ITEM_NO_CHOICE);

	return menu;
}
Beispiel #8
0
static Menu *
add_safe_mode_menu()
{
    Menu *safeMenu = new(nothrow) Menu(SAFE_MODE_MENU, "Safe Mode Options");
    MenuItem *item;

    safeMenu->AddItem(item = new(nothrow) MenuItem("Safe mode"));
    item->SetData(B_SAFEMODE_SAFE_MODE);
    item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Puts the system into safe mode. This can be enabled "
                      "independently from the other options.");

    safeMenu->AddItem(item = new(nothrow) MenuItem("Disable user add-ons"));
    item->SetData(B_SAFEMODE_DISABLE_USER_ADD_ONS);
    item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Prevents all user installed add-ons from being loaded. "
                      "Only the add-ons in the system directory will be used.");

    safeMenu->AddItem(item = new(nothrow) MenuItem("Disable IDE DMA"));
    item->SetData(B_SAFEMODE_DISABLE_IDE_DMA);
    item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Disables IDE DMA, increasing IDE compatibilty "
                      "at the expense of performance.");

    platform_add_menus(safeMenu);

#if DEBUG_SPINLOCK_LATENCIES
    item = new(std::nothrow) MenuItem("Disable latency checks");
    if (item != NULL) {
        item->SetType(MENU_ITEM_MARKABLE);
        item->SetData(B_SAFEMODE_DISABLE_LATENCY_CHECK);
        item->SetHelpText("Disables latency check panics.");
        safeMenu->AddItem(item);
    }
#endif

    safeMenu->AddItem(item
                      = new(nothrow) MenuItem("Enable serial debug output"));
    item->SetData("serial_debug_output");
    item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Turns on forwarding the syslog output to the serial "
                      "interface.");

    safeMenu->AddItem(item
                      = new(nothrow) MenuItem("Enable on screen debug output"));
    item->SetData("debug_screen");
    item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Displays debug output on screen while the system "
                      "is booting, instead of the normal boot logo.");

    safeMenu->AddSeparatorItem();
    safeMenu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));

    return safeMenu;
}
Beispiel #9
0
void MaintainRect()
{
    Menu MaintainMenu;
	FigureFirst();
	MaintainMenu.AddItem( 'f', "First", FigureFirst );
	MaintainMenu.AddItem( 'n', "Next", FigureNext );
	MaintainMenu.AddItem( 'p', "Previous", FigurePrevious );
	MaintainMenu.AddItem( 'd', "Delete", FigureDelete );
	MaintainMenu.AddItem( 'q', "Print current", FigurePrint );
	MaintainMenu.AddItem( ' ', "", MenuSeparator );
	MaintainMenu.AddItem( 'x', "Exit", MenuExit );
	MaintainMenu.AddItem( '?', "Help", MenuPrintHelp );

	MaintainMenu.Run();
}
Beispiel #10
0
int main()
{
	cout << "Hello \n";

	Menu MyMenu; 

	MyMenu.AddItem( 'r', "Read from files", FileRead );
	MyMenu.AddItem( 'l', "List all", ListAll );
	MyMenu.AddItem( 's', "Show big", ShowBig );
	MyMenu.AddItem( 'a', "Add new item",AddMenu );
	MyMenu.AddItem( 'c', "Accumulate Area", AccumulateArea );
	MyMenu.AddItem( 'm', "Maintain Rects",MaintainRect );
	MyMenu.AddItem( 'w', "Write to files", FileWrite );

	MyMenu.AddItem( ' ', "", MenuSeparator );
	MyMenu.AddItem( 'x', "Exit", MenuExit );
	MyMenu.AddItem( '?', "Help", MenuPrintHelp );

	MyMenu.Run();

	return 0;
}
Beispiel #11
0
void AddMenu()
{
    Menu AddMenu;
	AddMenu.AddItem( 'c', "Add new circle", AddCircle );
	AddMenu.AddItem( 'r', "Add new rectangle", AddRectangle );
	AddMenu.AddItem( 't', "Add new triangle", AddTriangle );
	AddMenu.AddItem( ' ', "", MenuSeparator );
	AddMenu.AddItem( 'x', "Exit", MenuExit );
	AddMenu.AddItem( '?', "Help", MenuPrintHelp );

	AddMenu.Run();
}
Beispiel #12
0
/**
*  @brief
*    Constructor
*/
TestWindow::TestWindow(Widget *pParent) : Window(pParent),
	EventHandlerTrayClicked(&TestWindow::TrayClicked, this),
	EventHandlerClicked(&TestWindow::ButtonClicked, this),
	EventHandlerPressed(&TestWindow::ButtonPressed, this),
	EventHandlerReleased(&TestWindow::ButtonReleased, this),
	EventHandlerMenu(&TestWindow::MenuClicked, this),
	m_pLabel(nullptr),
	m_pButton(nullptr),
	m_pToggleButton(nullptr),
	m_pClickTest(nullptr),
	m_pPressedTest(nullptr),
	m_pBitmapButton(nullptr),
	m_pBitmapToggleButton(nullptr),
	m_cMenu(*GetGui()),
	m_pMenuBar(nullptr),
//	m_pTabBar(nullptr),
	m_pPopupMenu(nullptr),
	m_cTrayIcon(*GetGui()),
	m_bClicked(false)
{
	// Create a tray icon
	m_cTrayIcon.SetTooltip(L"Hallo!!");
	m_cTrayIcon.SetIcon(Image(*Gui::GetSystemGui()));
	m_cTrayIcon.EventMouseButtonDown.Connect(EventHandlerTrayClicked);

	// Create some widgets
	m_pLabel = new Label(GetContentWidget());
		m_pLabel->SetText("Hallo!");
		m_pLabel->SetPos(Vector2i(10, 30));
		m_pLabel->SetSize(Vector2i(200, 32));
		m_pLabel->SetVisible(true);
	m_pButton = new Button(GetContentWidget());
		m_pButton->SetImage(Image(*Gui::GetSystemGui(), "PLGui/copy.png"));
		m_pButton->SetText("Button");
		m_pButton->SetPos(Vector2i(10, 70));
		m_pButton->SetSize(Vector2i(120, 32));
		m_pButton->SetVisible(true);
		m_pButton->SetRepeat(true);
		m_pButton->SetRepeatDelay(1000);
		m_pButton->SetRepeatInterval(250);
	m_pToggleButton = new ToggleButton(GetContentWidget());
		m_pToggleButton->SetText("Toggle");
		m_pToggleButton->SetPos(Vector2i(10, 110));
		m_pToggleButton->SetSize(Vector2i(120, 32));
		m_pToggleButton->SetVisible(true);
	m_cCheckGroup.SetExclusive(false);
	for (int i=0; i<4; i++) {
		m_pCheckBoxes[i] = new CheckBox(GetContentWidget());
			m_pCheckBoxes[i]->SetGroup(&m_cCheckGroup);
			m_pCheckBoxes[i]->SetPartiallyAllowed(true);
			m_pCheckBoxes[i]->SetState(PartiallyChecked);
			m_pCheckBoxes[i]->SetText(String("Check Box ") + i);
			m_pCheckBoxes[i]->SetPos(Vector2i(10, 150 + i*20));
			m_pCheckBoxes[i]->SetSize(Vector2i(100, 20));
			m_pCheckBoxes[i]->SetVisible(true);
		m_pRadioButtons[i] = new RadioButton(GetContentWidget());
			m_pRadioButtons[i]->SetGroup(&m_cRadioGroup);
			m_pRadioButtons[i]->SetState(Checked);
			m_pRadioButtons[i]->SetText(String("Radio Button ") + i);
			m_pRadioButtons[i]->SetPos(Vector2i(150, 150 + i*20));
			m_pRadioButtons[i]->SetSize(Vector2i(100, 20));
			m_pRadioButtons[i]->SetVisible(true);
	}

	m_pClickTest = new Widget(GetContentWidget());
		m_pClickTest->SetBackgroundColor(Color4::Red);
		m_pClickTest->SetPos(Vector2i(150, 70));
		m_pClickTest->SetSize(Vector2i(32, 32));
		m_pClickTest->SetVisible(true);
	m_pPressedTest = new Widget(GetContentWidget());
		m_pPressedTest->SetBackgroundColor(Color4::Blue);
		m_pPressedTest->SetPos(Vector2i(200, 70));
		m_pPressedTest->SetSize(Vector2i(32, 32));
		m_pPressedTest->SetVisible(true);
	m_pBitmapButton = new BitmapButton(GetContentWidget());
		m_pBitmapButton->SetImageEnabled (Image(*Gui::GetSystemGui(), "PLGui/button.png"));
		m_pBitmapButton->SetImageDisabled(Image(*Gui::GetSystemGui(), "PLGui/button-inactive.png"));
		m_pBitmapButton->SetImageSelected(Image(*Gui::GetSystemGui(), "PLGui/button-over.png"));
		m_pBitmapButton->SetImagePressed (Image(*Gui::GetSystemGui(), "PLGui/button-pressed.png"));
		m_pBitmapButton->SetPos(Vector2i(10, 230));
		m_pBitmapButton->SetSize(Vector2i(64, 64));
		m_pBitmapButton->SetVisible(true);
	m_pBitmapToggleButton = new BitmapToggleButton(GetContentWidget());
		m_pBitmapToggleButton->SetImageDisabled  (Image(*Gui::GetSystemGui(), "PLGui/button-inactive.png"));
		m_pBitmapToggleButton->SetImageUnselected(NotChecked,		Image(*Gui::GetSystemGui(), "PLGui/button-off.png"));
		m_pBitmapToggleButton->SetImageUnselected(PartiallyChecked,	Image(*Gui::GetSystemGui(), "PLGui/button-on.png"));
		m_pBitmapToggleButton->SetImageUnselected(Checked,			Image(*Gui::GetSystemGui(), "PLGui/button-on.png"));
		m_pBitmapToggleButton->SetImageSelected  (NotChecked,		Image(*Gui::GetSystemGui(), "PLGui/button-over-off.png"));
		m_pBitmapToggleButton->SetImageSelected  (PartiallyChecked,	Image(*Gui::GetSystemGui(), "PLGui/button-over-on.png"));
		m_pBitmapToggleButton->SetImageSelected  (Checked,			Image(*Gui::GetSystemGui(), "PLGui/button-over-on.png"));
		m_pBitmapToggleButton->SetPos(Vector2i(10, 300));
		m_pBitmapToggleButton->SetSize(Vector2i(64, 64));
		m_pBitmapToggleButton->SetVisible(true);

	// Connect event handlers to button
	m_pButton->SignalClicked .Connect(EventHandlerClicked);
	m_pButton->SignalPressed .Connect(EventHandlerPressed);
	m_pButton->SignalReleased.Connect(EventHandlerReleased);

	// Create menu
	Menu *pMenuFile = new Menu(*GetGui());
		pMenuFile->SetText("&File");
		pMenuFile->AddItem("&Open");
		pMenuFile->AddItem("&Close");
		pMenuFile->AddSeparator();
		pMenuFile->AddItem("&Quit");
	Menu *pMenuEdit = new Menu(*GetGui());
		pMenuEdit->SetText("&Edit");
		pMenuEdit->AddItem("&Copy");
		pMenuEdit->AddItem("Cu&t");
		pMenuEdit->AddItem("&Paste");
	Menu *pMenuView = new Menu(*GetGui());
		pMenuView->SetText("&View");
		pMenuView->AddItem("View &All");
		pMenuView->AddItem("View &None");
	Menu *pMenuWindow = new Menu(*GetGui());
		pMenuWindow->SetText("&Window");
		pMenuWindow->AddItem("&Next");
		pMenuWindow->AddItem("&Previous");
		pMenuWindow->AddItem("&Close");
		pMenuWindow->AddItem( "Close &All");
	Menu *pMenuHelp = new Menu(*GetGui());
		pMenuHelp->SetText("&Help");
		pMenuHelp->AddItem("&Help");
		pMenuHelp->AddItem("&About");
	m_cMenu.SetText("&Menu");
	m_cMenu.AddSubMenu(pMenuFile);
	m_cMenu.AddSubMenu(pMenuEdit);
	m_cMenu.AddSubMenu(pMenuView);
	m_cMenu.AddSubMenu(pMenuWindow);
	m_cMenu.AddSubMenu(pMenuHelp);
	m_cMenu.AddSeparator();
	m_cMenu.AddItem("&Restore");
	m_cMenu.AddSeparator();

	// Add a menu bar
	m_pMenuBar = new MenuBar(GetContentWidget());
//		m_pMenuBar->SetSubmenuOrientationVert(Up);
		m_pMenuBar->SetMenu(&m_cMenu);
		m_pMenuBar->SetPos(Vector2i::Zero);
//		m_pMenuBar->SetSize(Vector2i(GetContentWidget()->GetSize().x, 26));
		m_pMenuBar->SetSize(Vector2i(640, 26));
		m_pMenuBar->SetVisible(true);

	// Add a tab bar
	/*
	m_pTabBar = new TabBar(GetContentWidget());
		m_pTabBar->AddTab("Test1");
		m_pTabBar->AddTab("Test2");
		m_pTabBar->AddTab("Test3");
		m_pTabBar->AddTab("Test4");
		m_pTabBar->AddTab("Test5");
		m_pTabBar->AddTab("Test6");
		m_pTabBar->SetPos(Vector2i(0, 370));
//		m_pTabBar->SetSize(Vector2i(GetContentWidget()->GetSize().x, 20));
		m_pTabBar->SetSize(Vector2i(640, 20));
		m_pTabBar->SetVisible(true);
	*/

	// Add a popup menu
	m_pPopupMenu = new PopupMenu(GetContentWidget());
		m_pPopupMenu->SetMenu(&m_cMenu);
		m_pPopupMenu->SetPos(Vector2i(300, 70));
		m_pPopupMenu->SetSize(Vector2i(100, 200));
		m_pPopupMenu->SetVisible(true);

	// Connect event handlers to menus
	m_pMenuBar->SignalItemClicked.Connect(EventHandlerMenu);
	m_pPopupMenu->SignalItemClicked.Connect(EventHandlerMenu);
}
Beispiel #13
0
static Menu*
add_safe_mode_menu()
{
	Menu* safeMenu = new(nothrow) Menu(SAFE_MODE_MENU, "Safe Mode Options");
	MenuItem* item;

	safeMenu->AddItem(item = new(nothrow) MenuItem("Safe mode"));
	item->SetData(B_SAFEMODE_SAFE_MODE);
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetHelpText("Puts the system into safe mode. This can be enabled "
		"independently from the other options.");

	safeMenu->AddItem(item = new(nothrow) MenuItem("Disable user add-ons"));
	item->SetData(B_SAFEMODE_DISABLE_USER_ADD_ONS);
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Prevents all user installed add-ons from being loaded. "
		"Only the add-ons in the system directory will be used.");

	safeMenu->AddItem(item = new(nothrow) MenuItem("Disable IDE DMA"));
	item->SetData(B_SAFEMODE_DISABLE_IDE_DMA);
	item->SetType(MENU_ITEM_MARKABLE);
    item->SetHelpText("Disables IDE DMA, increasing IDE compatibility "
		"at the expense of performance.");

#if B_HAIKU_PHYSICAL_BITS > 32
	// check whether we have memory beyond 4 GB
	bool hasMemoryBeyond4GB = false;
	for (uint32 i = 0; i < gKernelArgs.num_physical_memory_ranges; i++) {
		addr_range& range = gKernelArgs.physical_memory_range[i];
		if (range.start >= (uint64)1 << 32) {
			hasMemoryBeyond4GB = true;
			break;
		}
	}

	bool needs64BitPaging = true;
		// TODO: Determine whether 64 bit paging (i.e. PAE for x86) is needed
		// for other reasons (NX support).

	// ... add the menu item, if so
	if (hasMemoryBeyond4GB || needs64BitPaging) {
		safeMenu->AddItem(
			item = new(nothrow) MenuItem("Ignore memory beyond 4 GiB"));
		item->SetData(B_SAFEMODE_4_GB_MEMORY_LIMIT);
		item->SetType(MENU_ITEM_MARKABLE);
		item->SetHelpText("Ignores all memory beyond the 4 GiB address limit, "
			"overriding the setting in the kernel settings file.");
	}
#endif

	platform_add_menus(safeMenu);

	safeMenu->AddSeparatorItem();
	sBlacklistRootMenu = new(std::nothrow) BlacklistRootMenu;
	safeMenu->AddItem(item = new(std::nothrow) MenuItem("Blacklist entries",
		sBlacklistRootMenu));
	item->SetHelpText("Allows to select system files that shall be ignored. "
		"Useful e.g. to disable drivers temporarily.");

	safeMenu->AddSeparatorItem();
	safeMenu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));

	return safeMenu;
}
Beispiel #14
0
static Menu*
add_debug_menu()
{
	Menu* menu = new(std::nothrow) Menu(STANDARD_MENU, "Debug Options");
	MenuItem* item;

#if DEBUG_SPINLOCK_LATENCIES
	item = new(std::nothrow) MenuItem("Disable latency checks");
	if (item != NULL) {
		item->SetType(MENU_ITEM_MARKABLE);
		item->SetData(B_SAFEMODE_DISABLE_LATENCY_CHECK);
		item->SetHelpText("Disables latency check panics.");
		menu->AddItem(item);
	}
#endif

	menu->AddItem(item
		= new(nothrow) MenuItem("Enable serial debug output"));
	item->SetData("serial_debug_output");
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetHelpText("Turns on forwarding the syslog output to the serial "
		"interface (default: 115200, 8N1).");

	menu->AddItem(item
		= new(nothrow) MenuItem("Enable on screen debug output"));
	item->SetData("debug_screen");
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetHelpText("Displays debug output on screen while the system "
		"is booting, instead of the normal boot logo.");

	menu->AddItem(item
		= new(nothrow) MenuItem("Disable on screen paging"));
	item->SetData("disable_onscreen_paging");
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetHelpText("Disables paging when on screen debug output is "
		"enabled.");

	menu->AddItem(item = new(nothrow) MenuItem("Enable debug syslog"));
	item->SetType(MENU_ITEM_MARKABLE);
	item->SetMarked(gKernelArgs.keep_debug_output_buffer);
	item->SetTarget(&debug_menu_toggle_debug_syslog);
    item->SetHelpText("Enables a special in-memory syslog buffer for this "
    	"session that the boot loader will be able to access after rebooting.");

	ring_buffer* syslogBuffer
		= (ring_buffer*)gKernelArgs.debug_output.Pointer();
	bool hasPreviousSyslog
		= syslogBuffer != NULL && ring_buffer_readable(syslogBuffer) > 0;
	if (hasPreviousSyslog) {
		menu->AddItem(item = new(nothrow) MenuItem(
			"Save syslog from previous session during boot"));
		item->SetType(MENU_ITEM_MARKABLE);
		item->SetMarked(gKernelArgs.previous_debug_size);
		item->SetTarget(&debug_menu_toggle_previous_debug_syslog);
		item->SetHelpText("Saves the syslog from the previous Haiku session to "
			"/var/log/previous_syslog when booting.");
	}

	bool currentLogItemVisible = platform_debug_get_log_buffer(NULL) != NULL;
	if (currentLogItemVisible) {
		menu->AddSeparatorItem();
		menu->AddItem(item
			= new(nothrow) MenuItem("Display current boot loader log"));
		item->SetTarget(&debug_menu_display_current_log);
		item->SetType(MENU_ITEM_NO_CHOICE);
		item->SetHelpText(
			"Displays the debug info the boot loader has logged.");
	}

	if (hasPreviousSyslog) {
		if (!currentLogItemVisible)
			menu->AddSeparatorItem();

		menu->AddItem(item
			= new(nothrow) MenuItem("Display syslog from previous session"));
		item->SetTarget(&debug_menu_display_previous_syslog);
		item->SetType(MENU_ITEM_NO_CHOICE);
		item->SetHelpText(
			"Displays the syslog from the previous Haiku session.");

		menu->AddItem(item = new(nothrow) MenuItem(
			"Save syslog from previous session", add_save_debug_syslog_menu()));
		item->SetHelpText("Saves the syslog from the previous Haiku session to "
			"disk. Currently only FAT32 volumes are supported.");
	}

	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem(
		"Add advanced debug option"));
	item->SetType(MENU_ITEM_NO_CHOICE);
	item->SetTarget(&debug_menu_add_advanced_option);
	item->SetHelpText(
		"Allows advanced debugging options to be entered directly.");

	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));

	return menu;
}
Beispiel #15
0
status_t
user_menu(BootVolume& _bootVolume, PathBlacklist& _pathBlacklist)
{

	Menu* menu = new(std::nothrow) Menu(MAIN_MENU);

	sMainMenu = menu;
	sBootVolume = &_bootVolume;
	sPathBlacklist = &_pathBlacklist;

	Menu* safeModeMenu = NULL;
	Menu* debugMenu = NULL;
	MenuItem* item;

	TRACE(("user_menu: enter\n"));

	// Add boot volume
	menu->AddItem(item = new(std::nothrow) MenuItem("Select boot volume",
		add_boot_volume_menu()));

	// Add safe mode
	menu->AddItem(item = new(std::nothrow) MenuItem("Select safe mode options",
		safeModeMenu = add_safe_mode_menu()));

	// add debug menu
	menu->AddItem(item = new(std::nothrow) MenuItem("Select debug options",
		debugMenu = add_debug_menu()));

	// Add platform dependent menus
	platform_add_menus(menu);

	menu->AddSeparatorItem();

	menu->AddItem(item = new(std::nothrow) MenuItem("Reboot"));
	item->SetTarget(user_menu_reboot);
	item->SetShortcut('r');

	menu->AddItem(item = new(std::nothrow) MenuItem("Continue booting"));
	if (!_bootVolume.IsValid()) {
		item->SetEnabled(false);
		menu->ItemAt(0)->Select(true);
	} else
		item->SetShortcut('b');

	menu->Run();

	apply_safe_mode_options(safeModeMenu);
	apply_safe_mode_options(debugMenu);
	apply_safe_mode_path_blacklist();
	add_safe_mode_settings(sSafeModeOptionsBuffer.String());
	delete menu;


	TRACE(("user_menu: leave\n"));

	sMainMenu = NULL;
	sBlacklistRootMenu = NULL;
	sBootVolume = NULL;
	sPathBlacklist = NULL;
	return B_OK;
}
Beispiel #16
0
bool Menus::CreateMenus()
{
	// Build the menus
	Menu* menuMain = new Menu;
	ASSERT(menuMain);

	menuMain->AddItem(new MenuLabel(MenuItem::Title,L"main menu",0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"visualizations",1,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"color presets",2,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"options",3,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"capture source",4,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"info",5,false,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuMain->AddItem(new MenuLabel(MenuItem::Label,L"close",6,false,NULL));

	menuMain->SetSelectedFirstValid();
	menuMain->SetEventHandler(MenuEventHandler);

	mMenuRoot.AddMenu(menuMain);

	Menu* menuExit = new Menu;
	ASSERT(menuExit);

	menuExit->AddItem(new MenuLabel(MenuItem::Title,L"close",0,true,NULL));
	menuExit->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuExit->AddItem(new MenuLabel(MenuItem::Label,L"yes",1,false,NULL));
	menuExit->AddItem(new MenuLabel(MenuItem::Label,L"no",2,false,NULL));

	menuExit->SetSelected(3);	// No
	menuExit->SetEventHandler(MenuExitEventHandler);

	mMenuRoot.AddMenu(menuExit);

	Menu* menuCapture = new Menu;
	ASSERT(menuCapture);

	menuCapture->AddItem(new MenuLabel(MenuItem::Title,L"capture source menu",0,true,NULL));
	menuCapture->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));

	// Add the capture sources
	for(unsigned long i = 0; i < GetKernel()->GetAudio()->GetSourcesCount(); ++i)
		menuCapture->AddItem(new MenuLabel(MenuItem::Label,GetKernel()->GetAudio()->GetSource(i),i+1,false,NULL));

	if(!GetKernel()->GetAudio()->GetSourcesCount())
		menuCapture->AddItem(new MenuLabel(MenuItem::Label,L"no capture sources",1,true,NULL));

	menuCapture->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuCapture->AddItem(new MenuLabel(MenuItem::Label,L"back",GetKernel()->GetAudio()->GetSourcesCount()+1,false,NULL));

	menuCapture->SetSelectedFirstValid();
	menuCapture->SetEventHandler(MenuCaptureEventHandler);

	mMenuRoot.AddMenu(menuCapture);

	Menu* menuOptions = new Menu;
	ASSERT(menuOptions);

	menuOptions->AddItem(new MenuLabel(MenuItem::Title,L"options menu",0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,1,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,2,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,3,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,4,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,5,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,6,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,7,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,8,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,9,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,10,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,NULL,11,false,MenuItemTextHandler));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,L"write config",12,false,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,L"read config",13,false,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuOptions->AddItem(new MenuLabel(MenuItem::Label,L"back",14,false,NULL));

	menuOptions->SetSelectedFirstValid();
	menuOptions->SetEventHandler(MenuOptionsEventHandler);

	mMenuRoot.AddMenu(menuOptions);

	Menu* menuInfo = new Menu;
	ASSERT(menuInfo);

	menuInfo->AddItem(new MenuLabel(MenuItem::Title,L"info menu",0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,NULL,1,true,MenuInfoItemTextHandler));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,NULL,2,true,MenuInfoItemTextHandler));
	menuInfo->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,L"audio analyzer v\002" TOSTRINGW(ANALYZER_VERSION_MAJOR) L"." TOSTRINGW(ANALYZER_VERSION_MINOR) L"\001",0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,L"marko mihovilic",0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));
	menuInfo->AddItem(new MenuLabel(MenuItem::Label,L"back",6,false,NULL));

	menuInfo->SetSelectedFirstValid();
	menuInfo->SetEventHandler(MenuInfoEventHandler);

	mMenuRoot.AddMenu(menuInfo);

	Menu* menuVis = new Menu;
	ASSERT(menuVis);

	menuVis->AddItem(new MenuLabel(MenuItem::Title,L"visualizations menu",0,true,NULL));
	menuVis->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));

	// Add the visualizations
	for(unsigned long i = 0; i < GetKernel()->GetGraphics()->GetVisualizationCount(); ++i)
		menuVis->AddItem(new MenuLabel(MenuItem::Label,GetKernel()->GetGraphics()->GetVisualizationName(i),i+1,false,NULL));

	menuVis->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuVis->AddItem(new MenuLabel(MenuItem::Label,L"back",GetKernel()->GetGraphics()->GetVisualizationCount()+1,false,NULL));

	menuVis->SetSelectedFirstValid();
	menuVis->SetEventHandler(MenuVisEventHandler);

	mMenuRoot.AddMenu(menuVis);

	Menu* menuPreset = new Menu;
	ASSERT(menuPreset);

	menuPreset->AddItem(new MenuLabel(MenuItem::Title,L"color presets menu",0,true,NULL));
	menuPreset->AddItem(new MenuLabel(MenuItem::Margin,NULL,0,true,NULL));

	// Add the color presets
	for(unsigned long i = 0; i < GetKernel()->GetGraphics()->GetColorPresetCount(); ++i)
		menuPreset->AddItem(new MenuLabel(MenuItem::Label,GetKernel()->GetGraphics()->GetColorPresetName(i),i+1,false,NULL));

	menuPreset->AddItem(new MenuLabel(MenuItem::Seperator,NULL,0,true,NULL));
	menuPreset->AddItem(new MenuLabel(MenuItem::Label,L"back",GetKernel()->GetGraphics()->GetColorPresetCount()+1,false,NULL));

	menuPreset->SetSelectedFirstValid();
	menuPreset->SetEventHandler(MenuPresetEventHandler);

	mMenuRoot.AddMenu(menuPreset);

	return true;
}
Beispiel #17
0
BrowserWindow::BrowserWindow( const Rect &cFrame ) : Window( cFrame, "webview_wnd", "Webster" )
{
	Rect cMenuFrame, cToolFrame, cStatusFrame, cTabFrame;

	m_pcChromeClient = new BrowserChromeClient( this );
	m_pcWebSettings = new WebSettings();
	m_pcWebSettings->Load();

	m_pcSettings = new Settings();
	m_pcSettings->Load();

	/* Get window layouts */
	m_pcGuiSettings = new Settings();
	m_pcGuiSettings->SetFile( "Gui" );
	m_pcGuiSettings->Load();

	m_cWindowFrame = m_pcGuiSettings->GetRect( "webster", cFrame );
	m_cSettingsFrame = m_pcGuiSettings->GetRect( "settings", Rect( 25, 25, 600, 450 ) );

	SetFrame( m_cWindowFrame );
	cMenuFrame = cToolFrame = cStatusFrame = cTabFrame = GetBounds();

	/* DANGER WILL ROBINSON! See the note in the BrowserApp constructor about this mutex! */
	g_cGlobalMutex.Lock();
	SetMutex( &g_cGlobalMutex );

	m_pcMenuBar = new Menu( cMenuFrame, "menubar", ITEMS_IN_ROW );

	Menu *pcApplicationMenu = new Menu( Rect(), "Application", ITEMS_IN_COLUMN );
	pcApplicationMenu->AddItem( "Quit", new Message( M_TERMINATE ), "Ctrl+Q" );
	pcApplicationMenu->AddItem( new MenuSeparator() );
	pcApplicationMenu->AddItem( "About Webster", new Message( ID_MENU_APP_ABOUT ) );
	m_pcMenuBar->AddItem( pcApplicationMenu );

	Menu *pcWindowMenu = new Menu( Rect(), "Window", ITEMS_IN_COLUMN );
	pcWindowMenu->AddItem( "New window", new Message( ID_CREATE_WINDOW ), "Ctrl+N" );
	pcWindowMenu->AddItem( "Close window", new Message( M_QUIT ), "Ctrl+W" );
	pcWindowMenu->AddItem( new MenuSeparator() );
	pcWindowMenu->AddItem( "New tab", new Message( ID_MENU_WIN_NEW_TAB ), "Ctrl+T" );
	pcWindowMenu->AddItem( "Close tab", new Message( ID_MENU_WIN_CLOSE_TAB ) );
	m_pcMenuBar->AddItem( pcWindowMenu );

	Menu *pcEditMenu = new Menu( Rect(), "Edit", ITEMS_IN_COLUMN );
	pcEditMenu->AddItem( "Cut", new Message( ID_MENU_EDIT_CUT ), "Ctrl+X" );
	pcEditMenu->AddItem( "Copy", new Message( ID_MENU_EDIT_COPY ), "Ctrl+C" );
	pcEditMenu->AddItem( "Paste", new Message( ID_MENU_EDIT_PASTE ), "Ctrl+V" );
	pcEditMenu->AddItem( new MenuSeparator() );
	pcEditMenu->AddItem( "Delete", new Message( ID_MENU_EDIT_DELETE ) );
	m_pcMenuBar->AddItem( pcEditMenu );

	Menu *pcSettingsMenu = new Menu( Rect(), "Settings", ITEMS_IN_COLUMN );
	pcSettingsMenu->AddItem( "Configure", new Message( ID_MENU_SETTINGS_CONFIGURE ) );
	m_pcMenuBar->AddItem( pcSettingsMenu );

	m_pcBookmarksManager = new BookmarksManager();
	BookmarksMenu *pcBookmarksMenu = m_pcBookmarksManager->CreateMenu( "Bookmarks", Path( "" ) );
	m_pcMenuBar->AddItem( pcBookmarksMenu );

	m_pcMenuBar->SetTargetForItems( this );

	cMenuFrame.bottom = m_pcMenuBar->GetPreferredSize( false ).y;
	m_pcMenuBar->SetFrame( cMenuFrame );
	AddChild( m_pcMenuBar );

	/* Setup the toolbar */
	bool bShowButtonText = m_pcSettings->GetBool( "show_button_text", true );
	m_pcToolBar = new ToolBar( Rect(), "toolbar", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP );

	ResStream *pcStream;
	File cSelf( open_image_file( get_image_id() ) );
	Resources cCol( &cSelf );		

	m_pcBackButton = new ImageButton( Rect(), "back", "Back", new Message(ID_BUTTON_BACK), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "back.png" );
	m_pcBackButton->SetImage( pcStream );
	delete( pcStream );

	m_pcForwardButton = new ImageButton( Rect(), "foward", "Forward", new Message(ID_BUTTON_FORWARD), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "forward.png" );
	m_pcForwardButton->SetImage( pcStream );
	delete( pcStream );

	m_pcReloadButton = new ImageButton( Rect(), "reload", "Reload", new Message(ID_BUTTON_RELOAD), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "reload.png" );
	m_pcReloadButton->SetImage( pcStream );
	delete( pcStream );

	m_pcStopButton = new ImageButton( Rect(), "stop", "Stop", new Message(ID_BUTTON_STOP), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "stop.png" );
	m_pcStopButton->SetImage( pcStream );
	delete( pcStream );

	m_pcHomeButton = new ImageButton( Rect(), "home", "Home", new Message(ID_BUTTON_HOME), NULL, ImageButton::IB_TEXT_BOTTOM, true, bShowButtonText, true );
	pcStream = cCol.GetResourceStream( "home.png" );
	m_pcHomeButton->SetImage( pcStream );
	delete( pcStream );

	m_pcBackButton->SetEnable( false );
	m_pcForwardButton->SetEnable( false );
	m_pcStopButton->SetEnable( false );

	m_pcToolBar->AddChild( m_pcBackButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcForwardButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcReloadButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcStopButton, ToolBar::TB_FIXED_WIDTH );
	m_pcToolBar->AddChild( m_pcHomeButton, ToolBar::TB_FIXED_WIDTH );

	m_pcUrlEdit = new UrlEdit( Rect(), "urledit", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_TOP );
	m_pcUrlEdit->SetMinPreferredSize( 32 );
	m_pcUrlEdit->SetMaxPreferredSize( 256 );
	m_pcUrlEdit->SetEditMessage( new Message( ID_URL_CHANGED ) );
	m_pcUrlEdit->SetSelectionMessage( new Message( ID_URL_CHANGED ) );
	m_pcUrlEdit->SetTarget( this, this );

	m_pcToolBar->AddChild( m_pcUrlEdit, ToolBar::TB_FREE_WIDTH );

	cToolFrame.top = cMenuFrame.bottom + 1.0f;
	cToolFrame.bottom = cToolFrame.top + m_pcToolBar->GetPreferredSize(false).y;
	m_pcToolBar->SetFrame( cToolFrame );
	AddChild( m_pcToolBar );

	m_pcStatusBar = new StatusBar( Rect(), "statusbar", CF_FOLLOW_LEFT | CF_FOLLOW_RIGHT | CF_FOLLOW_BOTTOM );
	m_pcStatusBar->AddPanel( "text", "" );

	m_pcProgress = new ProgressPanel( "progress", 10 );
	m_pcStatusBar->AddPanel( m_pcProgress );

	cStatusFrame.top = cStatusFrame.bottom - 20;
	m_pcStatusBar->SetFrame( cStatusFrame );
	AddChild( m_pcStatusBar );

	cTabFrame.top = cToolFrame.bottom + 1.0f;
	cTabFrame.bottom = cStatusFrame.top - 1.0f;

	m_pcTabView = new TabView( cTabFrame, "webviewtabs", CF_FOLLOW_ALL );
	m_pcTabView->SetMessage( new Message( ID_TAB_CHANGED ) );
	AddChild( m_pcTabView );

	/* Create a tab and open the homepage, if one is configured */
	CreateTab( m_pcSettings->GetString( "homepage", "about:blank" ) );

	/* Set Window icon */
	pcStream = cCol.GetResourceStream( "icon24x24.png" );
	BitmapImage *pcIcon = new BitmapImage( pcStream );
	delete( pcStream );
	SetIcon( pcIcon->LockBitmap() );
	delete( pcIcon );

	/* Nothing is being loaded at this point */
	UpdateButtonState( false );
}
Beispiel #18
0
static Menu*
add_save_debug_syslog_menu()
{
	Menu* menu = new(nothrow) Menu(STANDARD_MENU, "Save syslog to volume ...");
	MenuItem* item;

	const char* const kHelpText = "Currently only FAT32 volumes are supported. "
		"Newly plugged in removable devices are only recognized after "
		"rebooting.";

	int32 itemsAdded = 0;

	void* cookie;
	if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
		Node* node;
		while (gRoot->GetNextNode(cookie, &node) == B_OK) {
			Directory* volume = static_cast<Directory*>(node);
			Partition* partition;
			if (gRoot->GetPartitionFor(volume, &partition) != B_OK)
				continue;

			// we support only FAT32 volumes ATM
			if (partition->content_type == NULL
				|| strcmp(partition->content_type, kPartitionTypeFAT32) != 0) {
				continue;
			}

			char name[B_FILE_NAME_LENGTH];
			if (volume->GetName(name, sizeof(name)) != B_OK)
				strcpy(name, "unnamed");

			// append offset, size, and type to the name
			size_t len = strlen(name);
			char offsetBuffer[32];
			char sizeBuffer[32];
			snprintf(name + len, sizeof(name) - len,
				" (%s, offset %s, size %s)", partition->content_type,
				size_to_string(partition->offset, offsetBuffer,
					sizeof(offsetBuffer)),
				size_to_string(partition->size, sizeBuffer,
					sizeof(sizeBuffer)));

			item = new(nothrow) MenuItem(name);
			item->SetData(volume);
			item->SetTarget(&debug_menu_save_syslog);
			item->SetType(MENU_ITEM_NO_CHOICE);
			item->SetHelpText(kHelpText);
			menu->AddItem(item);
			itemsAdded++;
		}

		gRoot->Close(cookie);
	}

	if (itemsAdded == 0) {
		menu->AddItem(item
			= new(nothrow) MenuItem("No supported volumes found"));
		item->SetType(MENU_ITEM_NO_CHOICE);
		item->SetHelpText(kHelpText);
		item->SetEnabled(false);
	}

	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to debug menu"));
	item->SetHelpText(kHelpText);

	return menu;
}