]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormGraphics.h
4c82174b246f80627c09dc2dc9874c48e7b578a9
[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  * ======================================================
14  */
15
16 #ifndef FORMGRAPHICS_H
17 #define FORMGRAPHICS_H
18
19 #include <boost/smart_ptr.hpp>
20
21 #ifdef __GNUG__
22 #pragma interface
23 #endif 
24
25 #include "LString.h"
26 #include "RadioButtonGroup.h"
27 #include "ButtonPolicies.h"
28 #include "FormInset.h"
29 #include "xformsBC.h"
30
31 // Forward declarations for classes we use only as pointers.
32 class InsetGraphics;
33
34 struct FD_form_graphics;
35
36 /** This class provides an XForms implementation of the FormGraphics Dialog.
37  *
38  *  @Author Baruch Even <baruch.even@writeme.com>
39  */
40 class FormGraphics : public FormInset {
41 public:
42         /// #FormGraphics x(LyXFunc ..., Dialogs ...);#
43         FormGraphics(LyXView *, Dialogs *);
44         ///
45         ~FormGraphics();
46
47 private:
48         /// The maximum digits for the image width (cm, inch, percent)
49         enum {
50             ///
51             WIDTH_MAXDIGITS = 3
52         };
53         /// The maximum digits for the image height (cm, inch, percent)
54         enum {
55             ///
56             HEIGHT_MAXDIGITS = 3
57         };
58         /// The maximum characters in the rotation angle (minus sign and 3 digits)
59         enum {
60             ///
61             ROTATE_MAXCHARS = 4
62         };
63         /// The maximum characters in a filename.
64         enum {
65             ///
66             FILENAME_MAXCHARS = 1024
67         };
68         ///
69         enum State {
70                 ///
71                 CHECKINPUT,
72                 ///
73                 BROWSE,
74                 ///
75                 ADVANCEDINPUT
76         };
77
78         /// Pointer to the actual instantiation of the ButtonController.
79         virtual xformsBC & bc();
80         /// Build the dialog
81         virtual void build();
82         /// Filter the inputs
83         virtual bool input( FL_OBJECT *, long );
84         /// Update the popup.
85         virtual void update();
86         /// Apply from popup
87         virtual void apply();
88
89         /// Disconnect signals. Also perform any necessary housekeeping.
90         virtual void disconnect();
91
92         /// Save the active inset and show the dialog.
93         void showDialog(InsetGraphics *);
94         /// Verify that the input is correct. If not disable ok/apply buttons.
95         bool checkInput();
96         /// Open the file browse dialog to select an image file.
97         void browse();
98
99         /// Pointer to the actual instantiation of the xforms form
100         virtual FL_FORM * form() const;
101         /// Fdesign generated method
102         FD_form_graphics * build_graphics();
103
104         /// Real GUI implementation.
105         boost::scoped_ptr<FD_form_graphics> dialog_;
106         /** Which Inset do we belong to?
107            Used to set and update data to/from the inset.
108         */
109         InsetGraphics * inset_;
110         /// The radio buttons groups
111         RadioButtonGroup widthButtons;
112         ///
113         RadioButtonGroup heightButtons;
114         ///
115         RadioButtonGroup displayButtons;
116         /// Last used figure path
117         string last_image_path;
118         /// The ButtonController
119         ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
120 };
121
122
123 inline
124 xformsBC & FormGraphics::bc()
125 {
126         return bc_;
127 }
128 #endif