1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/** \file
* \brief Progress bar Control
*
* See Copyright Notice in "iup.h"
*/
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <stdarg.h>
#include "iup.h"
#include "iupcbs.h"
#include "iup_object.h"
#include "iup_layout.h"
#include "iup_attrib.h"
#include "iup_str.h"
#include "iup_progressbar.h"
#include "iup_drv.h"
#include "iupgtk_drv.h"
static int gtkProgressBarSetMarqueeAttrib(Ihandle* ih, const char* value)
{
GtkProgress* progress = (GtkProgress*)ih->handle;
if (iupStrBoolean(value))
{
ih->data->marquee = 1;
gtk_progress_set_activity_mode(progress, TRUE);
}
else
{
gtk_progress_set_activity_mode(progress, FALSE);
ih->data->marquee = 0;
}
return 1;
}
static int gtkProgressBarSetValueAttrib(Ihandle* ih, const char* value)
{
GtkProgressBar* pbar = (GtkProgressBar*)ih->handle;
if (!value)
ih->data->value = 0;
else
ih->data->value = atof(value);
iProgressBarCropValue(ih);
if (ih->data->marquee)
gtk_progress_bar_pulse(pbar);
else
gtk_progress_bar_set_fraction(pbar, (ih->data->value - ih->data->vmin) / (ih->data->vmax - ih->data->vmin));
return 0;
}
static int gtkProgressBarSetDashedAttrib(Ihandle* ih, const char* value)
{
GtkProgressBar* pbar = (GtkProgressBar*)ih->handle;
/* gtk_progress_bar_set_bar_style is deprecated */
if (iupStrBoolean(value))
{
ih->data->dashed = 1;
gtk_progress_bar_set_bar_style(pbar, GTK_PROGRESS_DISCRETE);
}
else /* Default */
{
ih->data->dashed = 0;
gtk_progress_bar_set_bar_style(pbar, GTK_PROGRESS_CONTINUOUS);
}
return 0;
}
static int gtkProgressBarMapMethod(Ihandle* ih)
{
ih->handle = gtk_progress_bar_new();
if (!ih->handle)
return IUP_ERROR;
/* add to the parent, all GTK controls must call this. */
iupgtkBaseAddToParent(ih);
gtk_widget_realize(ih->handle);
if (iupStrEqualNoCase(iupAttribGetStr(ih, "ORIENTATION"), "VERTICAL"))
{
gtk_progress_bar_set_orientation((GtkProgressBar*)ih->handle, GTK_PROGRESS_BOTTOM_TO_TOP);
if (ih->currentheight < ih->currentwidth)
{
int tmp = ih->currentheight;
ih->currentheight = ih->currentwidth;
ih->currentwidth = tmp;
}
}
else
gtk_progress_bar_set_orientation((GtkProgressBar*)ih->handle, GTK_PROGRESS_LEFT_TO_RIGHT);
return IUP_NOERROR;
}
void iupdrvProgressBarInitClass(Iclass* ic)
{
/* Driver Dependent Class functions */
ic->Map = gtkProgressBarMapMethod;
/* Driver Dependent Attribute functions */
/* Visual */
iupClassRegisterAttribute(ic, "BGCOLOR", NULL, iupdrvBaseSetBgColorAttrib, IUPAF_SAMEASSYSTEM, "DLGBGCOLOR", IUPAF_DEFAULT);
/* Special */
iupClassRegisterAttribute(ic, "FGCOLOR", NULL, NULL, NULL, NULL, IUPAF_DEFAULT);
/* IupProgressBar only */
iupClassRegisterAttribute(ic, "VALUE", iProgressBarGetValueAttrib, gtkProgressBarSetValueAttrib, NULL, NULL, IUPAF_NO_DEFAULTVALUE|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "DASHED", iProgressBarGetDashedAttrib, gtkProgressBarSetDashedAttrib, NULL, NULL, IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "ORIENTATION", NULL, NULL, IUPAF_SAMEASSYSTEM, "HORIZONTAL", IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "MARQUEE", NULL, gtkProgressBarSetMarqueeAttrib, NULL, NULL, IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "DASHED", NULL, NULL, NULL, NULL, IUPAF_NO_INHERIT);
}
|