libyui-gtk  2.44.5
YGUI.h
1 /********************************************************************
2  * YaST2-GTK - http://en.opensuse.org/YaST2-GTK *
3  ********************************************************************/
4 
5 #ifndef YGUI_H
6 #define YGUI_H
7 
8 #include <yui/Libyui_config.h>
9 #include <yui/YUI.h>
10 #define YUILogComponent "gtk"
11 #include <yui/YUILog.h>
12 #include <yui/YSimpleEventHandler.h>
13 #include <map>
14 #include <gtk/gtk.h>
15 
16 
17 /* Comment the following line to disable debug messages */
18 #define RET(a) { return (a); }
19 
20 class YGUI: public YUI
21 {
22 public:
23  YGUI (bool with_threads);
24  void checkInit(); // called 1st time when execution thread kicks in
25 
26  static YGUI *ui() { return (YGUI *) YUI::ui(); }
27 
28 protected:
29  virtual YWidgetFactory *createWidgetFactory();
30  virtual YOptionalWidgetFactory *createOptionalWidgetFactory();
31  virtual YApplication *createApplication();
32 
33 public:
34  static void setTextdomain (const char *domain);
35 
36  virtual void idleLoop (int fd_ycp);
37  // called by YDialog::waitInput() / pollEvent()...
38  YEvent *waitInput (unsigned long timeout_ms, bool block);
39 
40  virtual YEvent *runPkgSelection (YWidget *packageSelector);
41 
42  // used internally: for public use, see YApplication
43  void busyCursor();
44  void normalCursor();
45  void makeScreenShot();
46 
47  // Plays a macro, opening a dialog first to ask for the filename
48  // activated by Ctrl-Shift-Alt-P
49  void askPlayMacro();
50  void toggleRecordMacro();
51 
52  // On Shift-F8, run save_logs
53  void askSaveLogs();
54 
55  YSimpleEventHandler m_event_handler;
56  void sendEvent (YEvent *event);
57  YEvent *pendingEvent() const { return m_event_handler.pendingEvent(); }
58  bool eventPendingFor (YWidget *widget) const
59  { return m_event_handler.eventPendingFor (widget); }
60 
61 private:
62  bool m_done_init;
63  guint busy_timeout; // for busy cursor
64  static gboolean busy_timeout_cb (gpointer data);
65 
66  // window-related arguments
67  bool m_no_border, m_fullscreen, m_swsingle;
68 
69 public:
70  // Helpers for internal use [ visibility hidden ]
71  bool setFullscreen() const { return m_fullscreen; }
72  bool unsetBorder() const { return m_no_border; }
73  bool isSwsingle() const { return m_swsingle; }
74 };
75 
76 #include <YWidgetFactory.h>
77 
78 class YGWidgetFactory : public YWidgetFactory
79 {
80  virtual YDialog *createDialog (YDialogType dialogType, YDialogColorMode colorMode);
81 
82  virtual YPushButton *createPushButton (YWidget *parent, const std::string &label);
83  virtual YLabel *createLabel (YWidget *parent, const std::string &text, bool isHeading, bool isOutputField);
84  virtual YInputField *createInputField (YWidget *parent, const std::string &label, bool passwordMode);
85  virtual YCheckBox *createCheckBox (YWidget *parent, const std::string &label, bool isChecked);
86  virtual YRadioButton *createRadioButton (YWidget *parent, const std::string &label, bool isChecked);
87  virtual YComboBox *createComboBox (YWidget *parent, const std::string & label, bool editable);
88  virtual YSelectionBox *createSelectionBox (YWidget *parent, const std::string &label);
89  virtual YTree *createTree (YWidget *parent, const std::string &label, bool multiselection, bool recursiveSelection);
90  virtual YTable *createTable (YWidget *parent, YTableHeader *headers, bool multiSelection);
91  virtual YProgressBar *createProgressBar (YWidget *parent, const std::string &label, int maxValue);
92  virtual YBusyIndicator *createBusyIndicator (YWidget *parent, const std::string &label, int timeout);
93  virtual YRichText *createRichText (YWidget *parent, const std::string &text, bool plainTextMode);
94 
95  virtual YIntField *createIntField (YWidget *parent, const std::string &label, int minVal, int maxVal, int initialVal);
96  virtual YMenuButton *createMenuButton (YWidget *parent, const std::string &label);
97  virtual YMultiLineEdit *createMultiLineEdit (YWidget *parent, const std::string &label);
98  virtual YImage *createImage (YWidget *parent, const std::string &imageFileName, bool animated);
99  virtual YLogView *createLogView (YWidget *parent, const std::string &label, int visibleLines, int storedLines);
100  virtual YMultiSelectionBox *createMultiSelectionBox (YWidget *parent, const std::string &label);
101 
102  virtual YPackageSelector *createPackageSelector (YWidget * parent, long ModeFlags);
103  virtual YWidget *createPkgSpecial (YWidget * parent, const std::string & subwidgetName) RET (NULL) // for ncurses
104 
105  virtual YLayoutBox *createLayoutBox (YWidget *parent, YUIDimension dimension);
106  virtual YButtonBox *createButtonBox (YWidget *parent);
107 
108  virtual YSpacing *createSpacing (YWidget *parent, YUIDimension dim, bool stretchable, YLayoutSize_t size);
109  virtual YEmpty *createEmpty (YWidget *parent);
110  virtual YAlignment *createAlignment (YWidget *parent, YAlignmentType horAlignment, YAlignmentType vertAlignment);
111  virtual YSquash *createSquash (YWidget *parent, bool horSquash, bool vertSquash);
112 
113  virtual YFrame *createFrame (YWidget *parent, const std::string &label);
114  virtual YCheckBoxFrame *createCheckBoxFrame (YWidget *parent, const std::string &label, bool checked);
115 
116  virtual YRadioButtonGroup *createRadioButtonGroup (YWidget *parent);
117  virtual YReplacePoint *createReplacePoint (YWidget *parent);
118 };
119 
120 #include <YOptionalWidgetFactory.h>
121 
122 class YGOptionalWidgetFactory : public YOptionalWidgetFactory
123 {
124 public:
125  virtual bool hasWizard() RET (true)
126  virtual YWizard *createWizard (YWidget *parent, const std::string &backButtonLabel,
127  const std::string &abortButtonLabel, const std::string &nextButtonLabel,
128  YWizardMode wizardMode);
129 
130  virtual bool hasDumbTab() RET (true)
131  virtual YDumbTab *createDumbTab (YWidget *parent);
132 
133  virtual bool hasSlider() RET (true)
134  virtual YSlider *createSlider (YWidget *parent, const std::string &label, int minVal,
135  int maxVal, int initialVal);
136 
137  virtual bool hasDateField() RET (true)
138  virtual YDateField *createDateField (YWidget *parent, const std::string &label);
139 
140  virtual bool hasTimeField() RET (true)
141  virtual YTimeField *createTimeField (YWidget *parent, const std::string &label);
142 
143  virtual bool hasTimezoneSelector() RET (true)
144  virtual YTimezoneSelector *createTimezoneSelector (YWidget *parent,
145  const std::string &pixmap, const std::map <std::string, std::string> &timezones);
146 
147  virtual bool hasBarGraph() RET (true)
148  virtual YBarGraph *createBarGraph (YWidget *parent);
149 
150  virtual bool hasMultiProgressMeter() RET (true)
151  virtual YMultiProgressMeter *createMultiProgressMeter (YWidget *parent,
152  YUIDimension dim, const std::vector<float> &maxValues);
153 
154  virtual bool hasPartitionSplitter() RET (true)
155  virtual YPartitionSplitter *createPartitionSplitter (YWidget *parent,
156  int usedSize, int totalFreeSize, int newPartSize, int minNewPartSize,
157  int minFreeSize, const std::string &usedLabel, const std::string &freeLabel,
158  const std::string &newPartLabel, const std::string &freeFieldLabel,
159  const std::string &newPartFieldLabel);
160 
161  virtual bool hasDownloadProgress() RET (true)
162  virtual YDownloadProgress *createDownloadProgress (YWidget *parent,
163  const std::string &label, const std::string & filename, YFileSize_t expectedFileSize);
164 
165  virtual bool hasContextMenu() RET (true)
166 
167  virtual bool hasSimplePatchSelector() RET (true)
168  virtual YWidget *createSimplePatchSelector (YWidget *parent, long modeFlags);
169  virtual bool hasPatternSelector() RET (true)
170  virtual YWidget *createPatternSelector (YWidget *parent, long modeFlags);
171 };
172 
173 #include <YApplication.h>
174 
175 class YGApplication : public YApplication
176 {
177 public:
178  YGApplication();
179 
180  virtual std::string glyph (const std::string &symbolName);
181 
182  virtual std::string askForExistingDirectory (const std::string &startDir,
183  const std::string &headline);
184  virtual std::string askForExistingFile (const std::string &startWith,
185  const std::string &filter, const std::string &headline);
186  virtual std::string askForSaveFileName (const std::string &startWith,
187  const std::string &filter, const std::string &headline);
188 
189  virtual void busyCursor() { YGUI::ui()->busyCursor(); }
190  virtual void normalCursor() { YGUI::ui()->normalCursor(); }
191 
192  virtual void makeScreenShot (const std::string &filename);
193  virtual void beep();
194 
195  virtual int deviceUnits (YUIDimension dim, float layout_units);
196  virtual float layoutUnits (YUIDimension dim, int device_units);
197 
198  virtual int displayWidth();
199  virtual int displayHeight();
200  virtual int displayDepth();
201  virtual long displayColors();
202  virtual int defaultWidth(); // internally, use _defaultWidth / Height()
203  virtual int defaultHeight();
204 
205  virtual bool isTextMode() RET (false)
206  virtual bool leftHandedMouse() RET (false)
207  virtual bool hasImageSupport() RET (true)
208  virtual bool hasLocalImageSupport() RET (true)
209  virtual bool hasAnimationSupport() RET (true)
210  virtual bool hasIconSupport() RET (true)
211  virtual bool hasFullUtf8Support() RET (true)
212 #ifdef USE_WEBKIT
213  virtual bool richTextSupportsTable() RET (true)
214 #else
215  virtual bool richTextSupportsTable() RET (false)
216 #endif
217 
218  virtual bool openContextMenu (const YItemCollection &itemCollection);
219 
220 private:
221  // for screenshots:
222  std::map <std::string, int> screenShotNb;
223  std::string screenShotNameTemplate;
224 };
225 
226 #undef RET
227 
228 #endif /*YGUI_H*/
229 
Definition: YGUI.h:20