]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormGraphics.h
88abccabce7410c569be8421c513525880999a66
[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 "LString.h"
22 #include "frontends/DialogBase.h"
23 #include "RadioButtonGroup.h"
24 #include <boost/utility.hpp>
25
26 #ifdef __GNUG__
27 #pragma interface
28 #endif 
29
30 class Dialogs;
31 // same arguement as in Dialogs.h s/LyX/UI/
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 class FormGraphics: public DialogBase, public noncopyable {
40 public:
41         /// #FormGraphics x(LyXFunc ..., Dialogs ...);#
42         FormGraphics(LyXView *, Dialogs *);
43         ///
44         ~FormGraphics();
45         ///
46         static int WMHideCB(FL_FORM *, void *);
47         ///
48         static void OKCB(FL_OBJECT *, long);
49         ///
50         static void ApplyCB(FL_OBJECT *, long);
51         ///
52         static void CancelCB(FL_OBJECT *, long);
53         ///
54         static void BrowseCB(FL_OBJECT *, long);
55         ///
56         static void AdvancedOptionsCB(FL_OBJECT *, long);
57         ///
58         static void InputCB(FL_OBJECT *, long);
59
60 private:
61         /// The maximum digits for the image width (cm, inch, percent)
62         enum {
63             ///
64             WIDTH_MAXDIGITS = 3
65         };
66         /// The maximum digits for the image height (cm, inch, percent)
67         enum {
68             ///
69             HEIGHT_MAXDIGITS = 3
70         };
71         /// The maximum characters in the rotation angle (minus sign and 3 digits)
72         enum {
73             ///
74             ROTATE_MAXCHARS = 4
75         };
76         /// The maximum characters in a filename.
77         enum {
78             ///
79             FILENAME_MAXCHARS = 1024
80         };
81
82         /// Save the active inset and show the dialog.
83         void showDialog(InsetGraphics * inset);
84         /// Create the dialog if necessary, update it and display it.
85         void show();
86         /// Hide the dialog.
87         void hide();
88         /// Update the dialog
89         void update();
90
91         /// Apply the changes to the inset.
92         void apply();
93         /// Verify that the input is correct. If not disable ok/apply buttons.
94         void input();
95         /// Open the file browse dialog to select an image file.
96         void browse();
97
98         /// Build the dialog
99         void build();
100         ///
101         FD_form_graphics * build_graphics();
102         /// Explicitly free the dialog.
103         void free();
104         /// Display a file browser dialog and return the file chosen.
105         string browseFile(string const & filename);
106
107         /// Real GUI implementation.
108         FD_form_graphics * dialog_;
109         /** Which LyXFunc do we use?
110             We could modify Dialogs to have a visible LyXFunc* instead and
111             save a couple of bytes per dialog.
112         */
113         LyXView * lv_;
114         /** Which Dialogs do we belong to?
115             Used so we can get at the signals we have to connect to.
116         */
117         Dialogs * d_;
118         /** Which Inset do we belong to?
119            Used to set and update data to/from the inset.
120         */
121         InsetGraphics * inset_;
122         /// The radio buttons groups
123         RadioButtonGroup widthButtons;
124         ///
125         RadioButtonGroup heightButtons;
126         ///
127         RadioButtonGroup displayButtons;
128
129         /// Inset Hide connection, connected to the calling inset hide signal.
130         Connection ih_;
131         /// Hide connection.
132         Connection h_;
133         /// Update connection.
134         Connection u_;
135         /// Last used figure path
136         string last_image_path;
137 };
138
139 #endif