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()
Repaints the widget directly by calling $paintEvent() immediately.
$update([<x:ingeter>,<y:integer>,<width:integer>,<height:integer>])
Updates enterily the widget or a rectangle. This function does not cause an immediate $paintEvent(); instead it schedules a paint event for processing when KVIrc returns to the main event loop.
$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.
$setWindowTitle(<text>)
Sets the title 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.
$windowTitle()
Returns the title 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 "return$true" 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 "return $true" 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 "return $true" 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 "return $true" 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 "return $true" 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 "return $true" 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 "return $true" 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 "return $true" 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 "return $true" 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 "return $true" you will stop the internal processing of this event. The default implementation does nothing.
$paintEvent(<painter:h_object>,<rect_x:integer>,<rect_y:integer>,<width:integer>,<height:integer>)
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 framework will pass as parameter a painterobject. You don't need to begin/end/delete the painter. If you call "return $true" you will stop the internal processing of this event. The default implementation does nothing.
$setParent(<widget_object:parent>)
Sets the parent of the widget to parent
$setWindowIcon(<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
If you just want to set a style without altering the preset font size and family, you can use $setFont() like this:
    %widget->$setFont(0,0,"bold")
$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
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 mo>use pointer global position.
<tip:string> $maybeTipEvent(<x_tip_pos:integer>,<y_tip_pos:integer>)
This event handler is called when a eventualy tip is going to be show. You can be reimplement this event and set a dynamic tool tip by using "return <tooltip_string>". If a tooltip has setted with $setTooltip the dynamic tooltip will be ignored. The default implementation does nothing.
integer $setAttribute(<string>,<bool_flag>)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute. Valid attributes are: OpaquePaintEvent - Indicates that the widget paints all its pixels when it receives a paint event. NoSystemBackground - Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not automatically repainted. PaintOnScreen - Indicates that the widget wants to draw directly onto the screen. NoMousePropagation - Prohibits mouse events from being propagated to the widget's parent.
$setStyleSheet(<string>)
$array(<red:integer,green:integer,blue:integer) $colorPalette(<color_role:string><color_group:string>)
Returns the color in color_group(disabled, active or inactive), used for color_role. Valid color role are: Window - A general background color. WindowText - A general foreground color. Base - Used as the background color for text. Text - Used as foreground color for the text. Button - The general button background color. ButtonText - A foreground color used with the Button color. Highlight - A color to indicate a selected item or the current item. HighlightedText - A text color that contrasts with Highlight.
<short_cut_id:integer> $setKeyShortCut(<key:char>)
Adds a shortcut whith key. A $shortCutEvent will be triggered when the user will press alt+key.
$shortCutEvent(<shortcut_id:integer>)
This function will be called when a shortcut key has been triggered. You must reimplement this event to manage a shortcut system in a custom widget. The default implementation does nothing.
$insertIntoStatusBar(<index:unsigned integer>)
Insert the widget into the statusbar at the given index. If index is out of range, the widget is appended. See also $removeFromStatusBar().
$removeFromStatusBar()
Remove the widget from statusbar.
Examples

    %Widget = $new(widget)
    # This is the main container for other elements.
    %Widget->$setWindowTitle("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->%listwidget = $new(listwidget,%Widget)
    %Widget->%listwidget->$setGeometry(10,180,150,40)
    %Widget->%listwidget->$insertItem("This is another item")
    %Widget->%listwidget->$insertItem("This is a listwidget's item")
    %Widget->%listwidget->$insertItem("This is a listwidget")
    %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 $$->$parent()
        # This closes the widget automatically
    }


Index, Object Classes
KVIrc 4.0.0 Documentation
Generated by mockbuild at Sun Apr 18 14:58:16 2010