void Ide::SaveConfig() { SaveChangedFile(ConfigFile(), StoreAsString(*this)); if(GetIniKey("DebugClipboard") == "1") { SaveChangedFile(ConfigFile() + ".bak", StoreAsString(*this)); StoreToFile(*this, ConfigFile() + ".bak1"); } SaveChangedFile(ConfigFile("ide.key"), StoreKeys()); SaveChangedFile(ConfigFile("ide.colors"), editor.StoreHlStyles()); config_time = ConfigTime(); }
void PropertiesWindow::OnEndEdit(int mode) { if (_Item) { for (int i = 0; i < _Properties.GetCount(); ++i) { String param = _Properties.GetKey(i); if (param.Find("Color") >= 0) // if color found { Color r = _Properties[i].GetData(); _Item->Set(param, Encode64(StoreAsString(r))); continue; } String value = AsString(_Properties[i].GetData()); _Item->Set(param, value); } if (mode) { _Options.EndEdit(); _Options.ClearCursor(); _Item->Set("Type", _Headers.Get(0, 1)); Generate(_Item, _Index); } WhenChildZ.Execute(); } }
void Ctrl::GtkDragDataReceived(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time, gpointer user_data) { LLOG("GtkDragDataReceived"); dnd_data_wait = false; if(dnd_data_fmt == "text") { guchar *s = gtk_selection_data_get_text(data); if(s) { dnd_data = (const char *)s; g_free(s); } } else if(dnd_data_fmt == "image") { Image img = ImageFromPixbufUnref(gtk_selection_data_get_pixbuf(data)); dnd_data = StoreAsString(img); // Not very optimal... } else dnd_data = GtkDataGet(data); }
String sImage(const Value& image) { Image img = image; return StoreAsString(const_cast<Image&>(img)); }
void PropertiesWindow::Generate(FormObject* pI, int index) { if (!pI) return; _Properties.Clear(); _Options.Clear(); _Item = pI; _Index = index; String type = pI->Get("Type"); if (type.IsEmpty()) return; Property("Variable", t_("Variable:"), "EditField", Array<String>() << pI->Get("Variable")); if (_Headers.GetRowCount() != 1) { _Headers.Clear(); _Headers.AddRow(t_("Type:"), type); } Property("Font.Height", t_("Font height:"), "EditInt", Array<String>() << AsString(pI->GetNumber("Font.Height", 0, 0, 500))); if (type == "EditField") { Property("Style", t_("Style:"), "DropList", Array<String>() << pI->Get("Style") << "Text Field" << "Password"); Property("TextAlign", t_("Text align:"), "DropList", Array<String>() << pI->Get("TextAlign") << "Left" << "Right"); Property("Tip", t_("Tip:"), "EditField", Array<String>() << pI->Get("Tip")); Property("NotNull", t_("Not null:"), "Option", Array<String>() << pI->Get("NotNull", "0")); } if (type == "EditInt") { Property("Min", t_("Min:"), "EditInt", Array<String>() << pI->Get("Min")); Property("Max", t_("Max:"), "EditInt", Array<String>() << pI->Get("Max")); Property("Tip", t_("Tip:"), "EditField", Array<String>() << pI->Get("Tip")); Property("NotNull", t_("Not null:"), "Option", Array<String>() << pI->Get("NotNull", "0")); } if (type == "Label") { Color src = DefaultInk(); LoadFromString( src, Decode64(pI->Get("Font.Color", Encode64(StoreAsString(src)))) ); Property("Label", t_("Label:"), "EditField", Array<String>() << pI->Get("Label")); Property("Text.Align", t_("Text align:"), "DropList", Array<String>() << pI->Get("Text.Align") << "Left" << "Center" << "Right"); Property("Font.Color", t_("Font color:"), "EditColor", src); } if (type == "Button") { Property("Label", t_("Label:"), "EditField", Array<String>() << pI->Get("Label")); Property("Action", t_("Action:"), "EditField", Array<String>() << pI->Get("Action")); Property("Tip", t_("Tip:"), "EditField", Array<String>() << pI->Get("Tip")); } if (type == "Form") { Property("Form.PathType", t_("Type of path:"), "DropList", Array<String>() << pI->Get("Form.PathType") << "Relative" << "Absolute"); Property("Form.Path", t_("Path:"), "EditField", Array<String>() << pI->Get("Form.Path")); Property("Form.Layout", t_("Layout:"), "EditField", Array<String>() << pI->Get("Form.Layout")); } if (type == "TabCtrl") { Property("Tab.Content", t_("Tabs:"), "EditTabs", Array<String>() << pI->Get("Tab.Content", "[Tabs];")); } if (type == "GridCtrl") { Property("Grid.Columns", t_("Columns:"), "EditColumns", Array<String>() << pI->Get("Grid.Columns", "[Columns];")); } Property("Frame", t_("Frame:"), "DropList", Array<String>() << pI->Get("Frame") << "Default frame" << "Null frame" << "Top separator frame" << "Left separator frame" << "Right separator frame" << "Bottom separator frame" << "Field frame" << "Inset frame" << "Outset frame" << "Thin inset frame" << "Thin outset frame" << "Black frame" << "Button frame"); _Options.HideRow(0); _Headers.SetCursor(0); _Headers.StartEdit(); _Options.SetCursor(0); }
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(); }
void DlgSqlExport::Run(Sql& cursor, String command, String tablename) { Title(Nvl(tablename, t_("SQL query")) + t_(" export")); object_name <<= tablename; if(!cursor.Execute(command)) { Exclamation(NFormat(t_("Error executing [* \1%s\1]: \1%s"), command, cursor.GetLastError())); return; } for(int i = 0; i < cursor.GetColumns(); i++) { const SqlColumnInfo& sci = cursor.GetColumnInfo(i); String type; switch(sci.valuetype) { case BOOL_V: case INT_V: type = t_("integer"); break; case DOUBLE_V: type = t_("real number"); break; case STRING_V: case WSTRING_V: type = t_("string"); break; case DATE_V: type = t_("date"); break; case TIME_V: type = t_("date/time"); break; case /*ORA_BLOB_V*/-1: type = t_("BLOB"); break; case /*ORA_CLOB_V*/-2: type = t_("CLOB"); break; default: type = FormatInt(sci.valuetype); break; } columns.Add(sci.name, sci.valuetype, sci.width, 1); } static String cfg; LoadFromString(*this, cfg); SyncUI(); while(TopWindow::Run() == IDOK) try { String out_table = ~object_name; String delim; switch((int)~delimiters) { case DELIM_TAB: delim = "\t"; break; case DELIM_SEMICOLON: delim = ";"; break; } Vector<int> out; String colstr; String title; for(int i = 0; i < columns.GetCount(); i++) if(columns.Get(i, 3)) { out.Add(i); String cname = cursor.GetColumnInfo(i).name; colstr << (i ? ", " : "") << cname; if(i) title << delim; title << cname; } if(out.IsEmpty()) { throw Exc(t_("No columns selected!")); continue; } String rowbegin, rowend; int fmt = ~format; FileSel fsel; String ext; switch(fmt) { case FMT_TEXT: { rowend = ""; ext = ".txt"; fsel.Type(t_("Text files (*.txt)"), "*.txt"); break; } case FMT_SQL: { if(identity_insert) rowbegin << "set identity_insert " << out_table << " on "; rowbegin << "insert into " << out_table << "(" << colstr << ") values ("; rowend = ");"; ext = ".sql"; fsel.Type(t_("SQL scripts (*.sql)"), "*.sql"); break; } } fsel.AllFilesType().DefaultExt(ext.Mid(1)); if(!IsNull(recent_file)) fsel <<= ForceExt(recent_file, ext); if(!fsel.ExecuteSaveAs(t_("Save export as"))) continue; recent_file = ~fsel; FileOut fo; if(!fo.Open(recent_file)) { Exclamation(NFormat(t_("Error creating file [* \1%s\1]."), recent_file)); continue; } if(fmt == FMT_TEXT) fo.PutLine(title); Progress progress(t_("Exporting row %d")); while(cursor.Fetch()) { String script = rowbegin; for(int i = 0; i < out.GetCount(); i++) { Value v = cursor[out[i]]; switch(fmt) { case FMT_TEXT: { if(i) script.Cat(delim); if(IsString(v) && quote) { String s = v; script << '\"'; for(const char *p = s, *e = s.End(); p < e; p++) if(*p == '\"') script.Cat("\"\""); else script.Cat(*p); script << '\"'; } else script << StdFormat(v); break; } case FMT_SQL: { if(i) script.Cat(", "); // script << SqlCompile(SQLD_ORACLE, SqlFormat(v)); break; } } } script << rowend; fo.PutLine(script); /* if(autocommit && --left <= 0) { fo.PutLine("commit;"); left = autocommit; } */ if(progress.StepCanceled()) { Exclamation(t_("Export aborted!")); return; } } fo.Close(); if(fo.IsError()) throw Exc(NFormat(t_("Error writing file %s."), recent_file)); break; } catch(Exc e) { ShowExc(e); } cfg = StoreAsString(*this); }