~ubuntu-branches/ubuntu/trusty/kvirc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/modules/objects/KvsObject_groupBox.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=============================================================================
 
2
//
 
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)
 
6
//
 
7
//   This file is part of the KVIrc irc client distribution
 
8
//   Copyright (C) 2005-2009 Alessandro Carbone (elfonol at gmail dot com)
 
9
//
 
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.
 
14
//
 
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.
 
19
//
 
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.
 
23
//
 
24
//=============================================================================
 
25
 
 
26
#include <KviTalGroupBox.h>
 
27
#include "KvsObject_groupBox.h"
 
28
#include "KviError.h"
 
29
#include "kvi_debug.h"
 
30
 
 
31
#include "KviLocale.h"
 
32
#include "KviIconManager.h"
 
33
 
 
34
 
 
35
// Tables used in $setAlignment, $alignment and in $setOrientation & $orientation
 
36
 
 
37
const char * const align_tbl[] = {
 
38
        "Left",
 
39
        "Right",
 
40
        "HCenter"
 
41
};
 
42
 
 
43
const int align_cod[] = {
 
44
        Qt::AlignLeft,
 
45
        Qt::AlignRight,
 
46
        Qt::AlignHCenter
 
47
};
 
48
 
 
49
#define align_num       (sizeof(align_tbl) / sizeof(align_tbl[0]))
 
50
 
 
51
 
 
52
/*
 
53
        @doc:   groupbox
 
54
        @keyterms:
 
55
                groupbox object class,
 
56
        @title:
 
57
                groupbox class
 
58
        @type:
 
59
                class
 
60
        @short:
 
61
                Provides a groupbox bar.
 
62
        @inherits:
 
63
                [class]object[/class]
 
64
                [class]widget[/class]
 
65
        @description:
 
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.
 
70
        @functions:
 
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.
 
91
                !fn: $addSpace()
 
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.
 
99
        @examples:
 
100
                [example]
 
101
                        //Let's start.
 
102
                        //First we'll create the main widget. as a dialog
 
103
                        %widget=$new(dialog)
 
104
                        %layout=$new(layout,%widget)
 
105
                        //then the groupbox
 
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
 
113
                        %hbox=$new(hbox,%gb)
 
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
 
119
                        %hbox=$new(hbox,%gb)
 
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
 
125
                        %hbox=$new(hbox,%gb)
 
126
                        %btnok=$new(button,%hbox)
 
127
                        %btnok->$settext("OK")
 
128
                        %btncancel=$new(button,%hbox)
 
129
                        %btncancel->$settext("Cancel")
 
130
 
 
131
                        //Let's show our nice form
 
132
                        %widget->$show()
 
133
                [/example]
 
134
 
 
135
*/
 
136
 
 
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)
 
154
 
 
155
KVSO_END_REGISTERCLASS(KvsObject_groupBox)
 
156
 
 
157
KVSO_BEGIN_CONSTRUCTOR(KvsObject_groupBox,KvsObject_widget)
 
158
 
 
159
KVSO_END_CONSTRUCTOR(KvsObject_groupBox)
 
160
 
 
161
 
 
162
KVSO_BEGIN_DESTRUCTOR(KvsObject_groupBox)
 
163
 
 
164
KVSO_END_CONSTRUCTOR(KvsObject_groupBox)
 
165
 
 
166
bool KvsObject_groupBox::init(KviKvsRunTimeContext *,KviKvsVariantList *)
 
167
{
 
168
        KviTalGroupBox *groupbox=new KviTalGroupBox(getName(),parentScriptWidget());
 
169
 
 
170
        groupbox->setOrientation(Qt::Horizontal);
 
171
        groupbox->setObjectName(getName());
 
172
        setObject(groupbox,true);
 
173
        return true;
 
174
}
 
175
 
 
176
KVSO_CLASS_FUNCTION(groupBox,setTitle)
 
177
{
 
178
        CHECK_INTERNAL_POINTER(widget())
 
179
        QString szTitle;
 
180
        KVSO_PARAMETERS_BEGIN(c)
 
181
                KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
 
182
        KVSO_PARAMETERS_END(c)
 
183
        ((KviTalGroupBox *)widget())->setTitle(szTitle);
 
184
        return true;
 
185
}
 
186
KVSO_CLASS_FUNCTION(groupBox,title)
 
187
{
 
188
        CHECK_INTERNAL_POINTER(widget())
 
189
        c->returnValue()->setString(((KviTalGroupBox *)widget())->title());
 
190
        return true;
 
191
}
 
192
KVSO_CLASS_FUNCTION(groupBox,setFlat)
 
193
{
 
194
        CHECK_INTERNAL_POINTER(widget())
 
195
        bool bEnabled;
 
196
        KVSO_PARAMETERS_BEGIN(c)
 
197
                KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
 
198
        KVSO_PARAMETERS_END(c)
 
199
        ((KviTalGroupBox *)widget())->setFlat(bEnabled);
 
200
        return true;
 
201
}
 
202
KVSO_CLASS_FUNCTION(groupBox,isFlat)
 
203
{
 
204
        CHECK_INTERNAL_POINTER(widget())
 
205
        c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isFlat());
 
206
        return true;
 
207
}
 
208
KVSO_CLASS_FUNCTION(groupBox,setCheckable)
 
