]> git.lyx.org Git - lyx.git/blob - src/toolbar.h
67b4a549bbed7fae53ba77cc9253192e77f93fbe
[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 private:
90         ///
91         struct toolbarItem
92         {
93                 ///
94                 toolbarItem *next;
95                 ///
96                 int action;
97                 ///
98                 string help;
99                 ///
100                 FL_OBJECT *icon;
101                 ///
102                 bool IsBitmap;
103                 ///
104                 char **pixmap;
105                 ///
106                 toolbarItem(){
107                         next = 0;
108                         action = LFUN_NOACTION;
109                         icon = 0;
110                         pixmap = 0;
111                         IsBitmap = false;
112                 }
113                 ///
114                 ~toolbarItem(){
115                         if (icon){
116                                 fl_delete_object(icon);
117                                 fl_free_object(icon);
118                         }
119                 }
120                         
121         };
122
123         /// a list containing all the buttons
124         toolbarItem *toollist;
125         ///
126         LyXView *owner;
127         ///
128         FL_OBJECT *bubble_timer;
129         /// Starting position
130         int sxpos, sypos;
131         ///
132         int xpos;
133         ///
134         int ypos;
135         ///
136         int buttonwidth;
137         ///
138         int height;
139         ///
140         int standardspacing;
141         ///
142         int sepspace;
143         ///
144         bool cleaned;
145
146         ///
147         char **getPixmap(kb_action, string const & arg=string());
148         /// removes all toolbar buttons from the toolbar.
149         void clean();
150         ///
151         static void ToolbarCB(FL_OBJECT*, long);
152         ///
153         static void BubbleTimerCB(FL_OBJECT *, long);
154         ///
155         static int BubblePost(FL_OBJECT *ob, int event,
156                               FL_Coord mx, FL_Coord my, int key, void *xev);
157
158         /** more...
159          */
160         void reset(){
161                 toollist = 0;
162                 cleaned = false;
163                 
164                 lightReset();
165         }
166
167         /** more...
168          */
169         void lightReset(){
170                 standardspacing = 2; // the usual space between items
171                 sepspace = 6; // extra space
172                 xpos = sxpos - standardspacing;
173                 ypos = sypos;
174                 buttonwidth = 30; // the standard button width
175                 height = 30; // the height of all items in the toolbar
176         }
177 };
178 #endif