00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_AWS_EMBEDDED_COMPONENT_H__
00020 #define __CS_AWS_EMBEDDED_COMPONENT_H__
00021
00022 #include "csutil/ref.h"
00023 #include "iaws/aws.h"
00024 #include "iaws/awsparm.h"
00025 #include "iutil/event.h"
00026 #include "iaws/awsdefs.h"
00027
00041 class awsEmbeddedComponent : public iAwsComponent
00042 {
00043 csRef<iAwsComponent> comp;
00044
00045 public:
00046 awsEmbeddedComponent() { }
00047 virtual ~awsEmbeddedComponent() { }
00048
00049 public:
00051 virtual iAwsComponent *GetComponent ()
00052 { return this; }
00053
00055 virtual bool RegisterSlot (iAwsSlot *slot, unsigned long signal)
00056 { return comp->RegisterSlot (slot, signal); }
00057
00059 virtual bool UnregisterSlot (iAwsSlot *slot, unsigned long signal)
00060 { return comp->UnregisterSlot (slot, signal); }
00061
00063 virtual void Broadcast (unsigned long signal)
00064 { comp->Broadcast (signal); }
00065
00066 public:
00068 virtual void Initialize (iAwsComponent *component)
00069 {
00070 comp = component;
00071 }
00072
00090 virtual bool Create (iAws *m, iAwsComponent *parent,
00091 iAwsComponentNode *settings)
00092 {
00093 SetID (settings->Name());
00094 SetParent (parent);
00095
00096
00097 if (!Setup (m, settings)) return false;
00098
00099
00100 if (Parent () == 0)
00101 {
00102
00103 if (m->GetTopComponent () == 0)
00104 {
00105 m->SetTopComponent (this);
00106 }
00107 else
00108 {
00109 LinkAbove (m->GetTopComponent ());
00110 m->SetTopComponent (this);
00111 }
00112 }
00113
00114
00115
00116 if (~Flags() & AWSF_CMP_NON_CLIENT && Parent() && Parent()->Layout())
00117 Parent()->Layout()->AddComponent(this, settings);
00118
00119 if (Parent())
00120 Parent()->AddChild(this);
00121 return true;
00122 }
00123
00125 virtual bool Setup (iAws *wmgr, iAwsComponentNode *settings)
00126 { return comp->Setup (wmgr, settings); }
00127
00132 virtual bool HandleEvent(iEvent& Event)
00133 {
00134 switch (Event.Type)
00135 {
00136 case csevMouseMove:
00137 return OnMouseMove (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00138 case csevMouseUp:
00139 return OnMouseUp (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00140 case csevMouseDown:
00141 return OnMouseDown (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00142 case csevMouseClick:
00143 return OnMouseClick (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y);
00144 case csevMouseEnter:
00145 return OnMouseEnter ();
00146 case csevMouseExit:
00147 return OnMouseExit ();
00148 case csevKeyDown:
00149 return OnKeypress (Event.Key.Code, Event.Key.Char, Event.Key.Modifiers);
00150 case csevGainFocus:
00151 return OnGainFocus ();
00152 case csevLostFocus:
00153 return OnLostFocus ();
00154 case csevFrameStart:
00155 return OnFrame ();
00156 }
00157 return false;
00158 }
00159
00164 virtual bool GetProperty (const char *name, void **parm)
00165 { return comp->GetProperty (name, parm); }
00166
00171 virtual bool SetProperty (const char *name, void *parm)
00172 { return comp->SetProperty (name, parm); }
00173
00175 virtual bool Execute (const char *action, iAwsParmList* parmlist)
00176 { return comp->Execute (action, parmlist); }
00177
00179 virtual void SetFlag (unsigned int flag)
00180 { comp->SetFlag (flag); }
00181
00183 virtual void ClearFlag (unsigned int flag)
00184 { comp->ClearFlag (flag); }
00185
00187 virtual unsigned int Flags ()
00188 { return comp->Flags (); }
00189
00191 virtual void Invalidate ()
00192 { comp->Invalidate (); }
00193
00195 virtual void Invalidate (csRect area)
00196 { comp->Invalidate (area); }
00197
00199 virtual csRect Frame ()
00200 { return comp->Frame (); }
00201
00203 virtual csRect ClientFrame ()
00204 { return comp->ClientFrame (); }
00205
00210 virtual const char *Type ()
00211 { return comp->Type (); }
00212
00214 virtual bool Overlaps (csRect &r)
00215 { return comp->Overlaps (r); }
00216
00218 virtual bool isHidden ()
00219 { return comp->isHidden (); }
00220
00222 virtual void Hide ()
00223 { comp->Hide (); }
00224
00226 virtual void Show ()
00227 { comp->Show (); }
00228
00230 virtual void Move (int delta_x, int delta_y)
00231 { comp->Move (delta_x, delta_y); }
00232
00234 virtual void MoveTo (int x, int y)
00235 { comp->MoveTo (x, y); }
00236
00238 virtual void Resize (int width, int height)
00239 { comp->Resize (width, height); }
00240
00242 virtual void ResizeTo (csRect newFrame)
00243 { comp->ResizeTo (newFrame); }
00244
00246 virtual unsigned long GetID ()
00247 { return comp->GetID (); }
00248
00253 virtual void SetID (unsigned long id)
00254 { comp->SetID (id); }
00255
00256 virtual iAwsComponent* FindChild (const char* name)
00257 { return comp->FindChild (name); }
00258
00259 virtual iAwsComponent* DoFindChild (unsigned int id)
00260 { return comp->DoFindChild (id); }
00261
00262 virtual bool IsMaximized()
00263 { return comp->IsMaximized(); }
00264
00265 virtual void Maximize()
00266 { comp->Maximize(); }
00267
00268 virtual void UnMaximize()
00269 { comp->UnMaximize(); }
00270
00272 virtual void LayoutChildren ()
00273 { comp->LayoutChildren (); }
00274
00275 virtual void AddToLayout (iAwsComponent *cmp, iAwsComponentNode* settings)
00276 { comp->AddToLayout (cmp, settings); }
00277
00279 virtual void SetFocusable (bool focusable)
00280 { comp->SetFocusable (focusable); }
00281
00283 virtual bool Focusable ()
00284 { return comp->Focusable (); }
00285
00287 virtual bool isFocused ()
00288 { return comp->isFocused (); }
00289
00291 virtual void SetFocus ()
00292 { comp->SetFocus (); }
00293
00295 virtual void UnsetFocus ()
00296 { comp->UnsetFocus (); }
00297
00299 virtual bool AddToTabOrder (iAwsComponent *cmp)
00300 { return comp->AddToTabOrder (cmp); }
00301
00303 virtual iAwsComponent *TabNext (iAwsComponent *cmp)
00304 { return comp->TabNext (cmp); }
00305
00307 virtual iAwsComponent *TabPrev (iAwsComponent *cmp)
00308 { return comp->TabPrev (cmp); }
00309
00311 virtual int GetTabLength ()
00312 { return comp->GetTabLength (); }
00313
00315 virtual iAwsComponent *GetTabComponent (int index)
00316 { return comp->GetTabComponent (index); }
00317
00319 virtual iAwsComponent *GetFirstFocusableChild (iAwsComponent *comp)
00320 { return comp->GetFirstFocusableChild (comp); }
00321
00323 virtual void AddChild(iAwsComponent* child)
00324 { comp->AddChild(child); }
00325
00327 virtual void RemoveChild(iAwsComponent *child)
00328 { comp->RemoveChild(child); }
00329
00331 virtual int GetChildCount()
00332 { return comp->GetChildCount(); }
00333
00335 virtual iAwsComponent *GetTopChild()
00336 { return comp->GetTopChild(); }
00337
00339 virtual bool HasChildren()
00340 { return comp->HasChildren(); }
00341
00342 virtual iAwsComponent *ChildAt(int x, int y)
00343 { return comp->ChildAt(x,y); }
00344
00350 iAws *WindowManager()
00351 { return comp->Window()->WindowManager(); }
00352
00354 iAwsComponent *Window()
00355 { return comp->Window(); }
00356
00358 iAwsComponent *Parent()
00359 { return comp->Parent(); }
00360
00362 virtual void SetParent(iAwsComponent *parent)
00363 { comp->SetParent(parent); }
00364
00366 virtual iAwsComponent *ComponentAbove()
00367 { return comp->ComponentAbove(); }
00368
00370 virtual iAwsComponent *ComponentBelow()
00371 { return comp->ComponentBelow(); }
00372
00374 virtual void SetComponentAbove(iAwsComponent *cmp)
00375 { comp->SetComponentAbove(cmp); }
00376
00378 virtual void SetComponentBelow(iAwsComponent *cmp)
00379 { comp->SetComponentBelow(cmp); }
00380
00382 virtual void Raise()
00383 { comp->Raise (); }
00384
00386 virtual void Lower()
00387 { comp->Lower (); }
00388
00390 virtual void SetRedrawTag(unsigned int tag)
00391 { comp->SetRedrawTag (tag); }
00392
00394 virtual unsigned int RedrawTag()
00395 { return comp->RedrawTag (); }
00396
00398 virtual void OnDraw(csRect clip)
00399 { comp->OnDraw (clip); }
00400
00402 virtual bool OnMouseDown(int button, int x, int y)
00403 { return comp->OnMouseDown (button, x, y); }
00404
00406 virtual bool OnMouseUp(int button, int x, int y)
00407 { return comp->OnMouseUp (button, x, y); }
00408
00410 virtual bool OnMouseMove(int button, int x, int y)
00411 { return comp->OnMouseMove (button, x, y); }
00412
00414 virtual bool OnMouseClick(int button, int x, int y)
00415 { return comp->OnMouseClick (button, x, y); }
00416
00418 virtual bool OnMouseDoubleClick(int button, int x, int y)
00419 { return comp->OnMouseDoubleClick (button, x, y); }
00420
00422 virtual bool OnMouseExit()
00423 { return comp->OnMouseExit (); }
00424
00426 virtual bool OnMouseEnter()
00427 { return comp->OnMouseEnter (); }
00428
00430 virtual bool OnKeypress(int key, int cha, int modifiers)
00431 { return comp->OnKeypress (key, cha, modifiers); }
00432
00434 virtual bool OnLostFocus()
00435 { return comp->OnLostFocus (); }
00436
00438 virtual bool OnGainFocus()
00439 { return comp->OnGainFocus (); }
00440
00442 virtual iAwsLayoutManager *Layout()
00443 { return comp->Layout ();}
00444
00446 virtual void SetLayout(iAwsLayoutManager *layoutMgr)
00447 { comp->SetLayout(layoutMgr); }
00448
00450 virtual csRect getPreferredSize()
00451 { return comp->getPreferredSize (); }
00452
00454 virtual csRect getMinimumSize()
00455 { return comp->getMinimumSize (); }
00456
00458 virtual csRect getInsets()
00459 { return comp->getInsets (); }
00460
00462 virtual bool isDeaf()
00463 { return comp->isDeaf (); }
00464
00466 virtual void SetDeaf (bool isDeaf)
00467 { comp->SetDeaf (isDeaf); }
00468
00470 virtual bool OnFrame()
00471 { return comp->OnFrame ();}
00472
00474 virtual void OnAdded()
00475 { comp->OnAdded ();}
00476
00478 virtual void OnResized()
00479 { comp->OnResized ();}
00480
00482 virtual void OnChildMoved()
00483 { comp->OnChildMoved(); }
00484
00486 virtual void OnRaise()
00487 { comp->OnRaise(); }
00488
00490 virtual void OnLower()
00491 { comp->OnLower(); }
00492
00494 virtual void OnChildHide()
00495 { comp->OnChildHide(); }
00496
00498 virtual void OnChildShow()
00499 { comp->OnChildShow(); }
00500
00502 virtual void Unlink()
00503 { comp->Unlink(); }
00504
00506 virtual void LinkAbove(iAwsComponent* other)
00507 { comp->LinkAbove(other); }
00508
00510 virtual void LinkBelow(iAwsComponent* other)
00511 { comp->LinkBelow(other); }
00512
00514 virtual void SetTopChild(iAwsComponent* child)
00515 { comp->SetTopChild(child); }
00516
00518 virtual void OnSetFocus()
00519 { comp->OnSetFocus(); }
00520
00522 virtual void OnUnsetFocus()
00523 { comp->OnUnsetFocus(); }
00524 };
00525
00529 class awsEmbeddedComponentFactory : public iAwsComponentFactory
00530 {
00531 protected:
00532 iAws *wmgr;
00533
00534 public:
00539 awsEmbeddedComponentFactory(iAws *_wmgr)
00540 {
00541 wmgr = _wmgr;
00542 }
00543
00545 virtual ~awsEmbeddedComponentFactory()
00546 {
00547 }
00548
00550 iAws *WindowManager() { return wmgr; }
00551
00553 virtual void Register(const char *type)
00554 {
00555 wmgr->RegisterComponentFactory(this, type);
00556 }
00557
00559 virtual void RegisterConstant(const char *name, int value)
00560 {
00561 wmgr->GetPrefMgr()->RegisterConstant(name, value);
00562 }
00563 };
00564
00565 #endif // __CS_AWS_EMBEDDED_COMPONENT_H__
00566