Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Examples  

frame.h

Go to the documentation of this file.
00001 
00002 //
00003 // YASA frame code declarations
00004 //
00005 // Project: Yasa 2
00006 // Author : Jan Blumenthal
00007 // Start  : 2002/02/28
00008 // $Header: /sources/yasa/yasagui/frame.h,v 1.4 2003/01/24 15:47:41 bj Exp $
00009 //
00011 //
00012 // This program is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU General Public License as published by
00014 // the Free Software Foundation; either version 2 of the License, or
00015 // (at your option) any later version.
00016 //
00017 // This program is distributed in the hope that it will be useful,
00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 // GNU General Public License for more details.
00021 //
00022 // You should have received a copy of the GNU General Public License
00023 // along with this program (See the included file COPYING);
00024 // if not, write to the Free Software Foundation, Inc.,
00025 // 675 Mass Ave, Cambridge, MA 02139, USA.
00026 //
00028 // Use frames to create mdi child windows. In this way you can cascade frames
00030 #ifndef YASAGUI_FRAME_INCLUDE
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 //  virtual void        PostCreateWindow(YMDIWindow *)              {   return;             }
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

Generated on Thu Feb 13 23:43:53 2003 for Yasa by doxygen1.3-rc3