CrystalSpace

Public API Reference

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

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 #ifndef __CS_IAWS_AWS_H__
00019 #define __CS_IAWS_AWS_H__
00020 
00025 #include "csutil/scf.h"
00026 #include "csgeom/csrect.h"
00027 #include "csgeom/cspoint.h"
00028 #include "csutil/csvector.h"
00029 #include "iutil/string.h"
00030 
00031 struct iAws;
00032 struct iAwsSlot;
00033 struct iAwsSink;
00034 struct iAwsSource;
00035 struct iAwsParmList;
00036 struct iAwsComponent;
00037 struct iAwsPrefManager;
00038 struct iAwsSinkManager;
00039 struct iAwsCanvas;
00040 struct iAwsKeyFactory;
00041 struct iAwsComponentFactory;
00042 struct iAwsConnectionNodeFactory;
00043 
00044 typedef iAwsComponent iAwsWindow;
00045 
00046 class  awsWindow;
00047 class  awsComponent;
00048 class  awsComponentNode;
00049 class  awsConnectionNode;
00050 class  awsComponentFactory;
00051 class  awsLayoutManager;
00052 
00053 struct  iGraphics2D;
00054 struct  iGraphics3D;
00055 struct  iEngine;
00056 struct  iView;
00057 struct  iTextureManager;
00058 struct  iObjectRegistry;
00059 struct  iTextureHandle;
00060 struct  iFontServer;
00061 struct  iFont;
00062 struct  iEvent;
00063 
00064 const   bool aws_debug=false;  // set to true to turn on debugging printf's
00065 
00074 const int AWSF_AlwaysEraseWindows=1;
00075 
00082 const int AWSF_AlwaysRedrawWindows=2;
00083 
00088 const int AWSF_RaiseOnMouseOver = 4;
00089 
00094 SCF_VERSION(iAwsKey, 0, 0, 1)
00095 
00096 struct iAwsKey : public iBase
00097 {
00099   virtual uint8 Type () = 0;
00100 
00102   virtual unsigned long Name () = 0;
00103 };
00104 
00105 SCF_VERSION(iAwsIntKey, 0, 0, 1)
00106 
00107 struct iAwsIntKey : public iAwsKey
00108 {
00110   virtual int Value () = 0;
00111 };
00112 
00113 SCF_VERSION(iAwsStringKey, 0, 0, 1);
00114 
00115 struct iAwsStringKey : public iAwsKey
00116 {
00118   virtual iString* Value () = 0;
00119 };
00120 
00121 SCF_VERSION(iAwsRectKey, 0, 0, 1);
00122 
00123 struct iAwsRectKey : public iAwsKey
00124 {
00126   virtual csRect Value () = 0;
00127 };
00128 
00129 SCF_VERSION(iAwsRGBKey, 0, 0, 1);
00130 
00131 struct iAwsRGBKey : public iAwsKey
00132 {
00133   struct RGB
00134   { 
00135     unsigned char red, green, blue;
00136   };
00137   
00139   virtual iAwsRGBKey::RGB &Value() = 0;
00140 };
00141 
00142 SCF_VERSION(iAwsPointKey, 0, 0, 1);
00143 
00144 struct iAwsPointKey : public iAwsKey
00145 {
00147   virtual csPoint Value () = 0;
00148 };
00149 
00150 SCF_VERSION(iAwsConnectionKey, 0, 0, 1);
00151 
00152 struct iAwsConnectionKey : public iAwsKey
00153 {
00155   virtual iAwsSink *Sink () = 0;
00156 
00158   virtual unsigned long Trigger () = 0;
00159 
00161   virtual unsigned long Signal () = 0;
00162 };
00163 
00164 SCF_VERSION(iAwsKeyContainer, 0, 0, 1);
00165 
00166 struct iAwsKeyContainer : public iAwsKey
00167 {
00169   virtual iAwsKey* Find (iString* name) = 0;
00170 
00172   virtual iAwsKey* Find (const char* name) = 0;
00173 
00175   virtual iAwsKey *Find (unsigned long id) = 0;
00176 
00177   virtual csBasicVector &Children () = 0;
00178 
00180   virtual void Add (iAwsKey *key) = 0;
00181 
00183   virtual iAwsKey* GetAt (int i) = 0;
00184 
00186   virtual int Length () = 0;
00187     
00189   virtual void Remove (iString *name) = 0;
00191   virtual void Remove (const char* name) = 0;
00193   virtual void Remove (iAwsKey *key) = 0;
00195   virtual void RemoveAll () = 0;
00196 
00198   virtual void Consume (iAwsKeyContainer *c) = 0;
00199 };
00200 
00201 SCF_VERSION(iAwsComponentNode, 0, 0, 1);
00202 
00203 struct iAwsComponentNode : public iAwsKeyContainer
00204 {
00206   virtual iString *ComponentTypeName () = 0;
00207 };
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00219 SCF_VERSION (iAws, 0, 2, 1);
00220 
00222 struct iAws : public iBase
00223 {
00224 public:
00226   virtual iAwsPrefManager *GetPrefMgr()=0;
00227 
00229   virtual iAwsSinkManager *GetSinkMgr()=0;
00230 
00232   virtual void SetPrefMgr(iAwsPrefManager *pmgr)=0;
00233 
00235   virtual void RegisterComponentFactory(iAwsComponentFactory *factory, const char* name)=0;
00236 
00238   virtual iAwsComponentFactory *FindComponentFactory (const char* name)=0;
00239 
00241   virtual iAwsComponent *GetTopComponent()=0;
00242 
00244   virtual void SetTopComponent(iAwsComponent *win)=0;
00245 
00247   virtual iAwsComponent* ComponentAt(int x, int y)=0;
00248 
00250   virtual bool MouseInComponent(int x, int y)=0;
00251 
00253   virtual void Print(iGraphics3D *g3d, uint8 Alpha=0)=0;
00254 
00256   virtual void Redraw()=0;
00257 
00259   virtual void Mark(const csRect &rect)=0;
00260 
00262   virtual void Unmark(const csRect &rect)=0;
00263 
00265   virtual void Erase(const csRect &rect)=0;
00266 
00268   virtual void MaskEraser(const csRect &rect)=0;
00269 
00271   virtual void InvalidateUpdateStore()=0;
00272 
00274   virtual void CaptureMouse(iAwsComponent *comp)=0;
00275 
00277   virtual void ReleaseMouse()=0;
00278 
00280   virtual bool HandleEvent(iEvent&)=0;
00281 
00283   virtual void SetCanvas(iAwsCanvas *newCanvas)=0;
00284 
00286   virtual iAwsCanvas* GetCanvas()=0;
00287 
00289   virtual iAwsCanvas *CreateDefaultCanvas(iEngine* engine, iTextureManager* txtmgr)=0;
00290 
00292   virtual iAwsCanvas *CreateDefaultCanvas(iEngine* engine, iTextureManager* txtmgr,
00293     int width, int height, const char *name)=0;
00294 
00296   virtual iAwsCanvas *CreateCustomCanvas(iGraphics2D *g2d, iGraphics3D *g3d)=0;
00297 
00299   virtual iGraphics2D *G2D()=0;
00300 
00302   virtual iGraphics3D *G3D()=0;
00303 
00305   virtual iAwsComponent *CreateWindowFrom(const char* defname)=0;
00306 
00308   virtual iAwsComponent *CreateEmbeddableComponent()=0;
00309 
00311   virtual iAwsParmList *CreateParmList()=0;
00312 
00318   virtual void CreateTransition(iAwsComponent *win, unsigned transition_type, float step_size=0.1)=0;
00319 
00325   virtual void CreateTransitionEx(iAwsComponent *win, unsigned transition_type, float step_size, csRect &user)=0;
00326 
00332   virtual void SetFlag(unsigned int flags)=0;
00333 
00339   virtual void ClearFlag(unsigned int flags)=0;
00340 
00346   virtual unsigned int GetFlags()=0;
00347   
00349   virtual iObjectRegistry *GetObjectRegistry ()=0;
00350 
00352   virtual bool AllWindowsHidden()=0;
00353 
00354 };
00355 
00356 SCF_VERSION (iAwsPrefManager, 0, 0, 3);
00357 
00359 struct iAwsPrefManager : public iBase
00360 {
00361 public:
00363   virtual bool Setup(iObjectRegistry *object_reg)=0;
00364 
00366   virtual bool Load(const char *def_file)=0;
00367 
00369   virtual unsigned long NameToId (const char*name)=0;
00370 
00372   virtual bool SelectDefaultSkin (const char* skin_name)=0;
00373 
00375   virtual bool LookupIntKey (const char* name, int &val)=0;
00376 
00378   virtual bool LookupIntKey(unsigned long id, int &val)=0;
00379 
00381   virtual bool LookupStringKey(const char* name, iString *&val)=0;
00382 
00384   virtual bool LookupStringKey(unsigned long id, iString *&val)=0;
00385 
00387   virtual bool LookupRectKey(const char* name, csRect &rect)=0;
00388 
00390   virtual bool LookupRectKey(unsigned long id, csRect &rect)=0;
00391 
00393   virtual bool LookupRGBKey(const char* name, unsigned char &red, unsigned char &green, unsigned char &blue)=0;
00394 
00396   virtual bool LookupRGBKey(unsigned long id, unsigned char &red, unsigned char &green, unsigned char &blue)=0;
00397 
00399   virtual bool LookupPointKey(const char* name, csPoint &point)=0;
00400 
00402   virtual bool LookupPointKey(unsigned long id, csPoint &point)=0;
00403 
00405   virtual bool GetInt(iAwsComponentNode *node, const char* name, int &val)=0;
00406 
00408   virtual bool GetRect(iAwsComponentNode *node, const char* name, csRect &rect)=0;
00409 
00411   virtual bool GetString(iAwsComponentNode *node, const char* name, iString *&val)=0;
00412 
00414   virtual bool GetRGB(iAwsComponentNode *node, const char* name, unsigned char& r, unsigned char& g, unsigned char& b)=0;
00415 
00417   virtual iAwsComponentNode *FindWindowDef(const char* name)=0;
00418 
00420   virtual iAwsKeyContainer *FindSkinDef(const char* name)=0;
00421 
00423   virtual bool RemoveWindowDef (const char *name)=0;
00424 
00426   virtual void RemoveAllWindowDefs ()=0;
00427 
00429   virtual bool RemoveSkinDef (const char *name)=0;
00430 
00432   virtual void RemoveAllSkinDefs ()=0;
00433 
00435   virtual void SetColor(int index, int color)=0;
00436 
00438   virtual int  GetColor(int index)=0;
00439 
00441   virtual int FindColor(unsigned char r, unsigned char g, unsigned char b)=0;
00442 
00444   virtual iFont *GetDefaultFont()=0;
00445 
00447   virtual iFont *GetFont(const char* filename)=0;
00448 
00450   virtual iTextureHandle *GetTexture(const char* name, const char* filename=NULL)=0;
00451 
00454   virtual iTextureHandle *GetTexture (const char* name, const char* filename, 
00455                                       unsigned char key_r,
00456                                       unsigned char key_g,
00457                                       unsigned char key_b)=0;
00458 
00460   virtual void SetTextureManager(iTextureManager *txtmgr)=0;
00461 
00463   virtual void SetFontServer(iFontServer *fntsvr)=0;
00464 
00466   virtual void SetWindowMgr(iAws *wmgr)=0;
00467 
00473   virtual void SetupPalette()=0;
00474 
00476   virtual void RegisterConstant(const char* name, int value)=0;
00477 
00479   virtual bool ConstantExists(const char* name)=0;
00480 
00482   virtual int  GetConstantValue(const char* name)=0;
00483 
00485   virtual iAwsKeyFactory *CreateKeyFactory()=0;
00486 
00488   virtual iAwsConnectionNodeFactory *CreateConnectionNodeFactory()=0;
00489 };
00490 
00491 
00492 SCF_VERSION (iAwsSinkManager, 0, 0, 2);
00493 
00495 struct iAwsSinkManager : public iBase
00496 {
00498   virtual void RegisterSink(const char *name, iAwsSink *sink)=0;
00499 
00500   virtual bool RemoveSink (iAwsSink* sink) = 0;
00501 
00503   virtual iAwsSink* FindSink(const char *name)=0;
00504 
00506   virtual iAwsSink *CreateSink(void *parm)=0;
00507 
00508 
00509 
00511 
00512   virtual iAwsSlot *CreateSlot ()=0;
00513 };
00514 
00515 
00516 SCF_VERSION (iAwsSink, 0, 0, 2);
00517 
00519 struct iAwsSink : public iBase
00520 {
00522   virtual unsigned long GetTriggerID(const char *name)=0;
00523 
00525   virtual void HandleTrigger(int trigger_id, iAwsSource *source)=0;
00526 
00528   virtual void RegisterTrigger(const char *name, void (*Trigger)(void *, iAwsSource *))=0;
00529 
00535   virtual unsigned int GetError()=0;
00536 };
00537 
00538 
00539 SCF_VERSION (iAwsSource, 0, 0, 1);
00540 
00542 struct iAwsSource : public iBase
00543 {
00545   virtual iAwsComponent *GetComponent()=0;
00546 
00548   virtual bool RegisterSlot(iAwsSlot *slot, unsigned long signal)=0;
00549 
00551   virtual bool UnregisterSlot(iAwsSlot *slot, unsigned long signal)=0;
00552 
00554   virtual void Broadcast(unsigned long signal)=0;
00555 };
00556 
00557 
00558 SCF_VERSION (iAwsSlot, 0, 0, 1);
00559 
00561 struct iAwsSlot : public iBase
00562 {
00566   virtual void Connect(iAwsSource *source, unsigned long signal, iAwsSink *sink, unsigned long trigger)=0;
00567 
00571   virtual void Disconnect(iAwsSource *source, unsigned long signal, iAwsSink *sink, unsigned long trigger)=0;
00572 
00575   virtual void Emit(iAwsSource &source, unsigned long signal)=0;
00576 };
00577 
00578 SCF_VERSION(iAwsLayoutManager, 0, 0, 1);
00579 
00580 struct iAwsLayoutManager : public iBase
00581 {
00587   virtual void SetOwner (iAwsComponent *_owner) = 0;
00588 
00591   virtual csRect AddComponent (iAwsComponent *cmp, iAwsComponentNode* settings) = 0;
00592 
00594   virtual void RemoveComponent(iAwsComponent* ) = 0;
00595 
00597   virtual void LayoutComponents () = 0;
00598 };
00599 
00600 SCF_VERSION (iAwsComponent, 0, 1, 3);
00601 
00603 struct iAwsComponent : public iAwsSource
00604 {
00605   
00616   virtual bool Create(iAws* mgr, iAwsComponent* parent, iAwsComponentNode* settings)=0;
00617 
00619   virtual bool Setup(iAws *wmgr, iAwsComponentNode *settings)=0;
00620 
00622   virtual bool HandleEvent(iEvent& Event)=0;
00623 
00625   virtual bool GetProperty(const char* name, void **parm)=0;
00626 
00628   virtual bool SetProperty(const char* name, void *parm)=0;
00629 
00631   virtual bool Execute(const char* action, iAwsParmList* parmlist = NULL) = 0;
00632 
00634   virtual void Invalidate()=0;
00635 
00637   virtual void Invalidate(csRect area)=0;
00638 
00640   virtual csRect Frame()=0;
00641 
00643   virtual csRect ClientFrame()=0;
00644 
00646   virtual const char *Type()=0;
00647 
00653   virtual void SetFlag(unsigned int flag)=0;
00654 
00660   virtual void ClearFlag(unsigned int flag)=0;
00661 
00667   virtual unsigned int Flags()=0;
00668 
00670   virtual iAws *WindowManager ()=0;
00671 
00673   virtual iAwsComponent *Parent()=0;
00674 
00676   virtual iAwsComponent *Window()=0;
00677 
00679   virtual iAwsLayoutManager *Layout()=0;
00680 
00682   virtual void SetParent(iAwsComponent *parent)=0;
00683 
00685   virtual void SetLayout(iAwsLayoutManager *layout)=0;
00686 
00688   virtual void AddToLayout(iAwsComponent *cmp, iAwsComponentNode *settings)=0;
00689   
00691   virtual csRect getPreferredSize()=0;
00692 
00694   virtual csRect getMinimumSize()=0;
00695 
00697   virtual csRect getInsets()=0;
00698 
00700   virtual bool Overlaps(csRect &r)=0;
00701 
00703   virtual bool isHidden()=0;
00704 
00706   virtual bool IsMaximized()=0;
00707 
00709   virtual void Hide()=0;
00710 
00712   virtual void Show()=0;
00713 
00715   virtual void Move(int delta_x, int delta_y)=0;
00716 
00718   virtual void MoveTo(int x, int y)=0;
00719 
00721   virtual void Resize(int width, int height)=0;
00722 
00724   virtual void ResizeTo(csRect newFrame)=0;
00725 
00727   virtual void Maximize()=0;
00728 
00730   virtual void UnMaximize()=0;
00731 
00733   virtual void LayoutChildren()=0;
00734 
00736   virtual bool isDeaf()=0;
00737 
00739   virtual void SetDeaf (bool bDeaf)=0;
00740 
00742   virtual unsigned long GetID()=0;
00743 
00745   virtual void SetID(unsigned long _id)=0;
00746 
00748   virtual iAwsComponent *FindChild(const char *name)=0;
00749 
00751   virtual iAwsComponent *DoFindChild(unsigned id)=0;
00752 
00754   virtual iAwsComponent* ChildAt(int x, int y)=0;
00755 
00757   virtual void AddChild(iAwsComponent* child)=0;
00758 
00760   virtual void RemoveChild(iAwsComponent *child)=0;
00761 
00763   virtual int GetChildCount()=0;
00764 
00766   virtual iAwsComponent *GetTopChild()=0;
00767 
00769   virtual iAwsComponent *ComponentAbove()=0;
00770 
00772   virtual iAwsComponent *ComponentBelow()=0;
00773 
00775   virtual void SetComponentAbove(iAwsComponent *comp)=0;
00776 
00778   virtual void SetComponentBelow(iAwsComponent *comp)=0;
00779 
00781   virtual void Raise()=0;
00782 
00784   virtual void Lower()=0;
00785 
00787   virtual bool HasChildren()=0;
00788 
00790   virtual void SetRedrawTag(unsigned int tag)=0;
00791 
00793   virtual unsigned int RedrawTag()=0;
00794 
00796   virtual void OnDraw(csRect clip)=0;
00797 
00799   virtual bool OnMouseDown(int button, int x, int y)=0;
00800 
00802   virtual bool OnMouseUp(int button, int x, int y)=0;
00803 
00805   virtual bool OnMouseMove(int button, int x, int y)=0;
00806 
00808   virtual bool OnMouseClick(int button, int x, int y)=0;
00809 
00811   virtual bool OnMouseDoubleClick(int button, int x, int y)=0;
00812 
00814   virtual bool OnMouseExit()=0;
00815 
00817   virtual bool OnMouseEnter()=0;
00818 
00820   virtual bool OnKeypress(int key, int cha, int modifiers)=0;
00821 
00823   virtual bool OnLostFocus()=0;
00824 
00826   virtual bool OnGainFocus()=0;
00827 
00829   virtual bool OnFrame()=0;
00830 
00832   virtual void OnAdded()=0;
00833 
00835   virtual void OnResized()=0;
00836 
00838   virtual void OnChildMoved() = 0;
00839 
00841   virtual void OnRaise()=0;
00842 
00844   virtual void OnLower()=0;
00845 
00847   virtual void OnChildHide()=0;
00848 
00850   virtual void OnChildShow()=0;
00851 
00852 
00853   /* Only awsComponent should make use of the funcs below. Nothing else =) */
00854 
00856     virtual void Unlink()=0;
00857 
00859     virtual void LinkAbove(iAwsComponent* comp)=0;
00860 
00862     virtual void LinkBelow(iAwsComponent* comp)=0;
00863 
00865         virtual void SetTopChild(iAwsComponent* child)=0;
00866 
00867 };
00868 
00869 
00870 SCF_VERSION (iAwsComponentFactory, 0, 0, 2);
00871 
00873 struct iAwsComponentFactory : public iBase
00874 {
00876   virtual iAwsComponent *Create()=0;
00877 
00879   virtual void Register(const char *type)=0;
00880 
00882   virtual void RegisterConstant(const char *name, int value)=0;
00883 };
00884 
00885 
00886 SCF_VERSION (iAwsKeyFactory, 0, 0, 4);
00887 
00889 struct iAwsKeyFactory : public iBase
00890 {
00892    virtual void Initialize(const char* name, const char* component_type)=0;
00894    virtual void AddToWindowList(iAwsPrefManager *pm)=0;
00896    virtual void AddFactory(iAwsKeyFactory *factory)=0;
00898    virtual void AddIntKey (const char* name, int v)=0;
00900    virtual void AddStringKey (const char* name, const char* v)=0;
00902    virtual void AddRectKey (const char* name, csRect v)=0;
00904    virtual void AddRGBKey (const char* name, unsigned char r, unsigned char g, unsigned char b)=0;
00906    virtual void AddPointKey (const char* name, csPoint v)=0;
00908    virtual void AddConnectionKey (const char* name, iAwsSink *s, unsigned long t, unsigned long sig)=0;
00910    virtual void AddConnectionNode (iAwsConnectionNodeFactory *node)=0;
00911    
00912    virtual iAwsComponentNode* GetThisNode () = 0;
00913 };
00914 
00915 SCF_VERSION (iAwsConnectionNodeFactory, 0, 0, 1);
00916 
00918 struct iAwsConnectionNodeFactory : public iBase
00919 {
00921    virtual void Initialize ()=0;
00923    virtual void AddConnectionKey (
00924                  const char* name,
00925                  iAwsSink *s,
00926                  unsigned long t,
00927                  unsigned long sig)=0;
00928 
00930    virtual awsConnectionNode* GetThisNode () = 0;
00931 };
00932 
00933 
00934 
00935 /* @} */
00936 
00937 #endif // __CS_IAWS_AWS_H__

Generated for Crystal Space by doxygen 1.2.14