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

forms.h

00001 /*
00002  * ===========================
00003  * VDK Visual Develeopment Kit
00004  * Version 0.4
00005  * October 1998
00006  * ===========================
00007  *
00008  * Copyright (C) 1998, Mario Motta
00009  * Developed by Mario Motta <mmotta@guest.net>
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Library General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Library General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Library General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00024  * 02111-1307, USA.
00025  */
00026 
00027 #ifndef FORMS_H
00028 #define FORMS_H
00029 
00030 #include <vdk/application.h>
00031 #include <vdk/dlist.h>
00032 #include <vdk/vdktypes.h>
00033 #include <vdk/rawobj.h>
00034 #include <vdk/vdkprops.h>
00035 #include <vdk/vdkutils.h>
00036 #include <vdk/vdkstring.h>
00037 #include <vdk/vdkobj.h>
00038 class VDKObject;
00039 
00040 class VDKColor;
00041 class VDKForm;
00042 class VDKFont;
00043 class VDKBox;
00044 class VDKRawPixmap;
00045 
00046 typedef VDKList<VDKForm> ChildList;
00047 typedef VDKListiterator<VDKForm> ChildListIterator;
00048 
00049 typedef VDKList<VDKObject> ObjectList;
00050 typedef VDKListiterator<VDKObject> ObjectListIterator;
00051 
00052 
00068 class VDKForm : public VDKObject
00069 {
00070 
00071  private:
00075   VDKForm(VDKForm& ):VDKObject( NULL) {}
00079   VDKForm& operator=(VDKForm& ) { return *this; }
00080 protected:
00084   void SignalsConnect();
00088   VDKApplication* app;
00092   ChildList childs,childsGarbage;
00096   GtkWidget *window;
00100   VDKBox* box;
00104   bool isModal;
00108   bool never_showed;
00109   /*
00110     position storage
00111   */
00112   VDKPoint _oldPos;
00116   VDKPoint _oldSize;
00121   int modalCount;
00122   /*
00123     \internal
00124   */
00125   static int ConfigureEvent(GtkWidget* ,
00126                              GdkEventConfigure* ev,
00127                              gpointer gp);
00128   /*
00129     \internal
00130   */
00131   static gboolean WindowStateEvent (GtkWidget  *widget, GdkEventWindowState *event);
00132   /*
00133     \internal
00134   */
00135   static int DestroyEvent (GtkWidget*, gpointer gp);
00136   /*
00137     \internal
00138   */
00139   static int DeleteEvent(GtkWidget* , GdkEvent* , gpointer gp);
00140   /*
00141     \internal
00142   */
00143   static int ExposeEvent(GtkWidget* ,
00144                           GdkEventExpose* ev, gpointer gp);
00145   /*
00146     \internal
00147   */
00148   static void RealizeSignal(GtkWidget* , gpointer gp);
00149   /*
00150     \internal
00151   */
00152   static int MapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00153   /*
00154     \internal
00155   */
00156   static int UnmapEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00157   /*
00158     \internal
00159   */
00160   static int FocusInEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00161   /*
00162     \internal
00163   */
00164   static int FocusOutEvent(GtkWidget* , GdkEvent* ev ,gpointer gp);
00165   /*
00166     \internal
00167   */
00168   static void SizeAllocateSignal(GtkWidget      *widget,
00169                             GtkAllocation  *allocation,
00170                             gpointer gp);
00171 public:
00172   /*
00173     properties
00174   */
00175   VDKReadWriteValueProp<VDKForm,bool> Visible;
00176   VDKReadWriteValueProp<VDKForm,VDKString> Title;
00177   VDKReadWriteValueProp<VDKForm,VDKPoint> Position;
00178   VDKReadWriteValueProp<VDKForm,bool> Iconized;
00179   VDKReadWriteValueProp<VDKForm,VDKRawPixmap*> BackgroundPixmap;
00180   VDKReadWriteValueProp<VDKForm,VDKObject*> FocusWidget;
00181 
00182   /*
00183     constructors
00184   */
00197   VDKForm(VDKApplication* app,
00198           char* title = (char*) NULL,
00199           int mode = v_box,
00200           GtkWindowType display = GTK_WINDOW_TOPLEVEL);
00213   VDKForm(VDKForm* owner,
00214           char* title = (char*) NULL,
00215           int mode = v_box,
00216           GtkWindowType display = GTK_WINDOW_TOPLEVEL);
00220   VDKForm(VDKApplication* app,
00221           GtkWidget* wid,
00222           char* title = (char*) NULL);
00223 
00224 #if HAVE_GNOME
00225 
00228 VDKForm(VDKForm* owner,
00229          GtkWidget* wid,
00230          char* title = (char*) NULL);
00231 #endif
00232 
00235  virtual ~VDKForm();
00239  bool                     Destroy();
00243  virtual int              isA() { return form_class; }
00247  VDKBox*                   Box() { return box; }
00257  virtual void              Show(GtkWindowPosition pos = GTK_WIN_POS_NONE);
00261  virtual void              Hide();
00271  virtual void              ShowModal(GtkWindowPosition pos = GTK_WIN_POS_NONE);
00275  bool                      IsModal() { return isModal; }
00288  virtual void Add(VDKObject* obj, int justify = l_justify,
00289                   int expand = TRUE, int fill = TRUE ,
00290                   int padding = 1);
00294  void              AddChild(VDKForm* child);
00299  VDKForm*                 Owner() { return owner; }
00303  void                       RemoveChild(VDKForm* child);
00309  virtual bool               CanClose(void);
00316  virtual void               Close(void);
00317 
00318  // this makes a VDKForm an abstract class
00323  virtual void               Setup(void) = 0;
00324 
00325  void                       SetTitle(VDKString title)
00326    { gtk_window_set_title(GTK_WINDOW(window),(char*) title); }
00327 
00328  VDKString                  GetTitle(void)
00329    {
00330      VDKString title = Title;
00331      return VDKString(title);
00332    }
00333 
00334  GtkWidget*                  Window() { return window; }
00335 
00336  VDKApplication*             Application() { return app; }
00337 
00338  void                        CloseChilds(void);
00339 
00340  void                        CollectGarbage();
00341 
00342  ObjectList& Objects(void) { return items; }
00343 
00344  ChildList&                  Childs(void) { return childs; }
00345  ChildList&                  ChildsGarbage(void)
00346    { return childsGarbage; }
00350  void                 Raise();
00354  void                 Lower();
00355 
00356  void                 SetVisible(bool flag)
00357    {
00358      if(flag) Show();
00359      else Hide();
00360    }
00361  bool                        GetVisible()
00362    { return GTK_WIDGET_VISIBLE(window); };
00363  /*
00364   */
00365  void SetIcon(VDKRawPixmap*);
00366  void SetIconName(char* name);
00367  void SetPosition(VDKPoint p);
00368  VDKPoint GetPosition();
00369  //
00370  void SetDefaultSize(VDKPoint p);
00371  void SetFormSize(VDKPoint p)
00372    { if(window) gdk_window_resize(window->window,p.X(),p.Y()); }
00373  bool GetIconized();
00374  void SetIconized(bool flag);
00375  void SetBackgroundPixmap(VDKRawPixmap* pix);
00376  void SetFocusWidget(VDKObject* focuswidget);
00377  /*
00378 event response (place holders for subclasses)
00379 */
00380  static void  ButtonPressEvent(GtkWidget* ,
00381                                GdkEventButton* ev,
00382                                gpointer gp);
00383 
00384  virtual void OnExpose( VDKForm* sender, GdkRectangle area);
00385  virtual void OnChildClosing(VDKForm* child);
00386  virtual void OnShow(VDKForm* sender);
00387  virtual void OnRealize(VDKForm* sender);
00388  virtual void OnConfigure(VDKForm* sender);
00389  virtual void OnMove(VDKForm* sender);
00390  virtual void OnResize(VDKForm* sender, VDKPoint& size);
00391  virtual void OnIconize(VDKForm* sender);
00392  virtual void OnRestore(VDKForm* sender);
00393  virtual void OnFormActivate(VDKForm* sender, bool in_out);
00394 /*
00395   Answers to a MS Windows-like message.
00396   Not very useful, just added  to facilitate
00397   porting my neural lib from MS Windows to VDK.
00398   Casual user should override in his own forms.
00399   */
00400  virtual int
00401      WindozeMessage(int /*msg*/,
00402                     unsigned int /*wParam*/,
00403                     long unsigned int /*lParam*/)
00404      {
00405          return 0;
00406      }
00407 };
00408 
00409 #endif
00410 
00411 
00412 

Generated on Wed Apr 17 13:24:54 2002 for vdk 2.0.1 by doxygen1.2.15