BFont
SettingsWindow::_FindDefaultSerifFont() const
{
	// Default to the first "serif" font we find.
	BFont serifFont(*be_plain_font);
	font_family family;
	int32 familyCount = count_font_families();
	for (int32 i = 0; i < familyCount; i++) {
		if (get_font_family(i, &family) == B_OK) {
			BString familyString(family);
			if (familyString.IFindFirst("sans") >= 0)
				continue;
			if (familyString.IFindFirst("serif") >= 0) {
				serifFont.SetFamilyAndFace(family, B_REGULAR_FACE);
				break;
			}
		}
	}
	return serifFont;
}
Esempio n. 2
0
/*static*/ BMenu*
AppearancePrefView::_MakeFontMenu(uint32 command,
	const char* defaultFamily, const char* defaultStyle)
{
	BPopUpMenu* menu = new BPopUpMenu("");
	int32 numFamilies = count_font_families();
	uint32 flags;

	for (int32 i = 0; i < numFamilies; i++) {
		font_family family;
		if (get_font_family(i, &family, &flags) == B_OK) {
			BFont font;
			font_style style;
			int32 numStyles = count_font_styles(family);
			for (int32 j = 0; j < numStyles; j++) {
				if (get_font_style(family, j, &style) == B_OK) {
					font.SetFamilyAndStyle(family, style);
					if (IsFontUsable(font)) {
						BMessage* message = new BMessage(command);
						message->AddString("font_family", family);
						message->AddString("font_style", style);
						char itemLabel[134];
						snprintf(itemLabel, sizeof(itemLabel),
							"%s - %s", family, style);
						BMenuItem* item = new BMenuItem(itemLabel,
							message);
						menu->AddItem(item);
						if (!strcmp(defaultFamily, family)
							&& !strcmp(defaultStyle, style))
							item->SetMarked(true);
					}
				}
			}
		}
	}

	if (menu->FindMarked() == NULL)
		menu->ItemAt(0)->SetMarked(true);

	return menu;
}
Esempio n. 3
0
bool Bookmark::Exists(const char* f, const char* s) const {
	font_family family;
	font_style  style;
	uint32      flags;
	int32       nFamilies;
	int32       nStyles;
	
	nFamilies = count_font_families();
	
	for (int32 i = 0; i < nFamilies; i ++) {
		if (get_font_family(i, &family, &flags) == B_OK && strcmp(f, family) == 0) {
			nStyles = count_font_styles(family);
			for (int32 j = 0; j < nStyles; j++) {
				if (get_font_style(family, j, &style, &flags) == B_OK && strcmp(s, style) == 0) {
					return true;
				}
			}
		}
	}
	return false;
}
Esempio n. 4
0
BMenu*
CharacterWindow::_CreateFontMenu()
{
	BMenu* menu = new BMenu("Font");

	font_family currentFamily;
	font_style currentStyle;
	fCharacterView->CharacterFont().GetFamilyAndStyle(&currentFamily,
		&currentStyle);

	int32 numFamilies = count_font_families();

	for (int32 i = 0; i < numFamilies; i++) {
		font_family family;
		if (get_font_family(i, &family) == B_OK) {
			BMenu* subMenu = new BMenu(family);
			menu->AddItem(new BMenuItem(subMenu,
				new BMessage(kMsgFontSelected)));

			int numStyles = count_font_styles(family);
			for (int32 j = 0; j < numStyles; j++) {
				font_style style;
				uint32 flags;
				if (get_font_style(family, j, &style, &flags) == B_OK) {
					BMenuItem* item = new BMenuItem(style,
						new BMessage(kMsgFontSelected));
					subMenu->AddItem(item);

					if (!strcmp(family, currentFamily)
						&& !strcmp(style, currentStyle)) {
						fSelectedFontItem = item;
						item->SetMarked(true);
					}
				}
			}
		}
	}

	return menu;
}
Esempio n. 5
0
CInfoDialog::CInfoDialog(BRect frame, const char *name, window_type type, int flags,
			BWindow *owner, BPositionIO* data)
	: HDialog(frame, name, type, flags, owner, data)
{
	fDoc = dynamic_cast<PDoc*>(owner);
	FailNil(fDoc);

	SetText("name", owner->Title());

	char s[32];
	sprintf(s, "%d", fDoc->TextView()->Size());
	SetText("docsize", s);

	sprintf(s, "%d", fDoc->TextView()->LineCount());
	SetText("lines", s);

	BMenuField *mf = dynamic_cast<BMenuField*>(FindView("mime"));
	FailNil(mf);
	fTypes = mf->Menu();

	const char *p;
	int i = 0;
	while ((p = gPrefs->GetIxPrefString(prf_X_Mimetype, i++)) != NULL)
		fTypes->AddItem(new BMenuItem(p, new BMessage(msg_FieldChanged)));

	if (i == 1)
		fTypes->AddItem(new BMenuItem("text/plain", new BMessage(msg_FieldChanged)));

	const char *mime = fDoc->MimeType();

	if (mime && mime[0])
	{
		for (i = 0; i < fTypes->CountItems(); i++)
		{
			BMenuItem *item = fTypes->ItemAt(i);
			if (strcmp(item->Label(), mime) == 0)
			{
				item->SetMarked(true);
				break;
			}
		}

		if (i == fTypes->CountItems())
		{
			fTypes->AddSeparatorItem();
			fTypes->AddItem(new BMenuItem(mime, new BMessage(msg_FieldChanged)));
			fTypes->ItemAt(fTypes->CountItems() - 1)->SetMarked(true);
		}
	}
	else
	{
		BMenuItem *item;
		fTypes->AddSeparatorItem();
		fTypes->AddItem(item = new BMenuItem("<undefined>", new BMessage(msg_FieldChanged)));
		item->SetMarked(true);
	}

	if (fDoc->EntryRef())
	{
		BNode node;
		FailOSErr(node.SetTo(fDoc->EntryRef()));

		time_t t;
		node.GetModificationTime(&t);

		char time[256];
		strcpy(time, ctime(&t));
		time[strlen(time) - 1] = 0;

		SetText("time", time);
	}
	else
	{
		//SetEnabled("mime", false);
		SetText("time", "Not Saved");
	}

	mf = dynamic_cast<BMenuField*>(FindView("font"));
	FailNil(mf);

	fMenu = mf->Menu();
	FailNil(fMenu);

	font_family ff;
	font_style fs;

	for (int i = 0; i < count_font_families(); i++)
	{
		get_font_family(i, &ff);
		BMenu *fontItem = new BMenu(ff);
		FailNil(fontItem);
		fMenu->AddItem(new BMenuItem(fontItem, new BMessage(msg_FieldChanged)));
		fontItem->SetFont(be_plain_font);

		for (int j = 0; j < count_font_styles(ff); j++)
		{
			get_font_style(ff, j, &fs);

			BMessage *msg = new BMessage(msg_FieldChanged);
			msg->AddString("family", ff);
			msg->AddString("style", fs);
			fontItem->AddItem(new BMenuItem(fs, msg));
		}
	}

	fMenu->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("encoding"));
	FailNil(mf);
	fEncoding = mf->Menu();
	FailNil(fEncoding);
	fEncoding->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("source encoding"));
	FailNil(mf);
	fSourceEncoding = mf->Menu();
	FailNil(fSourceEncoding);
	fSourceEncoding->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("linebreaks"));
	FailNil(mf);
	fLineBreaks = mf->Menu();
	FailNil(fLineBreaks);
	fLineBreaks->SetRadioMode(true);

	BTextControl *tc = dynamic_cast<BTextControl*>(FindView("tabs"));
	if (tc) tc->SetDivider(be_plain_font->StringWidth(tc->Label()) + 4);

	BMenu *lang;
	mf = dynamic_cast<BMenuField*>(FindView("language"));
	FailNil(mf);
	lang = mf->Menu();

	CLanguageInterface *intf;
	int cookie = 0;
	while ((intf = CLanguageInterface::NextIntf(cookie)) != NULL)
		lang->AddItem(new BMenuItem(intf->Name(), new BMessage(msg_FieldChanged)));

	lang->SetRadioMode(true);
	int curLang = fDoc->TextView()->Language();
	SetValue("language", curLang >= 0 ? curLang + 3 : 1);

	CancelClicked();
} /* CInfoDialog::CInfoDialog */
Esempio n. 6
0
void
PreferenceFont::AttachedToWindow (void)
{
	BView::AttachedToWindow();

	SetViewColor (Parent()->ViewColor());

	
	// Moved this here because Gord has 3000 fonts,
	// and he was complaining that the preferences
	// window was coming up slow.  This will postpone it
	// until he wants to change the fonts.  Can you believe it,
	// 3000!?!?
	if (clientFont[0] == 0)
	{
		int32 i, family_count (count_font_families());
		float label_width (0.0);

		for (i = 0; ControlLabels[i]; ++i)
			if (be_plain_font->StringWidth (ControlLabels[i]) > label_width)
				label_width = be_plain_font->StringWidth (ControlLabels[i]);

	
		FontStat *font_stat = new FontStat [family_count];

		for (i = 0; i < family_count; ++i)
		{
			uint32 flags;

			*font_stat[i].family       = '\0';
			font_stat[i].style_count   = 0;
			font_stat[i].styles        = 0;

			if (get_font_family (i, &font_stat[i].family, &flags) == B_OK
			&& (font_stat[i].style_count = count_font_styles (font_stat[i].family)) > 0)
			{
				font_stat[i].styles = new font_style [font_stat[i].style_count];
			
				for (int32 j = 0; j < font_stat[i].style_count; ++j)
				{
					*font_stat[i].styles[j] = '\0';
					get_font_style (font_stat[i].family, j, font_stat[i].styles + j, &flags);
				}
			}
		}

		BMenu *parentMenu[2][5];
		BRect frame (Bounds());
		font_height fh;
		float height;

		GetFontHeight (&fh);
		height = fh.ascent + fh.descent + fh.leading + 20;

		for (i = 0; i < 5; ++i)
		{
			font_family cur_family;
			font_style  cur_style;
			float cur_size;
			int32 j;

			bowser_app->GetClientFont (i)->GetFamilyAndStyle (
				&cur_family,
				&cur_style);
			cur_size = bowser_app->GetClientFont (i)->Size();

			parentMenu[0][i] = new BMenu ("Font");
			parentMenu[1][i] = new BMenu ("Size");

			clientFont[i] = new BMenuField (
				BRect (0, i * height, 185, 20 + i * height),
				"clientFont",
				ControlLabels[i],
				parentMenu[0][i]);

			AddChild (clientFont[i]);

			fontSize[i] = new BMenuField (
				BRect (210, i * height, frame.right, 20 + i * height),
				"fontSize",
				"",
				parentMenu[1][i]);
			fontSize[i]->Menu()->SetRadioMode (true);
			fontSize[i]->SetDivider (0.0);
	
			AddChild (fontSize[i]);

			clientFont[i]->SetDivider (label_width + 5.0);

			for (j = 0; j < family_count; ++j)
				if (*font_stat[j].family && font_stat[j].style_count)
				{
					BMenu *menu (new BMenu (font_stat[j].family));
					parentMenu[0][i]->AddItem (menu);

					for (int32 k = 0; k < font_stat[j].style_count; ++k)
					{
						BMessage *msg (new BMessage (M_FONT_CHANGE));
						BMenuItem *item;

						msg->AddString ("family", font_stat[j].family);
						msg->AddString ("style", font_stat[j].styles[k]);
						msg->AddInt32 ("which", i);

						menu->AddItem (item = new BMenuItem (font_stat[j].styles[k], msg));
	
						if (strcmp (font_stat[j].family,     cur_family) == 0
						&&  strcmp (font_stat[j].styles[k],  cur_style)  == 0)
						{
							item->SetMarked (true);
							clientFont[i]->MenuItem()->SetLabel (font_stat[j].family);
						}
					}
				}

			for (j = 0; FontSizes[j]; ++j)
			{
				BMessage *msg (new BMessage (M_FONT_SIZE_CHANGE));
				BMenuItem *item;
				char buffer[32];
	
				sprintf (buffer, "%ld", FontSizes[j]);
				msg->AddInt32 ("size", FontSizes[j]);
				msg->AddInt32 ("which", i);
	
				parentMenu[1][i]->AddItem (item = new BMenuItem (buffer, msg));
	
				if (FontSizes[j] == cur_size)
					item->SetMarked (true);
			}
	
		}

		for (i = 0; i < family_count; ++i)
			delete [] font_stat[i].styles;
		delete [] font_stat;
	}

	for (int32 i = 0; i < 5; ++i)
	{
		fontSize[i]->Menu()->SetLabelFromMarked (true);
		fontSize[i]->MenuItem()->SetLabel (fontSize[i]->Menu()->FindMarked()->Label());

		fontSize[i]->Menu()->SetTargetForItems (this);

		for (int32 j = 0; j < clientFont[i]->Menu()->CountItems(); ++j)
		{
			BMenuItem *item (clientFont[i]->Menu()->ItemAt (j));

			item->Submenu()->SetTargetForItems (this);
		}
	}

	ResizeTo (Frame().Width(), clientFont[4]->Frame().bottom);
}
Esempio n. 7
0
// ------------------------------------------------------------- RHTML_Preferences_Win - RHTMLPreferencesWin -
RHTMLPreferencesWin::RHTMLPreferencesWin(BRect fRect,BWindow *parent): BWindow(fRect,fOptions->GetLocaleString("Preferences_Window","Preferences"),B_FLOATING_WINDOW,B_UNTYPED_WINDOW)
{
 fParent=parent;
 IsQuit=false;
 fList = new BOutlineListView(BRect(0,0,150,Bounds().bottom),"List",B_SINGLE_SELECTION_LIST,B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 BView *view1= new BView(BRect(151,0,151,Bounds().bottom),"view",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fView=new BView(BRect(152,0,Bounds().right,Bounds().bottom),"view",B_FOLLOW_ALL,B_WILL_DRAW);
 AddChild(fList);
 AddChild(view1);
 AddChild(fView);
 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 view1->SetViewColor(184,184,184,0);
 fList->SetSelectionMessage(new BMessage('LIST'));

 JViewDb=5;
 fJView = (BView**) calloc(JViewDb,sizeof(BView));

// - Create Languages
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Languages")));

 fJView[0] = new BView(fView->Bounds(),"LangView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[0]);
 fLangMenu = new BMenu(fOptions->Locale[fOptions->CurrentLocale]->Lang.String());
 fLangMenu->SetLabelFromMarked(true);
 fLangMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->LocaleDb;i++)
 {
  BMessage* msg = new BMessage('LANG');
  msg->AddInt32("Lang",i);
  BMenuItem *item;
  fLangMenu->AddItem(item=new BMenuItem(fOptions->Locale[i]->Lang.String(),msg));
  item->SetTarget(this);
 }
 fLanguages= new BMenuField(BRect(10,10,250,30),"LanguagesMenu",fOptions->GetLocaleString("Preferences_Window_Languages","Languages"),fLangMenu);
 fJView[0]->AddChild(fLanguages);
 
 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

 fStrView1 = new BStringView(BRect(10,50,250,100),"strview1","Language:");
 fJView[0]->AddChild(fStrView1);

 fStrView2 = new BStringView(BRect(10,50,250,120),"strview1","");
 fJView[0]->AddChild(fStrView2);

 fStrView3 = new BStringView(BRect(10,50,250,150),"strview1","Author:");
 fJView[0]->AddChild(fStrView3);

 author = new URLView( BRect(0,50,250,170),"author","","");
 fJView[0]->AddChild(author);

 fStrView4 = new BStringView(BRect(10,50,250,200),"strview4","Language version:");
 fJView[0]->AddChild(fStrView4);
 
 fStrView5 = new BStringView(BRect(10,50,300,220),"strview5","");
 fJView[0]->AddChild(fStrView5);

 fStrView6 = new BStringView(BRect(10,50,300,250),"strview6","Language create to:");
 fJView[0]->AddChild(fStrView6);
 
 fStrView7 = new BStringView(BRect(10,50,300,270),"strview7","");
 fJView[0]->AddChild(fStrView7);

 LSetAuthor();

// - Create FileTypes

 fJView[1] = new BView(fView->Bounds(),"FTView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[1]);

// - Create FileTypes/Fonts

 fFTFontsBox= new BBox(BRect(10,10,200,120));
 fFTFontsBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default font"));
 fFTFontsBox->SetFont(new BFont(be_plain_font));
 fJView[1]->AddChild(fFTFontsBox);


 BString stmp;
 stmp << (int32) fOptions->DefaultFont->Size();
 BMenu *fSizeMenu = new BMenu(stmp.String());
 fSizeMenu->SetRadioMode(false);
 fSizeMenu->SetLabelFromMarked(true);
 
 for (int32 o=8;o<15;o++)
 {
  BMessage *msg2;
  msg2 = new BMessage('FTSZ');
  msg2->AddInt32("font_size",o);
  BString tmp;
  tmp << o;
  fSizeMenu->AddItem(new BMenuItem(tmp.String(),msg2));
 }
 fFTDFSize= new BMenuField(BRect(10,75,180,105),"Font Size",fOptions->GetLocaleString("Preferences_Window_FileTypes","Size"),fSizeMenu);
 fFTDFSize->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFSize);

 font_family fFamily;
 font_style	fStyle;

 fOptions->DefaultFont->GetFamilyAndStyle(&fFamily,&fStyle);
 fFTDFStyle= new BMenuField(BRect(10,45,180,75),"Font Style",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),new BMenu("Style"));
 fFTDFStyle->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFStyle);
 FTSetFont(fFamily,fStyle);
 BMenu *fMenu = new BMenu(fFamily);
 fMenu->SetRadioMode(false);
 fMenu->SetLabelFromMarked(true);

 const int32 fontNum = count_font_families();

 for(int32 i = 0; i < fontNum; i++)
 {
  get_font_family(i,&fFamily);
  BMessage*	msg = new BMessage('FTDF');
  msg->AddString("font_family", fFamily);
  fMenu->AddItem(new BMenuItem(fFamily,msg));
 }

 fFTDFont= new BMenuField(BRect(10,15,180,35),"Default font",fOptions->GetLocaleString("Preferences_Window_FileTypes","Font"),fMenu);
 fFTDFont->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFont);

