widget class

Base class for all widgets
Inherits
object
Description
This object class is the rappresentation of a widget. All the other widget-type classes inherit from this one.
Functions
$show()
Shows this widget and the children. See also $hide() and $isVisible.
$hide()
Hides this widget (and conseguently all the children). See also $show() and $isVisible.
$repaint(<bool erase>)
Repaints the widget directly by calling $paintEvent() immediately.
If erase is TRUE, erases the widget before the $paintEvent() call.
$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.
$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.
$width()
Returns the width of this widget in pixels.
$height()
Returns the height of this widget in pixels.
$geometry()
Returns the widget geometry in this form:
x, y, width, height.
$setGeometry(<x_or_array>,[<y>,<width>,<heigth>])
Sets the geometry of this widget. <x> and <y> are relative to the parent widget or to the desktop (if this widget is a toplevel one). All the parameters are in pixels.
$setMinimumWidth(<value>)
Sets the minimum width of this widget to <value>. The user will not be able to resize the widget to a smaller value. This value is also used by the layout class.
$setMinimumHeight(<value>)
Sets the minimum height of this widget to <value>. The user will not be able to resize the widget to a smaller value. This value is also used by the layout class.
$setMaximumWidth(<value>)
Sets the maximum width of this widget to <value>. The user will not be able to resize the widget to a bigger value. This value is also used by the layout class.
$setMaximumHeight(<value>)
Sets the maximum height of this widget to <value>. The user will not be able to resize the widget to a bigger value. This value is also used by the layout class.
$move(<x_or_array>[,<y>])
Moves this widget to the coordinate <x> and <y> relative to its parent widget (or the desktop if this widget is a toplevel one). This is equivalent to $setGeometry(<x>,<y>, $width(),$height()).
$resize(<w_or_array>,[height])
Changes the widget's width to <width> and height to <height>. See also $setGeometry().
$isEnabled()
Returns '1' if the widget is enabled , '0' otherwise. See also $setenabled().
$setEnabled(<bool>)
Sets the widget state to enabled or disabled if <bool> is 1 or 0 respectively. A disabled widget does not receive keyboard nor mouse input.
$setCaption(<text>)
Sets the caption of this widget to <text>. This is meaningful for toplevel widgets only.
$setToolTip(<tooltip_text>)
Set the tooltip of this widget; the text can contain HTML formatting.
$window.caption()
Returns the caption text of this widget.
$isTopLevel()
Returns '1' if this widget is a toplevel (parentless) one, '0' otherwise.
$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 $show() and $hide().
$raise()
Moves this widget to the top of the stack of the widgets relative to its parent. See also $lower.
$lower()
Moves this widget to the bottom of the stack of the widgets relative to its parent. See also $raise
$hasFocus()
Returns '1' if this widget has the keyboard focus. See also $setFocus.
$setFocus()
Sets this widget to be the one that receives keyboard events. See also $hasFocus
$parentWidget()
Returns the object id of the parent widget, or '0' if this widget is a toplevel one.
$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 $setBackgroundColor()
$setBackgroundColor(<rgb(hex string)_array(red:integer,green:integer,blue_integer)_or_red>,[geen:integer],[blue:integer])
Sets the background color of this widget to <rgb_value>: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 $foregroundColor.
$setForegroundColor(<rgb(hex string)_array(red:integer,green:integer,blue_integer)_or_red>,[geen:integer],[blue:integer])
Sets the foreground color of this widget to <rgb_value>: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 $foregroundColor.
$foregroundColor()
Returns the foreground color of this widget in hexadecimal html-like format. See also $setForegroundColor.
$setMouseTracking(<bool>)
Enables or disables the mouse tracking if <bool> 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).
$mousePressEvent(<button>,<x>,<y>)
This function is called when a mouse button is pressed while the cursor is in this widget. <button> is 0 if the pressed button is the left one, 1 if the button is the right one and 2 if it is the middle one. The <x> and <y> coordinates are relative to this widget upper-left corner and are expressed in pixels. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$mouseReleaseEvent(<button>,<x>,<y>)
This function is called when a mouse button is released while the cursor is in this widget. <button> is 0 if the released button is the left one, 1 if the button is the right one and 2 if it is the middle one. The <x> and <y> coordinates are relative to this widget upper-left corner and are expressed in pixels. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$mouseDoubleClickEvent(<button>,<x>,<y>)
This function is called when a mouse button is double clicked while the cursor is in this widget. <button> is 0 if the double clicked button is the left one, 1 if the button is the right one and 2 if it is the middle one. The <x> and <y> coordinates are relative to this widget upper-left corner and are expressed in pixels. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$mouseMoveEvent(<button>,<x>,<y>)
This function is called when the mouse cursor moves inside this widget. <button> is 0 if the pressed button is the left one, 1 if the button is the right one and 2 if it is the middle one. The special value of -1 indicates that no button is being pressed. The <x> and <y> coordinates are relative to this widget upper-left corner and are expressed in pixels. Normally you will receive this event only if a mouse button is being pressed while moving. If you want to receive it also when the mouse buttons are not pressed, call $setMouseTracking(). If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$focusInEvent()
This function is called when this widget gains keyboard focus. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$focusOutEvent()
This function is called when this widget looses keyboard focus. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$mouseLeaveEvent()
This function is called when the mouse leaves this widget. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$mouseEnterEvent()
This function is called when the mouse enters this widget. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$showEvent()
This function is called when this widget is being shown. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$hideEvent()
This function is called when this widget is being hidden. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$closeEvent()
This function is called when this widget is going to be closed. If you call "setreturn 1" you will ignore the close event. The default implementation does nothing.
$resizeEvent()
This function is called immediately after this widget has been resized. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$moveEvent()
This function is called immediately after this widget has been moved. If you call "setreturn 1" you will stop the internal processing of this event. The default implementation does nothing.
$paintEvent()
This event handler can be reimplemented to repaint all or part of the widget. It's needed by the Painter class. It's very useful for drawing flicker free animations or low level special graphic effects. The default implementation does nothing.
$setIcon(<image_id>)
Sets the icon for this widget. This is meaningful only for toplevel widgets. See the image identifier documentation for the explaination of the <image_id> parameter.
$setBackgroundImage(<image_id>)
Sets the background image for this widget. See the image identifier documentation for the explaination of the <image_id> parameter. For some kind of widgets, setting a background pixmap may have no effect or have strange results. Experiment with it. To unset the background image call $setBackgroundColor
$setFont(<size>,<family>,<style>)
Set the font's size, family and stile, valid flag for style are:
 italic     
