00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028
00030
00031 #define YASAGUI_FRAME_INCLUDE
00032
00033 #include <qwidget.h>
00034 #include "translations.h"
00035 #include "object.h"
00036
00038 class YFrame;
00039 class YFrameArgs;
00040 class YMDIWindow;
00041 typedef YFrame* (*CreateYFrameCall) (QWidget *parent, YFrameArgs &args);
00042
00043
00045 class YFrameArgs
00046 {
00047 protected:
00048 QString title;
00049 CreateYFrameCall createcall;
00050 int refcount;
00051 public: YFrameArgs(CreateYFrameCall call, const QString &t) :
00052 title(t),
00053 createcall(call),
00054 refcount(0)
00055 {}
00056 virtual ~YFrameArgs()
00057 {}
00058 const QString& GetTitle() const { return title; }
00059 void SetTitle(const QString &t) { title=t; }
00060 YFrame* CreateFrame(QWidget *parent)
00061 {
00062 refcount++;
00063 return createcall(parent, *this );
00064 }
00065 static void DeleteFrameArgs(YFrameArgs &args)
00066 {
00067 args.refcount--;
00068 if (!args.refcount)
00069 delete &args;
00070 }
00071 virtual YObject* GetObject() const { return 0; }
00074
00075 };
00076
00077
00079 class YFrameObjectArgs : public YFrameArgs
00080 { YObject *object;
00081 public: YFrameObjectArgs(CreateYFrameCall call, YObject *o) :
00082 YFrameArgs(call, o->GetName() ),
00083 object(o)
00084 {}
00085 virtual YObject* GetObject() const { return object; }
00086 };
00087
00088
00089
00090
00092 class YFrame : public QObject
00093 { Q_OBJECT
00094 YFrameArgs &frameargs;
00095 public: YFrame(YFrameArgs &args) :
00096 frameargs(args)
00097 {}
00098 ~YFrame();
00099 virtual int InitInstance() { return 0; }
00100 virtual QWidget* GetMainWidget() =0;
00101 YFrameArgs& GetFrameArgs() const { return frameargs; }
00102 void SetTitle(const QString &newtitle)
00103 {
00104 frameargs.SetTitle(newtitle);
00105 TitleChanged(newtitle, frameargs.GetObject() );
00106 }
00109 virtual void PostCreateWindow(YMDIWindow *) { return; }
00110 signals:
00111 void CloseFrame();
00112 void TitleChanged(const QString &newname, YObject *object);
00113 void StatusMessage(const QString &message, int time_ms=0);
00114 };
00115
00116
00117
00119 class YObjectFrame : public YFrame
00120 { Q_OBJECT
00121 public: YObjectFrame(YFrameArgs &args):
00122 YFrame(args)
00123 {}
00124 virtual int InitInstance();
00125 YObject* GetObject() const
00126 { return ((YFrameObjectArgs&)GetFrameArgs()).GetObject(); }
00127 public slots:
00128 void ObjectUpdated()
00129 {
00130 SetTitle(GetObject()->GetName());
00131 }
00132 };
00133
00135 #endif // ifndef YASAGUI_FRAMES_INCLUDE