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