209
{
 
210
        CHECK_INTERNAL_POINTER(widget())
 
211
        bool bEnabled;
 
212
        KVSO_PARAMETERS_BEGIN(c)
 
213
                KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
 
214
        KVSO_PARAMETERS_END(c)
 
215
        ((KviTalGroupBox *)widget())->setCheckable(bEnabled);
 
216
        return true;
 
217
}
 
218
KVSO_CLASS_FUNCTION(groupBox,isCheckable)
 
219
{
 
220
        CHECK_INTERNAL_POINTER(widget())
 
221
        c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isCheckable());
 
222
        return true;
 
223
}
 
224
KVSO_CLASS_FUNCTION(groupBox,setChecked)
 
225
{
 
226
        CHECK_INTERNAL_POINTER(widget())
 
227
        bool bEnabled;
 
228
        KVSO_PARAMETERS_BEGIN(c)
 
229
                KVSO_PARAMETER("bFlag",KVS_PT_BOOL,0,bEnabled)
 
230
        KVSO_PARAMETERS_END(c)
 
231
        ((KviTalGroupBox *)widget())->setChecked(bEnabled);
 
232
        return true;
 
233
}
 
234
KVSO_CLASS_FUNCTION(groupBox,isChecked)
 
235
{
 
236
        CHECK_INTERNAL_POINTER(widget())
 
237
        c->returnValue()->setBoolean(((KviTalGroupBox *)widget())->isChecked());
 
238
        return true;
 
239
}
 
240
KVSO_CLASS_FUNCTION(groupBox,setInsideMargin)
 
241
{
 
242
        CHECK_INTERNAL_POINTER(widget())
 
243
        kvs_uint_t uMargin;
 
244
        KVSO_PARAMETERS_BEGIN(c)
 
245
                KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
 
246
        KVSO_PARAMETERS_END(c)
 
247
        ((KviTalGroupBox *)widget())->setInsideMargin(uMargin);
 
248
        return true;
 
249
}
 
250
KVSO_CLASS_FUNCTION(groupBox,insideMargin)
 
251
{
 
252
        CHECK_INTERNAL_POINTER(widget())
 
253
        c->returnValue()->setInteger(((KviTalGroupBox *)widget())->insideMargin());
 
254
        return true;
 
255
}
 
256
KVSO_CLASS_FUNCTION(groupBox,setInsideSpacing)
 
257
{
 
258
        CHECK_INTERNAL_POINTER(widget())
 
259
        kvs_uint_t uSpacing;
 
260
        KVSO_PARAMETERS_BEGIN(c)
 
261
                KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
 
262
        KVSO_PARAMETERS_END(c)
 
263
    ((KviTalGroupBox *)widget())->setInsideSpacing(uSpacing);
 
264
        return true;
 
265
}
 
266
KVSO_CLASS_FUNCTION(groupBox,insideSpacing)
 
267
{
 
268
        CHECK_INTERNAL_POINTER(widget())
 
269
        c->returnValue()->setInteger(((KviTalGroupBox *)widget())->insideSpacing());
 
270
        return true;
 
271
}
 
272
 
 
273
KVSO_CLASS_FUNCTION(groupBox,addSpace)
 
274
{
 
275
        CHECK_INTERNAL_POINTER(widget())
 
276
        kvs_uint_t iSpace;
 
277
        KVSO_PARAMETERS_BEGIN(c)
 
278
                KVSO_PARAMETER("colums",KVS_PT_UNSIGNEDINTEGER,0,iSpace)
 
279
        KVSO_PARAMETERS_END(c)
 
280
        (((KviTalGroupBox *)widget())->addSpace(iSpace));
 
281
        return true;
 
282
}
 
283
 
 
284
KVSO_CLASS_FUNCTION(groupBox,setAlignment)
 
285
{
 
286
        CHECK_INTERNAL_POINTER(widget())
 
287
        QString szAlign;
 
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++)
 
292
        {
 
293
                if(KviQString::equalCI(szAlign, align_tbl[i]))
 
294
                {
 
295
                        ((KviTalGroupBox *)widget())->setAlignment(align_cod[i]);
 
296
                        return true;
 
297
                }
 
298
        }
 
299
        c->warning(__tr2qs_ctx("Unknown alignment '%Q'","objets"),&szAlign);
 
300
        return true;
 
301
}
 
302
 
 
303
KVSO_CLASS_FUNCTION(groupBox,alignment)
 
304
{
 
305
        CHECK_INTERNAL_POINTER(widget())
 
306
        int mode = ((KviTalGroupBox *)widget())->alignment();
 
307
        QString szAlignment="";
 
308
        for(unsigned int i = 0; i < align_num; i++)
 
309
        {
 
310
                if(mode == align_cod[i])
 
311
                {
 
312
                        szAlignment=align_tbl[i];
 
313
                        break;
 
314
                }
 
315
        }
 
316
        c->returnValue()->setString(szAlignment);
 
317
        return true;
 
318
}
 
319
 
 
320
KVSO_CLASS_FUNCTION(groupBox,setOrientation)
 
321
{
 
322
        CHECK_INTERNAL_POINTER(widget())
 
323
        QString szMode;
 
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);
 
329
        else
 
330
        if(KviQString::equalCI(szMode, "Vertical"))
 
331
                ((KviTalGroupBox *)widget())->setOrientation(Qt::Horizontal);
 
332
        else c->warning( __tr2qs_ctx("Unknown orientation '%Q'","objects"),&szMode);
 
333
 
 
334
        return true;
 
335
}