ActivePerl Documentation
Table of Contents

(Usage Statistics)
(about this ver)

* Getting Started
    * Welcome To ActivePerl
    * Release Notes
    * Readme
    * ActivePerl Change Log
* Install Notes
    * Linux
    * Solaris
    * Windows
* ActivePerl Components
    * Overview
    * PPM
    * Windows Specifics
       * OLE Browser
       * PerlScript
       * Perl for ISAPI
       * PerlEZ
* ActivePerl FAQ
    * Introduction
    * Availability & Install
    * Using PPM
    * Docs & Support
    * Windows Specifics
       * Perl for ISAPI
       * Windows 9X/NT/2000
       * Quirks
       * Web Server Config
       * Web programming
       * Programming
       * Modules & Samples
       * Embedding & Extending
       * Using OLE with Perl
* Windows Scripting
    * Active Server Pages
    * Windows Script Host
    * Windows Script Components

Core Perl Documentation

* perl
* perlfaq
* perltoc
* perlbook

* perlsyn
* perldata
* perlop
* perlreftut
* perldsc
* perllol

* perllexwarn
* perldebug

* perlrun
* perlfunc
* perlopentut
* perlvar
* perlsub
* perlmod
* perlpod

* perlstyle
* perlmodlib
* perlmodinstall
* perltrap
* perlport
* perlsec

* perlref
* perlre
* perlform
* perllocale
* perlunicode

* perlboot
* perltoot
* perltootc
* perlobj
* perlbot
* perltie

* perlipc
* perlnumber
* perlfork
* perlthrtut

* perldiag
* perlfaq1
* perlfaq2
* perlfaq3
* perlfaq4
* perlfaq5
* perlfaq6
* perlfaq7
* perlfaq8
* perlfaq9

* perlcompile

* perlembed
* perlxstut
* perlxs
* perlguts
* perlcall
* perlfilter
* perldbmfilter
* perlapi
* perlintern
* perlapio
* perltodo
* perlhack

* perlhist
* perldelta
* perl5005delta
* perl5004delta

* perlamiga
* perlcygwin
* perldos
* perlhpux
* perlmachten
* perlos2
* perlos390
* perlvms
* perlwin32


* attributes
* attrs
* autouse
* base
* blib
* bytes
* charnames
* constant
* diagnostics
* fields
* filetest
* integer
* less
* lib
* locale
* lwpcook
* open
* ops
* overload
* perllocal
* re
* sigtrap
* strict
* subs
* utf8
* vars
* warnings


* ActivePerl
    * DocTools
        * TOC
            * RDF
* AnyDBM_File
* Archive
    * Tar
* AutoLoader
* AutoSplit
* B
    * Asmdata
    * Assembler
    * Bblock
    * Bytecode
    * C
    * CC
    * Debug
    * Deparse
    * Disassembler
    * Lint
    * Showlex
    * Stackobj
    * Terse
    * Xref
* Benchmark
* Bundle
    * LWP
* ByteLoader
* Carp
    * Heavy
    * Apache
    * Carp
    * Cookie
    * Fast
    * Pretty
    * Push
    * Switch
* Class
    * Struct
* Compress
    * Zlib
* Config
    * FirstTime
    * Nox
* Cwd
* Data
    * Dumper
* DB
* Devel
    * DProf
    * Peek
    * SelfStubber
* Digest
    * HMAC
    * HMAC_MD5
    * HMAC_SHA1
    * MD2
    * MD5
    * SHA1
* DirHandle
* Dumpvalue
* DynaLoader
* English
* Env
* Errno
* Exporter
    * Heavy
* ExtUtils
    * Command
    * Embed
    * Install
    * Installed
    * Liblist
    * MakeMaker
    * Manifest
    * Miniperl
    * Mkbootstrap
    * Mksymlists
    * MM_Cygwin
    * MM_OS2
    * MM_Unix
    * MM_VMS
    * MM_Win32
    * Packlist
    * testlib
* Fatal
* Fcntl
* File
    * Basename
    * CheckTree
    * Compare
    * Copy
    * CounterFile
    * DosGlob
    * Find
    * Glob
    * Listing
    * Path
    * Spec
        * Functions
        * Mac
        * OS2
        * Unix
        * VMS
        * Win32
    * stat
