From 2184508144846b0cc9363b5ab35d7ce8365b7d0f Mon Sep 17 00:00:00 2001 From: Noldor Date: Mon, 22 Jan 2007 05:35:40 +0000 Subject: fixed clickevent on checkbox and removed old code from class buton git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@222 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/objects/class_button.cpp | 231 ----------------------------------- 1 file changed, 231 deletions(-) (limited to 'src/modules/objects/class_button.cpp') diff --git a/src/modules/objects/class_button.cpp b/src/modules/objects/class_button.cpp index bd2f85fef..56e50d3c0 100644 --- a/src/modules/objects/class_button.cpp +++ b/src/modules/objects/class_button.cpp @@ -28,237 +28,6 @@ #include "kvi_iconmanager.h" #include "class_button.h" -/* -static KviScriptObjectClass * g_pButtonClass = 0; - -static KviScriptObject * buttonClassCreateInstance(KviScriptObjectClass * c, - KviScriptObject * p, const char * n) -{ - return new KviScriptButtonObject(c, p, n); -} - -KviScriptButtonObject::KviScriptButtonObject(KviScriptObjectClass * c, KviScriptObject * p, - const char * n) : KviScriptWidgetObject(c, p, n) -{ -} - -KviScriptButtonObject::~KviScriptButtonObject() -{ -// debug("KviScriptButtonObject::~KviScriptButtonObject(%s)",id()); -} - - -/* - @doc: button - @keyterms: - button object class - @title: - button class - @type: - class - @short: - A simple, well-known button - @inherits: - [class]object[/class] - [class]widget[/class] - @description: - A button - nothing more, nothing else... - @functions: - !fn: $setText() - This function sets the text for this button. - !fn: $text() - Returns the current text of the button - !fn: $setImage() - Sets the image to be displayed on this label. - Giving empty argument clears the pixmap[br] - See the [doc:image_id]image identifier[/doc] documentation for - the explaination of the parameter. - !fn: $clickEvent() - This function is called by the framework when the button is clicked.[br] - You can reimplement it to handle the user click events.[br] - The default implementation emits the [classfnc]$clicked[/classfnc]() signal, - so it is easy to handle the clicks from many buttons without reimplementing - the $clickEvent() for every one.[br] - Note:[br] - If you reimplement this function to catch the user click events, you will have - to emit the signal by yourself (if you still need it , obviously). - @signals: - !sg: $clicked() - This signal is emitted by the default implementation of [classfnc]$clickEvent[/classfnc]().[br] - If you reimplement that function you will have to emit the signal manually (if you still need it). - -*/ -/* -bool KviScriptButtonObject::init(KviCommand *,KviParameterList *params) -{ - setObject(new QPushButton(parentScriptWidget(),name()),true); - connect(widget(),SIGNAL(clicked()),this,SLOT(slotClicked())); - return true; -} - -#define buttonFuncReg(__nam, __func) \ - g_pButtonClass->registerFunctionHandler(__nam, \ - (KviScriptObjectFunctionHandlerProc)(KVI_PTR2MEMBER(KviScriptButtonObject::__func)), \ - 0, true); - -void KviScriptButtonObject::registerSelf() -{ - KviScriptObjectClass * base = g_pScriptObjectController-> - lookupClass("widget"); - __range_valid(base); - - g_pButtonClass = new KviScriptObjectClass(base, "button", - buttonClassCreateInstance, true); - - buttonFuncReg("setText", functionSetText); - buttonFuncReg("text", functionText); - buttonFuncReg("setAutoDefault", functionSetAutoDefault); - buttonFuncReg("setToggleButton", functionSetToggleButton); - buttonFuncReg("setOn", functionSetOn); - buttonFuncReg("isOn", functionIsOn); - buttonFuncReg("toggle", functionToggle); - buttonFuncReg("setIsMenuButton", functionSetIsMenuButton); - buttonFuncReg("isMenuButton", functionIsMenuButton); - buttonFuncReg("clickEvent", functionClickEvent); - buttonFuncReg("setImage", functionSetImage); - -// g_pButtonClass->registerFunctionHandler("clickEvent",0,"emit clicked()"); -// slots -// buttonFuncReg("slotClicked", functionSlotClicked); -// buttonFuncReg("slotClicked", __slotClicked); - //g_pButtonClass->registerEmptyFunctionHandler("slotClicked"); -} - -void KviScriptButtonObject::unregisterSelf() -{ - delete g_pButtonClass; - g_pButtonClass = 0; -} - -bool KviScriptButtonObject::functionSetText(KviCommand *, KviParameterList * p, \ - KviStr &) -{ - if(widget()) - { - if(p->first()) - ((QPushButton *)widget())->setText(p->first()->ptr()); - else - ((QPushButton *)widget())->setText(""); - } - return true; -} - -bool KviScriptButtonObject::functionText(KviCommand *, KviParameterList *, KviStr & b) -{ - if(widget()) - { - KviStr s = ((QPushButton *)widget())->text(); - b.append(s); - } - return true; -} - -bool KviScriptButtonObject::functionSetAutoDefault(KviCommand *, KviParameterList * p, - KviStr &) -{ - if(widget()) - { - ((QPushButton *)widget())->setAutoDefault(p->getBool()); - } - return true; -} - -bool KviScriptButtonObject::functionSetToggleButton(KviCommand *,KviParameterList * p, - KviStr &) -{ - if(widget()) - { - ((QPushButton *)widget())->setToggleButton(p->getBool()); - } - return true; -} - -bool KviScriptButtonObject::functionSetOn(KviCommand *,KviParameterList * p, KviStr &) -{ - if(widget()) - { - ((QPushButton *)widget())->setOn(p->getBool()); - } - return true; -} - -bool KviScriptButtonObject::functionIsOn(KviCommand *, KviParameterList *, KviStr & b) -{ - if(widget()) - { - bool t = ((QPushButton *)widget())->isOn(); - b.append( t ? '1' : '0' ); - } - return true; -} - -bool KviScriptButtonObject::functionToggle(KviCommand *,KviParameterList * p, - KviStr &) -{ - if(widget()) - { - ((QPushButton *)widget())->toggle(); - } - return true; -} - -bool KviScriptButtonObject::functionSetIsMenuButton(KviCommand *,KviParameterList * p, - KviStr &) -{ - if(widget()) - { - ((QPushButton *)widget())->setIsMenuButton(p->getBool()); - } - return true; -} - -bool KviScriptButtonObject::functionIsMenuButton(KviCommand *,KviParameterList *, - KviStr & b) -{ - if(widget()) - { - bool t = ((QPushButton *)widget())->isMenuButton(); - b.append( t ? '1' : '0' ); - } - return true; -} -bool KviScriptButtonObject::functionSetImage(KviCommand * c, KviParameterList * p, - KviStr & b) -{ - QPixmap *pix = 0; - - if(!widget())return true; - - if(p->first())pix = g_pIconManager->getImage(p->first()->ptr()); - - if(pix) - { - ((QPushButton *)widget())->setIconSet(QIconSet(*pix,QIconSet::Small)); - } else { - ((QPushButton *)widget())->setIconSet(QIconSet()); - } - return true; - } - - -bool KviScriptButtonObject::functionClickEvent(KviCommand *c,KviParameterList *,KviStr &) -{ - ENTER_STACK_FRAME(c,"button::clickEvent"); - emitSignal("clicked",0,0,c); - return c->leaveStackFrame(); -} - -void KviScriptButtonObject::slotClicked() -{ - callEventFunction("clickEvent"); -} -*/ -//--------------------------------------------------------------------------------- KVSO_BEGIN_REGISTERCLASS(KviKvsObject_button,"button","widget") -- cgit v1.3.1-10-gc9f91