]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormGraphics.h
4cba3e2ba6109ec186c51ddd23dafc8eaba4980e
[lyx.git] / src / frontends / xforms / FormGraphics.h
1 // -*- C++ -*-
2 /* FormGraphics.h
3  * FormGraphics Interface Class
4  *
5  * This file is part of
6  * ====================================================== 
7  *
8  *           LyX, The Document Processor
9  *
10  *           Copyright 1995 Matthias Ettrich
11  *           Copyright 1995-2000 The LyX Team.
12  *
13  *           This file Copyright 2000
14  *           Baruch Even
15  * ======================================================
16  */
17
18 #ifndef FORMGRAPHICS_H
19 #define FORMGRAPHICS_H
20
21 #include <config.h>
22
23 #include "LString.h"
24 #include "frontends/DialogBase.h"
25 //#include "form_graphics.h"
26 #include "RadioButtonGroup.h"
27
28 #ifdef __GNUG__
29 #pragma interface
30 #endif
31
32 class Dialogs;
33 // same arguement as in Dialogs.h s/LyX/UI/
34 class LyXView;
35 class InsetGraphics;
36
37 struct FD_form_graphics;
38
39 /** This class provides an XForms implementation of the FormGraphics Dialog.
40  */
41 class FormGraphics: public DialogBase {
42 public:
43         /// #FormGraphics x(LyXFunc ..., Dialogs ...);#
44         FormGraphics(LyXView *, Dialogs *);
45         ///
46         ~FormGraphics();
47         ///
48         static  int WMHideCB(FL_FORM *, void *);
49         ///
50         static void OKCB(FL_OBJECT *, long);
51         ///
52         static void ApplyCB(FL_OBJECT *, long);
53         ///
54         static void CancelCB(FL_OBJECT *, long);
55         ///
56         static void BrowseCB(FL_OBJECT *, long);
57         ///
58         static void AdvancedOptionsCB(FL_OBJECT *, long);
59         ///
60         static void InputCB(FL_OBJECT *, long);
61
62 private:
63         ///
64         FormGraphics()
65                 : widthButtons(5), heightButtons(4), displayButtons(4) {}
66         //
67         FormGraphics(FormGraphics const &) : DialogBase() {}
68         
69         /// The maximum digits for the image width (cm, inch, percent)
70         enum {
71                 ///
72                 WIDTH_MAXDIGITS = 3
73         }; 
74         /// The maximum digits for the image height (cm, inch, percent)
75         enum {
76                 ///
77                 HEIGHT_MAXDIGITS = 3
78         };
79         /// The maximum characters in the rotation angle (minus sign and 3 digits)
80         enum {
81                 ///
82                 ROTATE_MAXCHARS = 4
83         };
84         /// The maximum characters in a filename.
85         enum {
86                 ///
87                 FILENAME_MAXCHARS = 1024
88         };
89     
90         /**@name Slot Methods */
91         //@{
92         /// Save the active inset and show the dialog.
93         void showDialog(InsetGraphics * inset);
94         /// Create the dialog if necessary, update it and display it.
95         void show();
96         /// Hide the dialog.
97         void hide();
98         /// Update the dialog
99         void update();
100         //@}
101
102         /**@name Callback methods */
103         //@{
104         /// Apply the changes to the inset.
105         void apply();
106         /// Verify that the input is correct. If not disable ok/apply buttons.
107         void input();
108         /// Open the file browse dialog to select an image file.
109         void browse();
110         //@}
111         
112         /// Build the dialog
113         void build();
114         ///
115         FD_form_graphics * build_graphics();
116         /// Explicitly free the dialog.
117         void free();
118         /// Display a file browser dialog and return the file chosen.
119         string browseFile(string const & filename);
120
121         /**@name Data */
122         //@{
123         /// Real GUI implementation.
124         FD_form_graphics * dialog_;
125         /** Which LyXFunc do we use?
126             We could modify Dialogs to have a visible LyXFunc* instead and
127             save a couple of bytes per dialog.
128         */
129         LyXView * lv_;
130         /** Which Dialogs do we belong to?
131             Used so we can get at the signals we have to connect to.
132         */
133         Dialogs * d_;
134         /** Which Inset do we belong to?
135            Used to set and update data to/from the inset.
136         */
137         InsetGraphics * inset_;
138         /// The radio buttons groups
139         RadioButtonGroup widthButtons;
140         ///
141         RadioButtonGroup heightButtons;
142         ///
143         RadioButtonGroup displayButtons;
144
145         /// Inset Hide connection, connected to the calling inset hide signal.
146         Connection ih_;
147         /// Hide connection.
148         Connection h_;
149         /// Update connection.
150         Connection u_;
151         /// Last used figure path
152         string last_image_path;
153         //@}
154
155 };
156
157 #endif