]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormGraphics.h
bad8f822322928213189d00864aa15fc3442f831
[features.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  * ======================================================
14  */
15
16 #ifndef FORMGRAPHICS_H
17 #define FORMGRAPHICS_H
18
19 #include "LString.h"
20 #include "frontends/DialogBase.h"
21 #include "RadioButtonGroup.h"
22 #include <boost/utility.hpp>
23 #include "ButtonController.h"
24 #include "ButtonPolicies.h"
25
26 #ifdef __GNUG__
27 #pragma interface
28 #endif 
29
30 // Forward declarations for classes we use only as pointers.
31 class Dialogs;
32 class LyXView;
33 class InsetGraphics;
34
35 struct FD_form_graphics;
36
37 /** This class provides an XForms implementation of the FormGraphics Dialog.
38  *
39  *  @Author Baruch Even <baruch.even@writeme.com>
40  */
41 class FormGraphics: public DialogBase, public noncopyable {
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         /// The maximum digits for the image width (cm, inch, percent)
64         enum {
65             ///
66             WIDTH_MAXDIGITS = 3
67         };
68         /// The maximum digits for the image height (cm, inch, percent)
69         enum {
70             ///
71             HEIGHT_MAXDIGITS = 3
72         };
73         /// The maximum characters in the rotation angle (minus sign and 3 digits)
74         enum {
75             ///
76             ROTATE_MAXCHARS = 4
77         };
78         /// The maximum characters in a filename.
79         enum {
80             ///
81             FILENAME_MAXCHARS = 1024
82         };
83
84         /// Save the active inset and show the dialog.
85         void showDialog(InsetGraphics * inset);
86         /// Create the dialog if necessary, update it and display it.
87         void show();
88         /// Hide the dialog.
89         void hide();
90         /// Update the dialog
91         void update(bool switched = false);
92
93         /// Apply the changes to the inset.
94         void apply();
95         /// Verify that the input is correct. If not disable ok/apply buttons.
96         bool checkInput();
97         /// Open the file browse dialog to select an image file.
98         void browse();
99
100         /// Build the dialog
101         void build();
102         ///
103         FD_form_graphics * build_graphics();
104         /// Explicitly free the dialog.
105         void free();
106         /// Display a file browser dialog and return the file chosen.
107         string browseFile(string const & filename);
108
109         /// Real GUI implementation.
110         FD_form_graphics * dialog_;
111         /** Which LyXFunc do we use?
112             We could modify Dialogs to have a visible LyXFunc* instead and
113             save a couple of bytes per dialog.
114         */
115         LyXView * lv_;
116         /** Which Dialogs do we belong to?
117             Used so we can get at the signals we have to connect to.
118         */
119         Dialogs * d_;
120         /** Which Inset do we belong to?
121            Used to set and update data to/from the inset.
122         */
123         InsetGraphics * inset_;
124         /// The radio buttons groups
125         RadioButtonGroup widthButtons;
126         ///
127         RadioButtonGroup heightButtons;
128         ///
129         RadioButtonGroup displayButtons;
130         /// Controls the actions of the buttons.
131         ButtonController * bc_;
132
133         /// Inset Hide connection, connected to the calling inset hide signal.
134         Connection ih_;
135         /// Hide connection.
136         Connection h_;
137         /// Update connection.
138         Connection u_;
139         /// Last used figure path
140         string last_image_path;
141 };
142
143 #endif