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