Main Page   Class Hierarchy   Compound List   File List   Compound Members  

awscomp.h

00001  #ifndef __AWS_COMPONENT_H__
00002  #define __AWS_COMPONENT_H__
00003 /**************************************************************************
00004     Copyright (C) 2000-2001 by Christopher Nelson 
00005     
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010   
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015   
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the Free
00018     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 *****************************************************************************/
00020 #include "aws/iaws.h"
00021 #include "iutil/eventh.h"
00022 #include "iutil/comp.h"
00023 #include "csgeom/csrect.h"
00024 #include "aws/awsprefs.h"
00025 #include "aws/awsslot.h"
00026 
00027 class awsCanvas;
00028 
00029 SCF_VERSION (awsComponent, 0, 0, 1);
00030 
00031 /**************************************************************************************************************************
00032 *   The general idea for a component's initialization stage is like this:                                                 *
00033 *       1. construction - any internal structures should be created and intialized.                                       *
00034 *       2. setup - the window manager calls Setup() on the component being created when it is added into the window       *
00035 *       manager's hierarchy.  During setup the component should get a handle to the preference manager (via GetPrefMgr()) *
00036 *       and ask the preference manager about things like it's default texture, colors, etc; using the Lookup* functions.  *
00037 *       The component can then get texture handles from the preference manager using the values of the keys that it has   *
00038 *       looked up.
00039 *           e.g. 
00040 *            
00041 *            iAwsPrefManager *pm = wmgr->GetPrefMgr();
00042 *            
00043 *            pm->LookupStringKey("Texture", texturename);
00044 *            
00045 *            SetTexture(pm->GetPixmapFor(texturename));
00046 *                                                                                                                   
00047 *                                                                              
00048 *                                                                                                                         *
00049 **************************************************************************************************************************/
00050 class awsComponent : public iAwsComponent
00051 {
00053    iAws  *wmgr;
00054 
00056    csRect frame;
00057 
00059    csBasicVector *children;
00060 
00062    unsigned long id;
00063 
00065    bool hidden;
00066 
00068    awsSource signalsrc;
00069    
00070 public:
00071     SCF_DECLARE_IBASE;
00072 
00073     awsComponent();
00074     virtual ~awsComponent();
00075 
00076 public:
00078     virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal);
00079 
00081     virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal);
00082 
00084     virtual void Broadcast(unsigned long signal);
00085 
00087     virtual iAwsComponent *GetComponent();
00088          
00089 public:
00094     virtual bool Setup(iAws *wmgr, awsComponentNode *settings);
00095    
00097     virtual bool HandleEvent(iEvent& Event);
00098 
00100     virtual bool GetProperty(char *name, void **parm);
00101 
00103     virtual bool SetProperty(char *name, void *parm);
00104 
00106     virtual void Invalidate();
00107 
00109     virtual void Invalidate(csRect area);
00110 
00112     virtual csRect& Frame();
00113 
00115     virtual char *Type();
00116 
00118     virtual bool Overlaps(csRect &r);
00119 
00121     virtual bool isHidden();
00122     
00124     virtual void Hide();
00125 
00127     virtual void Show();
00128 
00130     virtual unsigned long GetID();
00131     
00133     virtual void SetID(unsigned long _id);
00134 
00136     virtual void MoveChildren(int delta_x, int delta_y);
00137 
00138 public:
00145     virtual void AddChild(iAwsComponent* child, bool owner=true);
00146 
00150     virtual void RemoveChild(iAwsComponent *child);
00151 
00153     virtual int GetChildCount();
00154 
00156     virtual iAwsComponent *GetChildAt(int i);
00157     
00159     virtual bool HasChildren();
00160 
00164     iAws *WindowManager();
00165     
00166 public:
00168     virtual void OnDraw(csRect clip);
00169 
00171     virtual bool OnMouseDown(int button, int x, int y);
00172     
00174     virtual bool OnMouseUp(int button, int x, int y);
00175     
00177     virtual bool OnMouseMove(int button, int x, int y);
00178 
00180     virtual bool OnMouseClick(int button, int x, int y);
00181 
00183     virtual bool OnMouseDoubleClick(int button, int x, int y);
00184 
00186     virtual bool OnMouseExit();
00187 
00189     virtual bool OnMouseEnter();
00190 
00192     virtual bool OnKeypress(int key, int modifiers);
00193     
00195     virtual bool OnLostFocus();
00196 
00198     virtual bool OnGainFocus();
00199 };
00200 
00201 class awsComponentFactory : public iAwsComponentFactory
00202 {
00203   iAws *wmgr;
00204 public:
00206     awsComponentFactory(iAws *_wmgr);
00207 
00209     virtual ~awsComponentFactory();
00210 
00212     iAws *WindowManager() { return wmgr; }
00213 
00215     virtual iAwsComponent *Create()=0;
00216 
00218     void Register(char *type);
00219 
00221     void RegisterConstant(char *name, int value);
00222 };
00223 
00224 #endif
00225 

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000