* FileCache
* FileHandle
* FindBin
* Font
    * AFM
* Getopt
    * Long
    * Std
    * AsSubs
    * Element
    * Entities
    * Filter
    * Form
    * FormatPS
    * Formatter
    * FormatText
    * HeadParser
    * LinkExtor
    * Parse
    * Parser
    * TokeParser
    * TreeBuilder
    * Cookies
    * Daemon
    * Date
    * Headers
        * Util
    * Message
    * Negotiate
    * Request
        * Common
    * Response
    * Status
* I18N
    * Collate
* IO
    * Dir
    * File
    * Handle
    * Pipe
    * Poll
    * Seekable
    * Select
    * Socket
        * INET
        * UNIX
    * Msg
    * Open2
    * Open3
    * Semaphore
    * SysV
    * Debug
    * MediaTypes
    * MemberMixin
    * Protocol
    * RobotUA
    * Simple
    * UserAgent
* Math
    * BigFloat
    * BigInt
    * Complex
    * Trig
* MD5
    * Base64
    * QuotedPrint
* NDBM_File
* Net
    * Cmd
    * Config
    * Domain
    * DummyInetd
    * FTP
    * hostent
    * libnetFAQ
    * netent
    * Netrc
    * NNTP
    * PH
    * Ping
    * POP3
    * protoent
    * servent
    * SMTP
    * SNPP
    * Time
* O
* ODBM_File
* Opcode
* Pod
    * Checker
    * Find
    * Html
    * InputObjects
    * Man
    * Parser
    * ParseUtils
    * Plainer
    * Select
    * Text
        * Color
        * Termcap
    * Usage
    * SOAPClient
    * SOAPServer
* Safe
* SDBM_File
* Search
    * Dict
* SelectSaver
* SelfLoader
* Shell
    * Defs
    * Envelope
    * EnvelopeMaker
    * GenericHashSerializer
    * GenericInputStream
    * GenericScalarSerializer
    * Lite
    * OutputStream
    * Packager
    * Parser
    * Transport
        * HTTP
            * Apache
            * CGI
            * Client
            * Server
        * LOCAL
        * MAILTO
        * POP3
        * TCP
    * TypeMapper
* Socket
* Symbol
* Sys
    * Hostname
    * Syslog
* Term
    * ANSIColor
    * Cap
    * Complete
    * ReadLine
* Test
    * Harness
* Text
    * Abbrev
    * ParseWords
    * Soundex
    * Tabs
    * Wrap
* Thread
    * Queue
    * Semaphore
    * Signal
    * Specific
* Tie
    * Array
    * Handle
    * Hash
    * RefHash
    * Scalar
    * SubstrHash
* Time
    * gmtime
    * Local
    * localtime
    * tm
    * Lite
    * data
    * Escape
    * file
    * Heuristic
    * ldap
    * URL
    * WithBase
* User
    * grent
    * pwent
* Win32
    * AuthenticateUser
    * ChangeNotify
    * Clipboard
    * Console
    * Event
    * EventLog
    * File
    * FileSecurity
    * Internet
    * IPC
    * Mutex
    * NetAdmin
    * NetResource
    * ODBC
    * OLE
        * Const
        * Enum
        * NEWS
        * NLS
        * TPJ
        * Variant
    * PerfLib
    * Pipe
    * Process
    * Registry
    * Semaphore
    * Service
    * Sound
    * TieRegistry
* Win32API
    * File
    * Net
    * Registry
    * RobotRules
        * AnyDBM_File
    * Element
    * Parser
        * Expat
    * PPD
    * PPMConfig
    * ValidatingElement
* XSLoader

 Tk::DItem - Tix Display Items


Tk::DItem - Tix Display Items


  • Linux
  • Solaris
  • Windows
This module is not included with the standard ActivePerl distribution. It is available as a separate download using PPM.



The Tix Display Items and Display Types are devised to solve a general problem: many Tix widgets (both existing and planned ones) display many items of many types simultaneously.

