1
// =============================================================================
3
// This file is part of the KVIrc IRC client distribution
4
// Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
6
// This program is FREE software. You can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your opinion) any later version.
11
// This program is distributed in the HOPE that it will be USEFUL,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
// See the GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program. If not, write to the Free Software Foundation,
18
// Inc, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
// =============================================================================
22
#define _KVI_DEBUG_CHECK_RANGE_
23
#define _KVI_DEBUG_CLASS_NAME_ "KviScriptToolBar"
25
#include "kvi_error.h"
26
#include "kvi_frame.h"
27
#include "kvi_script_objectclassdefinition.h"
28
#include "kvi_script_objectcontroller.h"
29
#include "kvi_script_toolbar.h"
30
#include "kvi_toolbar.h"
37
[class]object[/class]<br>
40
!fn: $dock(<docksite>)
41
Docks the toolbar to one of the sides of the main window.<br>
42
Returns 1 if the operation was sucessfull or 0 if the toolbar is not
43
a children or a KVIrc main window and thus cannot be docked successfully.<br>
44
The <docksite> can be one of :<br>
45
top, left, right, bottom, minimized.<br>
47
!fn: $setDockEnabled(<docksite>, <bEnabled>)
48
Enables or disables a specific docksite for this toolbar.<br>
49
The <docksite> can be one of :<br>
50
top, left, right, bottom, minimized.<br>
51
<bEnabled> can be '1' to enable the docksite and '0' to disable it.<br>
52
Returns 1 if the operation was sucessfull or 0 if the toolbar is not
53
a children or a KVIrc main window and thus cannot be docked successfully.<br>
57
It is used mainly with the [class]toolbutton[/class] objects.<br>
58
If the parent of the toolbar is a non-widget object ([fnc]$root[/fnc] for example),
59
the toolbar will be owned by the main KVIrc window.<br>
60
In that case, it will be possible to dock it to one of the four sides
61
of the window and drag it around.<br>
66
class [class]object[/class], <br>
67
class [class]widget[/class], <br>
68
class [class]toolbutton[/class], <br>
69
<a href="syntax_objects.kvihelp">Objects documentation</a><br>
75
void KviScriptToolBar::initializeClassDefinition(KviScriptObjectClassDefinition *d)
77
d->addBuiltinFunction("dock", (scriptObjectFunction) &KviScriptToolBar::builtinFunction_DOCK);
78
d->addBuiltinFunction("setDockEnabled", (scriptObjectFunction) &KviScriptToolBar::builtinFunction_SETDOCKENABLED);
81
KviScriptToolBar::KviScriptToolBar(
82
KviScriptObjectController *cntrl, KviScriptObject *p, const char *name, KviScriptObjectClassDefinition *pDef)
83
: KviScriptWidget(cntrl, p, name, pDef)
88
KviScriptToolBar::~KviScriptToolBar()
93
bool KviScriptToolBar::init(QPtrList<KviStr> *params)
96
if( parent()->inherits("KviScriptWidget") ) {
97
m_pWidget = new KviToolBar(
98
name(), controller()->mainFrame(), ((KviScriptWidget *) parent())->m_pWidget, Qt::DockTop, false, name()
103
m_pWidget = new KviToolBar(name(), controller()->mainFrame(), controller()->mainFrame(), Qt::DockTop, false, name());
104
m_bAutoDestroyControlledWidget = true;
105
m_pWidget->installEventFilter(this);
106
connect(m_pWidget, SIGNAL(destroyed()), this, SLOT(widgetDestroyed()));
110
Qt::Dock KviScriptToolBar::getDockId(const char *str)
112
if( !str ) return DockMinimized;
114
if( kvi_strEqualCI(str, "top") ) return DockTop;
115
if( kvi_strEqualCI(str, "bottom") ) return DockBottom;
116
if( kvi_strEqualCI(str, "left") ) return DockLeft;
117
if( kvi_strEqualCI(str, "right") ) return DockRight;
118
return DockMinimized;
121
int KviScriptToolBar::builtinFunction_DOCK(QPtrList<KviStr> *params, KviStr &buffer)
123
if( parent()->inherits("KviScriptWidget") ) {
126
return KVI_ERROR_Success;
129
KviStr *pS = params->first();
131
KviMainWindow *w = (KviMainWindow *) ((KviToolBar *) m_pWidget)->mainWindow();
133
w->moveToolBar((KviToolBar *) m_pWidget, getDockId(pS->ptr()));
139
return KVI_ERROR_Success;
142
return KVI_ERROR_MissingParameter;
145
int KviScriptToolBar::builtinFunction_SETDOCKENABLED(QPtrList<KviStr> *params, KviStr &buffer)
147
if( parent()->inherits("KviScriptWidget") ) {
150
return KVI_ERROR_Success;
153
KviStr *pS = params->first();
155
KviStr *pS2 = params->next();
158
if( kvi_strEqualCI(pS2->ptr(), "0") )
161
KviMainWindow *w = (KviMainWindow *) ((KviToolBar *) m_pWidget)->mainWindow();
163
w->setDockEnabled((KviToolBar *) m_pWidget, getDockId(pS->ptr()), bEnable);
169
return KVI_ERROR_Success;
172
return KVI_ERROR_MissingParameter;
175
#include "m_kvi_script_toolbar.moc"