f7242c14df1727247dbf5a30c452cbde32f249c9
[AXE.git] / src / frame.h
1
2 /**************************************************************************
3 **  (c) Copyright 1998, Andromeda Technology & Automation
4 ***************************************************************************
5 ** MODULE INFORMATION *
6 ***********************
7 **      FILE NAME      : frame.h
8 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
9 **      VERSION NUMBER : $Revision: 1.1 $
10 **
11 **  DESCRIPTION      :  Definition of the frame class
12 **
13 **  EXPORTED OBJECTS : 
14 **  LOCAL    OBJECTS : 
15 **  MODULES  USED    :
16 ***************************************************************************
17 **  ADMINISTRATIVE INFORMATION *
18 ********************************
19 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
20 **      CREATION DATE   : Mar 06, 1998
21 **      LAST UPDATE     : Mar 13, 1998
22 **      MODIFICATIONS   : 
23 **************************************************************************/
24
25 /*****************************
26    $Log: frame.h,v $
27    Revision 1.1  2002-07-25 08:01:27  arjen
28    First checkin, AXE release 0.2
29
30 *****************************/
31
32 /* static const char *RCSID = "$Id: frame.h,v 1.1 2002-07-25 08:01:27 arjen Exp $"; */
33
34 #ifndef FRAME_H
35 #define FRAME_H
36
37 #include "xappl.h"
38
39
40 /*
41 ///////////////////////////////////////////////////////////////////////////
42 //  NAME           : frame - window with border effect and aligned text
43 //  BASECLASS      : window
44 //  MEMBERS        : text     : The text to draw in the frame (may be 0).
45 //                   valign   : Vertical alignment of the text
46 //                   halign   : Horizontal alignment of the text.
47 //                   effect   : Type of border: 3D, Shadow, etc
48 //                   strength : Of the border effect. 0 = no effect, 
49 //                              positive means 'Up'; negative is 'Down'
50 //
51 //  OPERATORS      :
52 //  METHODS        : PRIVATE draw_effect()  : Draw border effect
53 //                   PRIVATE place_text()   : Draw the aligned text
54 //
55 //                   TextAlign()  : Set aligment of the text
56 //                   Strength()   : Change or read the strength of the effect.
57 //
58 //  DESCRIPTION    : A frame adds two visual effects to a window:
59 //                     1.  A border effect (3D or shadow)
60 //                     2.  An aligned line of text.
61 //
62 //  RELATIONS      :
63 //  SEE ALSO       :
64 //  LAST MODIFIED  :
65 ///////////////////////////////////////////////////////////////////////////
66 */
67
68 enum   hor_alignment { Left, Center, Right };
69 enum   ver_alignment { Top, Middle, Bottom };
70
71 class frame : public window
72 {
73    char      *text;
74
75    hor_alignment halign;
76    ver_alignment valign;
77
78    enum      { TriD, Shadow } effect;
79
80    int       strength;
81
82    void draw_effect(void);
83
84    void place_text(void);
85
86    virtual int  EV_Expose(XExposeEvent ev);
87
88 public:
89
90    frame(window &par, int x, int y, int s = 3) : window(par, x, y, 80, 30)
91    {
92       Background(inside_3D);
93       strength = s;
94       effect   = TriD;
95       text     = 0;
96       halign   = Center;
97       valign   = Middle;
98       SelectInput(ExposureMask, 1);
99    }
100
101    frame(window &par, int x, int y, char *t) : window(par, x, y, 80, 30)
102    {
103       Background(inside_3D);
104       strength = 5;
105       effect   = TriD;
106       text     = t;
107       halign   = Center;
108       valign   = Middle;
109       SelectInput(ExposureMask, 1);
110    }
111
112    void TextAlign(hor_alignment hor, ver_alignment ver)
113    {
114       halign = hor;
115       valign = ver;
116       place_text();
117    }
118
119    void Strength(int s)
120    {
121       strength = s;
122       draw_effect();
123    }
124    int Strength(void)
125    {
126       return strength;
127    }
128
129    virtual void redraw(void)
130    {
131    }
132 };
133
134 #endif /* FRAME_H */
135