Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

awsecomp.h

00001  #ifndef __AWS_EMBEDDED_COMPONENT_H__
00002  #define __AWS_EMBEDDED_COMPONENT_H__
00003 /**************************************************************************
00004     Copyright (C) 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/aws.h"
00021 
00022 class awsEmbeddedComponent : public iAwsComponent
00023 {
00024   iAwsComponent *comp;
00025 
00026 public:
00027   awsEmbeddedComponent() :comp(NULL) {}
00028   virtual ~awsEmbeddedComponent()
00029   { if (comp) comp->DecRef(); }
00030 
00031 public:
00033     virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)
00034     { return comp->RegisterSlot(slot, signal); }
00035 
00037     virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)
00038     { return comp->UnregisterSlot(slot, signal); }
00039 
00041     virtual void Broadcast(unsigned long signal)
00042     { comp->Broadcast(signal); }
00043 
00044 public:
00046     virtual void Initialize(iAwsComponent *component)
00047     { comp=component; }
00048 
00050     virtual bool Setup(iAws *wmgr, awsComponentNode *settings)
00051     { return comp->Setup(wmgr, settings); }
00052 
00054     virtual bool HandleEvent(iEvent& Event)
00055     {
00056       switch(Event.Type)
00057       {
00058         case csevMouseMove:
00059         return OnMouseMove(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00060 
00061         case csevMouseUp:
00062         return OnMouseUp(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00063 
00064         case csevMouseDown:
00065         return OnMouseDown(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00066 
00067         case csevMouseClick:
00068         return OnMouseClick(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00069 
00070         case csevMouseEnter:
00071         return OnMouseEnter();
00072 
00073         case csevMouseExit:
00074         return OnMouseExit();
00075 
00076         case csevKeyDown:
00077         return OnKeypress(Event.Key.Char, Event.Key.Modifiers);
00078 
00079         case csevGainFocus:
00080         return OnGainFocus();
00081 
00082         case csevLostFocus:
00083         return OnLostFocus();
00084       }
00085       return false;
00086     }
00087 
00089     virtual bool GetProperty(char *name, void **parm)
00090     { return comp->GetProperty(name, parm); }
00091 
00093     virtual bool SetProperty(char *name, void *parm);
00094     { return comp->SetProperty(name, parm); }
00095 
00097     virtual bool Execute(char *action, awsParmList &parmlist)
00098     { return comp->Execute(action, parmlist); }
00099 
00101     virtual void SetFlag(unsigned int flag)
00102     { comp->SetFlag(flag); }
00103 
00105     virtual void ClearFlag(unsigned int flag)
00106     { comp->ClearFlag(flag); }
00107 
00109     virtual unsigned int Flags()
00110     { return comp->Flags(); }
00111 
00113     virtual void Invalidate()
00114     { comp->Invalidate(); }
00115 
00117     virtual void Invalidate(csRect area)
00118     { comp->Invalidate(area); }
00119 
00121     virtual csRect& Frame()
00122     { return comp->Frame(); }
00123 
00125     virtual char *Type()
00126     { return comp->Type(); }
00127 
00129     virtual bool Overlaps(csRect &r)
00130     { return comp->Overlaps(r); }
00131 
00133     virtual bool isHidden()
00134     { return comp->isHidden(); }
00135 
00137     virtual void Hide()
00138     { comp->Hide(); }
00139 
00141     virtual void Show()
00142     { comp->Show(); }
00143 
00145     virtual unsigned long GetID()
00146     { return comp->GetID(); }
00147 
00149     virtual void SetID(unsigned long _id)
00150     { comp->SetID(_id); }
00151 
00153     virtual void MoveChildren(int delta_x, int delta_y)
00154     { comp->MoveChildren(delta_x, delta_y);
00155 
00156 public:
00158     virtual void AddChild(iAwsComponent* child, bool owner=true)
00159     { comp->AddChild(child, owner); }
00160 
00162     virtual void RemoveChild(iAwsComponent *child)
00163     { comp->RemoveChild(child); }
00164 
00166     virtual int GetChildCount()
00167     { return comp->GetChildCount(); }
00168 
00170     virtual iAwsComponent *GetChildAt(int i)
00171     { return comp->GetChildAt(i); }
00172 
00174     virtual bool HasChildren()
00175     { return comp->HasChildren(); }
00176 
00180     iAws *WindowManager()
00181     { return comp->WindowManager(); }
00182 
00184     iAwsWindow *Window()
00185     { return comp->Window(); }
00186 
00188     iAwsComponent *Parent()
00189     { return comp->Parent(); }
00190 
00192     virtual void SetWindow(iAwsWindow *win)
00193     { comp->SetWindow(win); }
00194 
00196     virtual void SetParent(iAwsComponent *parent)
00197     { comp->SetParent(parent); }
00198 
00199 public:
00201     virtual void OnDraw(csRect clip)=0;
00202 
00204     virtual bool OnMouseDown(int button, int x, int y)=0;
00205 
00207     virtual bool OnMouseUp(int button, int x, int y)=0;
00208 
00210     virtual bool OnMouseMove(int button, int x, int y)=0;
00211 
00213     virtual bool OnMouseClick(int button, int x, int y)=0;
00214 
00216     virtual bool OnMouseDoubleClick(int button, int x, int y)=0;
00217 
00219     virtual bool OnMouseExit()=0;
00220 
00222     virtual bool OnMouseEnter()=0;
00223 
00225     virtual bool OnKeypress(int key, int modifiers)=0;
00226 
00228     virtual bool OnLostFocus()=0;
00229 
00231     virtual bool OnGainFocus()=0;
00232 };
00233 
00234 class awsEmbeddedComponentFactory : public iAwsComponentFactory
00235 {
00236     iAws *wmgr;
00237 
00238 public:
00240     awsEmbeddedComponentFactory(iAws *_wmgr)
00241     {
00242       wmgr=_wmgr;
00243       if (wmgr) wmgr->IncRef();
00244     }
00245 
00247     virtual ~awsEmbeddedComponentFactory()
00248     {
00249       if (wmgr) wmgr->DecRef();
00250     }
00251 
00253     iAws *WindowManager() { return wmgr; }
00254 
00256     virtual void Register(char *type)
00257     {
00258       wmgr->RegisterComponentFactory(this, name);
00259     }
00260 
00262     virtual void RegisterConstant(char *name, int value)
00263     {
00264       wmgr->GetPrefMgr()->RegisterConstant(name, value);
00265     }
00266 };
00267 
00268 #endif

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