00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CS_AWS_EMBEDDED_COMPONENT_H__
00019 #define __CS_AWS_EMBEDDED_COMPONENT_H__
00020
00021 #include "iaws/aws.h"
00022 #include "iaws/awsparm.h"
00023 #include "iutil/event.h"
00024 #include "iaws/awsdefs.h"
00025
00038 class awsEmbeddedComponent : public iAwsComponent
00039 {
00040 iAwsComponent *comp;
00041
00042 public:
00043 awsEmbeddedComponent() :comp(NULL) {}
00044 virtual ~awsEmbeddedComponent()
00045 { if (comp) comp->DecRef(); }
00046
00047 public:
00048
00050 virtual iAwsComponent *GetComponent()
00051 {return this;}
00052
00054 virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)
00055 { return comp->RegisterSlot(slot, signal); }
00056
00058 virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)
00059 { return comp->UnregisterSlot(slot, signal); }
00060
00062 virtual void Broadcast(unsigned long signal)
00063 { comp->Broadcast(signal); }
00064
00065
00066 public:
00068 virtual void Initialize(iAwsComponent *component)
00069 {
00070 comp=component;
00071 if (comp) comp->IncRef ();
00072 }
00073
00085
00086
00087
00088
00089 virtual bool Create(iAws *m, iAwsComponent *parent, iAwsComponentNode *settings)
00090 {
00091 SetID(settings->Name());
00092 SetParent(parent);
00093
00094
00095 if(!Setup(m, settings)) return false;
00096
00097
00098 if(Parent() == NULL)
00099 {
00100
00101 if (m->GetTopComponent () == NULL)
00102 {
00103 m->SetTopComponent (this);
00104 }
00105 else
00106 {
00107 LinkAbove (m->GetTopComponent ());
00108 m->SetTopComponent (this);
00109 }
00110 }
00111
00112
00113
00114 if(~Flags() & AWSF_CMP_NON_CLIENT && Parent() && Parent()->Layout())
00115 Parent()->Layout()->AddComponent(this, settings);
00116
00117 if(Parent())
00118 Parent()->AddChild(this);
00119 return true;
00120 }
00121
00123 virtual bool Setup(iAws *wmgr, iAwsComponentNode *settings)
00124 { return comp->Setup(wmgr, settings); }
00125
00127 virtual bool HandleEvent(iEvent& Event)
00128 {
00129 switch (Event.Type)
00130 {
00131 case csevMouseMove:
00132 return OnMouseMove (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00133 case csevMouseUp:
00134 return OnMouseUp (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00135 case csevMouseDown:
00136 return OnMouseDown (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00137 case csevMouseClick:
00138 return OnMouseClick (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00139 case csevMouseEnter:
00140 return OnMouseEnter ();
00141 case csevMouseExit:
00142 return OnMouseExit ();
00143 case csevKeyDown:
00144 return OnKeypress (Event.Key.Code, Event.Key.Char, Event.Key.Modifiers);
00145 case csevGainFocus:
00146 return OnGainFocus ();
00147 case csevLostFocus:
00148 return OnLostFocus ();
00149 case csevFrameStart:
00150 return OnFrame ();
00151 }
00152 return false;
00153 }
00154
00156 virtual bool GetProperty(const char *name, void **parm)
00157 { return comp->GetProperty(name, parm); }
00158
00160 virtual bool SetProperty(const char *name, void *parm)
00161 { return comp->SetProperty(name, parm); }
00162
00164 virtual bool Execute(const char *action, iAwsParmList* parmlist)
00165 { return comp->Execute(action, parmlist); }
00166
00168 virtual void SetFlag(unsigned int flag)
00169 { comp->SetFlag(flag); }
00170
00172 virtual void ClearFlag(unsigned int flag)
00173 { comp->ClearFlag(flag); }
00174
00176 virtual unsigned int Flags()
00177 { return comp->Flags(); }
00178
00180 virtual void Invalidate()
00181 { comp->Invalidate(); }
00182
00184 virtual void Invalidate(csRect area)
00185 { comp->Invalidate(area); }
00186
00188 virtual csRect Frame()
00189 { return comp->Frame(); }
00190
00192 virtual csRect ClientFrame()
00193 { return comp->ClientFrame(); }
00194
00196 virtual const char *Type()
00197 { return comp->Type(); }
00198
00200 virtual bool Overlaps(csRect &r)
00201 { return comp->Overlaps(r); }
00202
00204 virtual bool isHidden()
00205 { return comp->isHidden(); }
00206
00208 virtual void Hide()
00209 { comp->Hide(); }
00210
00212 virtual void Show()
00213 { comp->Show(); }
00214
00216 virtual void Move(int delta_x, int delta_y)
00217 { comp->Move (delta_x, delta_y); }
00218
00220 virtual void MoveTo(int x, int y)
00221 { comp->MoveTo (x, y); }
00222
00224 virtual void Resize(int width, int height)
00225 { comp->Resize (width, height); }
00226
00228 virtual void ResizeTo(csRect newFrame)
00229 { comp->ResizeTo (newFrame); }
00230
00232 virtual unsigned long GetID()
00233 { return comp->GetID(); }
00234
00236 virtual void SetID(unsigned long _id)
00237 { comp->SetID(_id); }
00238
00239 virtual iAwsComponent* FindChild(const char* name)
00240 { return comp->FindChild(name); }
00241
00242 virtual iAwsComponent* DoFindChild(unsigned int id)
00243 { return comp->DoFindChild(id); }
00244
00245 virtual bool IsMaximized()
00246 { return comp->IsMaximized(); }
00247
00248 virtual void Maximize()
00249 { comp->Maximize(); }
00250
00251 virtual void UnMaximize()
00252 { comp->UnMaximize(); }
00253
00255 virtual void LayoutChildren()
00256 { comp->LayoutChildren (); }
00257
00258 virtual void AddToLayout(iAwsComponent *cmp, iAwsComponentNode* settings)
00259 { comp->AddToLayout(cmp, settings); }
00260
00261
00262 public:
00264 virtual void AddChild(iAwsComponent* child)
00265 { comp->AddChild(child); }
00266
00268 virtual void RemoveChild(iAwsComponent *child)
00269 { comp->RemoveChild(child); }
00270
00272 virtual int GetChildCount()
00273 { return comp->GetChildCount(); }
00274
00276 virtual iAwsComponent *GetTopChild()
00277 { return comp->GetTopChild(); }
00278
00280 virtual bool HasChildren()
00281 { return comp->HasChildren(); }
00282
00283 virtual iAwsComponent *ChildAt(int x, int y)
00284 { return comp->ChildAt(x,y); }
00285
00289 iAws *WindowManager()
00290 { return comp->Window()->WindowManager(); }
00291
00293 iAwsComponent *Window()
00294 { return comp->Window(); }
00295
00297 iAwsComponent *Parent()
00298 { return comp->Parent(); }
00299
00301 virtual void SetParent(iAwsComponent *parent)
00302 { comp->SetParent(parent); }
00303
00305 virtual iAwsComponent *ComponentAbove()
00306 { return comp->ComponentAbove(); }
00307
00309 virtual iAwsComponent *ComponentBelow()
00310 { return comp->ComponentBelow(); }
00311
00313 virtual void SetComponentAbove(iAwsComponent *cmp)
00314 { comp->SetComponentAbove(cmp); }
00315
00317 virtual void SetComponentBelow(iAwsComponent *cmp)
00318 { comp->SetComponentBelow(cmp); }
00319
00321 virtual void Raise()
00322 { comp->Raise (); }
00323
00325 virtual void Lower()
00326 { comp->Lower (); }
00327
00329 virtual void SetRedrawTag(unsigned int tag)
00330 { comp->SetRedrawTag (tag); }
00331
00333 virtual unsigned int RedrawTag()
00334 { return comp->RedrawTag (); }
00335
00336 public:
00338 virtual void OnDraw(csRect clip)
00339 { comp->OnDraw (clip); }
00340
00342 virtual bool OnMouseDown(int button, int x, int y)
00343 { return comp->OnMouseDown (button, x, y); }
00344
00346 virtual bool OnMouseUp(int button, int x, int y)
00347 { return comp->OnMouseUp (button, x, y); }
00348
00350 virtual bool OnMouseMove(int button, int x, int y)
00351 { return comp->OnMouseMove (button, x, y); }
00352
00354 virtual bool OnMouseClick(int button, int x, int y)
00355 { return comp->OnMouseClick (button, x, y); }
00356
00358 virtual bool OnMouseDoubleClick(int button, int x, int y)
00359 { return comp->OnMouseDoubleClick (button, x, y); }
00360
00362 virtual bool OnMouseExit()
00363 { return comp->OnMouseExit (); }
00364
00366 virtual bool OnMouseEnter()
00367 { return comp->OnMouseEnter (); }
00368
00370 virtual bool OnKeypress(int key, int cha, int modifiers)
00371 { return comp->OnKeypress (key, cha, modifiers); }
00372
00374 virtual bool OnLostFocus()
00375 { return comp->OnLostFocus (); }
00376
00378 virtual bool OnGainFocus()
00379 { return comp->OnGainFocus (); }
00380
00382 virtual iAwsLayoutManager *Layout()
00383 { return comp->Layout ();}
00384
00386 virtual void SetLayout(iAwsLayoutManager *layoutMgr)
00387 { comp->SetLayout(layoutMgr); }
00388
00390 virtual csRect getPreferredSize()
00391 { return comp->getPreferredSize (); }
00392
00394 virtual csRect getMinimumSize()
00395 { return comp->getMinimumSize (); }
00396
00398 virtual csRect getInsets()
00399 { return comp->getInsets (); }
00400
00402 virtual bool isDeaf()
00403 { return comp->isDeaf (); }
00404
00406 virtual void SetDeaf (bool isDeaf)
00407 { comp->SetDeaf (isDeaf); }
00408
00410 virtual bool OnFrame()
00411 { return comp->OnFrame ();}
00412
00414 virtual void OnAdded()
00415 { comp->OnAdded ();}
00416
00418 virtual void OnResized()
00419 { comp->OnResized ();}
00420
00422 virtual void OnChildMoved()
00423 { comp->OnChildMoved(); }
00424
00426 virtual void OnRaise()
00427 { comp->OnRaise(); }
00428
00430 virtual void OnLower()
00431 { comp->OnLower(); }
00432
00434 virtual void OnChildHide()
00435 { comp->OnChildHide(); }
00436
00438 virtual void OnChildShow()
00439 { comp->OnChildShow(); }
00440
00442 virtual void Unlink()
00443 { comp->Unlink(); }
00444
00446 virtual void LinkAbove(iAwsComponent* other)
00447 { comp->LinkAbove(other); }
00448
00450 virtual void LinkBelow(iAwsComponent* other)
00451 { comp->LinkBelow(other); }
00452
00454 virtual void SetTopChild(iAwsComponent* child)
00455 { comp->SetTopChild(child); }
00456 };
00457
00461 class awsEmbeddedComponentFactory : public iAwsComponentFactory
00462 {
00463 protected:
00464 iAws *wmgr;
00465
00466 public:
00468 awsEmbeddedComponentFactory(iAws *_wmgr)
00469 {
00470 wmgr=_wmgr;
00471 }
00472
00474 virtual ~awsEmbeddedComponentFactory()
00475 {
00476 }
00477
00479 iAws *WindowManager() { return wmgr; }
00480
00482 virtual void Register(const char *type)
00483 {
00484 wmgr->RegisterComponentFactory(this, type);
00485 }
00486
00488 virtual void RegisterConstant(const char *name, int value)
00489 {
00490 wmgr->GetPrefMgr()->RegisterConstant(name, value);
00491 }
00492 };
00493
00494 #endif // __CS_AWS_EMBEDDED_COMPONENT_H__
00495