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