bold
underline
overline
strikeout
fixedpitch
$setWFlags(<flag1>, <flag2>, ...)
This function sets widget flags, given as parameters. Valid flags are:
 TopLevel        - indicates that this widget is a top-level widget
Dialog        - indicates that this widget is a top-level window that should be decorated as a dialog
Desktop        - indicates that this widget is the desktop
Popup        - indicates that this widget is a popup top-level window
NoAutoErase - indicates that this widget paints all its pixels. Updating, resizing, scrolling and focus changes should therefore not erase the widget. Customize    - let's the user to customize the style of the widget.

Valid parameter for a customized widget are:
Title            - gives the window a title bar
StaysOnTop    - window stays on top
SysMenu        - add a windows system menu
Minimize        - add a minimize button for the sysmenu style
Maximize        - add a maximixe button for the sysmenu style
$centerToScreen()
Centers the window on the screen (useful only for toplevel widgets).
The best place to call this function is in $showEvent()
$setFocusPolicy(<key focus>)
Sets the way the widget accepts keyboard focus.
Valid parameters are:
 - TabFocus;    (widget accepts keyboard focus by tabbing)
- ClickFocus; (widget accepts keyboard focus by clicking)
- StrongFocus; (widget accepts both tabbing/clicking)
- No Focus; (widget does not accept focus at all; this is the default value)
$keyPressEvent(<key>)
If widget accepts keyboard focus (see $setFocusPolicy ) this function handles for keys; In its argument the key pressed.
Special keys are:
 - Return 
- Enter    
- Down (cursor arrow down)
- Up (cursor arrow up)
- Left (cursor arrow left)
- Right (cursor arrow right)
- Shift
- Ctrl
- Alt
- CapsLock
- Backspace
- Del
- Esc
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- +
- -
- *
- /
- (
- )
- =
- .
- ^
$mapFromGlobal(<x>,<y>)
Translates the global screen coordinate pos to widget coordinates.
$mapToGlobal(<x>,<y>)
Translates widget coordinates into the global screen coordinate pos.
integer $globalCursorX()
Return the x coordinate of mouse pointer global position.
integer $globalCursorY()
Return the y coordinate of the mouse pointer global position.
Examples

    %Widget = $new(widget)
    # This is the main container for other elements.
    %Widget->$setCaption("This is the widget title")
    %Widget->$setGeometry(100,200,170,290)
    # 100 and 200 are distance (pixel) from the left and the top of father widget (in this case the KVIrc window)
    # 300 and 400 are the weight and the height of the widget
    %Widget->%label = $new(label,%Widget)
    %Widget->%label->$setText("This is a text label")
    %Widget->%label->$setGeometry(10,10,150,20)
    %Widget->%lineedit = $new(lineedit,%Widget)
    %Widget->%lineedit->$setText("This is a lineedit")
    %Widget->%lineedit->$setGeometry(10,40,150,20)
    %Widget->%multilineedit = $new(multilineedit,%Widget)
    %Widget->%multilineedit->$setText("This is a multilineedit")
    %Widget->%multilineedit->$setGeometry(10,70,150,40)
    %Widget->%checkbox = $new(checkbox,%Widget)
    %Widget->%checkbox->$setText("This is a checkbox")
    %Widget->%checkbox->$setGeometry(10,120,150,20)
    %Widget->%combobox = $new(combobox,%Widget)
    %Widget->%combobox->$setGeometry(10,150,150,20)
    %Widget->%combobox->$insertItem("This is a combobox")
    %Widget->%combobox->$insertItem("This is a combobox's item")
    %Widget->%listbox = $new(listbox,%Widget)
    %Widget->%listbox->$setGeometry(10,180,150,40)
    %Widget->%listbox->$insertItem("This is another item")
    %Widget->%listbox->$insertItem("This is a listbox's item")
    %Widget->%listbox->$insertItem("This is a listbox")
    %Widget->%radiobutton = $new(radiobutton,%Widget)
    %Widget->%radiobutton->$setGeometry(10,230,150,20)
    %Widget->%radiobutton->$setText("This is a radiobutton")
    %Widget->%button = $new(button, %Widget)
    %Widget->%button->$setText("Close me")
    %Widget->%button->$setGeometry(10,260,150,20)
    %Widget->$show()
    # This shows the widget
    privateimpl(%Widget->%button, mousePressEvent) {
        delete %Widget
        # This closes the widget automatically
    }
    # privateimpl is triggered when user press the button.
    # To do that, widget must be a global variable.


Index, Object Classes

KVIrc 3.2.5 Documentation
Generated by alexey at Wed Dec 20 01:01:02 2006