#ifndef LAYDES_H #define LAYDES_H #include #include #include #include #define LAYOUTFILE #include #define IMAGECLASS LayImg #define IMAGEFILE #include #define KEYNAMESPACE LayoutKeys #define KEYGROUPNAME "Layout" #define KEYFILE #include class DiffPacker { String master; int mapn; Buffer map; Buffer prev; public: void SetMaster(const String& master); String Pack(const String& data); }; String DiffPack(const String& master, const String& data); String DiffUnpack(const String& master, const String& pack); struct TypeProperty : Moveable { int level; String type; String name; String defval; String help; TypeProperty() { level = 0; } }; enum { LAYOUT_CTRL, LAYOUT_SUBCTRL, LAYOUT_TEMPLATE }; struct LayoutType : Moveable { int kind; Array property; ArrayMap methods; String group; Image icon[2]; Size iconsize[2]; LayoutType() { iconsize[0] = iconsize[1] = Null; } }; VectorMap >& LayoutEnums(); VectorMap& LayoutTypes(); Point ReadPoint(CParser& p); struct EscDraw : public EscHandle { Draw& w; void DrawRect(EscEscape& e); void DrawText(EscEscape& e); void DrawSmartText(EscEscape& e); void DrawQtf(EscEscape& e); void GetTextSize(EscEscape& e); void DrawImage(EscEscape& e); typedef EscDraw CLASSNAME; EscDraw(EscValue& v, Draw& w); }; EscValue EscColor(Color c); Color ColorEsc(EscValue v); EscValue EscSize(Size sz); Size SizeEsc(EscValue v); EscValue EscPoint(Point sz); Point PointEsc(EscValue v); EscValue EscRect(const Rect& r); Rect RectEsc(EscValue v); EscValue EscFont(Font f); Font FontEsc(EscValue v); struct ItemProperty : public Ctrl { int level; String name; Value defval; String help; virtual void Paint(Draw& w); virtual int GetHeight() const; virtual void SetCharset(byte charset); virtual void Read(CParser& p); virtual String Save() const; virtual bool PlaceFocus(dword k, int c); ItemProperty() { NoWantFocus(); level = 0; } virtual ~ItemProperty() {} static VectorMap& Factory(); static ItemProperty *Create(const String& name); static void Register(const char *name, ItemProperty *(*creator)()); }; template class EditorProperty : public ItemProperty { public: virtual Value GetData() const { return ~editor; } virtual bool PlaceFocus(dword k, int c) { editor.SetFocus(); return editor.Key(k, c); } protected: void EditAction() { this->UpdateActionRefresh(); } Editor editor; EditorProperty() { editor.WhenAction = callback(this, &EditorProperty::EditAction); } }; String ReadPropertyParam(CParser& p); struct RawProperty : public EditorProperty { virtual String Save() const; virtual void Read(CParser& p); static ItemProperty *Create() { return new RawProperty; } RawProperty() { Add(editor.HSizePos(100, 2).TopPos(2)); } }; struct PropertyPane : public StaticRect { virtual void Layout(); virtual void ChildGotFocus(); int y; StaticRect pane; ScrollBar sb; void Clear(); void Add(ItemProperty& c); void SetSb(); void Scroll(); void AfterCreate(); typedef PropertyPane CLASSNAME; PropertyPane(); }; struct LayoutItem { String type; String variable; Ctrl::LogPos pos; Array property; bool hide; byte charset; private: Size csize; Drawing cache; void UnknownPaint(Draw& w); void CreateProperties(const String& classname, int level); void CreateMethods(EscValue& ctrl, const String& type, bool copy) const; public: void Invalidate() { csize.cx = -1; } EscValue CreateEsc() const; EscValue ExecuteMethod(const char *method, Vector& arg) const; EscValue ExecuteMethod(const char *method) const; Size GetMinSize(); Size GetStdSize(); void Paint(Draw& w, Size sz, bool sample = false); void Create(const String& type); int FindProperty(const String& s) const; void SetCharset(byte charset); void ReadProperties(CParser& p, bool addunknow = true); String SaveProperties() const; String Save(int i) const; LayoutItem() { csize.cx = -1; hide = false; charset = CHARSET_UNICODE; } }; Image GetTypeIcon(const String& type, int cx, int cy, int i, Color bg); Array ReadItems(CParser& p, byte charset); class LayoutUndo { Vector stack; public: void Clear() { stack.Clear(); } int GetCount() const { return stack.GetCount(); } operator bool() const { return stack.GetCount(); } void Push(const String& state); const String& Top() const { return stack.Top(); } String Pop(); }; struct LayoutData { String name; Size size; Array item; LayoutUndo undo, redo; byte charset; private: String MakeState(); void LoadState(const String& s); void Do(LayoutUndo& u1, LayoutUndo& u2); String GetTID(int i); public: void SetCharset(byte charset); void Read(CParser& p); String Save(); String Save(const Vector& sel); void SaveState(); bool IsUndo(); void Undo(); bool IsRedo(); void Redo(); LayoutData() { size = Size(400, 200); charset = CHARSET_UNICODE; } }; class LayDesigner; struct LayDesEditPos { Time filetime; Array undo; Array redo; int layouti; Vector cursor; LayDesEditPos() { filetime = Null; } }; class LayDes : public StaticRect { public: virtual void Paint(Draw& w); virtual Image CursorImage(Point p, dword keyflags); virtual void LeftDown(Point p, dword keyflags); virtual void LeftRepeat(Point p, dword keyflags); virtual void MouseMove(Point p, dword keyflags); virtual void LeftUp(Point p, dword keyflags); virtual void RightDown(Point p, dword keyflags); virtual void Layout(); private: bool DoKey(dword key, int count); struct KeyMaster : public ParentCtrl { LayDes *d; virtual bool Key(dword key, int count) { return d->DoKey(key, count); } }; String filename; byte charset; String layfile; bool newfile; Time filetime; String fileerror; friend class LayDesigner; LayDesigner *frame; ToolBar toolbar; MenuBar menubar; ArrayCtrl layoutlist; ArrayCtrl item; PropertyPane property; WithDropChoice type; EditString variable; KeyMaster km; Splitter lsplit, isplit, rsplit; FrameTop twsplit; ScrollBars sb; FrameRight