home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / aplusplus-1.01-src.lha / src / amiga / aplusplus-1.01 / include / aplusplus / graphics / GraphicObject.h < prev    next >
C/C++ Source or Header  |  1994-05-04  |  6KB  |  133 lines

  1. #ifndef APP_GraphicObject_H
  2. #define APP_GraphicObject_H
  3. /******************************************************************************
  4.  **
  5.  **    C++ Class Library for the Amiga© system software.
  6.  **
  7.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  8.  **    All Rights Reserved.
  9.  **
  10.  **    $VER: apphome:APlusPlus/graphics/GraphicObject.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14. extern "C" {
  15. #include <intuition/intuition.h>
  16. #include <intuition/gadgetclass.h>
  17. }
  18. #include <APlusPlus/intuition/IntuiObject.h>
  19. #include <APlusPlus/graphics/RectObject.h>
  20. #include <APlusPlus/graphics/GBorder.h>
  21.  
  22.  
  23. #define GOB_OWNER GraphicObject *gob_owner
  24.  
  25. /******************************************************************************************
  26.       » GraphicObject class «    virtual base class
  27.  
  28.    This class enhances the IntuiObject class to handle all objects within a GUI that have
  29.    any kind of graphical dimensions (Windows, Gadgets e.t.c).
  30.    GraphicObjects can incorporate other GraphicObjects which have a common GraphicObject
  31.    as owner. These depending GraphicObjects are placed within their owner relative
  32.    to the owners dimensions.
  33.    A GraphicObject itself can be used to group several GraphicObject derived objects.
  34.  
  35.  ******************************************************************************************/
  36. class GWindow;
  37. class GraphicObject : public IntuiObject, virtual public RectObject
  38. {
  39.     private:
  40.         
  41.    protected:
  42.       GraphicObject(GOB_OWNER,AttrList& attrs);    // create GO without ITransponder
  43.       ~GraphicObject();
  44.  
  45.       virtual void adjustChilds();  // adjust dimensions relative to the owner
  46.  
  47.    public:
  48.       virtual APTR redrawSelf(GWindow *home,ULONG& returnType);
  49.          /** redrawSelf() is called each time the home window has changed size
  50.           ** to have the GraphicObjects redraw themselves after they have been
  51.           ** adjusted to the new size (i.e. left(),top(),width() and height() are already set.)
  52.           ** GadgetCV derived classes have to return their incorporated gadget
  53.           ** structure/list to have it attached to the window.
  54.           **/
  55.           
  56.       ULONG setAttributes(AttrList& attrs);
  57.         ULONG getAttribute(Tag,ULONG&);
  58. };
  59.  
  60. #define GOB_Spec_Dummy    (TAG_USER | GRAPHICOBJECT)
  61.  
  62. #define gob_edge     8
  63. #define gob_reledge  4
  64. #define gob_orient   2
  65. #define gob_relative 1
  66. #define gob_spec(edge,reledge,orient,relative) (gob_edge*edge+gob_reledge*reledge+gob_orient*orient+gob_relative*relative)
  67.  
  68. #define GOB_LeftFromLeftOfParent       (GOB_Spec_Dummy + gob_spec(0,0,0,0))
  69. #define GOB_RightFromLeftOfParent      (GOB_Spec_Dummy + gob_spec(1,0,0,0))
  70. #define GOB_TopFromTopOfParent         (GOB_Spec_Dummy + gob_spec(0,0,1,0))
  71. #define GOB_BottomFromTopOfParent      (GOB_Spec_Dummy + gob_spec(1,0,1,0))
  72.  
  73. #define GOB_LeftFromRightOfParent      (GOB_Spec_Dummy + gob_spec(0,1,0,0))
  74. #define GOB_RightFromRightOfParent     (GOB_Spec_Dummy + gob_spec(1,1,0,0))
  75. #define GOB_TopFromBottomOfParent      (GOB_Spec_Dummy + gob_spec(0,1,1,0))
  76. #define GOB_BottomFromBottomOfParent   (GOB_Spec_Dummy + gob_spec(1,1,1,0))
  77.  
  78. #define GOB_LeftFromLeftOfPred         (GOB_Spec_Dummy + gob_spec(0,0,0,1))
  79. #define GOB_RightFromLeftOfPred        (GOB_Spec_Dummy + gob_spec(1,0,0,1))
  80. #define GOB_TopFromTopOfPred           (GOB_Spec_Dummy + gob_spec(0,0,1,1))
  81. #define GOB_BottomFromTopOfPred        (GOB_Spec_Dummy + gob_spec(1,0,1,1))
  82.  
  83. #define GOB_LeftFromRightOfPred        (GOB_Spec_Dummy + gob_spec(0,1,0,1))
  84. #define GOB_RightFromRightOfPred       (GOB_Spec_Dummy + gob_spec(1,1,0,1))
  85. #define GOB_TopFromBottomOfPred        (GOB_Spec_Dummy + gob_spec(0,1,1,1))
  86. #define GOB_BottomFromBottomOfPred     (GOB_Spec_Dummy + gob_spec(1,1,1,1))
  87.  
  88. #define GOB_Dummy  (GOB_Spec_Dummy + 16)
  89.  
  90. #define GOB_Left        GOB_LeftFromLeftOfParent
  91. #define GOB_Top         GOB_TopFromTopOfParent
  92. #define GOB_Right       GOB_RightFromLeftOfParent
  93. #define GOB_Bottom      GOB_BottomFromTopOfParent
  94.  
  95. #define GOB_Width       (GOB_Dummy + 1)
  96. #define GOB_Height      (GOB_Dummy + 2)
  97.  
  98. #define BDR_Dummy            (GOB_Dummy + 64)
  99.  
  100. //#define GOB_Percent(frac)  ( ( ((ULONG)0xffff)*frac ) )
  101. /** GOB_Percent computes a fraction that relates the dimension of a GraphicObject to
  102.  ** the same dimension of the owner. Proportional dimensions can be used with all GOB_ tags.
  103.  ** They are recognized by their sign: negative values are considered percentual values while
  104.  ** positive values are taken as absolute distances in pixel.
  105.  ** For instance, set a gadget a third of the windows width and 2/3 of this width
  106.  ** from the left egde:
  107.  **
  108.  **   GraphicObject(window, GOB_Left,GOB_Percent(2/3),GOB_Width,GOB_Percent(1/3)
  109.  **
  110.  ** Make sure that the denominator (here '2' of '2/3') is smaller than 65535 to prevent an
  111.  ** integer overflow!
  112.  **/
  113.  
  114. // Percent & Absolute do not work at the moment!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  115. #define GOB_Absolute(related,value) ((XYVAL)value)
  116. /*( ((LONG)(value)) > 0xffff ?          \
  117.          ( ( ((ULONG)(related)) * ( ((LONG)(value))-0xffff ) ) / 0x0000ffff)  :  value )
  118. */         
  119. /** GOB_Absolute gives the absolute value of a GOB_Percent tag data.
  120.  ** It determines if the value given is meant to be absolute or percentual. For percentual
  121.  ** values, which have to be defined with GOB_Percent(), it computes the fraction of the related
  122.  ** length and returns an absolute value.
  123.  **/
  124.  
  125. #define GOB_Border        (GOB_Dummy + 3)
  126. #define GOB_BorderObj(borderobj) GOB_Border,GBorder::confirm(borderobj)
  127.     /* GOB_Border allows the class user to specify a Border object that draws some kind
  128.      *    of border around the GraphicObject. Use the GOB_BorderObj(Border* borderkind) macro
  129.      *    rather than the GOB_Border tag since the first assures type checking.
  130.      */
  131.          
  132. #endif   /* GraphicObject.h */
  133.