iaws/aws.h
Go to the documentation of this file.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_IAWS_AWS_H__ 00020 #define __CS_IAWS_AWS_H__ 00021 00026 #include "csutil/scf.h" 00027 #include "csutil/refarr.h" 00028 #include "csgeom/csrect.h" 00029 #include "csgeom/cspoint.h" 00030 #include "iutil/event.h" 00031 #include "iutil/string.h" 00032 00033 struct iAws; 00034 struct iAwsSlot; 00035 struct iAwsSink; 00036 struct iAwsSource; 00037 struct iAwsParmList; 00038 struct iAwsComponent; 00039 struct iAwsPrefManager; 00040 struct iAwsSinkManager; 00041 struct iAwsCanvas; 00042 struct iAwsKeyFactory; 00043 struct iAwsComponentFactory; 00044 struct iAwsConnectionNodeFactory; 00045 00046 typedef iAwsComponent iAwsWindow; 00047 00048 class awsWindow; 00049 class awsComponent; 00050 class awsComponentNode; 00051 class awsConnectionNode; 00052 class awsComponentFactory; 00053 class awsLayoutManager; 00054 00055 struct iGraphics2D; 00056 struct iGraphics3D; 00057 struct iEngine; 00058 struct iView; 00059 struct iTextureManager; 00060 struct iObjectRegistry; 00061 struct iTextureHandle; 00062 struct iFontServer; 00063 struct iFont; 00064 struct iEvent; 00065 00066 const bool aws_debug=false; // set to true to turn on debugging printf's 00067 00078 const int AWSF_AlwaysEraseWindows=1; 00079 00087 const int AWSF_AlwaysRedrawWindows=2; 00088 00094 const int AWSF_RaiseOnMouseOver = 4; 00095 00101 const int AWSF_KeyboardControl = 8; 00102 00105 SCF_VERSION(iAwsKey, 0, 0, 1) 00106 00107 00108 struct iAwsKey : public iBase 00109 { 00111 virtual uint8 Type () = 0; 00112 00114 virtual unsigned long Name () = 0; 00115 }; 00116 00117 SCF_VERSION(iAwsIntKey, 0, 0, 1) 00118 00119 00120 struct iAwsIntKey : public iAwsKey 00121 { 00123 virtual int Value () = 0; 00124 }; 00125 00126 SCF_VERSION(iAwsFloatKey, 0, 0, 1) 00127 00128 00129 struct iAwsFloatKey : public iAwsKey 00130 { 00132 virtual float Value () = 0; 00133 }; 00134 00135 SCF_VERSION(iAwsStringKey, 0, 0, 1); 00136 00138 struct iAwsStringKey : public iAwsKey 00139 { 00141 virtual iString* Value () = 0; 00142 }; 00143 00144 SCF_VERSION(iAwsRectKey, 0, 0, 1); 00145 00147 struct iAwsRectKey : public iAwsKey 00148 { 00150 virtual csRect Value () = 0; 00151 }; 00152 00153 SCF_VERSION(iAwsRGBKey, 0, 0, 1); 00154 00156 struct iAwsRGBKey : public iAwsKey 00157 { 00158 struct RGB 00159 { 00160 unsigned char red, green, blue; 00161 }; 00162 00164 virtual iAwsRGBKey::RGB &Value() = 0; 00165 }; 00166 00167 SCF_VERSION(iAwsPointKey, 0, 0, 1); 00168 00170 struct iAwsPointKey : public iAwsKey 00171 { 00173 virtual csPoint Value () = 0; 00174 }; 00175 00176 SCF_VERSION(iAwsConnectionKey, 0, 0, 1); 00177 00179 struct iAwsConnectionKey : public iAwsKey 00180 { 00182 virtual iAwsSink *Sink () = 0; 00183 00185 virtual unsigned long Trigger () = 0; 00186 00188 virtual unsigned long Signal () = 0; 00189 }; 00190 00191 SCF_VERSION(iAwsKeyContainer, 0, 0, 1); 00192 00194 struct iAwsKeyContainer : public iAwsKey 00195 { 00197 virtual iAwsKey* Find (iString* name) = 0; 00198 00200 virtual iAwsKey* Find (const char* name) = 0; 00201 00203 virtual iAwsKey *Find (unsigned long id) = 0; 00204 00205 virtual const csRefArray<iAwsKey> &Children () = 0; 00206 00208 virtual void Add (iAwsKey *key) = 0; 00209 00211 virtual iAwsKey* GetAt (int i) = 0; 00212 00214 virtual int Length () = 0; 00215 00217 virtual void Remove (iString *name) = 0; 00219 virtual void Remove (const char* name) = 0; 00221 virtual void Remove (iAwsKey *key) = 0; 00223 virtual void RemoveAll () = 0; 00224 00229 virtual void Consume (iAwsKeyContainer *c) = 0; 00230 }; 00231 00232 SCF_VERSION(iAwsComponentNode, 0, 0, 1); 00233 00235 struct iAwsComponentNode : public iAwsKeyContainer 00236 { 00238 virtual iString *ComponentTypeName () = 0; 00239 }; 00240 00241 00246 SCF_VERSION (iAws, 0, 2, 3); 00247 00249 struct iAws : public iBase 00250 { 00251 public: 00253 virtual iAwsPrefManager *GetPrefMgr()=0; 00254 00256 virtual iAwsSinkManager *GetSinkMgr()=0; 00257 00259 virtual void SetPrefMgr(iAwsPrefManager *pmgr)=0; 00260 00265 virtual void RegisterComponentFactory(iAwsComponentFactory *factory, 00266 const char* name)=0; 00267 00269 virtual iAwsComponentFactory *FindComponentFactory (const char* name)=0; 00270 00272 virtual iAwsComponent *GetTopComponent()=0; 00273 00275 virtual void SetTopComponent(iAwsComponent *win)=0; 00276 00278 virtual iAwsComponent *GetFocusedComponent()=0; 00279 00281 virtual void SetFocusedComponent(iAwsComponent * _focused)=0; 00282 00284 virtual iAwsComponent *GetKeyboardFocusedComponent()=0; 00285 00287 virtual iAwsComponent* ComponentAt(int x, int y)=0; 00288 00290 virtual bool MouseInComponent(int x, int y)=0; 00291 00296 virtual void Print(iGraphics3D *g3d, uint8 Alpha=0)=0; 00297 00299 virtual void Redraw()=0; 00300 00302 virtual void Mark(const csRect &rect)=0; 00303 00305 virtual void Unmark(const csRect &rect)=0; 00306 00311 virtual void Erase(const csRect &rect)=0; 00312 00317 virtual void MaskEraser(const csRect &rect)=0; 00318 00320 virtual void InvalidateUpdateStore()=0; 00321 00326 virtual void CaptureMouse(iAwsComponent *comp)=0; 00327 00329 virtual void ReleaseMouse()=0; 00330 00332 virtual void SetModal(iAwsComponent *comp)=0; 00333 00335 virtual void UnSetModal()=0; 00336 00338 virtual bool HandleEvent(iEvent&)=0; 00339 00352 virtual bool SetupCanvas (iAwsCanvas *newCanvas, iGraphics2D *g2d=0, 00353 iGraphics3D *g3d=0)=0; 00354 00356 virtual iAwsCanvas* GetCanvas()=0; 00357 00359 //virtual iAwsCanvas *CreateDefaultCanvas(iEngine* engine, iTextureManager* txtmgr)=0; 00360 00362 //virtual iAwsCanvas *CreateDefaultCanvas(iEngine* engine, iTextureManager* txtmgr, 00363 // int width, int height, const char *name)=0; 00364 00366 //virtual iAwsCanvas *CreateCustomCanvas(iGraphics2D *g2d, iGraphics3D *g3d)=0; 00367 00369 virtual iGraphics2D *G2D()=0; 00370 00372 virtual iGraphics3D *G3D()=0; 00373 00375 virtual iAwsComponent *CreateWindowFrom(const char* defname)=0; 00376 00378 virtual iAwsComponent *CreateEmbeddableComponent()=0; 00379 00381 virtual iAwsParmList *CreateParmList()=0; 00382 00388 virtual void CreateTransition(iAwsComponent *win, unsigned transition_type, 00389 csTicks duration=250)=0; 00390 00397 virtual void CreateTransitionEx(iAwsComponent *win, 00398 unsigned transition_type, csTicks duration, csRect &user)=0; 00399 00405 virtual void SetFlag(unsigned int flags)=0; 00406 00412 virtual void ClearFlag(unsigned int flags)=0; 00413 00419 virtual unsigned int GetFlags()=0; 00420 00422 virtual iObjectRegistry *GetObjectRegistry ()=0; 00423 00425 virtual bool AllWindowsHidden()=0; 00426 00428 virtual bool ComponentIsInTransition(iAwsComponent *win)=0; 00429 }; 00430 00431 SCF_VERSION (iAwsPrefManager, 0, 0, 3); 00432 00434 struct iAwsPrefManager : public iBase 00435 { 00436 public: 00438 virtual bool Setup(iObjectRegistry *object_reg)=0; 00439 00441 virtual bool Load(const char *def_file)=0; 00442 00444 virtual unsigned long NameToId (const char*name)=0; 00445 00450 virtual bool SelectDefaultSkin (const char* skin_name)=0; 00451 00453 virtual bool LookupIntKey (const char* name, int &val)=0; 00454 00456 virtual bool LookupIntKey(unsigned long id, int &val)=0; 00457 00459 virtual bool LookupStringKey(const char* name, iString *&val)=0; 00460 00462 virtual bool LookupStringKey(unsigned long id, iString *&val)=0; 00463 00465 virtual bool LookupRectKey(const char* name, csRect &rect)=0; 00466 00468 virtual bool LookupRectKey(unsigned long id, csRect &rect)=0; 00469 00471 virtual bool LookupRGBKey(const char* name, unsigned char &red, 00472 unsigned char &green, unsigned char &blue)=0; 00473 00475 virtual bool LookupRGBKey(unsigned long id, unsigned char &red, 00476 unsigned char &green, unsigned char &blue)=0; 00477 00479 virtual bool LookupPointKey(const char* name, csPoint &point)=0; 00480 00482 virtual bool LookupPointKey(unsigned long id, csPoint &point)=0; 00483 00485 virtual bool GetInt(iAwsComponentNode *node, const char* name, int &val)=0; 00486 00488 virtual bool GetFloat(iAwsComponentNode *node, const char* name, float &val)=0; 00489 00491 virtual bool GetRect(iAwsComponentNode *node, const char* name, 00492 csRect &rect)=0; 00493 00495 virtual bool GetString(iAwsComponentNode *node, const char* name, 00496 iString *&val)=0; 00497 00499 virtual bool GetRGB(iAwsComponentNode *node, const char* name, 00500 unsigned char& r, unsigned char& g, unsigned char& b)=0; 00501 00506 virtual iAwsComponentNode *FindWindowDef(const char* name)=0; 00507 00509 virtual iAwsKeyContainer *FindSkinDef(const char* name)=0; 00510 00512 virtual bool RemoveWindowDef (const char *name)=0; 00513 00515 virtual void RemoveAllWindowDefs ()=0; 00516 00518 virtual bool RemoveSkinDef (const char *name)=0; 00519 00521 virtual void RemoveAllSkinDefs ()=0; 00522 00524 virtual void SetColor(int index, int color)=0; 00525 00527 virtual int GetColor(int index)=0; 00528 00530 virtual int FindColor(unsigned char r, unsigned char g, unsigned char b)=0; 00531 00533 virtual iFont *GetDefaultFont()=0; 00534 00536 virtual iFont *GetFont(const char* filename)=0; 00537 00539 virtual iTextureHandle *GetTexture(const char* name, 00540 const char* filename=0)=0; 00541 00546 virtual iTextureHandle *GetTexture (const char* name, const char* filename, 00547 unsigned char key_r, 00548 unsigned char key_g, 00549 unsigned char key_b)=0; 00550 00552 virtual void SetTextureManager(iTextureManager *txtmgr)=0; 00553 00555 virtual void SetFontServer(iFontServer *fntsvr)=0; 00556 00558 virtual void SetDefaultFont(iFont* font)=0; 00559 00561 virtual void SetWindowMgr(iAws *wmgr)=0; 00562 00570 virtual void SetupPalette()=0; 00571 00573 virtual void RegisterConstant(const char* name, int value)=0; 00574 00576 virtual bool ConstantExists(const char* name)=0; 00577 00582 virtual int GetConstantValue(const char* name)=0; 00583 00585 virtual iAwsKeyFactory *CreateKeyFactory()=0; 00586 00588 virtual iAwsConnectionNodeFactory *CreateConnectionNodeFactory()=0; 00589 }; 00590 00591 00592 SCF_VERSION (iAwsSinkManager, 0, 0, 2); 00593 00595 struct iAwsSinkManager : public iBase 00596 { 00598 virtual void RegisterSink(const char *name, iAwsSink *sink)=0; 00599 00600 virtual bool RemoveSink (iAwsSink* sink) = 0; 00601 00603 virtual iAwsSink* FindSink(const char *name)=0; 00604 00609 virtual iAwsSink *CreateSink(void *parm)=0; 00610 00612 virtual iAwsSlot *CreateSlot ()=0; 00613 }; 00614 00615 00616 SCF_VERSION (iAwsSink, 0, 0, 2); 00617 00619 struct iAwsSink : public iBase 00620 { 00622 virtual unsigned long GetTriggerID(const char *name)=0; 00623 00625 virtual void HandleTrigger(int trigger_id, iAwsSource *source)=0; 00626 00628 virtual void RegisterTrigger(const char *name, 00629 void (*Trigger)(void *, iAwsSource *))=0; 00630 00637 virtual unsigned int GetError()=0; 00638 }; 00639 00640 00641 SCF_VERSION (iAwsSource, 0, 0, 1); 00642 00644 struct iAwsSource : public iBase 00645 { 00647 virtual iAwsComponent *GetComponent()=0; 00648 00653 virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)=0; 00654 00656 virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)=0; 00657 00659 virtual void Broadcast(unsigned long signal)=0; 00660 }; 00661 00662 00663 SCF_VERSION (iAwsSlot, 0, 0, 1); 00664 00666 struct iAwsSlot : public iBase 00667 { 00673 virtual void Connect(iAwsSource *source, unsigned long signal, 00674 iAwsSink *sink, unsigned long trigger)=0; 00675 00681 virtual void Disconnect(iAwsSource *source, unsigned long signal, 00682 iAwsSink *sink, unsigned long trigger)=0; 00683 00687 virtual void Emit(iAwsSource &source, unsigned long signal)=0; 00688 }; 00689 00690 SCF_VERSION(iAwsLayoutManager, 0, 0, 1); 00691 00693 struct iAwsLayoutManager : public iBase 00694 { 00702 virtual void SetOwner (iAwsComponent *_owner) = 0; 00703 00707 virtual csRect AddComponent (iAwsComponent *cmp, 00708 iAwsComponentNode* settings) = 0; 00709 00711 virtual void RemoveComponent(iAwsComponent* ) = 0; 00712 00714 virtual void LayoutComponents () = 0; 00715 }; 00716 00717 SCF_VERSION (iAwsComponent, 0, 1, 4); 00718 00720 struct iAwsComponent : public iAwsSource 00721 { 00722 00735 virtual bool Create(iAws* mgr, iAwsComponent* parent, 00736 iAwsComponentNode* settings)=0; 00737 00739 virtual bool Setup(iAws *wmgr, iAwsComponentNode *settings)=0; 00740 00745 virtual bool HandleEvent(iEvent& Event)=0; 00746 00751 virtual bool GetProperty(const char* name, void **parm)=0; 00752 00757 virtual bool SetProperty(const char* name, void *parm)=0; 00758 00760 virtual bool Execute(const char* action, iAwsParmList* parmlist = 0) = 0; 00761 00763 virtual void Invalidate()=0; 00764 00766 virtual void Invalidate(csRect area)=0; 00767 00769 virtual csRect Frame()=0; 00770 00772 virtual csRect ClientFrame()=0; 00773 00775 virtual const char *Type()=0; 00776 00782 virtual void SetFlag(unsigned int flag)=0; 00783 00789 virtual void ClearFlag(unsigned int flag)=0; 00790 00796 virtual unsigned int Flags()=0; 00797 00799 virtual iAws *WindowManager ()=0; 00800 00802 virtual iAwsComponent *Parent()=0; 00803 00805 virtual iAwsComponent *Window()=0; 00806 00808 virtual iAwsLayoutManager *Layout()=0; 00809 00811 virtual void SetParent(iAwsComponent *parent)=0; 00812 00814 virtual void SetLayout(iAwsLayoutManager *layout)=0; 00815 00817 virtual void AddToLayout(iAwsComponent *cmp, iAwsComponentNode *settings)=0; 00818 00820 virtual csRect getPreferredSize()=0; 00821 00823 virtual void setPreferredSize (const csRect& size) = 0; 00824 00826 virtual void clearPreferredSize () = 0; 00827 00829 virtual csRect getMinimumSize()=0; 00830 00832 virtual csRect getInsets()=0; 00833 00835 virtual bool Overlaps(csRect &r)=0; 00836 00838 virtual bool isHidden()=0; 00839 00841 virtual void SetFocusable(bool _focusable)=0; 00842 00844 virtual bool Focusable()=0; 00845 00847 virtual bool isFocused()=0; 00848 00850 virtual bool IsMaximized()=0; 00851 00853 virtual void Hide()=0; 00854 00856 virtual void Show()=0; 00857 00859 virtual void SetFocus()=0; 00860 00862 virtual void UnsetFocus()=0; 00863 00865 virtual void Move(int delta_x, int delta_y)=0; 00866 00868 virtual void MoveTo(int x, int y)=0; 00869 00871 virtual void Resize(int width, int height)=0; 00872 00874 virtual void ResizeTo(csRect newFrame)=0; 00875 00877 virtual void Maximize()=0; 00878 00880 virtual void UnMaximize()=0; 00881 00883 virtual void LayoutChildren()=0; 00884 00886 virtual bool isDeaf()=0; 00887 00889 virtual void SetDeaf (bool bDeaf)=0; 00890 00892 virtual unsigned long GetID()=0; 00893 00898 virtual void SetID(unsigned long _id)=0; 00899 00901 virtual iAwsComponent *FindChild(const char *name)=0; 00902 00904 virtual iAwsComponent *DoFindChild(unsigned id)=0; 00905 00907 virtual iAwsComponent* ChildAt(int x, int y)=0; 00908 00910 virtual void AddChild(iAwsComponent* child)=0; 00911 00913 virtual void RemoveChild(iAwsComponent *child)=0; 00914 00916 virtual int GetChildCount()=0; 00917 00919 virtual iAwsComponent *GetTopChild()=0; 00920 00922 virtual iAwsComponent *ComponentAbove()=0; 00923 00925 virtual iAwsComponent *ComponentBelow()=0; 00926 00928 virtual void SetComponentAbove(iAwsComponent *comp)=0; 00929 00931 virtual void SetComponentBelow(iAwsComponent *comp)=0; 00932 00938 virtual bool AddToTabOrder(iAwsComponent *child)=0; 00939 00944 virtual iAwsComponent *TabNext(iAwsComponent *child)=0; 00945 00950 virtual iAwsComponent *TabPrev(iAwsComponent *child)=0; 00951 00953 virtual int GetTabLength()=0; 00954 00956 virtual iAwsComponent *GetTabComponent(int index)=0; 00957 00959 virtual iAwsComponent *GetFirstFocusableChild(iAwsComponent *comp)=0; 00960 00962 virtual void Raise()=0; 00963 00965 virtual void Lower()=0; 00966 00968 virtual bool HasChildren()=0; 00969 00971 virtual void SetRedrawTag(unsigned int tag)=0; 00972 00974 virtual unsigned int RedrawTag()=0; 00975 00977 virtual void OnDraw(csRect clip)=0; 00978 00980 virtual bool OnMouseDown(int button, int x, int y)=0; 00981 00983 virtual bool OnMouseUp(int button, int x, int y)=0; 00984 00986 virtual bool OnMouseMove(int button, int x, int y)=0; 00987 00989 virtual bool OnMouseClick(int button, int x, int y)=0; 00990 00992 virtual bool OnMouseDoubleClick(int button, int x, int y)=0; 00993 00995 virtual bool OnMouseExit()=0; 00996 00998 virtual bool OnMouseEnter()=0; 00999 01001 virtual bool OnKeyboard (const csKeyEventData& eventData) = 0; 01002 01004 virtual bool OnLostFocus()=0; 01005 01007 virtual bool OnGainFocus()=0; 01008 01010 virtual bool OnFrame()=0; 01011 01013 virtual void OnAdded()=0; 01014 01016 virtual void OnResized()=0; 01017 01019 virtual void OnChildMoved() = 0; 01020 01022 virtual void OnRaise()=0; 01023 01025 virtual void OnLower()=0; 01026 01028 virtual void OnChildHide()=0; 01029 01031 virtual void OnChildShow()=0; 01032 01034 virtual void OnSetFocus()=0; 01035 01037 virtual void OnUnsetFocus()=0; 01038 01039 /* Only awsComponent should make use of the funcs below. Nothing else =) */ 01040 01042 virtual void Unlink()=0; 01043 01045 virtual void LinkAbove(iAwsComponent* comp)=0; 01046 01048 virtual void LinkBelow(iAwsComponent* comp)=0; 01049 01051 virtual void SetTopChild(iAwsComponent* child)=0; 01052 }; 01053 01054 01055 SCF_VERSION (iAwsComponentFactory, 0, 0, 2); 01056 01058 struct iAwsComponentFactory : public iBase 01059 { 01061 virtual iAwsComponent *Create()=0; 01062 01064 virtual void Register(const char *type)=0; 01065 01067 virtual void RegisterConstant(const char *name, int value)=0; 01068 }; 01069 01070 01071 SCF_VERSION (iAwsKeyFactory, 0, 0, 4); 01072 01074 struct iAwsKeyFactory : public iBase 01075 { 01080 virtual void Initialize(const char* name, const char* component_type)=0; 01082 virtual void AddToWindowList(iAwsPrefManager *pm)=0; 01084 virtual void AddFactory(iAwsKeyFactory *factory)=0; 01086 virtual void AddIntKey (const char* name, int v)=0; 01088 virtual void AddStringKey (const char* name, const char* v)=0; 01090 virtual void AddRectKey (const char* name, csRect v)=0; 01092 virtual void AddRGBKey (const char* name, unsigned char r, 01093 unsigned char g, unsigned char b)=0; 01095 virtual void AddPointKey (const char* name, csPoint v)=0; 01097 virtual void AddConnectionKey (const char* name, iAwsSink *s, 01098 unsigned long t, unsigned long sig)=0; 01100 virtual void AddConnectionNode (iAwsConnectionNodeFactory *node)=0; 01101 01102 virtual iAwsComponentNode* GetThisNode () = 0; 01103 }; 01104 01105 SCF_VERSION (iAwsConnectionNodeFactory, 0, 0, 1); 01106 01108 struct iAwsConnectionNodeFactory : public iBase 01109 { 01111 virtual void Initialize ()=0; 01113 virtual void AddConnectionKey ( 01114 const char* name, 01115 iAwsSink *s, 01116 unsigned long t, 01117 unsigned long sig)=0; 01118 01120 virtual awsConnectionNode* GetThisNode () = 0; 01121 }; 01122 01123 01124 01125 /* @} */ 01126 01127 #endif // __CS_IAWS_AWS_H__ 01128
Generated for Crystal Space by doxygen 1.2.18