From a6d58bb6052ac8cb01805a48c4ad2f129126116f Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Feb 2010 02:13:59 +0000 Subject: Added KDE3 version of kvirc git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/modules/objects/class_widget.cpp | 1745 ++++++++++++++++++++++++++++++++++ 1 file changed, 1745 insertions(+) create mode 100644 src/modules/objects/class_widget.cpp (limited to 'src/modules/objects/class_widget.cpp') diff --git a/src/modules/objects/class_widget.cpp b/src/modules/objects/class_widget.cpp new file mode 100644 index 0000000..d248c98 --- /dev/null +++ b/src/modules/objects/class_widget.cpp @@ -0,0 +1,1745 @@ +//============================================================================= +// +// File : class_widget.cpp +// Creation date : Mon Sep 11 16:35:32 CET 2000 by Krzysztof Godlewski +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 1999-2005 Szymon Stefanek (pragma at kvirc dot net) +// +// 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 +// of the License, or (at your opinion) 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 Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "kvi_malloc.h" +#include "kvi_debug.h" + +#include "kvi_error.h" +#include "kvi_locale.h" +#include "kvi_iconmanager.h" +#include "kvi_window.h" +#include "kvi_out.h" +#include "kvi_mirccntrl.h" +#include "kvi_app.h" +#include "kvi_string.h" +#include +#include +#include +#include +#include +#include +#include "class_widget.h" +#include "class_pixmap.h" + +#ifdef COMPILE_USE_QT4 + #include + #include +#else + #include +#endif + +#include +#include +#include +#include + +// FIX ME: WFLAGS +const char * const widgettypes_tbl[] = { + "TopLevel", + "Dialog", + "Popup", + "Desktop", + "Customize", + "Title", + "StaysOnTop", + "SysMenu", + "Minimize", + "Maximize", + "NoAutoErase" + }; +#ifdef COMPILE_USE_QT4 +const Qt::WidgetAttribute widgetattributes_cod[]= { + Qt::WA_OpaquePaintEvent, + Qt::WA_NoSystemBackground, + Qt::WA_PaintOnScreen, + Qt::WA_NoMousePropagation, +}; + +const char * const widgetattributes_tbl[] = { + "opaquePaintEvent", + "noSystemBackground", + "paintOnScreen", + "noMousePropagation", +}; +#define widgetattributes_num (sizeof(widgetattributes_tbl) / sizeof(widgetattributes_tbl[0])) + + +const Qt::WindowType widgettypes_cod[] = { +#else +const int widgettypes_cod[] = { +#endif + Qt::WType_TopLevel, + Qt::WType_Dialog, + Qt::WType_Popup, + Qt::WType_Desktop, + Qt::WStyle_Customize, + Qt::WStyle_Title, + Qt::WStyle_StaysOnTop, + Qt::WStyle_SysMenu, + Qt::WStyle_Minimize, + Qt::WStyle_Maximize, + Qt::WNoAutoErase +}; + + +#ifdef COMPILE_USE_QT4 + + #define QT_WIDGET_TABFOCUS Qt::TabFocus + #define QT_WIDGET_CLICKFOCUS Qt::ClickFocus + #define QT_WIDGET_STRONGFOCUS Qt::StrongFocus + #define QT_WIDGET_NOFOCUS Qt::NoFocus + +#else + #define QT_WIDGET_TABFOCUS QWidget::TabFocus + #define QT_WIDGET_CLICKFOCUS QWidget::ClickFocus + #define QT_WIDGET_STRONGFOCUS QWidget::StrongFocus + #define QT_WIDGET_NOFOCUS QWidget::NoFocus +#endif + + +#define widgettypes_num (sizeof(widgettypes_tbl) / sizeof(widgettypes_tbl[0])) + +/* + @doc: widget + @keyterms: + widget object class + @title: + widget class + @type: + class + @short: + Base class for all widgets + @inherits: + [class]object[/class] + @description: + This object class is the rappresentation of a widget. + All the other widget-type classes inherit from this one. + @functions: + !fn: $show() + Shows this widget and the children. + See also [classfnc]$hide[/classfnc]() and [classfnc]$isVisible[/classfnc]. + !fn: $hide() + Hides this widget (and conseguently all the children). + See also [classfnc]$show[/classfnc]() and [classfnc]$isVisible[/classfnc]. + !fn: $repaint() + Repaints the widget directly by calling [classfnc]$paintEvent[/classfnc]() immediately.[br] + If erase is TRUE, erases the widget before the $paintEvent() call. + !fn: $x() + Returns the x coordinate of the upper-left corner + of this widget relative to the parent widget, + or to the desktop if this widget is a toplevel one. + !fn: $y() + Returns the y coordinate of the uspper-left corner + of this widget relative to the parent widget, + or to the desktop if this widget is a toplevel one. + !fn: $width() + Returns the width of this widget in pixels. + !fn: $height() + Returns the height of this widget in pixels. + !fn: $geometry() + Returns the widget geometry in this form:[br] + x, y, width, height. + !fn: $setGeometry(,[,,]) + Sets the geometry of this widget. and are relative + to the parent widget or to the desktop (if this widget is + a toplevel one). All the parameters are in pixels. + !fn: $setMinimumWidth() + Sets the minimum width of this widget to . + The user will not be able to resize the widget to a smaller + value. This value is also used by the [class:layout]layout class[/class]. + !fn: $setMinimumHeight() + Sets the minimum height of this widget to . + The user will not be able to resize the widget to a smaller + value. This value is also used by the [class:layout]layout class[/class]. + !fn: $setMaximumWidth() + Sets the maximum width of this widget to . + The user will not be able to resize the widget to a bigger + value. This value is also used by the [class:layout]layout class[/class]. + !fn: $setMaximumHeight() + Sets the maximum height of this widget to . + The user will not be able to resize the widget to a bigger + value. This value is also used by the [class:layout]layout class[/class]. + !fn: $move([,]) + Moves this widget to the coordinate and relative to its + parent widget (or the desktop if this widget is a toplevel one). + This is equivalent to [classfnc]$setGeometry[/classfnc](,, + [classfnc]$width[/classfnc](),[classfnc]$height[/classfnc]()). + !fn: $resize(,[height]) + Changes the widget's width to and height to . + See also [classfnc]$setGeometry[/classfnc](). + !fn: $isEnabled() + Returns '1' if the widget is enabled , '0' otherwise. + See also [classfnc:widget]$setEnabled[/classfnc](). + !fn: $setEnabled() + Sets the widget state to enabled or disabled if is 1 or 0 respectively. + A disabled widget does not receive keyboard nor mouse input. + !fn: $setCaption() + Sets the caption of this widget to . + This is meaningful for toplevel widgets only. + !fn: $setToolTip() + Set the tooltip of this widget; the text can contain HTML formatting. + !fn: $window.caption() + Returns the caption text of this widget. + !fn: $isTopLevel() + Returns '1' if this widget is a toplevel (parentless) one, + '0' otherwise. + !fn: $isVisible() + Returns '1' if this widget is currently visible (read: is managed + by the window manager and displayed by the X server; the widget + may be hidden behind other widgets). If the widget is not visible + this function returns '0'. + See also [classfnc]$show[/classfnc]() and [classfnc]$hide[/classfnc](). + !fn: $raise() + Moves this widget to the top of the stack of the widgets relative + to its parent. See also [classfnc]$lower[/classfnc]. + !fn: $lower() + Moves this widget to the bottom of the stack of the widgets relative + to its parent. See also [classfnc]$raise[/classfnc] + !fn: $hasFocus() + Returns '1' if this widget has the keyboard focus. + See also [classfnc]$setFocus[/classfnc]. + !fn: $setFocus() + Sets this widget to be the one that receives keyboard events. + See also [classfnc]$hasFocus[/classfnc] + !fn: $parentWidget() + Returns the object id of the parent widget, or '0' if this + widget is a toplevel one. + !fn: $backgroundColor() + Returns the background color of this widget in hexadecimal + html-like format. For example , for a black bacground you will get + the string "000000" , for a red one , "FF0000", for a white one + "FFFFFF". See also [classfnc]$setBackgroundColor[/classfnc]() + !fn: $setBackgroundColor(,[geen:integer],[blue:integer]) + Sets the background color of this widget to :valid values are: + - hex string: must be a string with 6 hexadecimal digits (like the ones used to + specify colors in html pages). The first two digits specify + the RED component, the third and fourth digit specify the GREEN component + and the last two specify the BLUE component. + For example "FFFF00" means full red, full green and no blue that gives + a yellow color, "808000" designates a brown color (dark yellow), + "A000A0" is a kind of violet. + - array(red:integer,green:integer,blue:integer) + - red:integer,green:integer,blue:integer. + See also [classfnc]$foregroundColor[/classfnc]. + !fn: $setForegroundColor(,[geen:integer],[blue:integer]) + Sets the foreground color of this widget to :valid values are: + - hex string: must be a string with 6 hexadecimal digits (like the ones used to + specify colors in html pages). The first two digits specify + the RED component, the third and fourth digit specify the GREEN component + and the last two specify the BLUE component. + For example "FFFF00" means full red, full green and no blue that gives + a yellow color, "808000" designates a brown color (dark yellow), + "A000A0" is a kind of violet. + - array(red:integer,green:integer,blue:integer) + - red:integer,green:integer,blue:integer. + See also [classfnc]$foregroundColor[/classfnc]. + !fn: $foregroundColor() + Returns the foreground color of this widget in hexadecimal + html-like format. + See also [classfnc]$setForegroundColor[/classfnc]. + !fn: $setMouseTracking() + Enables or disables the mouse tracking if is '1' or '0' respectively. + When mouse tracking is enabled you will receive mouse move events + even if no button is pressed, otherwise you will receive it only + when a mouse button is being pressed (so after a mousePressEvent). + !fn: $mousePressEvent(