//============================================================================= // // 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 TQt::WidgetAttribute widgetattributes_cod[]= { TQt::WA_OpaquePaintEvent, TQt::WA_NoSystemBackground, TQt::WA_PaintOnScreen, TQt::WA_NoMousePropagation, }; const char * const widgetattributes_tbl[] = { "opaquePaintEvent", "noSystemBackground", "paintOnScreen", "noMousePropagation", }; #define widgetattributes_num (sizeof(widgetattributes_tbl) / sizeof(widgetattributes_tbl[0])) const TQt::WindowType widgettypes_cod[] = { #else const int widgettypes_cod[] = { #endif TQt::WType_TopLevel, TQt::WType_Dialog, TQt::WType_Popup, TQt::WType_Desktop, TQt::WStyle_Customize, TQt::WStyle_Title, TQt::WStyle_StaysOnTop, TQt::WStyle_SysMenu, TQt::WStyle_Minimize, TQt::WStyle_Maximize, TQt::WNoAutoErase }; #ifdef COMPILE_USE_QT4 #define TQT_WIDGET_TABFOCUS TTQ_TabFocus #define TQT_WIDGET_CLICKFOCUS TTQ_ClickFocus #define TQT_WIDGET_STRONGFOCUS TTQ_StrongFocus #define TQT_WIDGET_NOFOCUS TTQ_NoFocus #else #define TQT_WIDGET_TABFOCUS TQ_TabFocus #define TQT_WIDGET_CLICKFOCUS TQ_ClickFocus #define TQT_WIDGET_STRONGFOCUS TQ_StrongFocus #define TQT_WIDGET_NOFOCUS TQ_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:tqlayout]tqlayout 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:tqlayout]tqlayout 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:tqlayout]tqlayout 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:tqlayout]tqlayout 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(