// - Create FileTypes/Extensions

 fFTBox= new BBox(BRect(10,130,200,290));
 fFTBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Extension"));
 fFTBox->SetFont(new BFont(be_plain_font));
 fJView[1]->AddChild(fFTBox);

 BListItem *FTUitem;
 fList->AddItem(FTUitem=new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Filetypes")));

 fFTFTMenu = new BMenu(fOptions->FileTypes[0]->Name->String());
 fFTFTMenu->SetLabelFromMarked(true);
 fFTFTMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->FileTypesDb;i++)
 {
  BMessage* msg = new BMessage('FTFT');
  msg->AddInt32("FileType",i);
  BMenuItem *item;
  fFTFTMenu->AddItem(item=new BMenuItem(fOptions->FileTypes[i]->Name->String(),msg));
  item->SetTarget(this);
 }
 fFTFT= new BMenuField(BRect(10,15,180,35),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Filetype"),fFTFTMenu);
 fFTFT->SetDivider(80);
 fFTBox->AddChild(fFTFT); 
 
 fFTKit = new BListView(BRect(10,40,54,120),"KitList",B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE,B_WILL_DRAW);
 BScrollView *fScrollView = new BScrollView("List",fFTKit,B_FOLLOW_ALL_SIDES,B_WILL_DRAW, false, true,B_FANCY_BORDER);
 fFTBox->AddChild(fScrollView);
 
 fFTKit->TargetedByScrollView(fScrollView);
 fFTKit->SetSelectionMessage(new BMessage('FTSL'));
 
 fFTAddButton = new BButton(BRect(90,40,170,60),"Add",fOptions->GetLocaleString("Preferences_Window_FileTypes","Add"),new BMessage('FTAD'));
 fFTEditButton = new BButton(BRect(90,80,170,100),"Edit",fOptions->GetLocaleString("Preferences_Window_FileTypes","Edit"),new BMessage('FTED'));
 fFTRemoveButton = new BButton(BRect(90,120,170,140),"Remove",fOptions->GetLocaleString("Preferences_Window_FileTypes","Remove"),new BMessage('FTRM'));
 fFTBox->AddChild(fFTAddButton);
 fFTBox->AddChild(fFTEditButton);
 fFTBox->AddChild(fFTRemoveButton);
 
 fFTStrView = new BTextControl(BRect(5,130,70,150),"Név","","",new BMessage('FTST'));
 fFTStrView->SetDivider(0);
 fFTBox->AddChild(fFTStrView);
 FTCreateKitList(0);

// - Create FileTypes - Highlighting

 fList->AddUnder(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Highlighting")), FTUitem);

 fJView[2] = new BView(fView->Bounds(),"FTView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[2]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[2]);

  // - FT
 fFTHFileTypes=0;
 fFTHFTBox= new BBox(BRect(10,10,320,260));
 fFTHFTBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Highlighting"));
 fFTHFTBox->SetFont(new BFont(be_plain_font));
 fJView[2]->AddChild(fFTHFTBox);

 fFTFTMenu = new BMenu(fOptions->FileTypes[0]->Name->String());
 fFTFTMenu->SetLabelFromMarked(true);
 fFTFTMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->FileTypesDb;i++)
 {
  BMessage* msg = new BMessage('FTHF');
  msg->AddInt32("FileType",i);
  BMenuItem *item;
  fFTFTMenu->AddItem(item=new BMenuItem(fOptions->FileTypes[i]->Name->String(),msg));
  item->SetTarget(this);
 }

 fFTHFT= new BMenuField(BRect(10,15,210,30),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Filetype"),fFTFTMenu);
 fFTHFT->SetDivider(100);
 fFTHFTBox->AddChild(fFTHFT);

 fFTHFC= new BMenuField(BRect(10,40,210,65),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Syntax styles"),new BMenu(""));
 fFTHFC->SetDivider(100);
 fFTHFTBox->AddChild(fFTHFC);
 
  // - Font
 fFTHFontColor=0;
 fFTHFontBox= new BBox(BRect(10,80,230,130));
 fFTHFontBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Font"));
 fFTHFontBox->SetFont(new BFont(be_plain_font));
 fFTHFTBox->AddChild(fFTHFontBox);

 fFTHStyle= new BMenuField(BRect(10,15,210,40),"Size",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),new BMenu("Style"));
 fFTHFontBox->AddChild(fFTHStyle);


  // - Color
 
 fFTHColorBox= new BBox(BRect(10,150,300,240));
 fFTHColorBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Color"));
 fFTHColorBox->SetFont(new BFont(be_plain_font));
 fFTHFTBox->AddChild(fFTHColorBox);

 fFTHCC = new BColorControl(BPoint(10,20),B_CELLS_32x8,1,"CC",new BMessage(R_FTH_Color_MSG));
 fFTHColorBox->AddChild(fFTHCC);

// - Default Folder
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Default Folder")));

 fJView[3] = new BView(fView->Bounds(),"OpenSaveView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[3]->SetViewColor(216,216,216,0);
 fView->AddChild(fJView[3]);

 fDFDefaultFolder = new BTextControl(BRect(10,10,260,30),"DFDefaultFolder",fOptions->GetLocaleString("Preferences_Window_DefaultFolder","Default Folder"),fOptions->DefaultFolder.String(),new BMessage('DFFN'));
 fDFDefaultFolder->SetDivider(100);
 fJView[3]->AddChild(fDFDefaultFolder);

 BButton *fDFButton = new BButton(BRect(270,8,330,30),"DFButton",fOptions->GetLocaleString("Preferences_Window_DefaultFolder","Browse"),new BMessage('DFBB'));
 fJView[3]->AddChild(fDFButton);
 fDFFilePanel = new BFilePanel(B_OPEN_PANEL,new BMessenger(this,this), NULL,
				   B_DIRECTORY_NODE, false,new BMessage('DFFP'));
 fDFCheckBox = new BCheckBox(BRect(150,40,280,60),"DFCheckBox",fOptions->GetLocaleString("Preferences_Window_DefaultFolder","Only Start"),new BMessage('DFCK'));
 fJView[3]->AddChild(fDFCheckBox);
 fDFCheckBox->SetValue(fOptions->DFOnlyStart);

// - Advanced Prefs
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Advanced preferences")));

 fJView[4] = new BView(fView->Bounds(),"AdvancedPrefs",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[4]->SetViewColor(216,216,216,0);
 fView->AddChild(fJView[4]);
 
 fAPSlider = new BSlider(BRect(10,10,330,50),"slider",fOptions->GetLocaleString("Preferences_Window_AdvancedPrefs","Parameter-Menu reaction time"),new BMessage('APRT'), 0, 1000);
 fAPSlider->SetLimitLabels("0ms", "1000ms");
 fAPSlider->SetValue(fOptions->ReakcioIdo);
 fAPSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
 fAPSlider->SetHashMarkCount(5);
 fJView[4]->AddChild(fAPSlider);

 fAPTMSlider = new BSlider(BRect(10,100,330,150),"slider",fOptions->GetLocaleString("Preferences_Window_AdvancedPrefs","Tag-Menu reaction time"),new BMessage('APTM'), 0, 3000);
 fAPTMSlider->SetLimitLabels("0ms", "3000ms");
 fAPTMSlider->SetValue(fOptions->ReakcioIdo);
 fAPTMSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
 fAPTMSlider->SetHashMarkCount(5);
 fJView[4]->AddChild(fAPTMSlider);

 // -
 FTHSetFT(0);

 fList->Select(0);
 for (uint i=0;i<JViewDb;i++)fJView[i]->ResizeTo(0,0);
 fJView[0]->ResizeTo(fView->Bounds().right,fView->Bounds().bottom);
}
bool					
BF_GUI_SetupDialog_FontItem::Invoke(BF_GUI_DlgView_Menu *po_Parent)
{
	BF_GUI_Func_EnableDialog( po_Parent->Parent()->Name(),false );
	/* prepare message */
	BMessage oMessage(BF_MSG_DIALOG_FOCUS/*BF_MSG_MAINVIEW_MAINSETUP_FONT_UPDATED*/);
	oMessage.AddPointer("bf_focus",po_Parent->Parent());
	/* make dialog */	
	printf("BF_GUI_SetupDialog_FontItem::Invoke this=%i\n",this);
	BF_GUI_SetupDialog_FontDialog *poDialog = new BF_GUI_SetupDialog_FontDialog(this,BRect(0,0,440,0),
		sTitle.String(),"color_dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER,true);	
	/* resize dialog */	
	BRect oRect;	
	
	// make fonts_menu //	
	BL_List *poList = new BL_List();	
	int32 iCountFam = count_font_families();
	for(int32 iFam=0;iFam<iCountFam;iFam++){
		font_family uFam;
		uint32 iFlags;
		if( B_OK != get_font_family(iFam,&uFam,&iFlags)) continue;
	
		// load styles
		BL_List *plsStyle = new BL_List();
		int32 iCountStyles = count_font_styles(uFam);
		for(int iStyle=0;iStyle<iCountStyles;iStyle++){
			font_style uStyle;
			if(B_OK != get_font_style(uFam,iStyle,&uStyle,&iFlags)) continue;
			plsStyle->AddItem( new BF_GUI_ViewMenu_Item(uStyle,uStyle));
		}			
		// make store item
		BF_GUI_SetupDialog_FontFamilyItem *poItem = new BF_GUI_SetupDialog_FontFamilyItem(uFam,plsStyle);
		poList->AddItem(poItem);										
	}			
	poDialog->LocalBounds(oRect);		
	oRect.bottom = oRect.top + 300;
	oRect.right = oRect.left + 200;
	poDialog->AddChild( new BF_GUI_DlgView_VMenu(oRect,"families",B_FOLLOW_ALL,poList,BF_GUI_DLGVIEW_VMENU_NAV_PARENTINFORM) );
	
	// make styles //
	poDialog->LocalBounds(oRect);
	oRect.bottom = oRect.top + 300;
	oRect.left += 210;	
	poDialog->AddChild( new BF_GUI_DlgView_VMenu(oRect,"styles",B_FOLLOW_ALL,new BL_List(),BF_GUI_DLGVIEW_VMENU_NAV_PARENTINFORM) );
	
	// make anti_aliasing
	{
		poDialog->LocalBounds(oRect);
		oRect.top += 310;
		oRect.bottom = oRect.top + poSysSetup->oFontToolView.fHeight*2;
		oRect.right = oRect.left + 140;
		BF_GUI_ViewCheck *poCheck = new BF_GUI_ViewCheck(oRect,"anti_aliasing",BF_DictAt(BF_DICT_FONTSETUP_ANTI)
			,poFont->iFlags & B_FORCE_ANTIALIASING
			,B_FOLLOW_LEFT|B_FOLLOW_TOP,B_WILL_DRAW|B_NAVIGABLE);
		poDialog->AddChild(poCheck);
	}
	
	
	// make test 
	poDialog->LocalBounds(oRect);
	oRect.top += 310;
	oRect.bottom = oRect.top + poSysSetup->oFontToolView.fHeight*3;
	oRect.left += 160;
	poDialog->AddChild( new BF_GUI_FontView(oRect,B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM) );	
	
	// make size 
	poDialog->LocalBounds(oRect);
	oRect.top += 310+poSysSetup->oFontToolView.fHeight*2;
	oRect.bottom = oRect.top + poSysSetup->oFontToolView.fHeight;
	oRect.right = oRect.left + 150;
	BL_String s;
	s<<poFont->fSize;
	BF_GUI_ViewEdit_Create(oRect,BF_DictAt(BF_DICT_SIZE),poDialog,"size",s.String()
		,B_FOLLOW_LEFT|B_FOLLOW_BOTTOM,B_NAVIGABLE);
							
	///////////////////////////////		
	/* make bottom menu */
	BRect oRect1;
	poDialog->LocalBounds(oRect1);
	oRect.left = oRect1.left;
	oRect.right = oRect1.right;	
	oRect.top = oRect.bottom+10;
	oRect.bottom = oRect.top + poSysSetup->oFontToolView.fHeight;
	BL_List *ploMenu = new BL_List();
	ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_OK),"ok"));
	poDialog->AddMenu(oRect,ploMenu,true);		
	
	/* finish */
	poDialog->SetHeightFromLastChild();
	poDialog->MoveToCenter( poWinView );					
	BF_GUI_Func_AddChildToMainView( poDialog );	
	
	return true;
}
Esempio n. 9
0
void
FontSelectionView::UpdateFontsMenu()
{
	int32 numFamilies = count_font_families();

	fFontsMenu->RemoveItems(0, fFontsMenu->CountItems(), true);
	BFont font;
	fFontsMenu->GetFont(&font);

	font_family currentFamily;
	font_style currentStyle;
	fCurrentFont.GetFamilyAndStyle(&currentFamily, &currentStyle);

	for (int32 i = 0; i < numFamilies; i++) {
		font_family family;
		uint32 flags;
		if (get_font_family(i, &family, &flags) != B_OK)
			continue;

		// if we're setting the fixed font, we only want to show fixed and
		// full-and-half-fixed fonts
		if (strcmp(Name(), "fixed") == 0
			&& (flags
				& (B_IS_FIXED | B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED)) == 0) {
			continue;
		}

		float width = font.StringWidth(family);
		if (width > fMaxFontNameWidth)
			fMaxFontNameWidth = width;

		BMenu* stylesMenu = new BMenu(family);
		stylesMenu->SetRadioMode(true);
		stylesMenu->SetFont(&font);

		BMessage* message = new BMessage(kMsgSetFamily);
		message->AddString("family", family);
		message->AddString("name", Name());

		BMenuItem* familyItem = new BMenuItem(stylesMenu, message);
		fFontsMenu->AddItem(familyItem);

		int32 numStyles = count_font_styles(family);

		for (int32 j = 0; j < numStyles; j++) {
			font_style style;
			if (get_font_style(family, j, &style, &flags) != B_OK)
				continue;

			message = new BMessage(kMsgSetStyle);
			message->AddString("family", (char*)family);
			message->AddString("style", (char*)style);
			message->AddString("name", Name());

			BMenuItem* item = new BMenuItem(style, message);

			if (!strcmp(style, currentStyle)
				&& !strcmp(family, currentFamily)) {
				item->SetMarked(true);
				familyItem->SetMarked(true);
			}
			stylesMenu->AddItem(item);
		}

		stylesMenu->SetTargetForItems(fMessageTarget);
	}

	fFontsMenu->SetTargetForItems(fMessageTarget);
}
Esempio n. 10
0
void CPrefsDialog::PostInit()
{
	BAutolock lock(this);

	strcpy(fNewFontFamily, gPrefs->GetPrefString("defdoc font family", NULL));
	fNewFontSize = gPrefs->GetPrefDouble("defdoc font size", 0.0);
	strcpy(fNewBFontFamily, gPrefs->GetPrefString("border font family", NULL));
	fNewBFontSize = gPrefs->GetPrefDouble("border font size", 0.0);

	CellStyle cs;
	font_style style;

	fOwner->GetCellView()->GetContainer()->GetDefaultCellStyle(cs);
	try {
		gFontSizeTable.GetFontInfo(cs.fFont, &fDocFontFamily, &style, &fDocFontSize);
		gFontSizeTable.GetFontInfo(fOwner->GetCellView()->BorderFontID(),
			&fDocBFontFamily, &style, &fDocBFontSize);
	}
	catch (CErr& e) {
		e.DoError();
	}

	BMenuField *mf = dynamic_cast<BMenuField*>(FindView("docfont"));
	fDocFont = mf->Menu();
	if (fDocFont) 
	{
		for (long i = 0; i < count_font_families(); i++)
		{
			font_family ff;
			get_font_family(i, &ff);
			fDocFont->AddItem(new BMenuItem(ff, new BMessage(msg_Changed)));
		}
		fDocFont->SetRadioMode(TRUE);
	}

	mf = dynamic_cast<BMenuField*>(FindView("borderfont"));
	fBorderFont = mf->Menu();
	for (long i = 0; i < count_font_families(); i++)
	{
		font_family ff;
		get_font_family(i, &ff);
		fBorderFont->AddItem(new BMenuItem(ff, new BMessage(msg_Changed)));
	}
	fBorderFont->SetRadioMode(TRUE);

	mf = dynamic_cast<BMenuField*>(FindView("dateorder"));
	fDMY = mf->Menu();
	fDMY->AddItem(new BMenuItem("dmy", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("dym", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("mdy", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("myd", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("ydm", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("ymd", new BMessage(msg_Changed)));

	mf = dynamic_cast<BMenuField*>(FindView("neworcur"));
	if (mf)
	{
		fNewOrCur = mf->Menu();
		fNewOrCur->AddItem(new BMenuItem("New Documents", new BMessage(msg_ChangeTarget)));
		if (fOwner)
		{
			char s[32];
			fDocFont->FindItem(fDocFontFamily)->SetMarked(true);
			ftoa(fDocFontSize, s);
			SetText("docsize", s);
			fBorderFont->FindItem(fDocBFontFamily)->SetMarked(true);
			ftoa(fDocBFontSize, s);
			SetText("bordersize", s);

			fNewOrCur->AddItem(new BMenuItem(fOwner->Title(), new BMessage(msg_ChangeTarget)));
			fNewOrCur->ItemAt(1)->SetMarked(true);
		}
		else
			fNewOrCur->ItemAt(0)->SetMarked(true);
		mf->SetDivider(be_plain_font->StringWidth(mf->Label()) + 4);
	}

	BBox *b;
	BView *v;
	v = FindView("prgrid");
	b = dynamic_cast<BBox*>(v->Parent());
	if (b)
	{
		char t[256];
		sprintf(t, b->Label(), fOwner->Title());
		b->SetLabel(t);
	}
	
	fAutoRecalc = fOwner->GetCellView()->DoesAutoRecalc();
	fDisplayZero = fOwner->GetCellView()->DoesDisplayZero();
	fPrGrid = fOwner->GetCellView()->PrintsGrid();
	fPrBorders = fOwner->GetCellView()->PrintsBorders();
	fShGrid = fOwner->GetCellView()->ShowsGrid();
	fShBorders = fOwner->GetCellView()->ShowsBorders();

	CancelClicked();

	Show();
} /* CPrefsDialog::PostInit */
Esempio n. 11
0
TextToolView::TextToolView(BRect rect) : 
	BView (rect, "containerview", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED)
{
	BRect srect;
	const int8 height=35;

	SetViewColor(208,208,208);

	// Create all controls for the view
	textedit = new BTextControl( BRect(5,15,95,30),"textedit",NULL,"BePhotoMagic",
				new BMessage(TEXT_CHANGED) );
	

	fontlist = new FontListView(BRect(5,55,95,150),"fontlist",
					this, new BMessage(FONT_FAMILY_CHANGED));
	stylelist = new BListView(BRect(5,185,110,240),"stylelist");
	
	fontscrollview = new BScrollView("fontscrollview", fontlist, B_FOLLOW_LEFT | B_FOLLOW_TOP,
					0,true,true);
	fontscrollview->SetViewColor(208,208,208);
	BScrollBar *bar=fontscrollview->ScrollBar(B_HORIZONTAL);
	bar->SetRange(0,75);

//	srect.Set(5,190,100,190+height);
	srect.Set(5,245,100,245+height);

	sizeslider = new BSlider(srect, "sizeslider", "Size", 
				new BMessage(SIZE_CHANGED), 4, 360, B_TRIANGLE_THUMB);
	sizeslider->SetBarThickness(3);
	sizeslider->SetValue(12);
	sizeslider->SetLabel("Size: 12");
	
	srect.OffsetBy(0,height);

	shearslider = new BSlider(srect, "shearslider", "Shear", 
				new BMessage(SHEAR_CHANGED), 45, 135, B_TRIANGLE_THUMB);
	shearslider->SetBarThickness(3);
	shearslider->SetValue(90);
	shearslider->SetLabel("Shear: 90");
	
	srect.OffsetBy(0,height);

	rotationslider = new BSlider(srect, "rotationslider", "Rotation", 
				new BMessage(ROTATION_CHANGED), 0, 359, B_TRIANGLE_THUMB);
	rotationslider->SetBarThickness(3);
	rotationslider->SetLabel("Rotation: 0");

	srect.OffsetBy(0,height);
	
	aacheckbox = new BCheckBox(srect,"aacheckbox","Antialias Text",
				new BMessage(ANTIALIAS_TEXT));
	// anti-aliased text by default
	aacheckbox->SetValue(B_CONTROL_ON);
	

	srect.bottom=srect.top + floor(srect.IntegerHeight() * .75);
	srect.OffsetBy(0,height-10);
	
	renderbutton = new BButton( srect,"renderbutton",SpTranslate("Create"), new BMessage(RENDER_TEXT));
	
	
	// Set up button which toggles the fontview being shown
	srect.OffsetBy(0,height);

	fontviewtoggle = new BButton( srect,"fontviewtoggle",SpTranslate("Hide Text"),
				 new BMessage(FONTVIEW_TOGGLE));
	

	// Display view
	srect=Bounds();
	srect.left=120;
	fontview = new FontDrawView(srect, (char *)textedit->Text());
	
	// Begin font setup
	int32 i,numFamilies;
	uint32 flags;
	font_family family;

	numFamilies = count_font_families();

	// Get font families installed
	for (i = 0; i < numFamilies; i++ ) 
	{
		if ( get_font_family(i, &family, &flags) == B_OK ) 
			fontlist->AddItem(new BStringItem((char *)&family));
	}
	fontlist->SetInvocationMessage(new BMessage(FONT_FAMILY_CHANGED));
	stylelist->SetInvocationMessage(new BMessage(FONT_STYLE_CHANGED));
	
	fontview->currentfont= be_plain_font;
	fontview->currentfont.SetSize((float)sizeslider->Value());
	fontview->SetFont(&(fontview->currentfont));

	Show();
	SetHighColor(0,0,0);
}
Esempio n. 12
0
BYdpMainWindow::BYdpMainWindow(const char *windowTitle) : BWindow(
	BRect(64, 64, 585, 480), windowTitle, B_DOCUMENT_WINDOW, B_OUTLINE_RESIZE ) {

	this->Hide();
	config = new bydpConfig();

	BView *MainView(
		new BView(BWindow::Bounds(), NULL, B_FOLLOW_ALL, 0) );

	if (MainView == NULL) {
		AppReturnValue = B_NO_MEMORY;
		be_app->PostMessage(B_QUIT_REQUESTED);
		return;
	}

	MainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BWindow::AddChild(MainView);
	wordInput = new BTextControl(
		BRect(5,24,210,45), "wordInput", NULL, "text", new BMessage(MSG_MODIFIED_INPUT));
	wordInput->SetModificationMessage(new BMessage(MSG_MODIFIED_INPUT));
	MainView->AddChild(wordInput);

	outputView = new BTextView(
		BRect(220,24,506,402), "outputView", BRect(10,10,300,200), B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW|B_PULSE_NEEDED);
	outputView->SetText("output");
	outputView->MakeEditable(false);
	outputView->SetStylable(true);
	MainView->AddChild(new BScrollView("scrolloutput",outputView,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM, 0, true, true));

	dictList = new bydpListView("listView", this);
	MainView->AddChild(new BScrollView("scrollview", dictList, B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM, 0, false, false, B_FANCY_BORDER));
	dictList->SetInvocationMessage(new BMessage(MSG_LIST_INVOKED));
	dictList->SetSelectionMessage(new BMessage(MSG_LIST_SELECTED));
	BRect barr = dictList->Bounds();
	barr.left = barr.right-B_V_SCROLL_BAR_WIDTH;
	scrollBar = new bydpScrollBar(barr, "scrollbar", dictList);
	dictList->AddChild(scrollBar);
	dictList->SetScrollBar(scrollBar);

	ydpConv = new ConvertYDP();
	sapConv = new ConvertSAP();
//	sq2Conv = new ConvertSQ2();
	ydpDict = new EngineYDP(outputView, dictList, config, ydpConv);
	sapDict = new EngineSAP(outputView, dictList, config, sapConv);
//	sq2Dict = new EngineSQ2(outputView, dictList, config, sq2Conv);
	switch(config->dictionarymode) {
/*		case DICTIONARY_SQ2:
			myDict = sq2Dict;
			myConverter = sq2Conv;
			break; */
		case DICTIONARY_YDP:
			myDict = ydpDict;
			myConverter = ydpConv;
			break;
		case DICTIONARY_SAP:
		default:
			myDict = sapDict;
			myConverter = sapConv;
			break;
	}
	dictList->SetConverter(myConverter);

	BRect r;
	r = MainView->Bounds();
	r.bottom = 19;
	BMenuBar *menubar = new BMenuBar(r, "menubar");
	MainView->AddChild(menubar);

	BMenu *menu = new BMenu("File");
	menu->AddItem(new BMenuItem("About...", new BMessage(MENU_ABOUT), 'O'));
	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
	menubar->AddItem(menu);

	BMenu *engineMenu;
	menu = new BMenu("Dictionary");
	menu->AddItem(new BMenuItem("Switch", new BMessage(MENU_SWITCH), 'J'));
	menu->AddItem(menuEng = new BMenuItem("Eng -> Pol", new BMessage(MENU_ENG2POL), 'E'));
	menu->AddItem(menuPol = new BMenuItem("Pol -> Eng", new BMessage(MENU_POL2ENG), 'P'));
	menu->AddSeparatorItem();
	menu->AddItem(engineMenu = new BMenu("Dictionary engine"));
	engineMenu->AddItem(menuSAP = new BMenuItem("SAP", new BMessage(MENU_ENGINESAP)));
	engineMenu->AddItem(menuYDP = new BMenuItem("YDP", new BMessage(MENU_ENGINEYDP)));
//	engineMenu->AddItem(menuSQ2 = new BMenuItem("SQ2", new BMessage(MENU_ENGINESQ2)));
	menubar->AddItem(menu);

	menu = new BMenu("Search type");
	menu->AddItem(menuPlain = new BMenuItem("Plain", new BMessage(MENU_PLAIN), 'Z'));
	menu->AddItem(menuFuzzy = new BMenuItem("Fuzzy", new BMessage(MENU_FUZZY), 'R'));
	menubar->AddItem(menu);

	menu = new BMenu("Settings");
	menu->AddItem(new BMenuItem("Path to dictionary", new BMessage(MENU_PATH), 'S'));
	menu->AddSeparatorItem();
	menu->AddItem(menuCol0 = new BMenuItem(myDict->ColourFunctionName(0), new BMessage(MENU_COLOR0)));
	menu->AddItem(menuCol1 = new BMenuItem(myDict->ColourFunctionName(1), new BMessage(MENU_COLOR1)));
	menu->AddItem(menuCol2 = new BMenuItem(myDict->ColourFunctionName(2), new BMessage(MENU_COLOR2)));
	menu->AddItem(menuCol3 = new BMenuItem(myDict->ColourFunctionName(3), new BMessage(MENU_COLOR3)));
	menu->AddSeparatorItem();
	menu->AddItem(menuClip = new BMenuItem("Clipboard tracking", new BMessage(MENU_CLIP), 'L'));
	menu->AddItem(menuFocus = new BMenuItem("Popup window", new BMessage(MENU_FOCUS), 'F'));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Fuzzy factor", new BMessage(MENU_DISTANCE)));
//	menu->AddItem(new BMenuItem("SQL data source", new BMessage(MENU_SQL)));
	menu->AddSeparatorItem();
	menubar->AddItem(menu);

	BMessage *fontMessage;
	fontMenu = new BMenu("Font");
	menu->AddItem(fontMenu);

	BMenu* fontSizeMenu = new BMenu("Size");
	fontSizeMenu->SetRadioMode(true);
	fontMenu->AddItem(fontSizeMenu);
	fontMenu->AddSeparatorItem();

	fontSizeMenu->AddItem(new BMenuItem("9", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size", 9.0);
	fontSizeMenu->AddItem(new BMenuItem("10", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",10.0);
	fontSizeMenu->AddItem(new BMenuItem("11", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",11.0);
	fontSizeMenu->AddItem(new BMenuItem("12", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",12.0);
	fontSizeMenu->AddItem(new BMenuItem("14", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",14.0);
	fontSizeMenu->AddItem(new BMenuItem("18", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",18.0);	
	fontSizeMenu->AddItem(new BMenuItem("24", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",24.0);
	fontSizeMenu->AddItem(new BMenuItem("36", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",36.0);
	fontSizeMenu->AddItem(new BMenuItem("48", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",48.0);
	fontSizeMenu->AddItem(new BMenuItem("72", fontMessage = new BMessage(FONT_SIZE)));
	fontMessage->AddFloat("size",72.0);

	font_family plain_family;
	font_style plain_style;
	config->currentFont.GetFamilyAndStyle(&plain_family,&plain_style);

	BMenu *subMenu;
	BMenuItem *menuItem;
	currentFontItem = 0;

	int32 numFamilies = count_font_families();
	for ( int32 i = 0; i < numFamilies; i++ ) {
		font_family localfamily;
		if ( get_font_family ( i, &localfamily ) == B_OK ) {
			subMenu = new BMenu(localfamily);
			subMenu->SetRadioMode(true);
			fontMenu->AddItem(menuItem = new BMenuItem(subMenu, new BMessage(FONT_FAMILY)));
			if (!strcmp(plain_family,localfamily)) {
				menuItem->SetMarked(true);
				currentFontItem = menuItem;
			}
			int32 numStyles=count_font_styles(localfamily);
			for(int32 j = 0;j<numStyles;j++){
				font_style style;
				uint32 flags;
				if( get_font_style(localfamily,j,&style,&flags)==B_OK){
					subMenu->AddItem(menuItem = new BMenuItem(style, new BMessage(FONT_STYLE)));
					if (!strcmp(plain_style,style)) {
						menuItem->SetMarked(true);
					}
				}
			}
		}
	}

	this->FrameResized(0.0, 0.0);
	UpdateMenus();

	wordInput->MakeFocus(true);
	firstStart = true;
	TryToOpenDict();

	BMessenger mesg(this);
	be_clipboard->StartWatching(mesg);
}
Esempio n. 13
0
void
ControlView::_UpdateFontmenus(bool setInitialfont)
{
	BFont font;
	BMenu* stylemenu = NULL;

	font_family fontFamilyName, currentFamily;
	font_style fontStyleName, currentStyle;

	GetFont(&font);
	font.GetFamilyAndStyle(&currentFamily, &currentStyle);

	const int32 fontfamilies = count_font_families();

	fFontFamilyMenu->RemoveItems(0, fFontFamilyMenu->CountItems(), true);

	for (int32 i = 0; i < fontfamilies; i++) {
		if (get_font_family(i, &fontFamilyName) == B_OK) {
			stylemenu = new BPopUpMenu(fontFamilyName);
			stylemenu->SetLabelFromMarked(false);
			const int32 styles = count_font_styles(fontFamilyName);

			BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG);
			familyMsg->AddString("_family", fontFamilyName);
			BMenuItem* familyItem = new BMenuItem(stylemenu, familyMsg);
			fFontFamilyMenu->AddItem(familyItem);

			for (int32 j = 0; j < styles; j++) {
				if (get_font_style(fontFamilyName, j, &fontStyleName) == B_OK) {
					BMessage* fontMsg = new BMessage(FONTSTYLE_CHANGED_MSG);
					fontMsg->AddString("_family", fontFamilyName);
					fontMsg->AddString("_style", fontStyleName);

					BMenuItem* styleItem = new BMenuItem(fontStyleName, fontMsg);
					styleItem->SetMarked(false);

					// setInitialfont is used when we attach the FontField
					if (!strcmp(fontStyleName, currentStyle)
						&& !strcmp(fontFamilyName, currentFamily)
						&& setInitialfont) {
						styleItem->SetMarked(true);
						familyItem->SetMarked(true);

						BString string;
						string << currentFamily << " " << currentStyle;

						if (fFontMenuField)
							fFontMenuField->MenuItem()->SetLabel(string.String());
					}
					stylemenu->AddItem(styleItem);
				}
			}

			stylemenu->SetRadioMode(true);
			stylemenu->SetTargetForItems(this);
		}
	}

	fFontFamilyMenu->SetLabelFromMarked(false);
	fFontFamilyMenu->SetTargetForItems(this);
}