iaws/awsecomp.h
00001 /************************************************************************** 00002 Copyright (C) 2001 by Christopher Nelson 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 #include "csutil/event.h" 00028 00042 class awsEmbeddedComponent : public iAwsComponent 00043 { 00044 csRef<iAwsComponent> comp; 00045 00046 public: 00047 awsEmbeddedComponent() { } 00048 virtual ~awsEmbeddedComponent() { } 00049 00050 public: 00052 virtual iAwsComponent *GetComponent () 00053 { return this; } 00054 00056 virtual bool RegisterSlot (iAwsSlot *slot, unsigned long signal) 00057 { return comp->RegisterSlot (slot, signal); } 00058 00060 virtual bool UnregisterSlot (iAwsSlot *slot, unsigned long signal) 00061 { return comp->UnregisterSlot (slot, signal); } 00062 00064 virtual void Broadcast (unsigned long signal) 00065 { comp->Broadcast (signal); } 00066 00067 public: 00069 virtual void Initialize (iAwsComponent *component) 00070 { 00071 comp = component; 00072 } 00073 00091 virtual bool Create (iAws *m, iAwsComponent *parent, 00092 iAwsComponentNode *settings) 00093 { 00094 SetID (settings->Name()); 00095 SetParent (parent); 00096 00097 // set ourself up by querying the settings 00098 if (!Setup (m, settings)) return false; 00099 00100 // if we are a top-level component link in to the top-level list 00101 if (Parent () == 0) 00102 { 00103 // Link into the current hierarchy, at the top. 00104 if (m->GetTopComponent () == 0) 00105 { 00106 m->SetTopComponent (this); 00107 } 00108 else 00109 { 00110 LinkAbove (m->GetTopComponent ()); 00111 m->SetTopComponent (this); 00112 } 00113 } 00114 00115 // unless you have set the non client flag by this point 00116 // you get added to the parent's layout 00117 if (~Flags() & AWSF_CMP_NON_CLIENT && Parent() && Parent()->Layout()) 00118 Parent()->Layout()->AddComponent(this, settings); 00119 00120 if (Parent()) 00121 Parent()->AddChild(this); 00122 return true; 00123 } 00124 00126 virtual bool Setup (iAws *wmgr, iAwsComponentNode *settings) 00127 { return comp->Setup (wmgr, settings); } 00128 00133 virtual bool HandleEvent(iEvent& Event) 00134 { 00135 switch (Event.Type) 00136 { 00137 case csevMouseMove: 00138 return OnMouseMove (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y); 00139 case csevMouseUp: 00140 return OnMouseUp (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y); 00141 case csevMouseDown: 00142 return OnMouseDown (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y); 00143 case csevMouseClick: 00144 return OnMouseClick (Event.Mouse.Button, Event.Mouse.x, Event.Mouse.y); 00145 case csevMouseEnter: 00146 return OnMouseEnter (); 00147 case csevMouseExit: 00148 return OnMouseExit (); 00149 case csevKeyboard: 00150 { 00151 if (csKeyEventHelper::GetEventType (&Event) == csKeyEventTypeDown) 00152 { 00153 csKeyEventData eventData; 00154 csKeyEventHelper::GetEventData (&Event, eventData); 00155 return OnKeyboard (eventData); 00156 } 00157 else 00158 return false; 00159 } 00160 case csevGainFocus: 00161 return OnGainFocus (); 00162 case csevLostFocus: 00163 return OnLostFocus (); 00164 case csevFrameStart: 00165 return OnFrame (); 00166 } 00167 return false; 00168 } 00169 00174 virtual bool GetProperty (const char *name, void **parm) 00175 { return comp->GetProperty (name, parm); } 00176 00181 virtual bool SetProperty (const char *name, void *parm) 00182 { return comp->SetProperty (name, parm); } 00183 00185 virtual bool Execute (const char *action, iAwsParmList* parmlist) 00186 { return comp->Execute (action, parmlist); } 00187 00189 virtual void SetFlag (unsigned int flag) 00190 { comp->SetFlag (flag); } 00191 00193 virtual void ClearFlag (unsigned int flag) 00194 { comp->ClearFlag (flag); } 00195 00197 virtual unsigned int Flags () 00198 { return comp->Flags (); } 00199 00201 virtual void Invalidate () 00202 { comp->Invalidate (); } 00203 00205 virtual void Invalidate (csRect area) 00206 { comp->Invalidate (area); } 00207 00209 virtual csRect Frame () 00210 { return comp->Frame (); } 00211 00213 virtual csRect ClientFrame () 00214 { return comp->ClientFrame (); } 00215 00220 virtual const char *Type () 00221 { return comp->Type (); } 00222 00224 virtual bool Overlaps (csRect &r) 00225 { return comp->Overlaps (r); } 00226 00228 virtual bool isHidden () 00229 { return comp->isHidden (); } 00230 00232 virtual void Hide () 00233 { comp->Hide (); } 00234 00236 virtual void Show () 00237 { comp->Show (); } 00238 00240 virtual void Move (int delta_x, int delta_y) 00241 { comp->Move (delta_x, delta_y); } 00242 00244 virtual void MoveTo (int x, int y) 00245 { comp->MoveTo (x, y); } 00246 00248 virtual void Resize (int width, int height) 00249 { comp->Resize (width, height); } 00250 00252 virtual void ResizeTo (csRect newFrame) 00253 { comp->ResizeTo (newFrame); } 00254 00256 virtual unsigned long GetID () 00257 { return comp->GetID (); } 00258 00263 virtual void SetID (unsigned long id) 00264 { comp->SetID (id); } 00265 00266 virtual iAwsComponent* FindChild (const char* name) 00267 { return comp->FindChild (name); } 00268 00269 virtual iAwsComponent* DoFindChild (unsigned int id) 00270 { return comp->DoFindChild (id); } 00271 00272 virtual bool IsMaximized() 00273 { return comp->IsMaximized(); } 00274 00275 virtual void Maximize() 00276 { comp->Maximize(); } 00277 00278 virtual void UnMaximize() 00279 { comp->UnMaximize(); } 00280 00282 virtual void LayoutChildren () 00283 { comp->LayoutChildren (); } 00284 00285 virtual void AddToLayout (iAwsComponent *cmp, iAwsComponentNode* settings) 00286 { comp->AddToLayout (cmp, settings); } 00287 00289 virtual void SetFocusable (bool focusable) 00290 { comp->SetFocusable (focusable); } 00291 00293 virtual bool Focusable () 00294 { return comp->Focusable (); } 00295 00297 virtual bool isFocused () 00298 { return comp->isFocused (); } 00299 00301 virtual void SetFocus () 00302 { comp->SetFocus (); } 00303 00305 virtual void UnsetFocus () 00306 { comp->UnsetFocus (); } 00307 00309 virtual bool AddToTabOrder (iAwsComponent *cmp) 00310 { return comp->AddToTabOrder (cmp); } 00311 00313 virtual iAwsComponent *TabNext (iAwsComponent *cmp) 00314 { return comp->TabNext (cmp); } 00315 00317 virtual iAwsComponent *TabPrev (iAwsComponent *cmp) 00318 { return comp->TabPrev (cmp); } 00319 00321 virtual int GetTabLength () 00322 { return comp->GetTabLength (); } 00323 00325 virtual iAwsComponent *GetTabComponent (int index) 00326 { return comp->GetTabComponent (index); } 00327 00329 virtual iAwsComponent *GetFirstFocusableChild (iAwsComponent *comp) 00330 { return comp->GetFirstFocusableChild (comp); } 00331 00333 virtual void AddChild(iAwsComponent* child) 00334 { comp->AddChild(child); } 00335 00337 virtual void RemoveChild(iAwsComponent *child) 00338 { comp->RemoveChild(child); } 00339 00341 virtual int GetChildCount() 00342 { return comp->GetChildCount(); } 00343 00345 virtual iAwsComponent *GetTopChild() 00346 { return comp->GetTopChild(); } 00347 00349 virtual bool HasChildren() 00350 { return comp->HasChildren(); } 00351 00352 virtual iAwsComponent *ChildAt(int x, int y) 00353 { return comp->ChildAt(x,y); } 00354 00360 iAws *WindowManager() 00361 { return comp->Window()->WindowManager(); } 00362 00364 iAwsComponent *Window() 00365 { return comp->Window(); } 00366 00368 iAwsComponent *Parent() 00369 { return comp->Parent(); } 00370 00372 virtual void SetParent(iAwsComponent *parent) 00373 { comp->SetParent(parent); } 00374 00376 virtual iAwsComponent *ComponentAbove() 00377 { return comp->ComponentAbove(); } 00378 00380 virtual iAwsComponent *ComponentBelow() 00381 { return comp->ComponentBelow(); } 00382 00384 virtual void SetComponentAbove(iAwsComponent *cmp) 00385 { comp->SetComponentAbove(cmp); } 00386 00388 virtual void SetComponentBelow(iAwsComponent *cmp) 00389 { comp->SetComponentBelow(cmp); } 00390 00392 virtual void Raise() 00393 { comp->Raise (); } 00394 00396 virtual void Lower() 00397 { comp->Lower (); } 00398 00400 virtual void SetRedrawTag(unsigned int tag) 00401 { comp->SetRedrawTag (tag); } 00402 00404 virtual unsigned int RedrawTag() 00405 { return comp->RedrawTag (); } 00406 00408 virtual void OnDraw(csRect clip) 00409 { comp->OnDraw (clip); } 00410 00412 virtual bool OnMouseDown(int button, int x, int y) 00413 { return comp->OnMouseDown (button, x, y); } 00414 00416 virtual bool OnMouseUp(int button, int x, int y) 00417 { return comp->OnMouseUp (button, x, y); } 00418 00420 virtual bool OnMouseMove(int button, int x, int y) 00421 { return comp->OnMouseMove (button, x, y); } 00422 00424 virtual bool OnMouseClick(int button, int x, int y) 00425 { return comp->OnMouseClick (button, x, y); } 00426 00428 virtual bool OnMouseDoubleClick(int button, int x, int y) 00429 { return comp->OnMouseDoubleClick (button, x, y); } 00430 00432 virtual bool OnMouseExit() 00433 { return comp->OnMouseExit (); } 00434 00436 virtual bool OnMouseEnter() 00437 { return comp->OnMouseEnter (); } 00438 00440 virtual bool OnKeyboard (const csKeyEventData& eventData) 00441 { return comp->OnKeyboard (eventData); } 00442 00444 virtual bool OnLostFocus() 00445 { return comp->OnLostFocus (); } 00446 00448 virtual bool OnGainFocus() 00449 { return comp->OnGainFocus (); } 00450 00452 virtual iAwsLayoutManager *Layout() 00453 { return comp->Layout ();} 00454 00456 virtual void SetLayout(iAwsLayoutManager *layoutMgr) 00457 { comp->SetLayout(layoutMgr); } 00458 00460 virtual csRect getPreferredSize() 00461 { return comp->getPreferredSize (); } 00462 00464 virtual void setPreferredSize (const csRect& size) 00465 { comp->setPreferredSize(size); } 00466 00468 virtual void clearPreferredSize () 00469 { comp->clearPreferredSize(); } 00470 00472 virtual csRect getMinimumSize() 00473 { return comp->getMinimumSize (); } 00474 00476 virtual csRect getInsets() 00477 { return comp->getInsets (); } 00478 00480 virtual bool isDeaf() 00481 { return comp->isDeaf (); } 00482 00484 virtual void SetDeaf (bool isDeaf) 00485 { comp->SetDeaf (isDeaf); } 00486 00488 virtual bool OnFrame() 00489 { return comp->OnFrame ();} 00490 00492 virtual void OnAdded() 00493 { comp->OnAdded ();} 00494 00496 virtual void OnResized() 00497 { comp->OnResized ();} 00498 00500 virtual void OnChildMoved() 00501 { comp->OnChildMoved(); } 00502 00504 virtual void OnRaise() 00505 { comp->OnRaise(); } 00506 00508 virtual void OnLower() 00509 { comp->OnLower(); } 00510 00512 virtual void OnChildHide() 00513 { comp->OnChildHide(); } 00514 00516 virtual void OnChildShow() 00517 { comp->OnChildShow(); } 00518 00520 virtual void Unlink() 00521 { comp->Unlink(); } 00522 00524 virtual void LinkAbove(iAwsComponent* other) 00525 { comp->LinkAbove(other); } 00526 00528 virtual void LinkBelow(iAwsComponent* other) 00529 { comp->LinkBelow(other); } 00530 00532 virtual void SetTopChild(iAwsComponent* child) 00533 { comp->SetTopChild(child); } 00534 00536 virtual void OnSetFocus() 00537 { comp->OnSetFocus(); } 00538 00540 virtual void OnUnsetFocus() 00541 { comp->OnUnsetFocus(); } 00542 }; 00543 00547 class awsEmbeddedComponentFactory : public iAwsComponentFactory 00548 { 00549 protected: 00550 iAws *wmgr; 00551 00552 public: 00557 awsEmbeddedComponentFactory(iAws *_wmgr) 00558 { 00559 wmgr = _wmgr; 00560 } 00561 00563 virtual ~awsEmbeddedComponentFactory() 00564 { 00565 } 00566 00568 iAws *WindowManager() { return wmgr; } 00569 00571 virtual void Register(const char *type) 00572 { 00573 wmgr->RegisterComponentFactory(this, type); 00574 } 00575 00577 virtual void RegisterConstant(const char *name, int value) 00578 { 00579 wmgr->GetPrefMgr()->RegisterConstant(name, value); 00580 } 00581 }; 00582 00583 #endif // __CS_AWS_EMBEDDED_COMPONENT_H__ 00584
Generated for Crystal Space by doxygen 1.2.18