-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC_GTK_Label.cpp
More file actions
142 lines (104 loc) · 4.79 KB
/
C_GTK_Label.cpp
File metadata and controls
142 lines (104 loc) · 4.79 KB
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
132
133
134
135
136
137
138
139
140
141
142
//////////////////////////////////////////////////////////////////////////////////
// [ GTK_Label_Class_Source ]
//////////////////////////////////////////////////////////////////////////////////
#include "C_GTK_Label.hpp"
//////////////////////////////////////////////////////////////////////////////////
// [Konstructor]
//////////////////////////////////////////////////////////////////////////////////
C_GTK_Label::C_GTK_Label(){
this->plabel = 0;
this->status = C_GTK_LABEL_ERROR;
}
//////////////////////////////////////////////////////////////////////////////////
// [Destructor]
//////////////////////////////////////////////////////////////////////////////////
C_GTK_Label::~C_GTK_Label(){
}
//////////////////////////////////////////////////////////////////////////////////
// [create]
//////////////////////////////////////////////////////////////////////////////////
GtkWidget* C_GTK_Label::create(const gchar *title){
if(this->status == C_GTK_LABEL_READY) return(this->plabel);
if(!title) return(C_GTK_LABEL_ERROR);
this->plabel = gtk_label_new(title);
if(!this->plabel) return(C_GTK_LABEL_ERROR);
this->status = C_GTK_LABEL_READY;
return(this->plabel);
}
//////////////////////////////////////////////////////////////////////////////////
// [setText]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::setText(const gchar *title){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
if(!title) return(C_GTK_LABEL_ERROR);
gtk_label_set_text(GTK_LABEL(this->plabel), title);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [setAlignment]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::setAlignment(float x, float y){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
gtk_misc_set_alignment(GTK_MISC(this->plabel), x, y);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [setBackground]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::setBackground(const GdkRGBA* color){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
if(!color) return(C_GTK_LABEL_ERROR);
gtk_widget_override_background_color(this->plabel, GTK_STATE_FLAG_NORMAL, color);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [setColor]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::setColor(const GdkRGBA* color){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
if(!color) return(C_GTK_LABEL_ERROR);
gtk_widget_override_color(this->plabel, GTK_STATE_FLAG_NORMAL, color);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [set_size]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::setSize(int x, int y){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
gtk_widget_set_size_request(this->plabel, x, y);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [setFont]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::setFont(const char* pFont){
if(this->status != C_GTK_LABEL_READY || !pFont) return(C_GTK_LABEL_ERROR);
PangoFontDescription *font_desc;
font_desc = pango_font_description_from_string(pFont);
gtk_widget_modify_font(this->plabel, font_desc);
pango_font_description_free(font_desc);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [get_label]
//////////////////////////////////////////////////////////////////////////////////
GtkWidget* C_GTK_Label::getLabel(){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
return(this->plabel);
}
//////////////////////////////////////////////////////////////////////////////////
// [hide]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::hide(){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
gtk_widget_hide(this->plabel);
return(C_GTK_LABEL_READY);
}
//////////////////////////////////////////////////////////////////////////////////
// [show]
//////////////////////////////////////////////////////////////////////////////////
int C_GTK_Label::show(){
if(this->status != C_GTK_LABEL_READY) return(C_GTK_LABEL_ERROR);
gtk_widget_show(this->plabel);
return(C_GTK_LABEL_READY);
}