For example, a hierarchical listbox widget (see the Tk::HList manpage) can display items of images, plain text and subwindows in the form of a hierarchy. Another widget, the tabular listbox widget (see the Tk::TList manpage) also displays items of the same types, although it arranges the items in a tabular form. Yet another widget, the spreadsheet widget (see the Tk::TixGrid manpage), also displays similar types items, but in yet another format.

In these examples, the display items in different widgets are only different in how they are arranged by the host widget. In Tix, display items are clearly separated from the host widgets. The advantage is two-fold: first, the creation and configuration of display items become uniform across different host widgets. Second, new display item types can be added without the need to modify the existing host widgets.

In a way, Tix display items are similar to the items inside Tk the canvas widget. However, unlike the Tix display items, the canvas items are not independent of the canvas widget; this makes it impossible to use the canvas items inside other types of TK widgets.

The appearance of a display item is controlled by a set of attributes. It is observed that each the attributes usually fall into one of two categroies: ``individual'' or ``collective''. For example, the text items inside a HList widget may all display a different text string; however, in most cases, the text items share the same color, font and spacing. Instead of keeping a duplicated version of the same attributes inside each display item, it will be advantageous to put the collective attributes in a special object called a display style. First, there is the space concern: a host widget may have many thousands of items; keeping dupilcated attributes will be very wasteful. Second, when it becomes necessary to change a collective attribute, such as changing all the text items' foreground color to red, it will be more efficient to change only the display style object than to modify all the text items one by one.

The attributes of the a display item are thus stored in two places: it has a set of item options to store its individual attributes. Each display item is also associated with a display style, which specifies the collective attributes of all items associated with itself.

The division between the individual and collective attributes are fixed and cannot be changed. Thus, when it becomes necessary for some items to differ in their collective attributes, two or more display styles can be used. For example, suppose you want to display two columns of text items inside an HList widget, one column in red and the other in blue. You can create a TextStyle object called ``$red'' which defines a red foreground, and another called ``$blue'', which defines a blue foreground. You can then associate all text items of the first column to ``$red'' and the second column to ``$blue''


Currently there are three types of display items: text, imagetext and window.


Display items of the type imagetext are used to display an image together with a text string. Imagetext items support the following options:

Imagetext Item Options

Name: bitmap
Class: Bitmap
Switch: -bitmap
Specifies the bitmap to display in the item.

Name: image
Class: Image
Switch: -image
Specifies the image to display in the item. When both the -bitmap and -image options are specified, only the image will be displayed.

Name: imageTextStyle
Class: ImageTextStyle
Switch: -style
Specifies the display style to use for this item. Must be the name of a imagetext display style that has already be created with ItemStyle.

Name: showImage
Class: ShowImage
Switch: -showimage
A Boolean value that specifies whether the image/bitmap should be displayed.

Name: showText
Class: ShowText
Switch: -showtext
A Boolean value that specifies whether the text string should be displayed.

Name: text
Class: Text
Switch: -text
Specifies the text string to display in the item.

Name: underline
Class: Underline
Switch: -underline
Specifies the integer index of a character to underline in the text string in the item. 0 corresponds to the first character of the text displayed in the widget, 1 to the next character, and so on.

Imagetext Style Options

The style information of imagetext items are stored in the imagetext display style. The following options are supported:



See the Tk::options manpage for details of the standard options.


Name: gap
Class: Gap
Switch: -gap
Specifies the distance between the bitmap/image and the text string, in number of pixels.

Name: textAnchor
Class: TextAnchor
Switch: -textanchor
The anchor position on the image to which text part is attached. This is a perl/Tk addition. Defaults to e for compatibility with standard Tix. The interesting cases are
Text is centred above the image.

Text is centred below the image

Text is centred to right of the image.

Text is centred to left of the image.

Text is centred over the image.

The sw, se, ne, and b<nw> cases look rather odd.

To get items to line up correctly it will usually be necessary to specify -anchor as well. e.g. with default e then anchoring item as a whole w lines images up down left with text stuck to right side.


Display items of the type text are used to display a text string in a widget. Text items support the following options:

Text Item Options

