Exemple #1
0
AppearancePrefView::AppearancePrefView(const char* name,
		const BMessenger& messenger)
	:
	BGroupView(name, B_VERTICAL, 5),
	fTerminalMessenger(messenger)
{
	const char* kColorTable[] = {
		B_TRANSLATE_MARK("Text"),
		B_TRANSLATE_MARK("Background"),
		B_TRANSLATE_MARK("Cursor"),
		B_TRANSLATE_MARK("Text under cursor"),
		B_TRANSLATE_MARK("Selected text"),
		B_TRANSLATE_MARK("Selected background"),
		NULL
	};

	fBlinkCursor = new BCheckBox(
		B_TRANSLATE("Blinking cursor"),
			new BMessage(MSG_BLINK_CURSOR_CHANGED));

	fAllowBold = new BCheckBox(
		B_TRANSLATE("Allow bold text"),
			new BMessage(MSG_ALLOW_BOLD_CHANGED));

	fWarnOnExit = new BCheckBox(
		B_TRANSLATE("Confirm exit if active programs exist"),
			new BMessage(MSG_WARN_ON_EXIT_CHANGED));

	BMenu* fontMenu = _MakeFontMenu(MSG_HALF_FONT_CHANGED,
		PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY),
		PrefHandler::Default()->getString(PREF_HALF_FONT_STYLE));
	fFontField = new BMenuField(B_TRANSLATE("Font:"), fontMenu);

	BMenu* sizeMenu = new (std::nothrow) BPopUpMenu(
		B_TRANSLATE_COMMENT("Custom", "Window size"));
	if (sizeMenu != NULL) {
		TermWindow::MakeWindowSizeMenu(sizeMenu);
		sizeMenu->SetLabelFromMarked(true);
	}
	fWindowSizeField = new BMenuField(B_TRANSLATE("Window size:"), sizeMenu);

	BMenu* encodingMenu = new (std::nothrow) BPopUpMenu("Text encoding");
	if (encodingMenu != NULL) {
		TermWindow::MakeEncodingMenu(encodingMenu);
		encodingMenu->SetLabelFromMarked(true);
	}
	fEncodingField = new BMenuField(B_TRANSLATE("Encoding:"), encodingMenu);

	BPopUpMenu* schemesPopUp = _MakeColorSchemeMenu(MSG_COLOR_SCHEME_CHANGED,
		gPredefinedColorSchemes, gPredefinedColorSchemes[0]);
	fColorSchemeField = new BMenuField(B_TRANSLATE("Color scheme:"),
		schemesPopUp);

	BPopUpMenu* colorsPopUp = _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
		kColorTable[0]);

	fColorField = new BMenuField(B_TRANSLATE("Color:"), colorsPopUp);

	fTabTitle = new BTextControl("tabTitle", B_TRANSLATE("Tab title:"), "",
		NULL);
	fTabTitle->SetModificationMessage(
		new BMessage(MSG_TAB_TITLE_SETTING_CHANGED));
	fTabTitle->SetToolTip(BString(B_TRANSLATE(
		"The pattern specifying the tab titles. The following placeholders\n"
		"can be used:")) << "\n" << kTooTipSetTabTitlePlaceholders
		<< "\n" << kToolTipCommonTitlePlaceholders);

	fWindowTitle = new BTextControl("windowTitle", B_TRANSLATE("Window title:"),
		"", NULL);
	fWindowTitle->SetModificationMessage(
		new BMessage(MSG_WINDOW_TITLE_SETTING_CHANGED));
	fWindowTitle->SetToolTip(BString(B_TRANSLATE(
		"The pattern specifying the window titles. The following placeholders\n"
		"can be used:")) << "\n" << kTooTipSetWindowTitlePlaceholders
		<< "\n" << kToolTipCommonTitlePlaceholders);

	BLayoutBuilder::Group<>(this)
		.SetInsets(5, 5, 5, 5)
		.AddGrid(5, 5)
			.Add(fTabTitle->CreateLabelLayoutItem(), 0, 0)
			.Add(fTabTitle->CreateTextViewLayoutItem(), 1, 0)
			.Add(fWindowTitle->CreateLabelLayoutItem(), 0, 1)
			.Add(fWindowTitle->CreateTextViewLayoutItem(), 1, 1)
			.Add(fWindowSizeField->CreateLabelLayoutItem(), 0, 2)
			.Add(fWindowSizeField->CreateMenuBarLayoutItem(), 1, 2)
			.Add(fFontField->CreateLabelLayoutItem(), 0, 3)
			.Add(fFontField->CreateMenuBarLayoutItem(), 1, 3)
			.Add(fEncodingField->CreateLabelLayoutItem(), 0, 4)
			.Add(fEncodingField->CreateMenuBarLayoutItem(), 1, 4)
			.Add(fColorSchemeField->CreateLabelLayoutItem(), 0, 5)
			.Add(fColorSchemeField->CreateMenuBarLayoutItem(), 1, 5)
			.Add(fColorField->CreateLabelLayoutItem(), 0, 6)
			.Add(fColorField->CreateMenuBarLayoutItem(), 1, 6)
			.End()
		.AddGlue()
		.Add(fColorControl = new BColorControl(BPoint(10, 10),
			B_CELLS_32x8, 8.0, "", new BMessage(MSG_COLOR_CHANGED)))
		.Add(fBlinkCursor)
		.Add(fAllowBold)
		.Add(fWarnOnExit);

	fTabTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fWindowTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fFontField->SetAlignment(B_ALIGN_RIGHT);
	fWindowSizeField->SetAlignment(B_ALIGN_RIGHT);
	fEncodingField->SetAlignment(B_ALIGN_RIGHT);
	fColorField->SetAlignment(B_ALIGN_RIGHT);
	fColorSchemeField->SetAlignment(B_ALIGN_RIGHT);

	Revert();

	BTextControl* redInput = (BTextControl*)fColorControl->ChildAt(0);
	BTextControl* greenInput = (BTextControl*)fColorControl->ChildAt(1);
	BTextControl* blueInput = (BTextControl*)fColorControl->ChildAt(2);

	redInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	greenInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	blueInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
}
Exemple #2
0
BString
StickItWindow::AddToList(BListView *bl, const char * str)
{
    bl->AddItem(new BStringItem(str));
    return BString ("");
}
Exemple #3
0
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	: HWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK,
 		B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 		B_NOT_ZOOMABLE),
	 fResult(B_ERROR),
	 fSetupMsg(msg),
	 fAdvancedSettings(*msg),
	 fPrinterDirName(printerName)
{
	fExitSem 	= create_sem(0, "PageSetup");

	if (printerName)
		SetTitle(BString(printerName).Append(" page setup").String());

	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("pdf_paper_size", &label) != B_OK)
		label = "Letter";

	int32 compression;
	fSetupMsg->FindInt32("pdf_compression", &compression);

	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BString setting_value;
	if (fSetupMsg->FindString("pdf_compatibility", &setting_value) != B_OK)
		setting_value = "1.3";

	// Load font settings
	fFonts = new Fonts();
	fFonts->CollectFonts();
	BMessage fonts;
	if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK)
		fFonts->SetTo(&fonts);

	// add a *dialog* background
	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);
	bounds.right = 230.0;
	bounds.bottom = 160.0;
	fMarginView = new MarginView(bounds, int32(width), int32(height), margin,
		MarginUnit(units));
	panel->AddChild(fMarginView);
	fMarginView->SetResizingMode(B_FOLLOW_NONE);

	BPopUpMenu* m = new BPopUpMenu("Page size");
	m->SetRadioMode(true);

	bounds.OffsetBy(bounds.Width() + 10.0, 5.0);
	float divider = be_plain_font->StringWidth("PDF compatibility: ");
	fPageSizeMenu = new BMenuField(bounds, "page_size", "Page size:", m);
	panel->AddChild(fPageSizeMenu);
	fPageSizeMenu->ResizeToPreferred();
	fPageSizeMenu->SetDivider(divider);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		m->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("Orientation");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fPageSizeMenu->Bounds().Height() + 10.0);
	fOrientationMenu = new BMenuField(bounds, "orientation", "Orientation:", m);
	panel->AddChild(fOrientationMenu);
	fOrientationMenu->ResizeToPreferred();
	fOrientationMenu->SetDivider(divider);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		m->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("PDF compatibility");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fOrientationMenu->Bounds().Height() + 10.0);
	fPDFCompatibilityMenu = new BMenuField(bounds, "pdf_compatibility",
		"PDF compatibility:", m);
	panel->AddChild(fPDFCompatibilityMenu);
	fPDFCompatibilityMenu->ResizeToPreferred();
	fPDFCompatibilityMenu->SetDivider(divider);
	fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
		BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
		m->AddItem(item);
		if (setting_value == pdf_compatibility[i])
			item->SetMarked(true);
	}

	bounds.OffsetBy(0.0, fPDFCompatibilityMenu->Bounds().Height() + 10.0);
	fPDFCompressionSlider = new BSlider(bounds, "pdf_compression",
		"Compression:", NULL, 0, 9);
	panel->AddChild(fPDFCompressionSlider);
	fPDFCompressionSlider->SetLimitLabels("None", "Best");
	fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fPDFCompressionSlider->SetValue(compression);
	fPDFCompressionSlider->ResizeToPreferred();

	bounds = Bounds();
	bounds.InsetBy(5.0, 0.0);
	bounds.top = MAX(fPDFCompressionSlider->Frame().bottom,
		fMarginView->Frame().bottom) + 10.0;
	BBox *line = new BBox(BRect(bounds.left, bounds.top, bounds.right,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT);
	panel->AddChild(line);

	bounds.InsetBy(5.0, 0.0);
	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fPDFCompressionSlider->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BButton *button = new BButton(bounds, NULL, "Fonts" B_UTF8_ELLIPSIS,
		new BMessage(FONTS_MSG));
	panel->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(fMarginView->Frame().left, bounds.top);

	bounds = button->Frame();
	button = new BButton(bounds, NULL, "Advanced" B_UTF8_ELLIPSIS,
		new BMessage(ADVANCED_MSG));
	panel->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(bounds.right + 10, bounds.top);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
/*!	\brief		Insert new item into the menu in alphabetical order.
 *	\param[in]	item	The CategoryMenuItem to insert.
 *	\note		\"Default\" item and separator
 *				The item with label "Default" is always the first in list.
 *				The separator, if it exists, is always the second.
 *				All other items are sorted alphabetically.
 */
bool	CategoryMenu::AddItem( CategoryMenuItem* item )
{
	int index, limit = this->CountItems();
	BString label( item->Label() ), testString("Default");
	BMenuItem* itemToTest = NULL;
	CategoryMenuItem *catItem = NULL;
	
	/* Maybe we're adding default item? */
	if ( label == testString ) 
	{
		// If current label is "Default"
		if ( ( limit == 0 ) || ( BString( ItemAt( 0 )->Label() ) != testString ) )
		{			
			// And the menu is empty or the first item has another label
			// Adding "Default" at the first place.
			return BMenu::AddItem( item, 0 );
		}
		else
		{
			// The menu is not empty, and the first item is already "Default".
			catItem = dynamic_cast<CategoryMenuItem*>( ItemAt( 0 ) );
			if ( catItem ) {
				catItem->UpdateColor( item->GetColor() );
			}
			delete item;
			return true;	// Exit - nothing to do
		}
	}
	// Else, the item should not be added at all - there must be only one! (c) Kurgan
	
	/* Well, the category to be added was not a "Default". 
	 * It's not a separator either; the separator is added by BMenu::AddItem(). 
	 */
	index = 0;
	while ( index < limit ) {
		itemToTest = ItemAt( index );
		catItem = dynamic_cast< CategoryMenuItem* >( itemToTest );
		testString.SetTo( itemToTest->Label() );
		
		// Jumping over "Default" item
		if ( testString == "Default" )
		{
			++index;
			continue;
		}
		
		// Jumping over non-CategoryMenuItem items
		if ( !catItem )
		{
			++index;
			continue;
		}
		
		/* Now the tough part starts */
			// Jump over items that are alphabetically lower
		if ( testString < label )
		{
			++index;
			continue;
		}
			// If same item was found - update its color
		else if ( testString == label )
		{
			if ( catItem ) {
				catItem->UpdateColor( item->GetColor() );
			}
			delete item;
			return true;	// Exit - nothing to do
		}
			// Found first item that's greater alphabetically
		else
		{
			// Verify the message
			if ( ! item->Message() )
			{
				BMessage* toSend = NULL;
				if ( fTemplateMessage ) {
					toSend = new BMessage( *fTemplateMessage );
				} else {
					toSend = new BMessage( kCategorySelected );
				}
				if ( !toSend ) { return false; }
				toSend->AddString( "Category", item->Label() );
				item->SetMessage( toSend );
			}
			return BMenu::AddItem( item, index );
		}
		
		++index;
	}
	
	// If we got here, then it should be the last item.
	if ( ! item->Message() )
	{
		BMessage* toSend = NULL;
		if ( fTemplateMessage ) {
			toSend = new BMessage( *fTemplateMessage );
		} else {
			toSend = new BMessage( kCategorySelected );
		}
		if ( !toSend ) { return false; }
		toSend->AddString( "Category", item->Label() );
		item->SetMessage( toSend );
	}
	return BMenu::AddItem( item );
	
}	//	<-- end of function CategoryMenu::AddItem
void SetDefault(s9x_settings &settings)
{
	memset(&settings, 0, sizeof(settings));

	// Sound
	settings.sound.s9x_mute = 0;
	settings.sound.s9x_stereo = 1;
	settings.sound.s9x_SixteenBitSound = 1;
	settings.sound.s9x_InterpolatedSound = 1;
	settings.sound.s9x_SoundEnvelopeHeightReading = 1;
	settings.sound.s9x_DisableSoundEcho = 0;
	settings.sound.s9x_DisableSampleCaching = 0;
	settings.sound.s9x_DisableMasterVolume = 0;
	settings.sound.s9x_ThreadSound = 0;
	settings.sound.s9x_NextAPUEnabled = 1;
			
	settings.sound.s9x_ReverseStereo = 0;
	settings.sound.s9x_TraceSoundDSP = 0;
	settings.sound.s9x_SoundSync = 0;
	settings.sound.s9x_AltSampleDecode = 0;
	settings.sound.s9x_FixFrequency = 0;
	
	//s9x_ROM_image
    settings.ROMImage.s9x_ForceLoROM = 0;
    settings.ROMImage.s9x_ForceHiROM = 0;
    settings.ROMImage.s9x_ForceHeader = 0;
    settings.ROMImage.s9x_ForceNoHeader = 0;
    settings.ROMImage.s9x_ForceInterleaved = 0;
    settings.ROMImage.s9x_ForceInterleaved2 = 0;
    settings.ROMImage.s9x_ForceNotInterleaved = 0;

	//peripherial
    settings.peripherial.s9x_ForceSuperFX = 0;
    settings.peripherial.s9x_ForceNoSuperFX = 0;
    settings.peripherial.s9x_ForceDSP1 = 0;
    settings.peripherial.s9x_ForceNoDSP1 = 0;
    settings.peripherial.s9x_ForceSA1 = 0;
    settings.peripherial.s9x_ForceNoSA1 = 0;
    settings.peripherial.s9x_ForceC4 = 0;
    settings.peripherial.s9x_ForceNoC4 = 0;
    settings.peripherial.s9x_ForceSDD1 = 0;
    settings.peripherial.s9x_ForceNoSDD1 = 0;
    settings.peripherial.s9x_MultiPlayer5 = 1;
    settings.peripherial.s9x_Mouse = 1;
    settings.peripherial.s9x_SuperScope = 0;
    settings.peripherial.s9x_SRTC = 0;
    settings.peripherial.s9x_ShutdownMaster = 1;
    settings.peripherial.s9x_MultiPlayer5Master = 0;
    settings.peripherial.s9x_SuperScopeMaster = 0;
    settings.peripherial.s9x_MouseMaster = 0;
    settings.peripherial.s9x_SuperFX = 0;
    settings.peripherial.s9x_DSP1Master = 0;
    settings.peripherial.s9x_SA1 = 0;
    settings.peripherial.s9x_C4 = 0;
    settings.peripherial.s9x_SDD1 = 0;
    settings.peripherial.s9x_SPC7110 = 0;
    settings.peripherial.s9x_SPC7110RTC = 0;
    settings.peripherial.s9x_OBC1 = 0;
    settings.peripherial.s9x_ControllerOption = SNES_MULTIPLAYER5;

	//s9x_Graphics
	settings.graphics.s9x_SixteenBit = 1;
	settings.graphics.s9x_Transparency = 1;
	settings.graphics.s9x_SupportHiRes = 1;
	settings.graphics.s9x_Mode7Interpolate = 0;
	settings.graphics.s9x_BGLayering = 0;
	settings.graphics.s9x_DisableGraphicWindows = 0;
	settings.graphics.s9x_ForceTransparency = 1;
	settings.graphics.s9x_ForceNoTransparency = 0;
	settings.graphics.s9x_DisableHDMA = 0;
	settings.graphics.s9x_DisplayFrameRate = 1;
	settings.graphics.s9x_DisableRangeTimeOver = 0;
	
	//s9x_Network
	settings.network.s9x_NetPlay = 0;
	settings.network.s9x_NetPlayServer = 0;
    settings.network.s9x_ServerName = BString("Haiku Server");
    settings.network.s9x_Port = 6096; //From netplay.h

	//s9x_Misc
	settings.misc.s9x_GlideEnable = 0;
	settings.misc.s9x_OpenGLEnable = 0;
	settings.misc.s9x_ApplyCheats = 1;
	settings.misc.s9x_TurboMode = 0;
    settings.misc.s9x_TurboSkipFrames = 15;
    settings.misc.s9x_AutoMaxSkipFrames = 0;
	settings.misc.s9x_AutoSaveDelay = 30;

	// Ui
	settings.ui.s9x_mode = 0;
	settings.ui.s9x_snooze = 1;
	settings.ui.s9x_inactive = 1;
	settings.ui.s9x_allow = 0;
	settings.ui.s9x_menuactive = 0;
	settings.ui.s9x_vsync = 0;
	settings.ui.s9x_extended = 0;
	settings.ui.s9x_drawmode = 0;
	
	//RecentRoms
	settings.recentroms.recentRom1 = BString("");
	settings.recentroms.recentRom2 = BString("");
	settings.recentroms.recentRom3 = BString("");
	settings.recentroms.recentRom4 = BString("");
	settings.recentroms.recentRom5 = BString("");
	
	// Controller
	settings.controll.s9x_SwapJoypads = 0;
	settings.controll.s9x_JoystickEnabled = 1;
	
	// Controller 1
	settings.controll.s9x_controller1.k_up = S9X_UP;
	settings.controll.s9x_controller1.k_down = S9X_DOWN;
	settings.controll.s9x_controller1.k_left = S9X_LEFT;
	settings.controll.s9x_controller1.k_right = S9X_RIGHT;
	settings.controll.s9x_controller1.k_a = S9X_Z;
	settings.controll.s9x_controller1.k_b = S9X_X;
	settings.controll.s9x_controller1.k_x = S9X_C;
	settings.controll.s9x_controller1.k_y = S9X_V;
	settings.controll.s9x_controller1.k_l = S9X_B;
	settings.controll.s9x_controller1.k_r = S9X_LCONTROL;
	settings.controll.s9x_controller1.k_start = S9X_RETURN;
	settings.controll.s9x_controller1.k_select = S9X_SPACE;
	
	// Controller 2
	settings.controll.s9x_controller2.k_up = S9X_Y;
	settings.controll.s9x_controller2.k_down = S9X_B;
	settings.controll.s9x_controller2.k_left = S9X_G;
	settings.controll.s9x_controller2.k_right = S9X_J;
	settings.controll.s9x_controller2.k_a = S9X_B;
	settings.controll.s9x_controller2.k_b = S9X_N;
	settings.controll.s9x_controller2.k_x = S9X_L;
	settings.controll.s9x_controller2.k_y = S9X_LBRACE;
	settings.controll.s9x_controller2.k_l = S9X_RBRACE;
	settings.controll.s9x_controller2.k_r = S9X_HASH;
	settings.controll.s9x_controller2.k_start = S9X_M;
	settings.controll.s9x_controller2.k_select = S9X_RSLASH;
}
void PeepsWindow::MessageReceived(BMessage *msg)
{
	switch(msg->what)
	{
		case B_ABOUT_REQUESTED:
		{
			be_app->PostMessage(msg);
			break;
		}
		case M_RUN_TOOL:
		{
			BString sig;
			if(msg->FindString("signature",&sig)==B_OK)
			{
				if(strcmp(sig.String(),"application/x-vnd.wgp-PeopleMover")==0)
				{
					be_roster->Launch(sig.String());
					break;
				}
				
				// Get the filename for the currently-selected person
				int32 selection=fPeopleList->CurrentSelection();
				if(selection<0)
					break;
				
				PeepsListItem *peepsitem=(PeepsListItem*)fPeopleList->ItemAt(selection);
				if(!peepsitem || peepsitem->IsGroup())
					break;
				
				PersonItem *personitem=(PersonItem*)peepsitem;
				PersonData *persondata=personitem->GetData();
				
				if(!persondata)
					break;
				
				entry_ref ref=persondata->FileRef();
				BPath path(&ref);
				
				char *launchv[1];
				launchv[0]=new char[255];
				
				sprintf(launchv[0],"%s",path.Path());
				
				be_roster->Launch(sig.String(),1,launchv,NULL);
				
				delete [] launchv[0];
			}
			break;
		}
		case M_SHOW_ACTIONS:
		{
			uint32 buttons;
			BPoint pt;
			
			fPeopleList->GetMouse(&pt,&buttons,false);
			pt.x=(pt.x>5)?pt.x-5:0;
			pt.y=(pt.y>5)?pt.y-5:0;
			fPeopleList->ShowContextMenu(fPeopleList->ConvertToScreen(pt));
			
			break;
		}
		case M_BITMAP_REMOVED:
		case M_PHOTO_MODIFIED:
		{
			fPeopleList->SaveImageData();
			break;
		}
		case B_REFS_RECEIVED:
		case B_SIMPLE_DATA:
		{
			entry_ref ref;
			if(msg->FindRef("refs",0,&ref)==B_OK)
			{
				if(!IsPerson(ref))
				{
					// Might be an image dropped on the photo view. find out which child is the
					// target
					BPoint pt;
					if(msg->FindPoint("_drop_offset",&pt)!=B_OK)
						break;
					
					BView *target=FindView(pt);
					if(!target || strcmp(target->Name(),"photoview")!=0)
						break;
					
					// This will set the image, if possible
					target->MessageReceived(msg);
					
					// Save the image data to a real file and attach the Person attributes
					// to it
					fPeopleList->SaveImageData();
				}
				
				// Offer to move/copy file if not in People directory
				BDirectory dir,peopledir("/boot/home/people");
				BEntry entry(&ref);
				entry.GetParent(&dir);
				if(dir!=peopledir)
				{
					BString refname(ref.name);
					BString errstr=TRANSLATE("%s is not currently stored in the People folder. Mr. Peeps! will not"
						" see it on startup unless it is stored there. Would you like to move it"
						" there?");
					char errmsg[errstr.CountChars() - 2 + refname.CountChars() + 1];
					sprintf(errmsg,errstr.String(),refname.String());
					
					BAlert *alert=new BAlert("Mr. Peeps!",errmsg,TRANSLATE("Move"),TRANSLATE("Don't Move"));
					if(alert->Go()==0)
					{
						entry.MoveTo(&peopledir);
						entry.GetRef(&ref);
					}
				}
				if(!SelectPerson(ref))
					AddPerson(ref,true);
			}
			break;
		}
		case M_PREV_ITEM:
		{
			if(fPeopleList->CountItems()==0)
				break;
				
			int32 selection=fPeopleList->CurrentSelection();

			if(!fPeopleList->IsFocus())
			{
				fPeopleList->MakeFocus(true);
				PeepsListItem *pitem=(PeepsListItem*)fPeopleList->ItemAt(selection);
				if(!pitem->IsGroup())
				{
					fPeopleList->SyncData((PersonItem*)pitem);
//					fPeopleList->SaveData();
				}
				fPeopleList->SaveData();
			}

			if(selection>=0)
			{
				if(selection>0)
					fPeopleList->Select(selection-1);
			}
			else
			{
				fPeopleList->Select(0L);
			}
			break;
		}
		case M_NEXT_ITEM:
		{
			if(fPeopleList->CountItems()==0)
				break;
				
			int32 selection=fPeopleList->CurrentSelection();

			if(!fPeopleList->IsFocus())
			{
				fPeopleList->MakeFocus(true);
				PeepsListItem *pitem=(PeepsListItem*)fPeopleList->ItemAt(selection);
				if(!pitem->IsGroup())
				{
					fPeopleList->SyncData((PersonItem*)pitem);
//					fPeopleList->SaveData();
				}
				fPeopleList->SaveData();
			}
			
			if(selection==fPeopleList->CountItems()-1 || selection<0)
				fPeopleList->Select(fPeopleList->CountItems()-1);
			else
				fPeopleList->Select(selection+1);
			
			break;
		}
		case M_MOD_DATA:
		case M_SAVE:
		{
			fPeopleList->SyncData(NULL);
			fPeopleList->SaveData();
			break;
		}
		case M_ADD_PERSON:
		{
			entry_ref ref;
			
			status_t stat=CreatePerson(&ref);
			if(stat==B_FILE_EXISTS)
			{
				for(int32 i=0;i<gPeopleData.CountItems(); i++)
				{
					PersonData *pdata=(PersonData*)gPeopleData.ItemAt(i);
					
					if(BString(TRANSLATE("New Person")).ICompare(pdata->Name())==0)
					{
						int32 selection=fPeopleList->CurrentSelection();
						if(selection>=0)
						{
							PeepsListItem *peepsitem=(PeepsListItem*)fPeopleList->ItemAt(selection);
							if(peepsitem && !peepsitem->IsGroup())
								fPeopleList->Collapse(fPeopleList->Superitem(peepsitem));
						}
						PersonItem *pitem=pdata->InstanceAt(0);
						GroupItem *gitem=(GroupItem*)fPeopleList->Superitem(pitem);
						if(!gitem->IsExpanded())
							fPeopleList->Expand(gitem);
						fPeopleList->Select(fPeopleList->IndexOf(pitem));
						fPeopleList->ScrollToSelection();
						break;
					}
				}
			}
			else
			{
				// Add the current group to the New Person's file so that we end up staying
				// in the current group.
				if(stat==B_OK)
				{
					int32 selection=fPeopleList->CurrentSelection();
					BString groupstr(TRANSLATE("Ungrouped"));

					if(selection>=0)
					{
						PeepsListItem *currentitem=(PeepsListItem*)fPeopleList->ItemAt(selection);
						if(currentitem->IsGroup())
							groupstr=currentitem->Name();
						else
							groupstr=((PersonItem*)currentitem)->Group();
					}
					PersonData *pdata=new PersonData(ref);
					pdata->SetGroup(groupstr.String());
					pdata->SetName(TRANSLATE("New Person"));
					pdata->SaveToFile();
					delete pdata;
					AddPerson(ref,true);
					SortList();
					SelectPerson(TRANSLATE("New Person"));
					dataview->SetFirstFieldFocus();
				}
			}
			break;
		}
		case M_DELETE_PERSON:
		{
			int32 selection=fPeopleList->CurrentSelection();
			if(selection<0)
				break;
			PeepsListItem *item=(PeepsListItem*)fPeopleList->ItemAt(selection);
			if(item->IsGroup())
				DeleteGroup((GroupItem*)item);
			else
			{
				DeletePerson(((PersonItem*)item)->GetData());
			}
			break;
		}
		case M_DISABLE_DELETE:
		{
			BMenuItem *item=fPeopleMenu->FindItem(TRANSLATE("Move To Trash"));
			if(item)
				item->SetEnabled(false);
			break;
		}	
		case M_ENABLE_DELETE:
		{
			BMenuItem *item=fPeopleMenu->FindItem(TRANSLATE("Move To Trash"));
			if(item)
				item->SetEnabled(true);
			break;
		}	
		case M_SET_LANGUAGE:
		{
			// Restart MrPeeps!
			gRestartApp=true;
			
			int32 language;
			if(msg->FindInt32("index",&language)!=B_OK)
				break;
			
			BMenuItem *item = fLanguageMenu->ItemAt(language);
			if(!item)
				break;
			
			fLocale = item->Label();
			WriteLocaleSettings();
			
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		}
		case M_HANDLE_NO_SELECTION:
		{
			// This is the initial case. No selection means quite a few different
			// menu items are disabled.
			fTabMenu->SetEnabled(false);
			fEditMenu->SetEnabled(false);
			
			if(fToolPeopleAtAGlance)
				fToolPeopleAtAGlance->SetEnabled(false);
			
			if(fToolVCardExport)
				fToolVCardExport->SetEnabled(false);
			
			UpdateActions(true);
			break;
		}	
		case M_HANDLE_GROUP_SELECTION:
		{
			// This is the initial case. No selection means quite a few different
			// menu items are disabled.
			fTabMenu->SetEnabled(false);
			fEditMenu->SetEnabled(true);
			
			if(fToolPeopleAtAGlance)
				fToolPeopleAtAGlance->SetEnabled(false);
			
			if(fToolVCardExport)
				fToolVCardExport->SetEnabled(false);
			
			UpdateActions(true);
			break;
		}	
		case M_HANDLE_PERSON_SELECTION:
		{
			// This is the initial case. No selection means quite a few different
			// menu items are disabled.
			fTabMenu->SetEnabled(true);
			fEditMenu->SetEnabled(true);
			
			if(fToolPeopleAtAGlance)
				fToolPeopleAtAGlance->SetEnabled(true);
			
			if(fToolVCardExport)
				fToolVCardExport->SetEnabled(true);
			
			UpdateActions(false);
			break;
		}	
		case M_SEND_PERSONAL_EMAIL:
		{
			if(dataview->Email())
			{
				BMessage *emailmsg=new BMessage(M_SEND_EMAIL);
				emailmsg->AddString("address",dataview->Email());
				be_app->PostMessage(emailmsg);
			}
			break;
		}
		case M_SEND_WORK_EMAIL:
		{
			if(dataview->WorkEmail())
			{
				BMessage *emailmsg=new BMessage(M_SEND_EMAIL);
				emailmsg->AddString("address",dataview->WorkEmail());
				be_app->PostMessage(emailmsg);
			}
			break;
		}
		case M_SEND_ALT_EMAIL:
		{
			if(dataview->Email3())
			{
				BMessage *emailmsg=new BMessage(M_SEND_EMAIL);
				emailmsg->AddString("address",dataview->Email3());
				be_app->PostMessage(emailmsg);
			}
			break;
		}
		case M_BROWSE_WWW_HOME:
		{
			if(dataview->URL())
			{
				BMessage *wwwmsg=new BMessage(M_LAUNCH_BROWSER);
				wwwmsg->AddString("address",dataview->URL());
				be_app->PostMessage(wwwmsg);
			}
			break;
		}
		case M_BROWSE_WWW_WORK:
		{
			if(dataview->WorkURL())
			{
				BMessage *wwwmsg=new BMessage(M_LAUNCH_BROWSER);
				wwwmsg->AddString("address",dataview->WorkURL());
				be_app->PostMessage(wwwmsg);
			}
			break;
		}
		case M_BROWSE_WWW_ALT:
		{
			if(dataview->OtherURL())
			{
				BMessage *wwwmsg=new BMessage(M_LAUNCH_BROWSER);
				wwwmsg->AddString("address",dataview->OtherURL());
				be_app->PostMessage(wwwmsg);
			}
			break;
		}
		case M_TAB_1:
		{
			fPeopleList->SyncData();
			fPeopleList->SaveData();
			dataview->ShowTab(0);
			if(!fPeopleList->IsFocus())
				dataview->SetFirstFieldFocus();
			break;
		}
		case M_TAB_2:
		{
			fPeopleList->SyncData();
			fPeopleList->SaveData();
			dataview->ShowTab(1);
			if(!fPeopleList->IsFocus())
				dataview->SetFirstFieldFocus();
			break;
		}
		case M_TAB_3:
		{
			fPeopleList->SyncData();
			fPeopleList->SaveData();
			dataview->ShowTab(2);
			if(!fPeopleList->IsFocus())
				dataview->SetFirstFieldFocus();
			break;
		}
		case M_TAB_4:
		{
			fPeopleList->SyncData();
			fPeopleList->SaveData();
			dataview->ShowTab(3);
			if(!fPeopleList->IsFocus())
				dataview->SetFirstFieldFocus();
			break;
		}
		case M_TAB_5:
		{
			fPeopleList->SyncData();
			fPeopleList->SaveData();
			dataview->ShowTab(4);
			if(!fPeopleList->IsFocus())
				dataview->SetFirstFieldFocus();
			break;
		}
		case M_UNDO:
		{
			dataview->UndoField();
			break;
		}
		case M_CUT:
		{
			dataview->CutField();
			break;
		}
		case M_COPY:
		{
			dataview->CopyField();
			break;
		}
		case M_PASTE:
		{
			dataview->PasteField();
			break;
		}
		case B_NODE_MONITOR:
		{
			HandleNodeMonitoring(msg);
			break;
		}
		default:
		{
			BWindow::MessageReceived(msg);
			break;
		}
	}
}
Exemple #7
0
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	: HWindow(BRect(0, 0, 200, 100), "Page setup", B_TITLED_WINDOW_LOOK,
 		B_MODAL_APP_WINDOW_FEEL,
 		B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
			| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
	 fResult(B_ERROR),
	 fSetupMsg(msg),
	 fAdvancedSettings(*msg),
	 fPrinterDirName(printerName)
{
	fExitSem = create_sem(0, "PageSetup");

	if (printerName)
		SetTitle(BString(printerName).Append(" page setup").String());

	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("pdf_paper_size", &label) != B_OK)
		label = "Letter";

	int32 compression;
	fSetupMsg->FindInt32("pdf_compression", &compression);

	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BString setting_value;
	if (fSetupMsg->FindString("pdf_compatibility", &setting_value) != B_OK)
		setting_value = "1.3";

	// Load font settings
	fFonts = new Fonts();
	fFonts->CollectFonts();
	BMessage fonts;
	if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK)
		fFonts->SetTo(&fonts);

	fMarginView = new MarginView(int32(width), int32(height), margin,
		MarginUnit(units));

	BPopUpMenu* pageSize = new BPopUpMenu("Page size");
	pageSize->SetRadioMode(true);

	fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSize);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		pageSize->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
	orientationPopUpMenu->SetRadioMode(true);

	fOrientationMenu = new BMenuField("orientation", "Orientation:",
		orientationPopUpMenu);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		orientationPopUpMenu->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	BPopUpMenu* compatibility = new BPopUpMenu("PDF compatibility");
	compatibility->SetRadioMode(true);

	fPDFCompatibilityMenu = new BMenuField("pdf_compatibility",
		"PDF compatibility:", compatibility);
	fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
		BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
		compatibility->AddItem(item);
		if (setting_value == pdf_compatibility[i])
			item->SetMarked(true);
	}

	fPDFCompressionSlider = new BSlider("pdf_compression",
		"Compression:", NULL, 0, 9, B_HORIZONTAL);
	fPDFCompressionSlider->SetLimitLabels("None", "Best");
	fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fPDFCompressionSlider->SetValue(compression);

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

	BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));

	BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
	ok->MakeDefault(true);

	BButton *fontsButton = new BButton("fonts", "Fonts" B_UTF8_ELLIPSIS,
		new BMessage(FONTS_MSG));

	BButton* advancedButton = new BButton("advanced",
		"Advanced" B_UTF8_ELLIPSIS,
		new BMessage(ADVANCED_MSG));

	BGridView* settings = new BGridView();
	BGridLayout* settingsLayout = settings->GridLayout();
	settingsLayout->AddItem(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0);
	settingsLayout->AddItem(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0);
	settingsLayout->AddItem(fOrientationMenu->CreateLabelLayoutItem(), 0, 1);
	settingsLayout->AddItem(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1);
	settingsLayout->AddItem(fPDFCompatibilityMenu->CreateLabelLayoutItem(), 0, 2);
	settingsLayout->AddItem(fPDFCompatibilityMenu->CreateMenuBarLayoutItem(), 1, 2);
	settingsLayout->AddView(fPDFCompressionSlider, 0, 3, 2);
	settingsLayout->SetSpacing(0, 0);

	SetLayout(new BGroupLayout(B_VERTICAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
		.AddGroup(B_HORIZONTAL, 5, 1)
			.AddGroup(B_VERTICAL, 0, 1.0f)
				.Add(fMarginView)
				.AddGlue()
			.End()
			.AddGroup(B_VERTICAL, 0, 1.0f)
				.Add(settings)
				.AddGlue()
			.End()
		.End()
		.Add(separator)
		.AddGroup(B_HORIZONTAL, 10, 1.0f)
			.Add(fontsButton)
			.Add(advancedButton)
			.AddGlue()
			.Add(cancel)
			.Add(ok)
		.End()
		.SetInsets(10, 10, 10, 10)
	);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
BString
PootleProject::Description()
{
	_EnsureData();
	return BString(mData.GetString("description", ""));
}
BString
PootleProject::FullName()
{
	_EnsureData();
	return BString(mData.GetString("fullname", ""));
}
BString
PootleProject::CheckStyle()
{
	_EnsureData();
	return BString(mData.GetString("checkstyle", ""));
}
BString
PootleProject::Code()
{
	_EnsureData();
	return BString(mData.GetString("code", ""));
}
BString
PootleProject::TreeStyle()
{
	_EnsureData();
	return BString(mData.GetString("treestyle", ""));
}
BString
PootleProject::Backlink()
{
	_EnsureData();
	return BString(mData.GetString("backlink", ""));
}
Exemple #14
0
void InfoView::UpdateDisplay( BMessage* message ) {
	
	time_t *membersince;
	char theTime[100], stemp[100];
	BString origProfile;
	unsigned idletime;
	ssize_t size;
	bool away = false;
	
	// away?
	if( message->HasBool("away") && message->FindBool("away") )
		away = true;
	
	// username
	if( message->HasString("userid") ) {
		
		BMessage* msg = new BMessage(BEAIM_UPDATE_NAME_FORMAT);
		msg->AddString("userid", message->FindString("userid"));
		Window()->PostMessage( msg );
		
		char windowTitle[DISPLAY_NAME_MAX+35];
		sprintf( windowTitle, "%s: %s", Language.get("IW_USER_INFO"), message->FindString("userid") );
		if( away ) {
			strcat( windowTitle, "  (" );
			strcat( windowTitle, Language.get("STAT_AWAY") );
			strcat( windowTitle, ")" );
		}
		Window()->SetTitle( windowTitle );
	}

	// user class
	if( message->HasString("userclass") ) {
		label2->SetText( message->FindString( "userclass" ) );
		printf( "IW: userclass done.\n" );
		fflush(stdout);
	}

	// member since
	if( message->HasData("membersince", B_TIME_TYPE) ) {
		message->FindData( "membersince", B_TIME_TYPE, (const void**)(&membersince), &size );
		strftime( theTime, 100, "%B %e, %Y", localtime(membersince) );
		label4->SetText( theTime );
	}
	
	// onsince	
	/*if( message->HasData("onsince", B_TIME_TYPE) ) {
	
		message->FindData( "onsince", B_TIME_TYPE, (const void**)(&onsince), &size );
		MakeElapsedTimeString( *onsince, theTime );
		label6->SetText( theTime );
	}*/
	
	// session length
	if( message->HasInt32("sessionlen") ) { 
		MakeElapsedTimeString( message->FindInt32("sessionlen"), theTime );
		label6->SetText( theTime );
	}
	
	// warning level
	if( message->HasInt32("warninglevel") ) {
		sprintf( stemp, "%u%%", (unsigned)(message->FindInt32("warninglevel")) );
		label8->SetText( stemp );
	}
	
	// idle time
	if( message->HasInt32( "idletime" ) ) {
		idletime = (unsigned)message->FindInt32("idletime");
		if( idletime ) {
			label9->SetText( (char*)LangWithSuffix("STAT_IDLE_TIME", ":") );
			MakeElapsedTimeString( (idletime*60), stemp );
			label10->SetText( stemp );
			statNotIdle = false;
		} else {
			label10->SetText( Language.get("STAT_ACTIVE") );
		}
	}
		
	// profile
	if( message->HasString("profile" ) )
		origProfile = BString((char*)message->FindString("profile"));

	if( origProfile.Length() ) {
		HTMLParser parse;
		styleList styles;

		// first, convert it to UTF-8
		origProfile = ConvertToUTF8( origProfile, encoding );

		// handle the away message variables
		client->ReplaceTagVars( origProfile );
		
		// automatically link the web and mail addresses that weren't linked
		Linkify( origProfile );

		profile->SetText("");
		profile->ClearInsertStuff();
		profile->ResetFontToBase();
		parse.Parse( const_cast<char*>(origProfile.String()) );
		styles = parse.Styles();
		profile->SetViewColor( styles.bgColor.R(), styles.bgColor.G(), styles.bgColor.B() );
		profile->Invalidate();
		profile->AddStyledText( parse.ParsedString(), styles );
		styles.Clear();
		profile->AddStatement();
	} 
	
	// put up a generic "no profile" message
	else
		profile->SetText( Language.get("IW_NO_PROFILE") );
	BView::Invalidate();
}
Exemple #15
0
void
DownloadProgressView::_UpdateStatusText()
{
	fInfoView->SetText("");
	BString buffer;
	if (sShowSpeed && fBytesPerSecond != 0.0) {
		// Draw speed info
		char sizeBuffer[128];
		buffer = "(";
		// Get strings for current and expected size and remove the unit
		// from the current size string if it's the same as the expected
		// size unit.
		BString currentSize = string_for_size((double)fCurrentSize, sizeBuffer,
			sizeof(sizeBuffer));
		BString expectedSize = string_for_size((double)fExpectedSize, sizeBuffer,
			sizeof(sizeBuffer));
		int currentSizeUnitPos = currentSize.FindLast(' ');
		int expectedSizeUnitPos = expectedSize.FindLast(' ');
		if (currentSizeUnitPos >= 0 && expectedSizeUnitPos >= 0
			&& strcmp(currentSize.String() + currentSizeUnitPos,
				expectedSize.String() + expectedSizeUnitPos) == 0) {
			currentSize.Truncate(currentSizeUnitPos);
		}
		buffer << currentSize;
		buffer << " ";
		buffer << B_TRANSLATE_COMMENT("of", "...as in '12kB of 256kB'");
		buffer << " ";
		buffer << expectedSize;
		buffer << ", ";
		buffer << string_for_size(fBytesPerSecond, sizeBuffer,
			sizeof(sizeBuffer));
		buffer << B_TRANSLATE_COMMENT("/s)", "...as in 'per second'");
		float stringWidth = fInfoView->StringWidth(buffer.String());
		if (stringWidth < fInfoView->Bounds().Width())
			fInfoView->SetText(buffer.String());
		else {
			// complete string too wide, try with shorter version
			buffer << string_for_size(fBytesPerSecond, sizeBuffer,
				sizeof(sizeBuffer));
			buffer << B_TRANSLATE_COMMENT("/s)", "...as in 'per second'");
			stringWidth = fInfoView->StringWidth(buffer.String());
			if (stringWidth < fInfoView->Bounds().Width())
				fInfoView->SetText(buffer.String());
		}
	} else if (!sShowSpeed && fCurrentSize < fExpectedSize) {
		double totalBytesPerSecond = (double)(fCurrentSize
				- fEstimatedFinishReferenceSize)
			* 1000000LL / (system_time() - fEstimatedFinishReferenceTime);
		double secondsRemaining = (fExpectedSize - fCurrentSize)
			/ totalBytesPerSecond;
		time_t now = (time_t)real_time_clock();
		time_t finishTime = (time_t)(now + secondsRemaining);

		tm _time;
		tm* time = localtime_r(&finishTime, &_time);
		int32 year = time->tm_year + 1900;

		char timeText[32];
		time_t secondsPerDay = 24 * 60 * 60;
		// TODO: Localization of time string...
		if (now < finishTime - secondsPerDay) {
			// process is going to take more than a day!
			sprintf(timeText, "%0*d:%0*d %0*d/%0*d/%ld",
				2, time->tm_hour, 2, time->tm_min,
				2, time->tm_mon + 1, 2, time->tm_mday, year);
		} else {
			sprintf(timeText, "%0*d:%0*d",
				2, time->tm_hour, 2, time->tm_min);
		}

		BString buffer1(B_TRANSLATE_COMMENT("Finish: ", "Finishing time"));
		buffer1 << timeText;
		finishTime -= now;
		time = gmtime(&finishTime);

		BString buffer2;
		if (finishTime > secondsPerDay) {
			int64 days = finishTime / secondsPerDay;
			if (days == 1)
				buffer2 << B_TRANSLATE("Over 1 day left");
			else {
				buffer2 << B_TRANSLATE("Over %days days left");
				buffer2.ReplaceFirst("%days", BString() << days);
			}
		} else if (finishTime > 60 * 60) {
			int64 hours = finishTime / (60 * 60);
			if (hours == 1)
				buffer2 << B_TRANSLATE("Over 1 hour left");
			else {
				buffer2 << B_TRANSLATE("Over %hours hours left");
				buffer2.ReplaceFirst("%hours", BString() << hours);
			}
		} else if (finishTime > 60) {
			int64 minutes = finishTime / 60;
			if (minutes == 1)
				buffer2 << B_TRANSLATE("Over 1 minute left");
			else {
				buffer2 << B_TRANSLATE("%minutes minutes");
				buffer2.ReplaceFirst("%minutes", BString() << minutes);
			}
		} else {
			if (finishTime == 1)
				buffer2 << B_TRANSLATE("1 second left");
			else {
				buffer2 << B_TRANSLATE("%seconds seconds left");
				buffer2.ReplaceFirst("%seconds", BString() << finishTime);
			}
		}

		buffer = "(";
		buffer << buffer1 << " - " << buffer2 << ")";

		float stringWidth = fInfoView->StringWidth(buffer.String());
		if (stringWidth < fInfoView->Bounds().Width())
			fInfoView->SetText(buffer.String());
		else {
			// complete string too wide, try with shorter version
			buffer = "(";
			buffer << buffer1 << ")";
			stringWidth = fInfoView->StringWidth(buffer.String());
			if (stringWidth < fInfoView->Bounds().Width())
				fInfoView->SetText(buffer.String());
		}
	}
}
BString
PootleProject::IgnoredFiles()
{
	_EnsureData();
	return BString(mData.GetString("ignoredfiles", ""));
}
void CharSheetManager::handleDatabaseJobComplete(void* ref, DatabaseResult* result)
{
    CSAsyncContainer* asyncContainer = reinterpret_cast<CSAsyncContainer*>(ref);

    switch(asyncContainer->mQuery)
    {
    case CharSheetQuery_Factions:
    {

        BString name;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_bstring,0,255,1);

        uint64 count = result->getRowCount();
        mvFactions.reserve((uint32)count);
        for(uint64 i = 0; i < count; i++)
        {
            result->getNextRow(binding,&name);
            mvFactions.push_back(BString(name.getAnsi()));
        }

        //LOG(info) << "Loaded " << count << " factions";

        mDatabase->destroyDataBinding(binding);

        // load badge categories
        mDatabase->executeSqlAsync(this,new(mDBAsyncPool.malloc()) CSAsyncContainer(CharSheetQuery_BadgeCategories),"SELECT * FROM %s.badge_categories ORDER BY id",mDatabase->galaxy());
        
    }
    break;

    case CharSheetQuery_BadgeCategories:
    {
        BString name;
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_bstring,0,255,1);

        uint64 count = result->getRowCount();
        mvBadgeCategories.reserve((uint32)count);
        for(uint64 i = 0; i < count; i++)
        {
            result->getNextRow(binding,&name);
            mvBadgeCategories.push_back(BString(name.getAnsi()));
        }

        //LOG(info) << "Loaded " << count << " badge categories";

        mDatabase->destroyDataBinding(binding);

        //gLogger->log(LogManager::DEBUG,"Finished Loading Badge Categories.");
        //gLogger->log(LogManager::NOTICE,"Loading Badges.");
        mDatabase->executeSqlAsync(this,new(mDBAsyncPool.malloc()) CSAsyncContainer(CharSheetQuery_Badges),"SELECT * FROM %s.badges ORDER BY id",mDatabase->galaxy());
        
    }
    break;

    case CharSheetQuery_Badges:
    {
        Badge* badge;

        DataBinding* binding = mDatabase->createDataBinding(4);
        binding->addField(DFT_uint32,offsetof(Badge,mId),4,0);
        binding->addField(DFT_bstring,offsetof(Badge,mName),255,1);
        binding->addField(DFT_uint32,offsetof(Badge,mSoundId),4,2);
        binding->addField(DFT_uint8,offsetof(Badge,mCategory),1,3);

        uint64 count = result->getRowCount();
        mvBadges.reserve((uint32)count);
        for(uint64 i = 0; i < count; i++)
        {
            badge = new Badge();
            result->getNextRow(binding,badge);
            mvBadges.push_back(badge);
        }

        //LOG(info) << "Loaded " << count << " badges";

        mDatabase->destroyDataBinding(binding);
        //gLogger->log(LogManager::DEBUG,"Finished Loading Badges.");
    }
    break;

    default:
        break;
    }

    mDBAsyncPool.free(asyncContainer);
}
BString
PootleProject::LocalFileType()
{
	_EnsureData();
	return BString(mData.GetString("localfiletype", ""));
}
Exemple #19
0
void
Job::AddPort(BMessage& data)
{
    const char* name = data.GetString("name");
    fPortMap.insert(std::pair<BString, BMessage>(BString(name), data));
}
BString
PootleProject::ResourceURI()
{
	_EnsureData();
	return BString(mData.GetString("resource_uri", ""));
}
Exemple #21
0
// --------------------------------------------------------------------------- RHTML_Tag_Menu - RHTMLTagMenu -
RHTMLTagMenu::RHTMLTagMenu(BTextView *textview): BWindow(BRect(-110,-210,-10,-10),"RHTMLTagMenuWindow",B_NO_BORDER_WINDOW_LOOK,B_FLOATING_APP_WINDOW_FEEL,B_AVOID_FRONT)
{
 fTextView=textview;

 fColorWin = new RHTMLcolorwin();
 fColorWin->Show();
 fColorWin->Activate(false);
// Activate();

 fListView = new RHTMLTagMenuList(this,textview);
 
 BScrollView *fScrollView = new BScrollView("TagMenuScrollView",fListView,B_FOLLOW_ALL,B_WILL_DRAW, false, true,B_FANCY_BORDER);
 AddChild(fScrollView);
 fListView->TargetedByScrollView(fScrollView);
 fListView->SetInvocationMessage(new BMessage('SEL'));

 BString dir=fOptions->SettingsDir;
 dir << "tags/htmltags.rdat";
 FILE *f;
 char c;
 BString line;
 int i=0;
 if( (f = fopen(dir.String(),"rt")) == NULL); else
 {
  while (feof(f)==false) 
  {
   line = "";
   fscanf(f,"%c",&c);
   while ((c!='\n')&&(!feof(f)))
   {
    line+=c;
    fscanf(f,"%c",&c);
   }
   line=rgetcomment(line);

   BString rtag, str3, str4, name, text, tag, param, type;
   std::vector<Cmd> cmd;

   int32 x,y;

   x=line.FindFirst('<');
   y=line.FindFirst(' ',x);
   if ((x>=0) && (y>=0) && (y>=x))
    line.CopyInto(rtag,x+1,y-x-1);
  
   i=line.FindFirst('<')+1;
   while (i<=line.FindFirst('>',i)-1)
   {
    x=line.FindFirst(' ',i)+1;
    y=line.FindFirst('=',x);
    if ((x>=0) && (y>=0) && ((y-x)>=0))
    line.CopyInto(str3,x,y-x);
 
    x=line.FindFirst('\'',i)+1;
    y=line.FindFirst('\'',x);
    if ((x>=0) && (y>=0) && ((y-x)>=0))
    line.CopyInto(str4,x,y-x);

    i=y+1;

    if (str3 == "NAME") name = str4;
    if (str3 == "TEXT") text = str4;
    if (str3 == "TAG") tag = str4;
    if (str3 == "PARAM") param = str4;
    if (str3 == "TYPE") type = str4;
    if ((str3 == "NEWLINE") || (str3 == "INSERTBACK") || (str3 == "INSERTFOR") || (str3 == "INSERT") || (str3 == "PUT"))
    {
     Cmd tmp;
     tmp.type = str3;
     tmp.param = str4;
     cmd.push_back(tmp);
    }
   }
   
   name.ToLower();
   type.ToLower();
   param.ToLower();
   tag.ToLower();
   
   if (rtag == "TAG")
   {
    Tag tmp;
    tmp.text=text;
    tmp.cmd=cmd;
    fTag[name] = tmp;
   }

   if (rtag == "PARAM")
   {
    Param tmp;
    tmp.text=text;
    tmp.type=type;
    tmp.cmd=cmd;
    fTag[tag].param[name] = tmp;
    if (type.ICompare("color") == 0)
    {
     Value vtmp;
     Cmd ctmp;
     ctmp.type = BString("SPECIAL");
     ctmp.param = BString("#Color");
     std::vector<Cmd> ccmd;
     ccmd.push_back(ctmp);
     vtmp.cmd = ccmd;
     fTag[tag].param[name].value["#Custom"] = vtmp;
    }
   }

   if (rtag == "VALUE")
   {
    Value tmp;
    tmp.cmd=cmd;
    fTag[tag].param[param].value[text] = tmp;
   }
  }
  fclose(f);
 }
}
Exemple #22
0
void UIInputBox::sendCreate()
{
	if(!mOwner || mOwner->getConnectionState() != PlayerConnState_Connected)
		return;

	Message*	newMessage;

	gMessageFactory->StartMessage();             
	gMessageFactory->addUint32(opSuiCreatePageMessage);  

	gMessageFactory->addUint32(mId);

	gMessageFactory->addString(mWindowTypeStr);

	uint32 propertyCount = 4 + getChildrenPropertyCount();
	
	gMessageFactory->addUint32(propertyCount);

	// main window properties
	gMessageFactory->addUint8(5);
	gMessageFactory->addUint32(0);
	gMessageFactory->addUint32(7);
	gMessageFactory->addUint16(0);
	gMessageFactory->addUint16(1);
	gMessageFactory->addUint8(9);
	gMessageFactory->addString(mEventStr);
	gMessageFactory->addString(BString("txtInput"));
	gMessageFactory->addString(BString("LocalText"));
	gMessageFactory->addString(BString("cmbInput"));
	gMessageFactory->addString(BString("SelectedText"));

	gMessageFactory->addUint8(5);
	gMessageFactory->addUint32(0);
	gMessageFactory->addUint32(7);
	gMessageFactory->addUint16(0);
	gMessageFactory->addUint16(1);
	gMessageFactory->addUint8(10);
	gMessageFactory->addString(mEventStr);
	gMessageFactory->addString(BString("txtInput"));
	gMessageFactory->addString(BString("LocalText"));
	gMessageFactory->addString(BString("cmbInput"));
	gMessageFactory->addString(BString("SelectedText"));

	// prompt
	gMessageFactory->addUint8(3);
	gMessageFactory->addUint32(1);
	gMessageFactory->addString(mPrompt);
	gMessageFactory->addUint32(2);
	gMessageFactory->addString(BString("Prompt.lblPrompt"));
	gMessageFactory->addString(BString("Text"));

	// caption
	gMessageFactory->addUint8(3);
	gMessageFactory->addUint32(1);
	gMessageFactory->addString(mCaption);
	gMessageFactory->addUint32(2);
	gMessageFactory->addString(BString("bg.caption.lblTitle"));
	gMessageFactory->addString(BString("Text"));

	// child elements
	Children::iterator childrenIt = mChildElements.begin();

	while(childrenIt != mChildElements.end())
	{
		(*childrenIt)->addMessageData();
		++childrenIt;
	}
	
	// unknown
	gMessageFactory->addUint64(0);
	gMessageFactory->addUint64(0);
	gMessageFactory->addUint32(0);

	newMessage = gMessageFactory->EndMessage();

	(mOwner->getClient())->SendChannelA(newMessage,mOwner->getAccountId(),CR_Client,2);
}
Exemple #23
0
void
TExpandoMenuBar::BuildItems()
{
	BMessenger self(this);
	TBarApp::Subscribe(self, &fTeamList);

	int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
	desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();

	float itemWidth = -1.0f;
	if (fVertical)
		itemWidth = Frame().Width();
	else {
		itemWidth = iconSize;
		if (!settings->hideLabels)
			itemWidth += gMinimumWindowWidth - kMinimumIconSize;
		else
			itemWidth += kIconPadding * 2;
	}
	float itemHeight = -1.0f;

	TeamMenuItemMap items;
	int32 itemCount = CountItems();
	BList itemList(itemCount);
	for (int32 i = 0; i < itemCount; i++) {
		BMenuItem* menuItem = RemoveItem((int32)0);
		itemList.AddItem(menuItem);
		TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(menuItem);
		if (item != NULL)
			items[BString(item->Signature()).ToLower()] = item;
	}

	if (settings->sortRunningApps)
		fTeamList.SortItems(TTeamMenu::CompareByName);

	int32 teamCount = fTeamList.CountItems();
	for (int32 i = 0; i < teamCount; i++) {
		BarTeamInfo* barInfo = (BarTeamInfo*)fTeamList.ItemAt(i);
		TeamMenuItemMap::const_iterator iter
			= items.find(BString(barInfo->sig).ToLower());
		if (iter == items.end()) {
			// new team
			TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
				barInfo->icon, barInfo->name, barInfo->sig, itemWidth,
				itemHeight);

			if (settings->trackerAlwaysFirst
				&& strcasecmp(barInfo->sig, kTrackerSignature) == 0) {
				AddItem(item, 0);
			} else
				AddItem(item);

			if (fFirstBuild && fVertical && settings->expandNewTeams)
				item->ToggleExpandState(true);

		} else {
			// existing team, update info and add it
			TTeamMenuItem* item = iter->second;
			item->SetIcon(barInfo->icon);
			item->SetOverrideWidth(itemWidth);
			item->SetOverrideHeight(itemHeight);

			if (settings->trackerAlwaysFirst
				&& strcasecmp(barInfo->sig, kTrackerSignature) == 0) {
				AddItem(item, 0);
			} else
				AddItem(item);

			// add window items back
			int32 index = itemList.IndexOf(item);
			TWindowMenuItem* windowItem;
			TWindowMenu* submenu = dynamic_cast<TWindowMenu*>(item->Submenu());
			bool hasWindowItems = false;
			while ((windowItem = dynamic_cast<TWindowMenuItem*>(
					(BMenuItem*)(itemList.ItemAt(++index)))) != NULL) {
				if (fVertical)
					AddItem(windowItem);
				else {
					delete windowItem;
					hasWindowItems = submenu != NULL;
				}
			}

			// unexpand if turn off show team expander
			if (fVertical && !settings->superExpando && item->IsExpanded())
				item->ToggleExpandState(false);

			if (hasWindowItems) {
				// add (new) window items in submenu
				submenu->SetExpanded(false, 0);
				submenu->AttachedToWindow();
			}
		}
	}

	if (CountItems() == 0) {
		// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
		// weird value - we just override it again
		ResizeTo(itemWidth, 0);
	}

	fFirstBuild = false;
}
Exemple #24
0
BString ChatSystemAvatar::getLoweredName()
{
    return BString("SYSTEM");
}
Exemple #25
0
void ChatTextView::MouseDown(BPoint pt)
{
	fprintf(stderr, "ChatTextView::MouseDown.\n");
	
	const char *text = BString(Text()).String();
	std::string url;

	// base
	BTextView::MouseDown(pt);

	// Ugly link search
	int32 curr_offset = OffsetAt(pt);

	// no more looking at spaces
	while (curr_offset >= 0 && !isspace(text[curr_offset])) {
		if (curr_offset + 8 <= TextLength() && text[curr_offset] == 'h'
			&& text[curr_offset + 1] == 't' && text[curr_offset + 2] == 't'
			&& text[curr_offset + 3] == 'p' && text[curr_offset + 4] == ':'
			&& text[curr_offset + 5] == '/' && text[curr_offset + 6] == '/') {

			url = text[curr_offset++];
			while(curr_offset < TextLength() && !isspace(text[curr_offset])) {
				url += text[curr_offset++];
			}

			break;
		}

		if (curr_offset + 7 <= TextLength() && text[curr_offset] == 'f'
			&& text[curr_offset + 1] == 't' && text[curr_offset + 2] == 'p'
			&& text[curr_offset + 3] == ':' && text[curr_offset + 4] == '/'
			&& text[curr_offset + 5] == '/') {

			url = text[curr_offset++];
			while(curr_offset < TextLength() && !isspace(text[curr_offset])) {
				url += text[curr_offset++];
			}

			break;
		}

		--curr_offset;
	}

	// default to www.
	if (url.empty()) {
		// Ugly link search
		curr_offset = OffsetAt(pt);

		while (curr_offset >= 0 && !isspace(text[curr_offset])) {
			if (curr_offset + 5 <= TextLength() && text[curr_offset] == 'w'
				&& text[curr_offset + 1] == 'w' && text[curr_offset + 2] == 'w'
				&& text[curr_offset + 3] == '.') {
				// ignore if it's not at the beginning or has no whitespace
				if ((curr_offset - 1) >= 0 && isalnum(text[curr_offset - 1])) {
					--curr_offset;
					continue;
				}

				// is it part of a sentence
				if (isspace(text[curr_offset + 4]) || text[curr_offset + 4] == '.') {
					--curr_offset;
					continue;
				}

				url = text[curr_offset++];

				while(curr_offset < TextLength() && !isspace(text[curr_offset])) {
					url += text[curr_offset++];
				}

				// prepend http
				url = "http://" + url;

				break;
			}

			if (curr_offset + 5 <= TextLength() && text[curr_offset] == 'f'
				&& text[curr_offset + 1] == 't' && text[curr_offset + 2] == 'p'
				&& text[curr_offset + 3] == '.') {
				url = text[curr_offset++];

				while(curr_offset < TextLength() && !isspace(text[curr_offset])) {
					url += text[curr_offset++];
				}

				// prepend http
				url = "ftp://" + url;

				break;
			}

			--curr_offset;
		}
	}

	// prune punctuation
	if (!url.empty()) {
		while (url.size() > 0) {
			if (url[url.size() - 1] == ',' || url[url.size() - 1] == '!'
				|| url[url.size() - 1] == '.' || url[url.size() - 1] == ')'
				|| url[url.size() - 1] == ';' || url[url.size() - 1] == ']'
				|| url[url.size() - 1] == '>' || url[url.size() - 1] == '?'
				|| url[url.size() - 1] == '\'' || url[url.size() - 1] == '"') {
				url.erase(url.size() - 1);
			} else {
				break;
			}
		}
	}

	// load up browser!!
	if (!url.empty()) {
		char *argv[] = {const_cast<char *>(url.c_str()), NULL};
		if (!be_roster->IsRunning("text/html"))
			be_roster->Launch("text/html", 1, argv);
		else {
			BMessenger messenger("text/html");
			BMessage msg(B_NETPOSITIVE_OPEN_URL);
			msg.AddString("be:url", url.c_str());
			messenger.SendMessage(&msg);
		}
	}
}
//------------------------------------------------------------------------------
void BSliderEditor::SetTo(BMessage* archive)
{
	BControlEditor::SetTo(archive);
	Init();

	BString Label;
	archive->FindString("_minlbl", &Label);
	fMinLabel->SetText(Label.String());

	Label = "";
	archive->FindString("_maxlbl", &Label);
	fMinLabel->SetText(Label.String());

	thumb_style style = B_BLOCK_THUMB;
	if (archive->FindInt16("_sstyle", (int16*)&style))
	{
		DEBUG_ARCHIVE("_sstyle");
	}
	SetThumbStyle(style);

	int32 orient = B_HORIZONTAL;
	if (archive->FindInt32("_orient", &orient))
	{
		DEBUG_ARCHIVE("_orient");
	}
	SetOrientation(orient);
	fOrientation->Menu()->ItemAt(orient)->SetMarked(true);

	int16 hashmarks = B_HASH_MARKS_NONE;
	if (archive->FindInt16("_hashloc", &hashmarks))
	{
		DEBUG_ARCHIVE("_hashloc");
	}
	SetHashLabel(hashmarks);

	int32 hashcount = 0;
	if (archive->FindInt32("_hashcount", &hashcount))
	{
		DEBUG_ARCHIVE("_hashcount");
	}
	fHashCount->SetText((BString() << hashcount).String());

	int32 min = 0;
	if (archive->FindInt32("_min", &min))
	{
		DEBUG_ARCHIVE("_min");
	}
	fMinValue->SetText((BString() << min).String());

	int32 max = 0;
	if (archive->FindInt32("_max", &max))
	{
		DEBUG_ARCHIVE("_max");
	}
	fMaxValue->SetText((BString() << max).String());

	BMessage modmsg;
	if (archive->FindMessage("_mod_msg", &modmsg) == B_OK)
	{
		// TODO: expand
		// This is a very simple way to handle messages; it might be nice to
		// have a BMessage editor which would allow for more complex control
		// message definitions.
		char msg[5];
		msg[0] = 0;
		strncpy(msg, (char *)(new int32(flipcode(modmsg.what))), 4);
		msg[4] = 0;
		fModMsg->SetText(msg);
	}
	else
	{
		fModMsg->SetText("");
	}

	int32 increment = 1;
	if (archive->FindInt32("_incrementvalue", &increment))
	{
		DEBUG_ARCHIVE("_incrementvalue");
	}
	fIncrValue->SetText((BString() << increment).String());

	rgb_color barcolor;
	if (archive->FindInt32("_bcolor", (int32*)&barcolor))
	{
		DEBUG_ARCHIVE("_bcolor");
	}
	else
	{
		char colortext[12];
		sprintf(colortext, "%lX", *(int32*)&barcolor);
		fBarColor->SetText(colortext);
	}

	rgb_color fillcolor;
	if (archive->FindInt32("_fcolor", (int32*)&barcolor))
	{
		fUseFillCheck->SetValue(B_CONTROL_OFF);
		fFillColor->SetEnabled(false);
	}
	else
	{
		fUseFillCheck->SetValue(B_CONTROL_ON);
		fFillColor->SetEnabled(true);
		char colortext[12];
		sprintf(colortext, "%lX", *(int32*)&fillcolor);
		fFillColor->SetText(colortext);
	}

	float thickness = 1.0;
	if (archive->FindFloat("_bthickness", &thickness))
	{
		DEBUG_ARCHIVE("_bthickness");
	}
	fBarThickness->SetText((BString() << thickness).String());

	int32 sdelay = 20000;
	if (archive->FindInt32("_sdelay", &sdelay))
	{
		DEBUG_ARCHIVE("_sdelay");
	}
	fSnoozeAmount->SetText((BString() << sdelay).String());

	fModMsg->SetTarget(Parent());
	fMinLabel->SetTarget(Parent());
	fMaxLabel->SetTarget(Parent());
	fMinValue->SetTarget(Parent());
	fMaxValue->SetTarget(Parent());
	fIncrValue->SetTarget(Parent());
	fOrientation->Menu()->SetTargetForItems(Parent());
	fHashStyle->Menu()->SetTargetForItems(Parent());
	fHashCount->SetTarget(Parent());
	fThumbStyle->Menu()->SetTargetForItems(Parent());
	fBarColor->SetTarget(Parent());
	fUseFillCheck->SetTarget(Parent());
	fFillColor->SetTarget(Parent());
	fBarThickness->SetTarget(Parent());
	fSnoozeAmount->SetTarget(Parent());

	Parent()->AddChild(fModMsg);
	Parent()->AddChild(fMinLabel);
	Parent()->AddChild(fMaxLabel);
	Parent()->AddChild(fMinValue);
	Parent()->AddChild(fMaxValue);
	Parent()->AddChild(fIncrValue);
	Parent()->AddChild(fOrientation);
	Parent()->AddChild(fHashStyle);
	Parent()->AddChild(fHashCount);
	Parent()->AddChild(fThumbStyle);
	Parent()->AddChild(fBarColor);
	Parent()->AddChild(fUseFillCheck);
	Parent()->AddChild(fFillColor);
	Parent()->AddChild(fBarThickness);
	Parent()->AddChild(fSnoozeAmount);
}