]> git.lyx.org Git - lyx.git/blob - src/toolbar.h
encoding + etc patch from dekel
[lyx.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 FORMS_H_LOCATION
22 #include "lyxfunc.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(LyXView * o, int x, int y);
34
35         ///
36         ~Toolbar() {
37                 clean();
38         }
39         
40         ///
41         int get_toolbar_func(string const & func);
42         
43         /// The special toolbar actions
44         enum  TOOLBARITEMS {
45                 /// adds space between buttons in the toolbar
46                 TOOL_SEPARATOR = -1,
47                 /// a special combox insead of a button
48                 TOOL_LAYOUTS = -2,
49                 /// begin a new line of button (not working)
50                 TOOL_NEWLINE = -3
51         };
52
53         ///
54         Combox * combox;
55
56         /// (re)sets the toolbar
57         void set(bool doingmain = false);
58
59         /** this is to be the entry point to the toolbar
60           frame, where you can change the toolbar realtime. */
61         void edit();
62         /// add a new button to the toolbar.
63         void add(int , bool doclean = true);
64         /// name of func instead of kb_action
65         void add(string const & , bool doclean = true);
66         /// invokes the n'th icon in the toolbar
67         void push(int);
68         /// activates the toolbar
69         void activate();
70         /// deactivates the toolbar
71         void deactivate();
72
73         ///
74         static void ToolbarCB(FL_OBJECT *, long);
75
76 #if FL_REVISION < 89
77         ///
78         static void BubbleTimerCB(FL_OBJECT *, long);
79         ///
80         static int BubblePost(FL_OBJECT * ob, int event,
81                               FL_Coord mx, FL_Coord my, int key, void * xev);
82 #endif
83
84 private:
85         ///
86         struct toolbarItem
87         {
88                 ///
89                 toolbarItem * next;
90                 ///
91                 int action;
92                 ///
93                 string help;
94                 ///
95                 FL_OBJECT * icon;
96                 ///
97                 toolbarItem() {
98                         next = 0;
99                         action = LFUN_NOACTION;
100                         icon = 0;
101                 }
102                 ///
103                 ~toolbarItem() {
104                         if (icon) {
105                                 fl_delete_object(icon);
106                                 fl_free_object(icon);
107                         }
108                 }
109                         
110         };
111
112         /// a list containing all the buttons
113         toolbarItem * toollist;
114         ///
115         LyXView * owner;
116 #if FL_REVISION < 89
117         ///
118         FL_OBJECT * bubble_timer;
119 #endif
120         /// Starting position
121         int sxpos, sypos;
122         ///
123         int xpos;
124         ///
125         int ypos;
126         ///
127         int buttonwidth;
128         ///
129         int height;
130         ///
131         int standardspacing;
132         ///
133         int sepspace;
134         ///
135         bool cleaned;
136
137         ///
138         char const ** getPixmap(kb_action, string const & arg = string());
139         /// removes all toolbar buttons from the toolbar.
140         void clean();
141
142         /** more...
143          */
144         void reset();// {
145 //              toollist = 0;
146 //              cleaned = false;
147 //              
148 //              lightReset();
149 //      }
150
151         /** more...
152          */
153         void lightReset() {
154                 standardspacing = 2; // the usual space between items
155                 sepspace = 6; // extra space
156                 xpos = sxpos - standardspacing;
157                 ypos = sypos;
158                 buttonwidth = 30; // the standard button width
159                 height = 30; // the height of all items in the toolbar
160         }
161 };
162 #endif