home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / wxwin140 / include / wx_gdi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  9.0 KB  |  409 lines

  1. /*
  2.  * File:     wx_gdi.h
  3.  * Purpose:  Declaration of various graphics objects - fonts, pens, icons etc.
  4.  *
  5.  *                       wxWindows 1.40
  6.  * Copyright (c) 1993 Artificial Intelligence Applications Institute,
  7.  *                   The University of Edinburgh
  8.  *
  9.  *                     Author: Julian Smart
  10.  *                       Date: 18-4-93
  11.  *
  12.  * Permission to use, copy, modify, and distribute this software and its
  13.  * documentation for any purpose is hereby granted without fee, provided
  14.  * that the above copyright notice, author statement and this permission
  15.  * notice appear in all copies of this software and related documentation.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
  18.  * IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
  19.  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
  22.  * UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
  23.  * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
  24.  * LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
  25.  * DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
  26.  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
  27.  */
  28.  
  29.  
  30. #ifndef wx_gdih
  31. #define wx_gdih
  32.  
  33. #ifdef wx_motif
  34. #include <Xm/Xm.h>
  35. #endif
  36.  
  37. #ifdef wx_xview
  38. #include <xview/font.h>
  39. #include <xview/icon.h>
  40. #include <xview/cursor.h>
  41. #endif
  42.  
  43. #ifdef wx_msw
  44. #include <windows.h>
  45. #endif
  46.  
  47. // Standard cursors
  48. #define wxCURSOR_ARROW           1
  49. #define wxCURSOR_BULLSEYE        2
  50. #define wxCURSOR_CHAR            3
  51. #define wxCURSOR_CROSS           4
  52. #define wxCURSOR_HAND            5
  53. #define wxCURSOR_IBEAM           6
  54. #define wxCURSOR_LEFT_BUTTON     7
  55. #define wxCURSOR_MAGNIFIER       8
  56. #define wxCURSOR_MIDDLE_BUTTON   9
  57. #define wxCURSOR_NO_ENTRY       10
  58. #define wxCURSOR_PAINT_BRUSH    11
  59. #define wxCURSOR_PENCIL         12
  60. #define wxCURSOR_POINT_LEFT     13
  61. #define wxCURSOR_POINT_RIGHT    14
  62. #define wxCURSOR_QUESTION_ARROW 15
  63. #define wxCURSOR_RIGHT_BUTTON   16
  64. #define wxCURSOR_SIZENESW       17
  65. #define wxCURSOR_SIZENS         18
  66. #define wxCURSOR_SIZENWSE       19
  67. #define wxCURSOR_SIZEWE         20
  68. #define wxCURSOR_SIZING         21
  69. #define wxCURSOR_SPRAYCAN       22
  70. #define wxCURSOR_WAIT           23
  71. #define wxCURSOR_WATCH          24
  72.  
  73. // Font
  74. class wxFont: public wxObject
  75. {
  76.  public:
  77.   Bool temporary;   // If TRUE, the pointer to the actual font
  78.                     // is temporary and SHOULD NOT BE DELETED by
  79.                     // destructor
  80.   int point_size;
  81.   int family;
  82.   int style;
  83.   int weight;
  84. #ifdef wx_motif
  85.   XFontStruct *xFont;
  86. #endif
  87. #ifdef wx_xview
  88.   Xv_Font x_font;
  89. #endif
  90. #ifdef wx_msw
  91.   HFONT cfont;
  92. #endif
  93.   wxFont(void);
  94.   wxFont(int PointSize, int Family, int Style, int Weight);
  95.   ~wxFont(void);
  96.  
  97.   int GetPointSize(void);
  98. };
  99.  
  100. // Colour
  101. class wxColour: public wxObject
  102. {
  103.  public:
  104.   char red;
  105.   char blue;
  106.   char green;
  107.  
  108.   wxColour(char r, char b, char g);
  109.   wxColour(char *col);
  110.  
  111.   virtual void Set(char r, char b, char g);
  112.   virtual void Get(char *r, char *b, char *g);
  113.  
  114.   virtual char Red(void);
  115.   virtual char Green(void);
  116.   virtual char Blue(void);
  117. };
  118.  
  119. // Point
  120. class wxPoint: public wxObject
  121. {
  122.  public:
  123.   float x;
  124.   float y;
  125.   wxPoint(void);
  126.   wxPoint(float the_x, float the_y);
  127. };
  128.  
  129. // Pen
  130. class wxPen: public wxObject
  131. {
  132.  public:
  133.   int width;
  134.   int style;
  135.   wxColour *colour;
  136. #ifdef wx_msw
  137.   HPEN cpen;
  138. #endif
  139.  
  140.   wxPen(void);
  141.   wxPen(int width);
  142.   wxPen(wxColour& col, int width, int style);
  143.   wxPen(char *col, int width, int style);
  144.   ~wxPen(void);
  145.  
  146.   virtual void SetColour(wxColour& col);
  147.   virtual void SetColour(char *col);
  148.   virtual void SetColour(char r, char g, char b);
  149.  
  150.   virtual void SetWidth(int width);
  151.   virtual void SetStyle(int style);
  152.  
  153.   virtual wxColour &GetColour(void);
  154.   virtual int GetWidth(void);
  155.   virtual int GetStyle(void);
  156. };
  157.  
  158. #ifdef wx_msw
  159. int wx2msPenStyle(int wx_style);
  160. #endif
  161.  
  162. // Brush
  163. class wxBrush: public wxObject
  164. {
  165.  public:
  166.   int style;
  167.   wxColour *colour;
  168. #ifdef wx_msw
  169.   HBRUSH cbrush;
  170. #endif
  171.  
  172.   wxBrush(void);
  173.   wxBrush(wxColour& col, int style);
  174.   wxBrush(char *col, int style);
  175.   ~wxBrush(void);
  176.  
  177.   virtual void SetColour(wxColour& col);
  178.   virtual void SetColour(char *col);
  179.   virtual void SetColour(char r, char g, char b);
  180.  
  181.   virtual void SetStyle(int style);
  182.   virtual wxColour &GetColour(void);
  183.   virtual int GetStyle(void);
  184. };
  185.  
  186. // Icon
  187. class wxIcon: public wxObject
  188. {
  189.  public:
  190. #ifdef wx_motif
  191.   int iconWidth;
  192.   int iconHeight;
  193.   Pixmap x_pixmap;
  194. #endif
  195. #ifdef wx_xview
  196.   Server_image x_image;
  197.   Icon x_icon;
  198. #endif
  199. #ifdef wx_msw
  200.   HICON ms_icon;
  201. #endif
  202.   wxIcon(short bits[], int width, int height);
  203.   wxIcon(char *name);
  204.   ~wxIcon(void);
  205. };
  206.  
  207. // Cursor
  208. class wxCursor: public wxObject
  209. {
  210.  public:
  211. #ifdef wx_motif
  212.   Cursor x_cursor;
  213.   Bool use_raw_x_cursor;
  214. #endif
  215. #ifdef wx_xview
  216.   Xv_Cursor x_cursor;
  217.   Bool use_raw_x_cursor;
  218. #endif
  219. #ifdef wx_msw
  220.   HCURSOR ms_cursor;
  221. #endif
  222.   wxCursor(short bits[], int width, int height);
  223.   wxCursor(char *name);
  224.   wxCursor(int cursor_type);
  225.   ~wxCursor(void);
  226. };
  227.  
  228. // Bitmap
  229. class wxBitmap: public wxObject
  230. {
  231.  public:
  232.   int width;
  233.   int height;
  234.   int no_bits;
  235.   int no_planes;
  236. #ifdef wx_x
  237.   Pixmap x_pixmap;
  238. #endif
  239. #ifdef wx_xview
  240.   Server_image x_image;
  241. #endif
  242. #ifdef wx_msw
  243.   HBITMAP ms_bitmap;
  244. #endif
  245.   wxBitmap(short bits[], int width, int height, int no_bits = 1);
  246.   wxBitmap(char *name);
  247.   ~wxBitmap(void);
  248.  
  249.   inline int GetWidth(void) { return width; }
  250.   inline int GetHeight(void) { return height; }
  251. };
  252.  
  253. // Management of pens, brushes and fonts
  254. class wxPenList: public wxList
  255. {
  256.  public:
  257.   wxPenList(void)
  258.     { }
  259.   ~wxPenList(void);
  260.   void AddPen(wxPen *pen);
  261.   void RemovePen(wxPen *pen);
  262.   wxPen *FindOrCreatePen(wxColour *colour, int width, int style);
  263.   wxPen *FindOrCreatePen(char *colour, int width, int style);
  264. };
  265.  
  266. class wxBrushList: public wxList
  267. {
  268.  public:
  269.   wxBrushList(void)
  270.     { }
  271.   ~wxBrushList(void);
  272.   void AddBrush(wxBrush *brush);
  273.   void RemoveBrush(wxBrush *brush);
  274.   wxBrush *FindOrCreateBrush(wxColour *colour, int style);
  275.   wxBrush *FindOrCreateBrush(char *colour, int style);
  276. };
  277.  
  278. class wxColourDatabase: public wxList
  279. {
  280.  public:
  281.   wxColourDatabase(int type);
  282.   wxColour *FindColour(char *colour);
  283.   char *FindName(wxColour& colour);
  284.   void Initialize(void);
  285. };
  286.  
  287. class wxGDIList: public wxList
  288. {
  289.  public:
  290.    wxGDIList(void);
  291.   ~wxGDIList(void);
  292. };
  293.  
  294. // Lists of GDI objects
  295. extern wxPenList   *wxThePenList;
  296. extern wxBrushList *wxTheBrushList;
  297. extern wxGDIList   *wxTheIconList;
  298. extern wxGDIList   *wxTheFontList;
  299. extern wxGDIList   *wxTheBitmapList;
  300.  
  301. // Stock objects
  302. extern wxFont *wxNORMAL_FONT;
  303. extern wxFont *wxSMALL_FONT;
  304. extern wxFont *wxITALIC_FONT;
  305. extern wxFont *wxSWISS_FONT;
  306. extern wxPen *wxRED_PEN;
  307. extern wxPen *wxCYAN_PEN;
  308. extern wxPen *wxGREEN_PEN;
  309. extern wxPen *wxBLACK_PEN;
  310. extern wxPen *wxTRANSPARENT_PEN;
  311. extern wxPen *wxBLACK_DASHED_PEN;
  312.  
  313. extern wxBrush *wxBLUE_BRUSH;
  314. extern wxBrush *wxGREEN_BRUSH;
  315. extern wxBrush *wxWHITE_BRUSH;
  316. extern wxBrush *wxBLACK_BRUSH;
  317. extern wxBrush *wxGREY_BRUSH;
  318. extern wxBrush *wxMEDIUM_GREY_BRUSH;
  319. extern wxBrush *wxLIGHT_GREY_BRUSH;
  320. extern wxBrush *wxTRANSPARENT_BRUSH;
  321. extern wxBrush *wxCYAN_BRUSH;
  322. extern wxBrush *wxRED_BRUSH;
  323.  
  324. extern wxColour *wxBLACK;
  325. extern wxColour *wxWHITE;
  326. extern wxColour *wxRED;
  327. extern wxColour *wxBLUE;
  328. extern wxColour *wxGREEN;
  329. extern wxColour *wxCYAN;
  330. extern wxColour *wxLIGHT_GREY;
  331.  
  332. // Stock cursors types
  333. extern wxCursor *wxSTANDARD_CURSOR;
  334. extern wxCursor *wxHOURGLASS_CURSOR;
  335. extern wxCursor *wxCROSS_CURSOR;
  336.  
  337. extern wxColourDatabase *wxTheColourDatabase;
  338. extern void wxInitializeStockObjects(void);
  339.  
  340. extern Bool wxColourDisplay(void);
  341. extern void wxDisplaySize(int *width, int *height);
  342.  
  343. extern void wxSetCursor(wxCursor *cursor);
  344.  
  345. #ifdef wx_x
  346. // X-specific font matching mechanism
  347. class XFontInfo: public wxObject
  348. {
  349.  public:
  350.   int family;
  351.   int style;
  352.   int weight;
  353.   int point_size; // Points in XView, 10ths of a point in Motif
  354. #ifdef wx_xview
  355.   Xv_Font font;
  356. #endif
  357. #ifdef wx_motif
  358.   XFontStruct *font;
  359. #endif
  360.   XFontInfo(int the_family, int the_style, int the_weight, int the_point_size,
  361. #ifdef wx_xview
  362.             Xv_Font the_font);
  363. #endif
  364. #ifdef wx_motif
  365.             XFontStruct *the_font);
  366. #endif
  367. };
  368.  
  369. class XFontPool: public wxList
  370. {
  371.   XFontInfo *cache;
  372.  public:
  373.   XFontPool(void);
  374.   void AddFont(int family, int style, int weight, int point_size,
  375. #ifdef wx_xview
  376.                Xv_Font font);
  377. #endif
  378. #ifdef wx_motif
  379.                XFontStruct *font);
  380. #endif
  381. #ifdef wx_xview
  382.   Xv_Font
  383. #endif
  384. #ifdef wx_motif
  385.   XFontStruct *
  386. #endif
  387.     FindFont(int family, int style, int weight, int point_size);
  388.  
  389. #ifdef wx_xview
  390.   Xv_Font
  391. #endif
  392. #ifdef wx_motif
  393.   XFontStruct *
  394. #endif
  395.     FindOrCreateFont(int family, int style, int weight, int point_size, int point_size_to_store, int xres, int yres);
  396.  
  397. #ifdef wx_xview
  398.   Xv_Font FindNearestFont(int family, int style, int weight, int point_size, int xres, int yres);
  399. #endif
  400. #ifdef wx_motif
  401.   XFontStruct *FindNearestFont(int family, int style, int weight, int point_size, int xres, int yres);
  402. #endif
  403. };
  404.  
  405. extern XFontPool *wxFontPool;
  406. #endif
  407.  
  408. #endif // wx_gdih
  409.