#include "Form.hpp" #include "IniConfig.hpp" static int tempFormsCount = 0; Form:: Form() : _Current(-1) {} Form::~Form() { Clear(); } bool Form::Load(const String& file) { Clear(); if (!FileExists(file)) return false; if (GetFileExt(file) == ".fz") { String s = ZDecompress(LoadFile(file)); if (!LoadFromXML(*this, s)) return false; _File = file; return true; } if (!LoadFromXMLFile(*this, file)) return false; _File = file; return true; } bool Form::Layout(const String& layout, Font font) { _Current = -1; for (int i = 0; i < _Layouts.GetCount(); ++i) if (_Layouts[i].Get("Form.Name") == layout) { _Current = i; return Generate(font); } return false; } bool Form::Generate(Font font) { if (!IsLayout()) return false; Clear(false); Size sz = _Layouts[_Current].GetFormSize(); SetRect( Rect(Point(0, 0), Size(HorzLayoutZoom(sz.cx), VertLayoutZoom(sz.cy))) ); Vector* p = &_Layouts[_Current].GetObjects(); if (_Layouts[_Current].GetBool("Form.MinimizeBox", false)) MinimizeBox(); if (_Layouts[_Current].GetBool("Form.MaximizeBox", false)) MaximizeBox(); #ifdef PLATFORM_WIN32 if (_Layouts[_Current].GetBool("Form.ToolWindow", false)) ToolWindow(); #endif if (_Layouts[_Current].GetBool("Form.Sizeable", false)) Sizeable(); Title(_Layouts[_Current].Get("Form.Title")); for (int i = 0; i < p->GetCount(); ++i) { Font objFont = font; int h = (*p)[i].GetNumber("Font.Height", 0); if (h != 0) objFont.Height( VertLayoutZoom(h) ); if (font.GetHeight() == 0) objFont.Height( StdFont().GetHeight() ); Ctrl *c = NULL; if ((*p)[i].Get("Type") == "Button") { Button *b = &_Ctrls.Create