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, 4); 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 *CreateCustomCanvas(iGraphics2D*, iGraphics3D*)=0; 00360 00362 virtual iGraphics2D *G2D()=0; 00363 00365 virtual iGraphics3D *G3D()=0; 00366 00368 virtual iAwsComponent *CreateWindowFrom(const char* defname)=0; 00369 00371 virtual iAwsComponent *CreateEmbeddableComponent(iAwsComponent *covercomp)=0; 00372 00374 virtual iAwsParmList *CreateParmList()=0; 00375 00381 virtual void CreateTransition(iAwsComponent *win, unsigned transition_type, 00382 csTicks duration=250)=0; 00383 00390 virtual void CreateTransitionEx(iAwsComponent *win, 00391 unsigned transition_type, csTicks duration, csRect &user)=0; 00392 00398 virtual void SetFlag(unsigned int flags)=0; 00399 00405 virtual void ClearFlag(unsigned int flags)=0; 00406 00412 virtual unsigned int GetFlags()=0; 00413 00415 virtual iObjectRegistry *GetObjectRegistry ()=0; 00416 00418 virtual bool AllWindowsHidden()=0; 00419 00421 virtual bool ComponentIsInTransition(iAwsComponent *win)=0; 00422 00424 virtual void ComponentDestroyed(iAwsComponent *comp)=0; 00425 }; 00426 00427 SCF_VERSION (iAwsPrefManager, 0, 0, 3); 00428 00430 struct iAwsPrefManager : public iBase 00431 { 00432 public: 00434 virtual bool Setup(iObjectRegistry *object_reg)=0; 00435 00437 virtual bool Load(const char *def_file)=0; 00438 00440 virtual unsigned long NameToId (const char*name)=0; 00441 00446 virtual bool SelectDefaultSkin (const char* skin_name)=0; 00447 00449 virtual bool LookupIntKey (const char* name, int &val)=0; 00450 00452 virtual bool LookupIntKey(unsigned long id, int &val)=0; 00453 00455 virtual bool LookupStringKey(const char* name, iString *&val)=0; 00456 00458 virtual bool LookupStringKey(unsigned long id, iString *&val)=0; 00459 00461 virtual bool LookupRectKey(const char* name, csRect &rect)=0; 00462 00464 virtual bool LookupRectKey(unsigned long id, csRect &rect)=0; 00465 00467 virtual bool LookupRGBKey(const char* name, unsigned char &red, 00468 unsigned char &green, unsigned char &blue)=0; 00469 00471 virtual bool LookupRGBKey(unsigned long id, unsigned char &red, 00472 unsigned char &green, unsigned char &blue)=0; 00473 00475 virtual bool LookupPointKey(const char* name, csPoint &point)=0; 00476 00478 virtual bool LookupPointKey(unsigned long id, csPoint &point)=0; 00479 00481 virtual bool GetInt(iAwsComponentNode *node, const char* name, int &val)=0; 00482 00484 virtual bool GetFloat(iAwsComponentNode *, const char* name, float &val)=0; 00485 00487 virtual bool GetRect(iAwsComponentNode *node, const char* name, 00488 csRect &rect)=0; 00489 00491 virtual bool GetString(iAwsComponentNode *node, const char* name, 00492 iString *&val)=0; 00493 00495 virtual bool GetRGB(iAwsComponentNode *node, const char* name, 00496 unsigned char& r, unsigned char& g, unsigned char& b)=0; 00497 00502 virtual iAwsComponentNode *FindWindowDef(const char* name)=0; 00503 00505 virtual iAwsKeyContainer *FindSkinDef(const char* name)=0; 00506 00508 virtual bool RemoveWindowDef (const char *name)=0; 00509 00511 virtual void RemoveAllWindowDefs ()=0; 00512 00514 virtual bool RemoveSkinDef (const char *name)=0; 00515 00517 virtual void RemoveAllSkinDefs ()=0; 00518 00520 virtual void SetColor(int index, int color)=0; 00521 00523 virtual int GetColor(int index)=0; 00524 00526 virtual int FindColor(unsigned char r, unsigned char g, unsigned char b)=0; 00527 00529 virtual iFont *GetDefaultFont()=0; 00530 00532 virtual iFont *GetFont(const char* filename)=0; 00533 00535 virtual iTextureHandle *GetTexture(const char* name, 00536 const char* filename=0)=0; 00537 00542 virtual iTextureHandle *GetTexture (const char* name, const char* filename, 00543 unsigned char key_r, 00544 unsigned char key_g, 00545 unsigned char key_b)=0; 00546 00548 virtual void SetTextureManager(iTextureManager *txtmgr)=0; 00549 00551 virtual void SetFontServer(iFontServer *fntsvr)=0; 00552 00554 virtual void SetDefaultFont(iFont* font)=0; 00555 00557 virtual void SetWindowMgr(iAws *wmgr)=0; 00558 00566 virtual void SetupPalette()=0; 00567 00569 virtual void RegisterConstant(const char* name, int value)=0; 00570 00572 virtual bool ConstantExists(const char* name)=0; 00573 00578 virtual int GetConstantValue(const char* name)=0; 00579 00581 virtual iAwsKeyFactory *CreateKeyFactory()=0; 00582 00584 virtual iAwsConnectionNodeFactory *CreateConnectionNodeFactory()=0; 00585 }; 00586 00587 00588 SCF_VERSION (iAwsSinkManager, 0, 0, 2); 00589 00591 struct iAwsSinkManager : public iBase 00592 { 00594 virtual void RegisterSink(const char *name, iAwsSink *sink)=0; 00595 00596 virtual bool RemoveSink (iAwsSink* sink) = 0; 00597 00599 virtual iAwsSink* FindSink(const char *name)=0; 00600 00605 virtual iAwsSink *CreateSink(void *parm)=0; 00606 00608 virtual iAwsSlot *CreateSlot ()=0; 00609 }; 00610 00611 00612 SCF_VERSION (iAwsSink, 0, 0, 2); 00613 00615 struct iAwsSink : public iBase 00616 { 00618 virtual unsigned long GetTriggerID(const char *name)=0; 00619 00621 virtual void HandleTrigger(int trigger_id, iAwsSource *source)=0; 00622 00624 virtual void RegisterTrigger(const char *name, 00625 void (*Trigger)(void *, iAwsSource *))=0; 00626 00633 virtual unsigned int GetError()=0; 00634 }; 00635 00636 00637 SCF_VERSION (iAwsSource, 0, 0, 1); 00638 00640 struct iAwsSource : public iBase 00641 { 00643 virtual iAwsComponent *GetComponent()=0; 00644 00649 virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)=0; 00650 00652 virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)=0; 00653 00655 virtual void Broadcast(unsigned long signal)=0; 00656 }; 00657 00658 00659 SCF_VERSION (iAwsSlot, 0, 0, 1); 00660 00662 struct iAwsSlot : public iBase 00663 { 00669 virtual void Connect(iAwsSource *source, unsigned long signal, 00670 iAwsSink *sink, unsigned long trigger)=0; 00671 00677 virtual void Disconnect(iAwsSource *source, unsigned long signal, 00678 iAwsSink *sink, unsigned long trigger)=0; 00679 00683 virtual void Emit(iAwsSource &source, unsigned long signal)=0; 00684 }; 00685 00686 SCF_VERSION(iAwsLayoutManager, 0, 0, 1); 00687 00689 struct iAwsLayoutManager : public iBase 00690 { 00698 virtual void SetOwner (iAwsComponent *_owner) = 0; 00699 00703 virtual csRect AddComponent (iAwsComponent *cmp, 00704 iAwsComponentNode* settings) = 0; 00705 00707 virtual void RemoveComponent(iAwsComponent* ) = 0; 00708 00710 virtual void LayoutComponents () = 0; 00711 }; 00712 00713 SCF_VERSION (iAwsComponent, 0, 1, 4); 00714 00716 struct iAwsComponent : public iAwsSource 00717 { 00718 00731 virtual bool Create(iAws* mgr, iAwsComponent* parent, 00732 iAwsComponentNode* settings)=0; 00733 00735 virtual bool Setup(iAws *wmgr, iAwsComponentNode *settings)=0; 00736 00741 virtual bool HandleEvent(iEvent& Event)=0; 00742 00747 virtual bool GetProperty(const char* name, void **parm)=0; 00748 00753 virtual bool SetProperty(const char* name, void *parm)=0; 00754 00756 virtual bool Execute(const char* action, iAwsParmList* parmlist = 0) = 0; 00757 00762 virtual void Invalidate()=0; 00763 00765 virtual void Invalidate(csRect area)=0; 00766 00768 virtual csRect Frame()=0; 00769 00771 virtual csRect ClientFrame()=0; 00772 00774 virtual const char *Type()=0; 00775 00781 virtual void SetFlag(unsigned int flag)=0; 00782 00788 virtual void ClearFlag(unsigned int flag)=0; 00789 00795 virtual unsigned int Flags()=0; 00796 00798 virtual iAws *WindowManager ()=0; 00799 00801 virtual iAwsComponent *Parent()=0; 00802 00804 virtual iAwsComponent *Window()=0; 00805 00807 virtual iAwsLayoutManager *Layout()=0; 00808 00810 virtual void SetParent(iAwsComponent *parent)=0; 00811 00813 virtual void SetLayout(iAwsLayoutManager *layout)=0; 00814 00816 virtual void AddToLayout(iAwsComponent *cmp, iAwsComponentNode *settings)=0; 00817 00819 virtual csRect getPreferredSize()=0; 00820 00822 virtual void setPreferredSize (const csRect& size) = 0; 00823 00825 virtual void clearPreferredSize () = 0; 00826 00828 virtual csRect getMinimumSize()=0; 00829 00831 virtual csRect getInsets()=0; 00832 00834 virtual bool Overlaps(csRect &r)=0; 00835 00837 virtual bool isHidden()=0; 00838 00840 virtual void SetFocusable(bool _focusable)=0; 00841 00843 virtual bool Focusable()=0; 00844 00846 virtual bool isFocused()=0; 00847 00849 virtual bool IsMaximized()=0; 00850 00852 virtual void Hide()=0; 00853 00855 virtual void Show()=0; 00856 00858 virtual void SetFocus()=0; 00859 00861 virtual void UnsetFocus()=0; 00862 00864 virtual void Move(int delta_x, int delta_y)=0; 00865 00867 virtual void MoveTo(int x, int y)=0; 00868 00870 virtual void Resize(int width, int height)=0; 00871 00873 virtual void ResizeTo(csRect newFrame)=0; 00874 00876 virtual void Maximize()=0; 00877 00879 virtual void UnMaximize()=0; 00880 00882 virtual void LayoutChildren()=0; 00883 00885 virtual bool isDeaf()=0; 00886 00888 virtual void SetDeaf (bool bDeaf)=0; 00889 00891 virtual unsigned long GetID()=0; 00892 00897 virtual void SetID(unsigned long _id)=0; 00898 00900 virtual iAwsComponent *FindChild(const char *name)=0; 00901 00903 virtual iAwsComponent *DoFindChild(unsigned id)=0; 00904 00906 virtual iAwsComponent* ChildAt(int x, int y)=0; 00907 00909 virtual void AddChild(iAwsComponent* child)=0; 00910 00912 virtual void RemoveChild(iAwsComponent *child)=0; 00913 00915 virtual int GetChildCount()=0; 00916 00918 virtual iAwsComponent *GetTopChild()=0; 00919 00921 virtual iAwsComponent *ComponentAbove()=0; 00922 00924 virtual iAwsComponent *ComponentBelow()=0; 00925 00927 virtual void SetComponentAbove(iAwsComponent *comp)=0; 00928 00930 virtual void SetComponentBelow(iAwsComponent *comp)=0; 00931 00937 virtual bool AddToTabOrder(iAwsComponent *child)=0; 00938 00943 virtual iAwsComponent *TabNext(iAwsComponent *child)=0; 00944 00949 virtual iAwsComponent *TabPrev(iAwsComponent *child)=0; 00950 00952 virtual int GetTabLength()=0; 00953 00955 virtual iAwsComponent *GetTabComponent(int index)=0; 00956 00958 virtual iAwsComponent *GetFirstFocusableChild(iAwsComponent *comp)=0; 00959 00961 virtual void Raise()=0; 00962 00964 virtual void Lower()=0; 00965 00967 virtual bool HasChildren()=0; 00968 00970 virtual void SetRedrawTag(unsigned int tag)=0; 00971 00973 virtual unsigned int RedrawTag()=0; 00974 00976 virtual void OnDraw(csRect clip)=0; 00977 00979 virtual bool OnMouseDown(int button, int x, int y)=0; 00980 00982 virtual bool OnMouseUp(int button, int x, int y)=0; 00983 00985 virtual bool OnMouseMove(int button, int x, int y)=0; 00986 00988 virtual bool OnMouseClick(int button, int x, int y)=0; 00989 00991 virtual bool OnMouseDoubleClick(int button, int x, int y)=0; 00992 00994 virtual bool OnMouseExit()=0; 00995 00997 virtual bool OnMouseEnter()=0; 00998 01000 virtual bool OnKeyboard (const csKeyEventData& eventData) = 0; 01001 01003 virtual bool OnLostFocus()=0; 01004 01006 virtual bool OnGainFocus()=0; 01007 01009 virtual bool OnFrame()=0; 01010 01012 virtual void OnAdded()=0; 01013 01015 virtual void OnResized()=0; 01016 01018 virtual void OnChildMoved() = 0; 01019 01021 virtual void OnRaise()=0; 01022 01024 virtual void OnLower()=0; 01025 01027 virtual void OnChildHide()=0; 01028 01030 virtual void OnChildShow()=0; 01031 01033 virtual void OnSetFocus()=0; 01034 01036 virtual void OnUnsetFocus()=0; 01037 01038 /* Only awsComponent should make use of the funcs below. Nothing else =) */ 01039 01041 virtual void Unlink()=0; 01042 01044 virtual void LinkAbove(iAwsComponent* comp)=0; 01045 01047 virtual void LinkBelow(iAwsComponent* comp)=0; 01048 01050 virtual void SetTopChild(iAwsComponent* child)=0; 01051 }; 01052 01053 01054 SCF_VERSION (iAwsComponentFactory, 0, 0, 2); 01055 01057 struct iAwsComponentFactory : public iBase 01058 { 01060 virtual iAwsComponent *Create()=0; 01061 01063 virtual void Register(const char *type)=0; 01064 01066 virtual void RegisterConstant(const char *name, int value)=0; 01067 }; 01068 01069 01070 SCF_VERSION (iAwsKeyFactory, 0, 0, 4); 01071 01073 struct iAwsKeyFactory : public iBase 01074 { 01079 virtual void Initialize(const char* name, const char* component_type)=0; 01081 virtual void AddToWindowList(iAwsPrefManager *pm)=0; 01083 virtual void AddFactory(iAwsKeyFactory *factory)=0; 01085 virtual void AddIntKey (const char* name, int v)=0; 01087 virtual void AddStringKey (const char* name, const char* v)=0; 01089 virtual void AddRectKey (const char* name, csRect v)=0; 01091 virtual void AddRGBKey (const char* name, unsigned char r, 01092 unsigned char g, unsigned char b)=0; 01094 virtual void AddPointKey (const char* name, csPoint v)=0; 01096 virtual void AddConnectionKey (const char* name, iAwsSink *s, 01097 unsigned long t, unsigned long sig)=0; 01099 virtual void AddConnectionNode (iAwsConnectionNodeFactory *node)=0; 01100 01101 virtual iAwsComponentNode* GetThisNode () = 0; 01102 }; 01103 01104 SCF_VERSION (iAwsConnectionNodeFactory, 0, 0, 1); 01105 01107 struct iAwsConnectionNodeFactory : public iBase 01108 { 01110 virtual void Initialize ()=0; 01112 virtual void AddConnectionKey ( 01113 const char* name, 01114 iAwsSink *s, 01115 unsigned long t, 01116 unsigned long sig)=0; 01117 01119 virtual awsConnectionNode* GetThisNode () = 0; 01120 }; 01121 01122 /* @} */ 01123 01124 #endif // __CS_IAWS_AWS_H__
Generated for Crystal Space by doxygen 1.2.18