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