CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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/string.h"
00031 
00032 struct iAws;
00033 struct iAwsSlot;
00034 struct iAwsSink;
00035 struct iAwsSource;
00036 struct iAwsParmList;
00037 struct iAwsComponent;
00038 struct iAwsPrefManager;
00039 struct iAwsSinkManager;
00040 struct iAwsCanvas;
00041 struct iAwsKeyFactory;
00042 struct iAwsComponentFactory;
00043 struct iAwsConnectionNodeFactory;
00044 
00045 typedef iAwsComponent iAwsWindow;
00046 
00047 class  awsWindow;
00048 class  awsComponent;
00049 class  awsComponentNode;
00050 class  awsConnectionNode;
00051 class  awsComponentFactory;
00052 class  awsLayoutManager;
00053 
00054 struct  iGraphics2D;
00055 struct  iGraphics3D;
00056 struct  iEngine;
00057 struct  iView;
00058 struct  iTextureManager;
00059 struct  iObjectRegistry;
00060 struct  iTextureHandle;
00061 struct  iFontServer;
00062 struct  iFont;
00063 struct  iEvent;
00064 
00065 const   bool aws_debug=false;  // set to true to turn on debugging printf's
00066 
00077 const int AWSF_AlwaysEraseWindows=1;
00078 
00086 const int AWSF_AlwaysRedrawWindows=2;
00087 
00093 const int AWSF_RaiseOnMouseOver = 4;
00094 
00100 const int AWSF_KeyboardControl = 8;
00101 
00104 SCF_VERSION(iAwsKey, 0, 0, 1)
00105 
00107 struct iAwsKey : public iBase
00108 {
00110   virtual uint8 Type () = 0;
00111 
00113   virtual unsigned long Name () = 0;
00114 };
00115 
00116 SCF_VERSION(iAwsIntKey, 0, 0, 1)
00117 
00119 struct iAwsIntKey : public iAwsKey
00120 {
00122   virtual int Value () = 0;
00123 };
00124 
00125 SCF_VERSION(iAwsStringKey, 0, 0, 1);
00126 
00128 struct iAwsStringKey : public iAwsKey
00129 {
00131   virtual iString* Value () = 0;
00132 };
00133 
00134 SCF_VERSION(iAwsRectKey, 0, 0, 1);
00135 
00137 struct iAwsRectKey : public iAwsKey
00138 {
00140   virtual csRect Value () = 0;
00141 };
00142 
00143 SCF_VERSION(iAwsRGBKey, 0, 0, 1);
00144 
00146 struct iAwsRGBKey : public iAwsKey
00147 {
00148   struct RGB
00149   { 
00150     unsigned char red, green, blue;
00151   };
00152   
00154   virtual iAwsRGBKey::RGB &Value() = 0;
00155 };
00156 
00157 SCF_VERSION(iAwsPointKey, 0, 0, 1);
00158 
00160 struct iAwsPointKey : public iAwsKey
00161 {
00163   virtual csPoint Value () = 0;
00164 };
00165 
00166 SCF_VERSION(iAwsConnectionKey, 0, 0, 1);
00167 
00169 struct iAwsConnectionKey : public iAwsKey
00170 {
00172   virtual iAwsSink *Sink () = 0;
00173 
00175   virtual unsigned long Trigger () = 0;
00176 
00178   virtual unsigned long Signal () = 0;
00179 };
00180 
00181 SCF_VERSION(iAwsKeyContainer, 0, 0, 1);
00182 
00184 struct iAwsKeyContainer : public iAwsKey
00185 {
00187   virtual iAwsKey* Find (iString* name) = 0;
00188 
00190   virtual iAwsKey* Find (const char* name) = 0;
00191 
00193   virtual iAwsKey *Find (unsigned long id) = 0;
00194 
00195   virtual const csRefArray<iAwsKey> &Children () = 0;
00196 
00198   virtual void Add (iAwsKey *key) = 0;
00199 
00201   virtual iAwsKey* GetAt (int i) = 0;
00202 
00204   virtual int Length () = 0;
00205     
00207   virtual void Remove (iString *name) = 0;
00209   virtual void Remove (const char* name) = 0;
00211   virtual void Remove (iAwsKey *key) = 0;
00213   virtual void RemoveAll () = 0;
00214 
00219   virtual void Consume (iAwsKeyContainer *c) = 0;
00220 };
00221 
00222 SCF_VERSION(iAwsComponentNode, 0, 0, 1);
00223 
00225 struct iAwsComponentNode : public iAwsKeyContainer
00226 {
00228   virtual iString *ComponentTypeName () = 0;
00229 };
00230 
00231 
00236 SCF_VERSION (iAws, 0, 2, 1);
00237 
00239 struct iAws : public iBase
00240 {
00241 public:
00243   virtual iAwsPrefManager *GetPrefMgr()=0;
00244 
00246   virtual iAwsSinkManager *GetSinkMgr()=0;
00247 
00249   virtual void SetPrefMgr(iAwsPrefManager *pmgr)=0;
00250 
00255   virtual void RegisterComponentFactory(iAwsComponentFactory *factory,
00256         const char* name)=0;
00257 
00259   virtual iAwsComponentFactory *FindComponentFactory (const char* name)=0;
00260 
00262   virtual iAwsComponent *GetTopComponent()=0;
00263 
00265   virtual void SetTopComponent(iAwsComponent *win)=0;
00266 
00268   virtual iAwsComponent *GetFocusedComponent()=0;
00269 
00271   virtual void SetFocusedComponent(iAwsComponent * _focused)=0;
00272 
00274   virtual iAwsComponent *GetKeyboardFocusedComponent()=0;
00275 
00277   virtual iAwsComponent* ComponentAt(int x, int y)=0;
00278 
00280   virtual bool MouseInComponent(int x, int y)=0;
00281 
00286   virtual void Print(iGraphics3D *g3d, uint8 Alpha=0)=0;
00287 
00289   virtual void Redraw()=0;
00290 
00292   virtual void Mark(const csRect &rect)=0;
00293 
00295   virtual void Unmark(const csRect &rect)=0;
00296 
00301   virtual void Erase(const csRect &rect)=0;
00302 
00307   virtual void MaskEraser(const csRect &rect)=0;
00308 
00310   virtual void InvalidateUpdateStore()=0;
00311 
00316   virtual void CaptureMouse(iAwsComponent *comp)=0;
00317 
00319   virtual void ReleaseMouse()=0;
00320 
00322   virtual void SetModal(iAwsComponent *comp)=0;
00323 
00325   virtual void UnSetModal()=0;
00326 
00328   virtual bool HandleEvent(iEvent&)=0;
00329 
00342   virtual bool SetupCanvas (iAwsCanvas *newCanvas, iGraphics2D *g2d=0,
00343         iGraphics3D *g3d=0)=0;
00344 
00346   virtual iAwsCanvas* GetCanvas()=0;
00347 
00349   //virtual iAwsCanvas *CreateDefaultCanvas(iEngine* engine, iTextureManager* txtmgr)=0;
00350 
00352   //virtual iAwsCanvas *CreateDefaultCanvas(iEngine* engine, iTextureManager* txtmgr,
00353   //  int width, int height, const char *name)=0;
00354 
00356   //virtual iAwsCanvas *CreateCustomCanvas(iGraphics2D *g2d, iGraphics3D *g3d)=0;
00357 
00359   virtual iGraphics2D *G2D()=0;
00360 
00362   virtual iGraphics3D *G3D()=0;
00363 
00365   virtual iAwsComponent *CreateWindowFrom(const char* defname)=0;
00366 
00368   virtual iAwsComponent *CreateEmbeddableComponent()=0;
00369 
00371   virtual iAwsParmList *CreateParmList()=0;
00372 
00378   virtual void CreateTransition(iAwsComponent *win, unsigned transition_type,
00379         float step_size=0.1)=0;
00380 
00387   virtual void CreateTransitionEx(iAwsComponent *win,
00388         unsigned transition_type, float step_size, csRect &user)=0;
00389 
00395   virtual void SetFlag(unsigned int flags)=0;
00396 
00402   virtual void ClearFlag(unsigned int flags)=0;
00403 
00409   virtual unsigned int GetFlags()=0;
00410   
00412   virtual iObjectRegistry *GetObjectRegistry ()=0;
00413 
00415   virtual bool AllWindowsHidden()=0;
00416 
00417 };
00418 
00419 SCF_VERSION (iAwsPrefManager, 0, 0, 3);
00420 
00422 struct iAwsPrefManager : public iBase
00423 {
00424 public:
00426   virtual bool Setup(iObjectRegistry *object_reg)=0;
00427 
00429   virtual bool Load(const char *def_file)=0;
00430 
00432   virtual unsigned long NameToId (const char*name)=0;
00433 
00438   virtual bool SelectDefaultSkin (const char* skin_name)=0;
00439 
00441   virtual bool LookupIntKey (const char* name, int &val)=0;
00442 
00444   virtual bool LookupIntKey(unsigned long id, int &val)=0;
00445 
00447   virtual bool LookupStringKey(const char* name, iString *&val)=0;
00448 
00450   virtual bool LookupStringKey(unsigned long id, iString *&val)=0;
00451 
00453   virtual bool LookupRectKey(const char* name, csRect &rect)=0;
00454 
00456   virtual bool LookupRectKey(unsigned long id, csRect &rect)=0;
00457 
00459   virtual bool LookupRGBKey(const char* name, unsigned char &red,
00460         unsigned char &green, unsigned char &blue)=0;
00461 
00463   virtual bool LookupRGBKey(unsigned long id, unsigned char &red,
00464         unsigned char &green, unsigned char &blue)=0;
00465 
00467   virtual bool LookupPointKey(const char* name, csPoint &point)=0;
00468 
00470   virtual bool LookupPointKey(unsigned long id, csPoint &point)=0;
00471 
00473   virtual bool GetInt(iAwsComponentNode *node, const char* name, int &val)=0;
00474 
00476   virtual bool GetRect(iAwsComponentNode *node, const char* name,
00477         csRect &rect)=0;
00478 
00480   virtual bool GetString(iAwsComponentNode *node, const char* name,
00481         iString *&val)=0;
00482 
00484   virtual bool GetRGB(iAwsComponentNode *node, const char* name,
00485         unsigned char& r, unsigned char& g, unsigned char& b)=0;
00486 
00491   virtual iAwsComponentNode *FindWindowDef(const char* name)=0;
00492 
00494   virtual iAwsKeyContainer *FindSkinDef(const char* name)=0;
00495 
00497   virtual bool RemoveWindowDef (const char *name)=0;
00498 
00500   virtual void RemoveAllWindowDefs ()=0;
00501 
00503   virtual bool RemoveSkinDef (const char *name)=0;
00504 
00506   virtual void RemoveAllSkinDefs ()=0;
00507 
00509   virtual void SetColor(int index, int color)=0;
00510 
00512   virtual int  GetColor(int index)=0;
00513 
00515   virtual int FindColor(unsigned char r, unsigned char g, unsigned char b)=0;
00516 
00518   virtual iFont *GetDefaultFont()=0;
00519 
00521   virtual iFont *GetFont(const char* filename)=0;
00522 
00524   virtual iTextureHandle *GetTexture(const char* name,
00525         const char* filename=0)=0;
00526 
00531   virtual iTextureHandle *GetTexture (const char* name, const char* filename, 
00532                                       unsigned char key_r,
00533                                       unsigned char key_g,
00534                                       unsigned char key_b)=0;
00535 
00537   virtual void SetTextureManager(iTextureManager *txtmgr)=0;
00538 
00540   virtual void SetFontServer(iFontServer *fntsvr)=0;
00541 
00543   virtual void SetWindowMgr(iAws *wmgr)=0;
00544 
00552   virtual void SetupPalette()=0;
00553 
00555   virtual void RegisterConstant(const char* name, int value)=0;
00556 
00558   virtual bool ConstantExists(const char* name)=0;
00559 
00564   virtual int  GetConstantValue(const char* name)=0;
00565 
00567   virtual iAwsKeyFactory *CreateKeyFactory()=0;
00568 
00570   virtual iAwsConnectionNodeFactory *CreateConnectionNodeFactory()=0;
00571 };
00572 
00573 
00574 SCF_VERSION (iAwsSinkManager, 0, 0, 2);
00575 
00577 struct iAwsSinkManager : public iBase
00578 {
00580   virtual void RegisterSink(const char *name, iAwsSink *sink)=0;
00581 
00582   virtual bool RemoveSink (iAwsSink* sink) = 0;
00583 
00585   virtual iAwsSink* FindSink(const char *name)=0;
00586 
00591   virtual iAwsSink *CreateSink(void *parm)=0;
00592 
00594   virtual iAwsSlot *CreateSlot ()=0;
00595 };
00596 
00597 
00598 SCF_VERSION (iAwsSink, 0, 0, 2);
00599 
00601 struct iAwsSink : public iBase
00602 {
00604   virtual unsigned long GetTriggerID(const char *name)=0;
00605 
00607   virtual void HandleTrigger(int trigger_id, iAwsSource *source)=0;
00608 
00610   virtual void RegisterTrigger(const char *name,
00611         void (*Trigger)(void *, iAwsSource *))=0;
00612 
00619   virtual unsigned int GetError()=0;
00620 };
00621 
00622 
00623 SCF_VERSION (iAwsSource, 0, 0, 1);
00624 
00626 struct iAwsSource : public iBase
00627 {
00629   virtual iAwsComponent *GetComponent()=0;
00630 
00635   virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)=0;
00636 
00638   virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)=0;
00639 
00641   virtual void Broadcast(unsigned long signal)=0;
00642 };
00643 
00644 
00645 SCF_VERSION (iAwsSlot, 0, 0, 1);
00646 
00648 struct iAwsSlot : public iBase
00649 {
00655   virtual void Connect(iAwsSource *source, unsigned long signal,
00656         iAwsSink *sink, unsigned long trigger)=0;
00657 
00663   virtual void Disconnect(iAwsSource *source, unsigned long signal,
00664         iAwsSink *sink, unsigned long trigger)=0;
00665 
00669   virtual void Emit(iAwsSource &source, unsigned long signal)=0;
00670 };
00671 
00672 SCF_VERSION(iAwsLayoutManager, 0, 0, 1);
00673 
00675 struct iAwsLayoutManager : public iBase
00676 {
00684   virtual void SetOwner (iAwsComponent *_owner) = 0;
00685 
00689   virtual csRect AddComponent (iAwsComponent *cmp,
00690         iAwsComponentNode* settings) = 0;
00691 
00693   virtual void RemoveComponent(iAwsComponent* ) = 0;
00694 
00696   virtual void LayoutComponents () = 0;
00697 };
00698 
00699 SCF_VERSION (iAwsComponent, 0, 1, 3);
00700 
00702 struct iAwsComponent : public iAwsSource
00703 {
00704   
00717   virtual bool Create(iAws* mgr, iAwsComponent* parent,
00718         iAwsComponentNode* settings)=0;
00719 
00721   virtual bool Setup(iAws *wmgr, iAwsComponentNode *settings)=0;
00722 
00727   virtual bool HandleEvent(iEvent& Event)=0;
00728 
00733   virtual bool GetProperty(const char* name, void **parm)=0;
00734 
00739   virtual bool SetProperty(const char* name, void *parm)=0;
00740 
00742   virtual bool Execute(const char* action, iAwsParmList* parmlist = 0) = 0;
00743 
00745   virtual void Invalidate()=0;
00746 
00748   virtual void Invalidate(csRect area)=0;
00749 
00751   virtual csRect Frame()=0;
00752 
00754   virtual csRect ClientFrame()=0;
00755 
00757   virtual const char *Type()=0;
00758 
00764   virtual void SetFlag(unsigned int flag)=0;
00765 
00771   virtual void ClearFlag(unsigned int flag)=0;
00772 
00778   virtual unsigned int Flags()=0;
00779 
00781   virtual iAws *WindowManager ()=0;
00782 
00784   virtual iAwsComponent *Parent()=0;
00785 
00787   virtual iAwsComponent *Window()=0;
00788 
00790   virtual iAwsLayoutManager *Layout()=0;
00791 
00793   virtual void SetParent(iAwsComponent *parent)=0;
00794 
00796   virtual void SetLayout(iAwsLayoutManager *layout)=0;
00797 
00799   virtual void AddToLayout(iAwsComponent *cmp, iAwsComponentNode *settings)=0;
00800   
00802   virtual csRect getPreferredSize()=0;
00803 
00805   virtual csRect getMinimumSize()=0;
00806 
00808   virtual csRect getInsets()=0;
00809 
00811   virtual bool Overlaps(csRect &r)=0;
00812 
00814   virtual bool isHidden()=0;
00815 
00817   virtual void SetFocusable(bool _focusable)=0;
00818 
00820   virtual bool Focusable()=0;
00821 
00823   virtual bool isFocused()=0;
00824 
00826   virtual bool IsMaximized()=0;
00827 
00829   virtual void Hide()=0;
00830 
00832   virtual void Show()=0;
00833 
00835   virtual void SetFocus()=0;
00836 
00838   virtual void UnsetFocus()=0;
00839 
00841   virtual void Move(int delta_x, int delta_y)=0;
00842 
00844   virtual void MoveTo(int x, int y)=0;
00845 
00847   virtual void Resize(int width, int height)=0;
00848 
00850   virtual void ResizeTo(csRect newFrame)=0;
00851 
00853   virtual void Maximize()=0;
00854 
00856   virtual void UnMaximize()=0;
00857 
00859   virtual void LayoutChildren()=0;
00860 
00862   virtual bool isDeaf()=0;
00863 
00865   virtual void SetDeaf (bool bDeaf)=0;
00866 
00868   virtual unsigned long GetID()=0;
00869 
00874   virtual void SetID(unsigned long _id)=0;
00875 
00877   virtual iAwsComponent *FindChild(const char *name)=0;
00878 
00880   virtual iAwsComponent *DoFindChild(unsigned id)=0;
00881 
00883   virtual iAwsComponent* ChildAt(int x, int y)=0;
00884 
00886   virtual void AddChild(iAwsComponent* child)=0;
00887 
00889   virtual void RemoveChild(iAwsComponent *child)=0;
00890 
00892   virtual int GetChildCount()=0;
00893 
00895   virtual iAwsComponent *GetTopChild()=0;
00896 
00898   virtual iAwsComponent *ComponentAbove()=0;
00899 
00901   virtual iAwsComponent *ComponentBelow()=0;
00902 
00904   virtual void SetComponentAbove(iAwsComponent *comp)=0;
00905 
00907   virtual void SetComponentBelow(iAwsComponent *comp)=0;
00908 
00914   virtual bool AddToTabOrder(iAwsComponent *child)=0;
00915 
00920   virtual iAwsComponent *TabNext(iAwsComponent *child)=0;
00921 
00926   virtual iAwsComponent *TabPrev(iAwsComponent *child)=0;
00927 
00929   virtual int GetTabLength()=0;
00930 
00932   virtual iAwsComponent *GetTabComponent(int index)=0;
00933 
00935   virtual iAwsComponent *GetFirstFocusableChild(iAwsComponent *comp)=0;
00936 
00938   virtual void Raise()=0;
00939 
00941   virtual void Lower()=0;
00942 
00944   virtual bool HasChildren()=0;
00945 
00947   virtual void SetRedrawTag(unsigned int tag)=0;
00948 
00950   virtual unsigned int RedrawTag()=0;
00951 
00953   virtual void OnDraw(csRect clip)=0;
00954 
00956   virtual bool OnMouseDown(int button, int x, int y)=0;
00957 
00959   virtual bool OnMouseUp(int button, int x, int y)=0;
00960 
00962   virtual bool OnMouseMove(int button, int x, int y)=0;
00963 
00965   virtual bool OnMouseClick(int button, int x, int y)=0;
00966 
00968   virtual bool OnMouseDoubleClick(int button, int x, int y)=0;
00969 
00971   virtual bool OnMouseExit()=0;
00972 
00974   virtual bool OnMouseEnter()=0;
00975 
00977   virtual bool OnKeypress(int key, int cha, int modifiers)=0;
00978 
00980   virtual bool OnLostFocus()=0;
00981 
00983   virtual bool OnGainFocus()=0;
00984 
00986   virtual bool OnFrame()=0;
00987 
00989   virtual void OnAdded()=0;
00990 
00992   virtual void OnResized()=0;
00993 
00995   virtual void OnChildMoved() = 0;
00996 
00998   virtual void OnRaise()=0;
00999 
01001   virtual void OnLower()=0;
01002 
01004   virtual void OnChildHide()=0;
01005 
01007   virtual void OnChildShow()=0;
01008 
01010   virtual void OnSetFocus()=0;
01011 
01013   virtual void OnUnsetFocus()=0;
01014 
01015   /* Only awsComponent should make use of the funcs below. Nothing else =) */
01016 
01018   virtual void Unlink()=0;
01019 
01021   virtual void LinkAbove(iAwsComponent* comp)=0;
01022 
01024   virtual void LinkBelow(iAwsComponent* comp)=0;
01025 
01027   virtual void SetTopChild(iAwsComponent* child)=0;
01028 };
01029 
01030 
01031 SCF_VERSION (iAwsComponentFactory, 0, 0, 2);
01032 
01034 struct iAwsComponentFactory : public iBase
01035 {
01037   virtual iAwsComponent *Create()=0;
01038 
01040   virtual void Register(const char *type)=0;
01041 
01043   virtual void RegisterConstant(const char *name, int value)=0;
01044 };
01045 
01046 
01047 SCF_VERSION (iAwsKeyFactory, 0, 0, 4);
01048 
01050 struct iAwsKeyFactory : public iBase
01051 {
01056    virtual void Initialize(const char* name, const char* component_type)=0;
01058    virtual void AddToWindowList(iAwsPrefManager *pm)=0;
01060    virtual void AddFactory(iAwsKeyFactory *factory)=0;
01062    virtual void AddIntKey (const char* name, int v)=0;
01064    virtual void AddStringKey (const char* name, const char* v)=0;
01066    virtual void AddRectKey (const char* name, csRect v)=0;
01068    virtual void AddRGBKey (const char* name, unsigned char r,
01069         unsigned char g, unsigned char b)=0;
01071    virtual void AddPointKey (const char* name, csPoint v)=0;
01073    virtual void AddConnectionKey (const char* name, iAwsSink *s,
01074         unsigned long t, unsigned long sig)=0;
01076    virtual void AddConnectionNode (iAwsConnectionNodeFactory *node)=0;
01077    
01078    virtual iAwsComponentNode* GetThisNode () = 0;
01079 };
01080 
01081 SCF_VERSION (iAwsConnectionNodeFactory, 0, 0, 1);
01082 
01084 struct iAwsConnectionNodeFactory : public iBase
01085 {
01087    virtual void Initialize ()=0;
01089    virtual void AddConnectionKey (
01090                  const char* name,
01091                  iAwsSink *s,
01092                  unsigned long t,
01093                  unsigned long sig)=0;
01094 
01096    virtual awsConnectionNode* GetThisNode () = 0;
01097 };
01098 
01099 
01100 
01101 /* @} */
01102 
01103 #endif // __CS_IAWS_AWS_H__
01104 

Generated for Crystal Space by doxygen 1.2.14