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 "iaws/aws.h"
00021 #include "iaws/awsparm.h"
00022 
00023 class awsEmbeddedComponent : public iAwsComponent
00024 {
00025   iAwsComponent *comp;
00026 
00027 public:
00028   awsEmbeddedComponent() :comp(NULL) {}
00029   virtual ~awsEmbeddedComponent()
00030   { if (comp) comp->DecRef(); }
00031 
00032 public:
00034     virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)
00035     { return comp->RegisterSlot(slot, signal); }
00036 
00038     virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)
00039     { return comp->UnregisterSlot(slot, signal); }
00040 
00042     virtual void Broadcast(unsigned long signal)
00043     { comp->Broadcast(signal); }
00044 
00045 public:
00047     virtual void Initialize(iAwsComponent *component)
00048     { comp=component; }
00049 
00051     virtual bool Setup(iAws *wmgr, awsComponentNode *settings)
00052     { return comp->Setup(wmgr, settings); }
00053 
00055     virtual bool HandleEvent(iEvent& Event)
00056     {
00057       switch(Event.Type)
00058       {
00059         case csevMouseMove:
00060         return OnMouseMove(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00061 
00062         case csevMouseUp:
00063         return OnMouseUp(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00064 
00065         case csevMouseDown:
00066         return OnMouseDown(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00067 
00068         case csevMouseClick:
00069         return OnMouseClick(Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00070 
00071         case csevMouseEnter:
00072         return OnMouseEnter();
00073 
00074         case csevMouseExit:
00075         return OnMouseExit();
00076 
00077         case csevKeyDown:
00078         return OnKeypress(Event.Key.Char, Event.Key.Modifiers);
00079 
00080         case csevGainFocus:
00081         return OnGainFocus();
00082 
00083         case csevLostFocus:
00084         return OnLostFocus();
00085       }
00086       return false;
00087     }
00088 
00090     virtual bool GetProperty(char *name, void **parm)
00091     { return comp->GetProperty(name, parm); }
00092 
00094     virtual bool SetProperty(char *name, void *parm)
00095     { return comp->SetProperty(name, parm); }
00096 
00098     virtual bool Execute(char *action, iAwsParmList &parmlist)
00099     { return comp->Execute(action, parmlist); }
00100 
00102     virtual void SetFlag(unsigned int flag)
00103     { comp->SetFlag(flag); }
00104 
00106     virtual void ClearFlag(unsigned int flag)
00107     { comp->ClearFlag(flag); }
00108 
00110     virtual unsigned int Flags()
00111     { return comp->Flags(); }
00112 
00114     virtual void Invalidate()
00115     { comp->Invalidate(); }
00116 
00118     virtual void Invalidate(csRect area)
00119     { comp->Invalidate(area); }
00120 
00122     virtual csRect& Frame()
00123     { return comp->Frame(); }
00124 
00126     virtual char *Type()
00127     { return comp->Type(); }
00128 
00130     virtual bool Overlaps(csRect &r)
00131     { return comp->Overlaps(r); }
00132 
00134     virtual bool isHidden()
00135     { return comp->isHidden(); }
00136 
00138     virtual void Hide()
00139     { comp->Hide(); }
00140 
00142     virtual void Show()
00143     { comp->Show(); }
00144 
00146     virtual unsigned long GetID()
00147     { return comp->GetID(); }
00148 
00150     virtual void SetID(unsigned long _id)
00151     { comp->SetID(_id); }
00152 
00154     virtual void MoveChildren(int delta_x, int delta_y)
00155     { comp->MoveChildren(delta_x, delta_y); }
00156 
00157 public:
00159     virtual void AddChild(iAwsComponent* child, bool owner=true)
00160     { comp->AddChild(child, owner); }
00161 
00163     virtual void RemoveChild(iAwsComponent *child)
00164     { comp->RemoveChild(child); }
00165 
00167     virtual int GetChildCount()
00168     { return comp->GetChildCount(); }
00169 
00171     virtual iAwsComponent *GetChildAt(int i)
00172     { return comp->GetChildAt(i); }
00173 
00175     virtual bool HasChildren()
00176     { return comp->HasChildren(); }
00177 
00181     iAws *WindowManager()
00182     { return comp->Window()->WindowManager(); }
00183 
00185     iAwsWindow *Window()
00186     { return comp->Window(); }
00187 
00189     iAwsComponent *Parent()
00190     { return comp->Parent(); }
00191 
00193     virtual void SetWindow(iAwsWindow *win)
00194     { comp->SetWindow(win); }
00195 
00197     virtual void SetParent(iAwsComponent *parent)
00198     { comp->SetParent(parent); }
00199 
00200 public:
00202     virtual void OnDraw(csRect clip)=0;
00203 
00205     virtual bool OnMouseDown(int button, int x, int y)=0;
00206 
00208     virtual bool OnMouseUp(int button, int x, int y)=0;
00209 
00211     virtual bool OnMouseMove(int button, int x, int y)=0;
00212 
00214     virtual bool OnMouseClick(int button, int x, int y)=0;
00215 
00217     virtual bool OnMouseDoubleClick(int button, int x, int y)=0;
00218 
00220     virtual bool OnMouseExit()=0;
00221 
00223     virtual bool OnMouseEnter()=0;
00224 
00226     virtual bool OnKeypress(int key, int modifiers)=0;
00227 
00229     virtual bool OnLostFocus()=0;
00230 
00232     virtual bool OnGainFocus()=0;
00233 };
00234 
00235 class awsEmbeddedComponentFactory : public iAwsComponentFactory
00236 {
00237     iAws *wmgr;
00238 
00239 public:
00241     awsEmbeddedComponentFactory(iAws *_wmgr)
00242     {
00243       wmgr=_wmgr;
00244       if (wmgr) wmgr->IncRef();
00245     }
00246 
00248     virtual ~awsEmbeddedComponentFactory()
00249     {
00250       if (wmgr) wmgr->DecRef();
00251     }
00252 
00254     iAws *WindowManager() { return wmgr; }
00255 
00257     virtual void Register(char *type, char *name)
00258     {
00259       wmgr->RegisterComponentFactory(this, name);
00260     }
00261 
00263     virtual void RegisterConstant(char *name, int value)
00264     {
00265       wmgr->GetPrefMgr()->RegisterConstant(name, value);
00266     }
00267 };
00268 
00269 #endif

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