From c601b5a27f74b16158adafe429faefbe573e64a2 Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Sat, 1 Jan 2011 20:19:56 +0000 Subject: The big rename for modules. Still some details remaining. git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5284 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/modules/objects/KvsObject_widget.cpp | 2030 ++++++++++++++++++++++++++++++ 1 file changed, 2030 insertions(+) create mode 100644 src/modules/objects/KvsObject_widget.cpp (limited to 'src/modules/objects/KvsObject_widget.cpp') diff --git a/src/modules/objects/KvsObject_widget.cpp b/src/modules/objects/KvsObject_widget.cpp new file mode 100644 index 000000000..c0598b7ae --- /dev/null +++ b/src/modules/objects/KvsObject_widget.cpp @@ -0,0 +1,2030 @@ +//============================================================================= +// +// File : KvsObject_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) 2000 Krzysztof Godlewski +// Copyright (C) 2000-2010 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 "KvsObject_widget.h" +#include "KvsObject_pixmap.h" + +#include "KviMemory.h" +#include "kvi_debug.h" +#include "KviError.h" +#include "KviLocale.h" +#include "KviIconManager.h" +#include "KviWindow.h" +#include "KviApplication.h" +#include "KviMainWindow.h" +#include "KviStatusBar.h" +#include "KvsObject_painter.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef COMPILE_WEBKIT_SUPPORT + #include +#endif + +KviKvsWidget::KviKvsWidget(KvsObject_widget * object,QWidget * par) +:QWidget(par), m_pObject(object) +{ +} + +KviKvsWidget::~KviKvsWidget() +{ +} + +QSize KviKvsWidget::sizeHint() const +{ + QSize size=QWidget::sizeHint(); + KviKvsVariant *tipret=new KviKvsVariant(); + KviKvsVariantList params(new KviKvsVariant((kvs_int_t)size.width()),new KviKvsVariant((kvs_int_t)size.height())); + m_pObject->callFunction(m_pObject,"sizeHintRequestEvent",tipret,¶ms); + if (tipret->isArray()) + { + if (tipret->array()->size()==2) + { + kvs_int_t w,h; + if (tipret->array()->at(0)->asInteger(w) && tipret->array()->at(1)->asInteger(h))return QSize(w,h); + } + } + return QWidget::sizeHint(); +} + + + +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 QPalette::ColorRole colorrole_cod[] = { + QPalette::Window, + QPalette::Background, + QPalette::WindowText, + QPalette::Foreground, + QPalette::Base, + QPalette::AlternateBase, + QPalette::Text, + QPalette::Button, + QPalette::ButtonText, + QPalette::BrightText, + QPalette::Highlight, + QPalette::HighlightedText +}; + +const char * const colorrole_tbl[] = { + "Window", + "Background", + "WindowText", + "Foreground", + "Base", + "AlternateBase", + "Text", + "Button", + "ButtonText", + "BrightText", + "Highlight", + "HighlightedText" +}; + +#define colorrole_num (sizeof(colorrole_tbl) / sizeof(colorrole_tbl[0])) + + +const Qt::WindowType widgettypes_cod[] = { + Qt::Window, + Qt::Dialog, + Qt::Popup, + Qt::Desktop, + Qt::WindowTitleHint, + Qt::WindowStaysOnTopHint, + Qt::WindowSystemMenuHint, + Qt::WindowMinimizeButtonHint, + Qt::WindowMaximizeButtonHint, + Qt::SubWindow, + Qt::FramelessWindowHint +}; + + +const char * const widgettypes_tbl[] = { + "Window", + "Dialog", + "Popup", + "Desktop", + "Title", + "StaysOnTop", + "SysMenu", + "Minimize", + "Maximize", + "Subwindow", + "FramelessWindow" +}; + + +#define widgettypes_num (sizeof(widgettypes_tbl) / sizeof(widgettypes_tbl[0])) + + +#define QT_WIDGET_TABFOCUS Qt::TabFocus +#define QT_WIDGET_CLICKFOCUS Qt::ClickFocus +#define QT_WIDGET_STRONGFOCUS Qt::StrongFocus +#define QT_WIDGET_NOFOCUS Qt::NoFocus +/* + @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. + !fn: $update([,,,]) + Updates enterily the widget or a rectangle. + This function does not cause an immediate [classfnc]$paintEvent[/classfnc](); instead it schedules a paint event for processing when KVIrc returns to the main event loop. + !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: $setWindowTitle() + Sets the title 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: $windowTitle() + Returns the title 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(