void CSchemeVisualizer::AddFontsToList() { #ifdef POSIX const char strOAccent[] = { 0xc3, 0x93, 0x00 }; // UTF-8 for U+00D3 (LATIN CAPITAL LETTER O WITH ACUTE) #else const uint8 strOAccent[] = { 0xd3, 0x00 }; #endif // Stick an intl character in here to test accents (O') CFmtStr fmtText( "ABCDEFGHIJKLMN%sPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz0123456789!@#$%%^&*()-_=+", strOAccent ); const int nFontCount = m_pViewScheme->GetFontCount(); for ( int i = 0; i < nFontCount; ++i ) { HFont hCurFont = m_pViewScheme->GetFontAtIndex( i ); const char *pCurFontName = m_pViewScheme->GetFontName( hCurFont ); CFmtStr fmtName( "FontPanel_%s", pCurFontName ); Label *pNewFontLabel = new Label( m_pList, fmtName.Access(), fmtText.Access() ); pNewFontLabel->SetFont( hCurFont ); pNewFontLabel->SizeToContents(); pNewFontLabel->SetWide( m_pList->GetWide() ); m_pList->AddItem( new Label( NULL, "Label", pCurFontName ), pNewFontLabel ); } }
TimeMenu::TimeMenu() { Label *label; LineSpacer *spacer; label = new Label(); label->SetFont(&MetaWatch_Large_16pt); label->SetText("Time & Date"); label->SetAlignment(caCentre); AddControl(label); spacer = new LineSpacer(5, 2); spacer->SetLeftPadding(10); spacer->SetRightPadding(10); AddControl(spacer); // Time editor timeEntry = new NumberEntry(); timeEntry->SetFont(&MetaWatch_Large_8pt); timeEntry->SetFormat("[0-2][0-9]:[0-5][0-9]:[0-5][0-9]"); // TODO: Change with time format? timeEntry->SetAlignment(caCentre); AddControl(timeEntry); // Date editor dateEntry = new NumberEntry(); dateEntry->SetFont(&MetaWatch_Large_8pt); dateEntry->SetFormat("[0-3][0-9]:[0-1][0-9]:[0-2][0-9][0-9][0-9]"); // TODO: Change with date format? dateEntry->SetAlignment(caCentre); AddControl(dateEntry); }
//----------------------------------------------------------------------------- // Purpose: sets up the current control to edit //----------------------------------------------------------------------------- void BuildModeDialog::SetActiveControl(Panel *controlToEdit) { if (m_pCurrentPanel == controlToEdit) { // it's already set, so just update the property data and quit if (m_pCurrentPanel) { UpdateControlData(m_pCurrentPanel); } return; } // reset the data m_pCurrentPanel = controlToEdit; RemoveAllControls(); m_pPanelList->m_pControls->MoveScrollBarToTop(); if (!m_pCurrentPanel) { m_pStatusLabel->SetText("[nothing currently selected]"); m_pStatusLabel->SetTextColorState(Label::CS_DULL); RemoveAllControls(); return; } // get the control description string const char *controlDesc = m_pCurrentPanel->GetDescription(); // parse out the control description int tabPosition = 1; while (1) { const char *dataType = ParseTokenFromString(&controlDesc); // finish when we have no more tokens if (*dataType == 0) break; // default the data type to a string int datat = TYPE_STRING; if (!stricmp(dataType, "int")) { datat = TYPE_STRING; //!! just for now } else if (!stricmp(dataType, "alignment")) { datat = TYPE_ALIGNMENT; } else if (!stricmp(dataType, "autoresize")) { datat = TYPE_AUTORESIZE; } else if (!stricmp(dataType, "corner")) { datat = TYPE_CORNER; } else if (!stricmp(dataType, "localize")) { datat = TYPE_LOCALIZEDSTRING; } // get the field name const char *fieldName = ParseTokenFromString(&controlDesc); int itemHeight = 18; // build a control & label Label *label = new Label(this, NULL, fieldName); label->SetSize(96, itemHeight); label->SetContentAlignment(Label::a_east); TextEntry *edit = NULL; ComboBox *editCombo = NULL; Button *editButton = NULL; if (datat == TYPE_ALIGNMENT) { // drop-down combo box editCombo = new ComboBox(this, NULL, 9, false); editCombo->AddItem("north-west", NULL); editCombo->AddItem("north", NULL); editCombo->AddItem("north-east", NULL); editCombo->AddItem("west", NULL); editCombo->AddItem("center", NULL); editCombo->AddItem("east", NULL); editCombo->AddItem("south-west", NULL); editCombo->AddItem("south", NULL); editCombo->AddItem("south-east", NULL); edit = editCombo; } else if (datat == TYPE_AUTORESIZE) { // drop-down combo box editCombo = new ComboBox(this, NULL, 4, false); editCombo->AddItem( "0 - no auto-resize", NULL); editCombo->AddItem( "1 - resize right", NULL); editCombo->AddItem( "2 - resize down", NULL); editCombo->AddItem( "3 - down & right", NULL); edit = editCombo; } else if (datat == TYPE_CORNER) { // drop-down combo box editCombo = new ComboBox(this, NULL, 4, false); editCombo->AddItem("0 - top-left", NULL); editCombo->AddItem("1 - top-right", NULL); editCombo->AddItem("2 - bottom-left", NULL); editCombo->AddItem("3 - bottom-right", NULL); edit = editCombo; } else if (datat == TYPE_LOCALIZEDSTRING) { editButton = new Button(this, NULL, "..."); editButton->SetParent(this); editButton->AddActionSignalTarget(this); editButton->SetTabPosition(tabPosition++); editButton->SetTall( itemHeight ); label->SetAssociatedControl(editButton); } else { // normal string edit edit = new CSmallTextEntry(this, NULL); } if (edit) { edit->SetTall( itemHeight ); edit->SetParent(this); edit->AddActionSignalTarget(this); edit->SetTabPosition(tabPosition++); label->SetAssociatedControl(edit); } HFont smallFont = scheme()->GetIScheme( GetScheme() )->GetFont( "DefaultVerySmall" ); if ( label ) { label->SetFont( smallFont ); } if ( edit ) { edit->SetFont( smallFont ); } if ( editCombo ) { editCombo->SetFont( smallFont ); } if ( editButton ) { editButton->SetFont( smallFont ); } // add to our control list m_pPanelList->AddItem(label, edit, editCombo, editButton, fieldName, datat); if ( edit ) { m_pPanelList->m_pControls->AddItem(label, edit); } else { m_pPanelList->m_pControls->AddItem(label, editButton); } } // check and see if the current panel is a Label // iterate through the class hierarchy if ( controlToEdit->IsBuildModeDeletable() ) { m_pDeleteButton->SetEnabled(true); } else { m_pDeleteButton->SetEnabled(false); } // update the property data in the dialog UpdateControlData(m_pCurrentPanel); // set our title if ( m_pBuildGroup->GetResourceName() ) { m_pFileSelectionCombo->SetText(m_pBuildGroup->GetResourceName()); } else { m_pFileSelectionCombo->SetText("[ no resource file associated with dialog ]"); } m_pApplyButton->SetEnabled(false); InvalidateLayout(); Repaint(); }
void FormEdit::UpdateChildCount(int count) { for (int i = 0; i < _Ctrls.GetCount(); ++i) _CtrlContainer.RemoveChild(&_Ctrls[i]); _Ctrls.Clear(); _ItemList.Clear(); _Temporaries.Clear(); if (!_View.IsLayout()) { UpdateItemList(); return; } // if (_ViewMode == VIEW_MODE_WIREFRAME) // return; for (int i = 0; i < count; ++i) { if (!_View.GetObject(i)) continue; String type = (*_View.GetObjects())[i].Get("Type"); Font font = _View.GetFont(); int h = _View.ZoomY((*_View.GetObjects())[i].GetNumber("Font.Height")); if (h != 0) font.Height(h); if (font.GetHeight() == 0) font.Height(StdFont().GetHeight()); _ItemList.AddRow(type, (*_View.GetObjects())[i].Get("Variable")); if ((*_View.GetObjects())[i].GetBool("OutlineDraw", false) && _ViewMode != VIEW_MODE_AS_IS) { if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( _Ctrls.Create<StaticRect>() ); } else if (type == "Button") { Button* b = &_Ctrls.Create<Button>(); b->SetFont(font); if (_ViewMode == VIEW_MODE_AS_IS) b->SetLabel((*_View.GetObjects())[i].Get("Label")); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } else if (type == "DropDate") { DropDate *b = &_Ctrls.Create<DropDate>(); b->SetFont(font); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } else if (type == "GridCtrl") { GridCtrl *b = &_Ctrls.Create<GridCtrl>(); // b->SetFont(font); TODO #ifdef PLATFORM_WIN32 b->Chameleon(); #endif String src = (*_View.GetObjects())[i].Get("Grid.Columns"); ReplaceString(src, ";", "\r\n"); StringStream s; s.Open(src); IniFile f; f.Load(s); Vector<String> names = f.EnumNames("Columns"); for (int j = 0; j < names.GetCount(); ++j) { int n = ScanInt(names[j]); Vector<String> values = f.GetArray("Columns", names[j]); if (values.GetCount() != 3) continue; if (values[1] == "Left") b->AddColumn(values[0]).HeaderAlignCenterLeft(); else if (values[1] == "Right") b->AddColumn(values[0]).HeaderAlignCenterRight(); else b->AddColumn(values[0]).HeaderAlignCenter(); } if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } else if (type == "EditField") { EditField *b = &_Ctrls.Create<EditField>(); b->SetFont(font); if (_ViewMode == VIEW_MODE_AS_IS) b->SetText((*_View.GetObjects())[i].Get("DefaultData")); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } else if (type == "EditInt") { EditInt *b = &_Ctrls.Create<EditInt>(); b->SetFont(font); if (_ViewMode == VIEW_MODE_AS_IS) b->SetText((*_View.GetObjects())[i].Get("DefaultData")); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } else if (type == "ProgressBar") { ProgressIndicator *b = &_Ctrls.Create<ProgressIndicator>(); b->Set(0, 100); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } else if (type == "TabCtrl") { TabCtrl* e = &_Ctrls.Create<TabCtrl>(); TabCtrl::Style& style = e->StyleDefault().Write(); style.font = font; style.tabheight = font.GetHeight() + VertLayoutZoom(10); e->SetStyle(style); String src = (*_View.GetObjects())[i].Get("Tab.Content"); ReplaceString(src, ";", "\r\n"); StringStream s; s.Open(src); IniFile f; f.Load(s); Vector<String> names = f.EnumNames("Tabs"); VectorMap<int, Vector<String> > cache; int tabCount = 0; for (int j = 0; j < names.GetCount(); ++j) { int n = ScanInt(names[j]); if (AsString(n) != names[j]) continue; Vector<String> values = f.GetArray("Tabs", names[j]); if (values.GetCount() != 3) continue; Container *cont = &_Temporaries.Create<Container>(); Form *f = &_Temporaries.Create<Form>(); if (values[0] != t_("Current form")) { if (!f->Load(GetFileDirectory(_File) + "\\" + values[0])) continue; } else { int lay = _View.HasLayout(values[1]); if (lay < 0) continue; f->GetLayouts().Add() <<= _View.GetLayouts()[lay]; } if (!f->Layout(values[1], font)) continue; cont->Set(*f, f->GetSize()); cont->SizePos(); e->Add(*cont, values[2]); tabCount++; } int activeTab = -1; if (tabCount) { activeTab = (*_View.GetObjects())[i].GetNumber("Tab.Active", 0, 0); if (activeTab >= tabCount) { activeTab = tabCount - 1; e->Set(activeTab); } e->Set(activeTab); } (*_View.GetObjects())[i].SetNumber("Tab.Active", activeTab); (*_View.GetObjects())[i].SetNumber("Tab.Count", tabCount); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( e->NoWantFocus() ); } else if (type == "Form") { Form f; String path = (*_View.GetObjects())[i].Get("Form.Path"); (*_View.GetObjects())[i].Get("Form.PathType") == "Relative" ? f.Load(::GetFileDirectory(_File) + "\\" + path) : f.Load(path); f.Layout((*_View.GetObjects())[i].Get("Form.Layout"), font); ImageDraw w(f.GetSize()); f.DrawCtrl(w); ImageBuffer buf(w); StaticImage *s = &_Ctrls.Create<StaticImage>(); s->SetImage(buf); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.AddChild( s ); } else { Label *b = &_Ctrls.Create<Label>(); b->SetFont(font); Color fontColor = DefaultInk(); LoadFromString(fontColor, Decode64((*_View.GetObjects())[i].Get("Font.Color", StoreAsString(fontColor)))); b->SetInk(fontColor); String align = (*_View.GetObjects())[i].Get("Text.Align"); if (align == "Center") b->SetAlign(ALIGN_CENTER); if (align == "Right") b->SetAlign(ALIGN_RIGHT); if (align == "Left") b->SetAlign(ALIGN_LEFT); if (_ViewMode == VIEW_MODE_AS_IS) b->SetLabel((*_View.GetObjects())[i].Get("Label")); if (_ViewMode != VIEW_MODE_WIREFRAME) _CtrlContainer.Add( b->NoWantFocus() ); } String frame = (*_View.GetObjects())[i].Get("Frame"); Ctrl* c = NULL; if (_Ctrls.GetCount()) c = &_Ctrls[_Ctrls.GetCount() - 1]; if (c) { if (frame == "Null frame") c->SetFrame(NullFrame()); if (frame == "Field frame") c->SetFrame(FieldFrame()); if (frame == "Inset frame") c->SetFrame(InsetFrame()); if (frame == "Outset frame") c->SetFrame(OutsetFrame()); if (frame == "Thin inset frame") c->SetFrame(ThinInsetFrame()); if (frame == "Thin outset frame") c->SetFrame(ThinOutsetFrame()); if (frame == "Black frame") c->SetFrame(BlackFrame()); if (frame == "Button frame") c->SetFrame(ButtonFrame()); if (frame == "Top separator frame") c->SetFrame(TopSeparatorFrame()); if (frame == "Left separator frame") c->SetFrame(LeftSeparatorFrame()); if (frame == "Right separator frame") c->SetFrame(RightSeparatorFrame()); if (frame == "Bottom separator frame") c->SetFrame(BottomSeparatorFrame()); } } UpdateItemList(); UpdateChildAllPos(); }