2010-02-10 02:12:56 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
gb.form.action.h
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2010-02-10 02:12:56 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2010-02-10 02:12:56 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __GB_FORM_ACTION_H
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
#define HAS_ACTION(_widget)
|
|
|
|
If a widget has the action flag set.
|
|
|
|
|
|
|
|
#define SET_ACTION(_widget, _flag)
|
|
|
|
Sets or clears the action flag.
|
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
static GB_FUNCTION _action_register_func;
|
|
|
|
static GB_FUNCTION _action_raise_func;
|
2011-09-01 16:19:34 +02:00
|
|
|
//static GB_FUNCTION _action_get_func;
|
2010-02-10 02:12:56 +01:00
|
|
|
|
|
|
|
static void init_action()
|
|
|
|
{
|
|
|
|
static bool init = false;
|
|
|
|
void *klass;
|
|
|
|
|
|
|
|
if (init)
|
|
|
|
return;
|
|
|
|
|
|
|
|
klass = (void *)GB.FindClass("Action");
|
2011-09-05 21:57:05 +02:00
|
|
|
GB.GetFunction(&_action_register_func, klass, "_Register", "oss", "");
|
2010-02-10 02:12:56 +01:00
|
|
|
GB.GetFunction(&_action_raise_func, klass, "Raise", "o", "");
|
2011-09-01 16:19:34 +02:00
|
|
|
//GB.GetFunction(&_action_get_func, klass, "Get", "o", "s");
|
2010-02-10 02:12:56 +01:00
|
|
|
|
|
|
|
init = true;
|
|
|
|
}
|
|
|
|
|
2011-09-01 16:19:34 +02:00
|
|
|
void CACTION_register(void *control, const char *old, const char *key)
|
2010-02-10 02:12:56 +01:00
|
|
|
{
|
|
|
|
//qDebug("CACTION_register: (%s %p) %s", GB.GetClassName(control), control, key);
|
|
|
|
//fprintf(stderr, "CACTION_register: (%s %p %p) %s\n", GB.GetClassName(control), control, ((CWIDGET *)control)->widget, key);
|
|
|
|
|
|
|
|
if ((!key || !*key) && !HAS_ACTION(control))
|
|
|
|
//&& !GB.Is(control, CLASS_UserControl) && !GB.Is(control, CLASS_UserContainer))
|
|
|
|
return;
|
|
|
|
|
|
|
|
init_action();
|
|
|
|
|
2011-09-01 16:19:34 +02:00
|
|
|
GB.Push(3,
|
2010-02-10 02:12:56 +01:00
|
|
|
GB_T_OBJECT, control,
|
2011-09-01 16:19:34 +02:00
|
|
|
GB_T_STRING, old, 0,
|
2010-02-10 02:12:56 +01:00
|
|
|
GB_T_STRING, key, 0);
|
|
|
|
|
2012-10-15 00:42:53 +02:00
|
|
|
// The register function must not raise an error, otherwise bad things may happen
|
2011-09-01 16:19:34 +02:00
|
|
|
GB.Call(&_action_register_func, 3, true);
|
2010-02-10 02:12:56 +01:00
|
|
|
|
|
|
|
SET_ACTION(control, key && *key);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CACTION_raise(void *control)
|
|
|
|
{
|
|
|
|
init_action();
|
|
|
|
|
|
|
|
//qDebug("CACTION_raise: (%s %p)", GB.GetClassName(THIS), THIS);
|
|
|
|
|
|
|
|
if (!HAS_ACTION(control))
|
|
|
|
return;
|
|
|
|
|
|
|
|
GB.Push(1, GB_T_OBJECT, control);
|
|
|
|
GB.Call(&_action_raise_func, 1, true);
|
|
|
|
}
|