Name: textStyle
Class: TextStyle
Switch: -style
Specifies the display style to use for this text item. Must be the name of a text display style that has already be created with ItemStyle.

Name: text
Class: Text
Switch: -text
Specifies the text string to display in the item.

Name: underline
Class: Underline
Switch: -underline
Specifies the integer index of a character to underline in the item. 0 corresponds to the first character of the text displayed in the widget, 1 to the next character, and so on.

Text Style Options



See the Tk::options manpage for details of the standard options.


Display items of the type window are used to display a sub-window in a widget. Window items support the following options:

Window Item Options

Name: windowStyle
Class: WindowStyle
Switch: -style
Specifies the display style to use for this window item. Must be the name of a window display style that has already be created with the ItemStyle method.

Name: window
Class: Window
Switch: -window
Alias: -widget
Specifies the sub-window to display in the item.

Window Style Options


-anchor -padx -pady

See the Tk::options manpage for details of the standard options.


Display items do not exist on their and thus they cannot be created independently of the widgets they reside in. As a rule, display items are created by special methods of their ``host'' widgets. For example, the HList widgets has a method item which can be used to create new display items. The following code creates a new text item at the third column of the entry foo inside an HList widget:

 my $hlist = $parent->HList(-columns=>3);
 $hlist->itemCreate('foo', 2, -itemtype=>'text', -text=>'Hello');

The itemCreate method of the HList widget accepts a variable number of arguments. The special argument -itemtype specifies which type of display item to create. Options that are valid for this type of display items can then be specified by one or more option-value pairs.

After the display item is created, they can then be configured or destroyed using the methods provided by the host widget. For example, the HList widget has the methods itemConfigure, itemCget and itemDelete for accessing the display items.


Item styles are created with ItemStyle:


   $widget->ItemStyle(itemType ?,-stylename=>name? ?,-refwindow=>pathName? ?,option=>value, ...>?);

itemType must be one of the existing display items types such as text, imagetext, window or any new types added by the user. Additional arguments can be given in one or more option-value pairs. option can be any of the valid option for this display style or any of the following:

-stylename => name
Specifies a name for this style. If unspecified, then a default name will be chosen for this style.

-refwindow => $otherwidget
Specifies a window to use for determine the default values of the display type. If unspecified, the $widget will be used. Default values for the display types can be set via the options database. The following example sets the -disablebackground and -disabledforeground options of a text display style via the option database:
  $widget->optionAdd('*table.list*disabledForeground' => 'blue');
  $widget->optionAdd('*table.list*disabledBackground' => 'darkgray');
  $widget->ItemStyle('text', -refwindow => $table_list, -fg => 'red');

By using the option database to set the options of the display styles, we can advoid hard-coding the option values and give the user more flexibility in customization. See the Tk::option manpage for a detailed description of the option database.


The ItemStyle method creates an object. This object supports the configure and cget methods described in the Tk::options manpage which can be used to enquire and modify the options described above.

The following additional methods are available for item styles:

Destroy this display style object.


The following example creates two columns of data in a HList widget. The first column is in red and the second column in blue. The colors of the columns are controlled by two different text styles. Also, the anchor and font of the second column is chosen so that the income data is aligned properly.

   use strict;
   use Tk;
   use Tk::HList;
   use Tk::ItemStyle;
   my $mw = MainWindow->new();
   my $hlist = $mw->HList(-columns=>2)->pack;
   my $red  = $hlist->ItemStyle('text', -foreground=>'#800000');
   my $blue = $hlist->ItemStyle('text', -foreground=>'#000080', -anchor=>'e');
   my $e;
   foreach ([Joe => '$10,000'], [Peter => '$20,000'],
            [Raj => '$90,000'],  [Zinh => '$0']) {
       $e = $hlist->addchild("");
       $hlist->itemCreate($e, 0, -itemtype=>'text',
                -text=>$_->[0], -style=>$red );
       $hlist->itemCreate($e, 1, -itemtype=>'text',
                -text=>$_->[1], -style=>$blue);


Tk::HList Tk::TixGrid Tk::TList


display item, display style, item style

 Tk::DItem - Tix Display Items