]> git.lyx.org Git - lyx.git/blob - src/toolbar.h
white-space changes, removed definitions.h several enum changes because of this,...
[lyx.git] / src / toolbar.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4
5 *           LyX, The Document Processor
6 *           Copyright (C) 1995 Matthias Ettrich
7 *
8 *           This file is Copyright (C) 1996-1998
9 *           Lars Gullik Bjønnes
10 *
11 * ====================================================== */
12
13 #ifndef TOOLBAR_H
14 #define TOOLBAR_H
15
16 #ifdef __GNUG__
17 #pragma interface
18 #endif
19
20 #include FORMS_H_LOCATION
21 #include "lyxfunc.h"
22 #include "lyxlex.h"
23 #include "combox.h"
24
25 /** The LyX toolbar class
26   This class {\em is} the LyX toolbar, and is not likely to be enhanced
27   further until we begin the move to Qt. We will probably have to make our
28   own QToolBar, at least until Troll Tech makes theirs.
29   */
30 class Toolbar {
31 public:
32         ///
33         Toolbar(Toolbar const &, LyXView *o, int x, int y);
34
35         ///
36         Toolbar()
37         {
38                 owner = 0;
39                 sxpos = 0;
40                 sypos = 0;
41                 bubble_timer = 0;
42                 combox = 0;
43                 reset();
44                 init(); // set default toolbar.
45         }
46
47         ///
48         ~Toolbar() {
49                 clean();
50         }
51         
52         ///
53         int get_toolbar_func(string const & func);
54         
55         /// The special toolbar actions
56         enum  TOOLBARITEMS {
57                 /// adds space between buttons in the toolbar
58                 TOOL_SEPARATOR = -1,
59                 /// a special combox insead of a button
60                 TOOL_LAYOUTS = -2,
61                 /// begin a new line of button (not working)
62                 TOOL_NEWLINE = -3
63         };
64
65         ///
66         Combox *combox;
67
68         ///
69         void read(LyXLex&);
70         /// sets up the default toolbar
71         void init();
72         /// (re)sets the toolbar
73         void set(bool doingmain= false);
74
75         /** this is to be the entry point to the toolbar
76           frame, where you can change the toolbar realtime. */
77         void edit();
78         /// add a new button to the toolbar.
79         void add(int , bool doclean= true);
80         /// name of func instead of kb_action
81         void add(string const & , bool doclean= true);
82         /// invokes the n'th icon in the toolbar
83         void push(int);
84         /// activates the toolbar
85         void activate();
86         /// deactivates the toolbar
87         void deactivate();
88
89         ///
90         static void ToolbarCB(FL_OBJECT*, long);
91         ///
92         static void BubbleTimerCB(FL_OBJECT *, long);
93         ///
94         static int BubblePost(FL_OBJECT *ob, int event,
95                               FL_Coord mx, FL_Coord my, int key, void *xev);
96
97 private:
98         ///
99         struct toolbarItem
100         {
101                 ///
102                 toolbarItem *next;
103                 ///
104                 int action;
105                 ///
106                 string help;
107                 ///
108                 FL_OBJECT *icon;
109                 ///
110                 bool IsBitmap;
111                 ///
112                 char **pixmap;
113                 ///
114                 toolbarItem(){
115                         next = 0;
116                         action = LFUN_NOACTION;
117                         icon = 0;
118                         pixmap = 0;
119                         IsBitmap = false;
120                 }
121                 ///
122                 ~toolbarItem(){
123                         if (icon){
124                                 fl_delete_object(icon);
125                                 fl_free_object(icon);
126                         }
127                 }
128                         
129         };
130
131         /// a list containing all the buttons
132         toolbarItem *toollist;
133         ///
134         LyXView *owner;
135         ///
136         FL_OBJECT *bubble_timer;
137         /// Starting position
138         int sxpos, sypos;
139         ///
140         int xpos;
141         ///
142         int ypos;
143         ///
144         int buttonwidth;
145         ///
146         int height;
147         ///
148         int standardspacing;
149         ///
150         int sepspace;
151         ///
152         bool cleaned;
153
154         ///
155         char **getPixmap(kb_action, string const & arg= string());
156         /// removes all toolbar buttons from the toolbar.
157         void clean();
158
159         /** more...
160          */
161         void reset(){
162                 toollist = 0;
163                 cleaned = false;
164                 
165                 lightReset();
166         }
167
168         /** more...
169          */
170         void lightReset(){
171                 standardspacing = 2; // the usual space between items
172                 sepspace = 6; // extra space
173                 xpos = sxpos - standardspacing;
174                 ypos = sypos;
175                 buttonwidth = 30; // the standard button width
176                 height = 30; // the height of all items in the toolbar
177         }
178 };
179 #endif