1
//=============================================================================
3
// File : KvsObject_groupBox.cpp
4
// Creation date : Fri Jan 28 14:21:48 CEST 2005
5
// by Tonino Imbesi(Grifisx) and Alessandro Carbone(Noldor)
7
// This file is part of the KVIrc irc client distribution
8
// Copyright (C) 2005-2009 Alessandro Carbone (elfonol at gmail dot com)
10
// This program is FREE software. You can redistribute it and/or
11
// modify it under the terms of the GNU General Public License
12
// as published by the Free Software Foundation; either version 2
13
// of the License, or (at your opinion) any later version.
15
// This program is distributed in the HOPE that it will be USEFUL,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
// See the GNU General Public License for more details.
20
// You should have received a copy of the GNU General Public License
21
// along with this program. If not, write to the Free Software Foundation,
22
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
//=============================================================================
26
#include <KviTalGroupBox.h>
27
#include "KvsObject_groupBox.h"
29
#include "kvi_debug.h"
31
#include "KviLocale.h"
32
#include "KviIconManager.h"
35
// Tables used in $setAlignment, $alignment and in $setOrientation & $orientation
37
const char * const align_tbl[] = {
43
const int align_cod[] = {
49
#define align_num (sizeof(align_tbl) / sizeof(align_tbl[0]))
55
groupbox object class,
61
Provides a groupbox bar.
66
This widget can be used to display a groupbox.
67
It will be usually a parent for other child controls.
68
You can either use a child layout to manage the children geometries
69
or use $setColumnLayout to manage the layout automatically.
71
!fn: $setTitle(<text:String>)
72
Sets the group box title to <text>.
73
!fn: <string> $title()
74
Returns the group box title text.
75
!fn: $setFlat(<bflag:boolean>)
76
Sets whether the group box is painted flat. Valid Values are 1 or 0.
77
!fn: <boolean> $isFlat()
78
Returns 1 (TRUE) if the group box is painted flat; otherwise returns 0 (FALSE).
79
!fn: <boolean> $isCheckable()
80
Returns 1 (TRUE) if the group box has a checkbox in its title; otherwise returns 0 (FALSE).
81
!fn: $setCheckable(<bflag:boolean>)
82
Sets whether the group box has a checkbox in its title: Valid values are 1 or 0.
83
!fn: $setInsideMargin(<margin:uint>)
84
Sets the the width of the inside margin to m pixels.
85
!fn: <integer> $insideMargin()
86
Returns the width of the empty space between the items in the group and margin of groupbox.
87
!fn: $setInsideSpacing(<spacing:uint>)
88
Sets the width of the empty space between each of the items in the group to m pixels.
89
!fn: <integer> $insideSpacing()
90
Returns the width of the empty space between each of the items in the group.
92
Adds an empty cell at the next free position.
93
!fn: <string> $alignment()
94
Returns the alignment of the group box title.
95
!fn: $setAlignment(<alignment:string>)
96
Set the alignment of the groupbox; Valid values are Left,Right,HCenter.
97
!fn: $setOrientation<orientation:string>
98
Sets the group box's orientation. Valid values are: Horizontal, Vertical.
102
//First we'll create the main widget. as a dialog
104
%layout=$new(layout,%widget)
106
%gb=$new(groupbox,%widget)
107
%gb->$setTitle(Login)
108
%gb->$setAlignment("Left")
109
// add the gbox to the main layout
110
%layout->$addWidget(%gb,0,0)
111
// now we create the user field (labels + lineedit)
112
// in a horizontal box
114
%labeluser=$new(label,%hbox)
115
%labeluser->$settext(User: )
116
%inputuser=$new(lineedit,%hbox)
117
//now we create the pass field (labels + lineedit).
118
// in a horizontal box
120
%labelpass=$new(label,%hbox)
121
%labelpass->$settext(Pass: )
122
%inputpass=$new(lineedit,%hbox)
123
%inputpass->$setechomode("password")
124
// now we create the ok/cancel box buttons
126
%btnok=$new(button,%hbox)
127
%btnok->$settext("OK")
128
%btncancel=$new(button,%hbox)
129
%btncancel->$settext("Cancel")
131
//Let's show our nice form
137
KVSO_BEGIN_REGISTERCLASS(KvsObject_groupBox,"groupbox","widget")
138
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setTitle)
139
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,title)
140
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setFlat)
141
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,isFlat)
142
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setCheckable)
143
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,isCheckable)
144
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setInsideMargin)
145
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,insideMargin)
146
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setInsideSpacing)
147
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,insideSpacing)
148
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,addSpace)
149
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,alignment)
150
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setAlignment)
151
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setOrientation)
152
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,isChecked)
153
KVSO_REGISTER_HANDLER_BY_NAME(KvsObject_groupBox,setChecked)
155
KVSO_END_REGISTERCLASS(KvsObject_groupBox)
157
KVSO_BEGIN_CONSTRUCTOR(KvsObject_groupBox,KvsObject_widget)
159
KVSO_END_CONSTRUCTOR(KvsObject_groupBox)
162
KVSO_BEGIN_DESTRUCTOR(KvsObject_groupBox)
164
KVSO_END_CONSTRUCTOR(KvsObject_groupBox)
166
bool KvsObject_groupBox::init(KviKvsRunTimeContext *,KviKvsVariantList *)
168
KviTalGroupBox *groupbox=new KviTalGroupBox(getName(),parentScriptWidget());
170
groupbox->setOrientation(Qt::Horizontal);
171
groupbox->setObjectName(getName());
172
setObject(groupbox,true);
176
KVSO_CLASS_FUNCTION(groupBox,setTitle)
178
CHECK_INTERNAL_POINTER(widget())
180
KVSO_PARAMETERS_BEGIN(c)
181
KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
182
KVSO_PARAMETERS_END(c)
183
((KviTalGroupBox *)widget())->setTitle(szTitle);
186
KVSO_CLASS_FUNCTION(groupBox,title)
188
CHECK_INTERNAL_POINTER(widget())
189
c->returnValue()->setString(((KviTalGroupBox *)widget())->title());
192
KVSO_CLASS_FUNCTION(groupBox,setFlat)
194
CHECK_INTERNAL_POINTER(widget())
196
KVSO_PARAMETERS_BEGIN(c)
197
KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
198
KVSO_PARAMETERS_END(c)
199
((KviTalGroupBox *)widget())->setFlat(bEnabled);
202
KVSO_CLASS_FUNCTION(groupBox,isFlat)
204
CHECK_INTERNAL_POINTER(widget())
205
c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isFlat());
208
KVSO_CLASS_FUNCTION(groupBox,setCheckable)
210
CHECK_INTERNAL_POINTER(widget())
212
KVSO_PARAMETERS_BEGIN(c)
213
KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
214
KVSO_PARAMETERS_END(c)
215
((KviTalGroupBox *)widget())->setCheckable(bEnabled);
218
KVSO_CLASS_FUNCTION(groupBox,isCheckable)
220
CHECK_INTERNAL_POINTER(widget())
221
c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isCheckable());
224
KVSO_CLASS_FUNCTION(groupBox,setChecked)
226
CHECK_INTERNAL_POINTER(widget())
228
KVSO_PARAMETERS_BEGIN(c)
229
KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
230
KVSO_PARAMETERS_END(c)
231
((KviTalGroupBox *)widget())->setChecked(bEnabled);
234
KVSO_CLASS_FUNCTION(groupBox,isChecked)
236
CHECK_INTERNAL_POINTER(widget())
237
c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isChecked());
240
KVSO_CLASS_FUNCTION(groupBox,setInsideMargin)
242
CHECK_INTERNAL_POINTER(widget())
244
KVSO_PARAMETERS_BEGIN(c)
245
KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
246
KVSO_PARAMETERS_END(c)
247
((KviTalGroupBox *)widget())->setInsideMargin(uMargin);
250
KVSO_CLASS_FUNCTION(groupBox,insideMargin)
252
CHECK_INTERNAL_POINTER(widget())
253
c->returnValue()->setInteger(((KviTalGroupBox *)widget())->insideMargin());
256
KVSO_CLASS_FUNCTION(groupBox,setInsideSpacing)
258
CHECK_INTERNAL_POINTER(widget())
260
KVSO_PARAMETERS_BEGIN(c)
261
KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
262
KVSO_PARAMETERS_END(c)
263
((KviTalGroupBox *)widget())->setInsideSpacing(uSpacing);
266
KVSO_CLASS_FUNCTION(groupBox,insideSpacing)
268
CHECK_INTERNAL_POINTER(widget())
269
c->returnValue()->setInteger(((KviTalGroupBox *)widget())->insideSpacing());
273
KVSO_CLASS_FUNCTION(groupBox,addSpace)
275
CHECK_INTERNAL_POINTER(widget())
277
KVSO_PARAMETERS_BEGIN(c)
278
KVSO_PARAMETER("colums",KVS_PT_UNSIGNEDINTEGER,0,iSpace)
279
KVSO_PARAMETERS_END(c)
280
(((KviTalGroupBox *)widget())->addSpace(iSpace));
284
KVSO_CLASS_FUNCTION(groupBox,setAlignment)
286
CHECK_INTERNAL_POINTER(widget())
288
KVSO_PARAMETERS_BEGIN(c)
289
KVSO_PARAMETER("alignment",KVS_PT_STRING,0,szAlign)
290
KVSO_PARAMETERS_END(c)
291
for(unsigned int i = 0; i < align_num; i++)
293
if(KviQString::equalCI(szAlign, align_tbl[i]))
295
((KviTalGroupBox *)widget())->setAlignment(align_cod[i]);
299
c->warning(__tr2qs_ctx("Unknown alignment '%Q'","objets"),&szAlign);
303
KVSO_CLASS_FUNCTION(groupBox,alignment)
305
CHECK_INTERNAL_POINTER(widget())
306
int mode = ((KviTalGroupBox *)widget())->alignment();
307
QString szAlignment="";
308
for(unsigned int i = 0; i < align_num; i++)
310
if(mode == align_cod[i])
312
szAlignment=align_tbl[i];
316
c->returnValue()->setString(szAlignment);
320
KVSO_CLASS_FUNCTION(groupBox,setOrientation)
322
CHECK_INTERNAL_POINTER(widget())
324
KVSO_PARAMETERS_BEGIN(c)
325
KVSO_PARAMETER("orientation",KVS_PT_STRING,0,szMode)
326
KVSO_PARAMETERS_END(c)
327
if(KviQString::equalCI(szMode, "Horizontal"))
328
((KviTalGroupBox *)widget())->setOrientation(Qt::Vertical);
330
if(KviQString::equalCI(szMode, "Vertical"))
331
((KviTalGroupBox *)widget())->setOrientation(Qt::Horizontal);
332
else c->warning( __tr2qs_ctx("Unknown orientation '%Q'","objects"),&szMode);