1 /***************************************************************************
2     begin       : Mon Feb 15 2010
3     copyright   : (C) 2010 by Martin Preuss
4     email       : martin@libchipcard.de
5 
6  ***************************************************************************
7  *          Please see toplevel file COPYING for license details           *
8  ***************************************************************************/
9 
10 
11 #include <gwen-gui-cpp/cppwidget.hpp>
12 
13 
14 class Qt5_W_ProgressBar: public Qt5_W_Widget {
15 public:
Qt5_W_ProgressBar(GWEN_WIDGET * w)16   Qt5_W_ProgressBar(GWEN_WIDGET *w):Qt5_W_Widget(w) {
17   }
18 
19 
20 
~Qt5_W_ProgressBar()21   ~Qt5_W_ProgressBar() {
22   }
23 
24 
25 
setup()26   virtual int setup() {
27     QProgressBar *qw;
28     uint32_t flags;
29     GWEN_WIDGET *wParent;
30     QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
31     QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
32 
33     flags=GWEN_Widget_GetFlags(_widget);
34     wParent=GWEN_Widget_Tree_GetParent(_widget);
35 
36     qw=new QProgressBar();
37     qw->setTextVisible(true);
38 
39     /* handle flags */
40     if (flags & GWEN_WIDGET_FLAGS_FILLX)
41       hpolicy=QSizePolicy::Expanding;
42     if (flags & GWEN_WIDGET_FLAGS_FILLY)
43       vpolicy=QSizePolicy::Expanding;
44     qw->setSizePolicy(hpolicy, vpolicy);
45 
46     GWEN_Widget_SetImplData(_widget, QT5_DIALOG_WIDGET_REAL, (void*) qw);
47 
48     if (wParent)
49       GWEN_Widget_AddChildGuiWidget(wParent, _widget);
50     return 0;
51   }
52 
53 
54 
setIntProperty(GWEN_DIALOG_PROPERTY prop,int index,int value,int doSignal)55   int setIntProperty(GWEN_DIALOG_PROPERTY prop,
56                      int index,
57                      int value,
58                      int doSignal) {
59     QProgressBar *qw;
60 
61     qw=(QProgressBar*) GWEN_Widget_GetImplData(_widget, QT5_DIALOG_WIDGET_REAL);
62     assert(qw);
63 
64     switch(prop) {
65     case GWEN_DialogProperty_Value:
66       qw->setValue(value);
67       return 0;
68 
69     case GWEN_DialogProperty_MinValue:
70       qw->setMinimum(value);
71       return 0;
72 
73     case GWEN_DialogProperty_MaxValue:
74       qw->setMaximum(value);
75       return 0;
76 
77     default:
78       return Qt5_W_Widget::setIntProperty(prop, index, value, doSignal);
79     }
80   };
81 
82 
83 
getIntProperty(GWEN_DIALOG_PROPERTY prop,int index,int defaultValue)84   int getIntProperty(GWEN_DIALOG_PROPERTY prop,
85                      int index,
86                      int defaultValue) {
87     QProgressBar *qw;
88 
89     qw=(QProgressBar*) GWEN_Widget_GetImplData(_widget, QT5_DIALOG_WIDGET_REAL);
90     assert(qw);
91 
92     switch(prop) {
93     case GWEN_DialogProperty_Value:
94       return qw->value();
95 
96     case GWEN_DialogProperty_MinValue:
97       return qw->minimum();
98 
99     case GWEN_DialogProperty_MaxValue:
100       return qw->maximum();
101 
102     default:
103       return Qt5_W_Widget::getIntProperty(prop, index, defaultValue);
104     }
105   };
106 
107 };
108 
109 
110 
111 
112 
113 
114 
115