From AlphaWiki

Commands: HiviewReference

Reference table

As a reference, the following table indicates the controls supporting the various creation or configuration options.

Creation optionRoot views
-alphaall views
-boundsall views
-closeBoxdocument, float, utility
-collapseBoxdocument, float, utility
-commandall views
-directiondrawer
-helpall views
-metaldocument, float
-resizabledialog, document, float, sheet, utility
-sidebarfloat, utility
-titleall views
-visibleall views
-zoomBoxdocument, float, utility
Creation optionSubviews
-attributescombobox, listview, scrollview, textview
-autoTogglecheckbox, checkgroupbox, disclosurebutton, disclosuretriangle, radiobutton
-behaviorbevelbutton
-boundsall views
-clockFlagsclock
-clockTypeclock
-commandall views
-constraintsall views
-determinateprogressbar
-directiontabbedview
-drawTitledisclosuretriangle
-enableall views
-helpall views
-iconAlignmentpushiconbutton
-iconFileimageview
-iconrefbevelbutton, icon, imagewell, pushiconbutton, roundbutton
-iconssegmentedview, tabbedview
-incrementlittlearrows
-itemsbevelbutton, combobox, popupbutton, popupgroupbox
-labelslistview, segmentedview, tabbedview
-listHeaderwindowheader
-maxlittlearrows, progressbar, relevancebar, scrollbar, slider
-menubevelbutton, popupbutton, popupgroupbox, searchfield
-menuPlacementbevelbutton
-minlittlearrows, progressbar, relevancebar, scrollbar, slider
-multiValuebevelbutton, columnview, listview
-numlistview, segmentedview, slider, tabbedview
-orientationdisclosuretriangle, popuparrow, slider
-parentall views
-passwordedittext
-primarycheckgroupbox, groupbox, popupgroupbox
-textcombobox, edittext, searchfield, statictext
-titleall views
-titleWidthpopupbutton, popupgroupbox
-trackingProcscrollbar, slider
-valuecheckbox, checkgroupbox, disclosurebutton, disclosuretriangle, littlearrows, progressbar, radiobutton, relevancebar, scrollbar, slider
-variableWidthpopupbutton, popupgroupbox
-variantbevelbutton, chasingarrows, checkbox, combobox, disclosurebutton, littlearrows, popuparrow, popupbutton, progressbar, pushbutton, radiobutton, roundbutton, scrollbar, scrollview, searchfield, slider, tabbedview
-visibleall views
Configuration optionSubviews
-alphaimageview
-animatechasingarrows, clock, progressbar
-cancelpushbutton
-colorcombobox, edittext, statictext, textview
-dateclock
-defaultpushbutton
-determinateprogressbar
-iconAlignmentbevelbutton
-iconrefbevelbutton, icon, imagewell, roundbutton
-incrementlittlearrows
-itemscolumnview, combobox, listview, popupbutton, popupgroupbox
-justifycombobox, edittext, statictext, textview
-listHeaderwindowheader
-lockedittext
-menubevelbutton, popupbutton, popupgroupbox
-menuValuebevelbutton, popupbutton, popupgroupbox
-multiLineedittext, statictext
-offsetbevelbutton
-opaqueimageview
-pathcolumnview
-readOnlytextview
-scaleimageview
-selectioncolumnview, edittext, listview, textview
-sizecombobox, edittext, popupbutton, popupgroupbox, statictext, textview
-stylecombobox, edittext, popupbutton, popupgroupbox, statictext, textview
-textcombobox, edittext, statictext, textview
-textPlacebevelbutton
-truncatestatictext
-urlwebview

Hiviews and bindings

How do the hiviews and the bindings fit together ? In AlphaX, bindings are key combinations which can trigger an action defined by a Tcl proc. When a root window defined with the [hiview root] command contains editable views (that is to say views which accept text input, such as a combo box, an edit field, a search field or a text view), and when one of these editable views has the focus, then only bindings containing the Command key or the Control key as a modifier are executed: other bindings associated with a simple key or involving the Option key or the Shift key are ignored so that the key combination is passed normally to the editable view. This allows keys like the Return key, the Delete key and the Tabulation key to be handled as expected by the default handlers attached to the views. If no editable view currently has the focus, then all the bindings are active (unless a modal dialog is running). This brings to another issue concerning activation. When an editable field in a document window has the focus and the user switches to another window, the focus is removed automatically. This happens with root windows of type ''document, drawer, plain, sheet and simple. But windows of type float'' and utility are different: they are always active, so if an editable view has the focus in this kind of window, one must remove it manually when it is not needed anymore: this can be done by clicking anywhere in the corresponding floating window. Clicking in another window (including the usual AlphaX editing windows) will also automatically remove the focus. The case of dialog windows is slightly different: since they are modal and block the application until they are dismissed, the usual handling of raw key events by AlphaX is disabled, so no bindings at all can be executed while the dialog is running. Note that root windows of type help, overlay and toolbar are never activated by the Window Manager so it is useless to have an editable field in them. Focus can also be manipulated programmatically (installed or cleared) using the [hiview focus] command.

Default buttons

It is common practice in a dialog window to designate a button as the "default" button and another one as the "cancel" button. The default button is drawn differently, with a blue theme, and can be triggered by pressing the Return key. The "cancel" button has the same appearance as the other buttons but it can be triggered by the Escape key or by the Command-Period combination, and the sound played by the system is different. This concept of default and cancel buttons can be extended to any kind of window, created with the [hiview root] command, not only the dialogs. In order to set the default and cancel buttons for a window with the [hiview] command, two steps are necessary:

  • after the button has been created, one must set the -default

or the -cancel option using the [hiview configure] command applied to the button. The value of these option is 1 to set the property, 0 to remove it.

  • after the button has been embedded in a window, one must declare it

as the default or the cancel button for this window using the -default or the -cancel option with the [hiview configure] command applied to the window. The value of the option is the token of the corresponding button. The first step has just the effect of setting the appearance of the button. The second step makes the connection between the window and the button so that the window manager knows which button is to be handled as the default or the cancel button. Here is a simplified example:

 
     set buttonToken [hiview create pushbutton -bounds {10 10 30 70} \
       -title "OK" -command hi::exit]
     hiview configure $buttonToken -default 1
     set windowToken [hiview root dialog]
     hiview add $windowToken $buttonToken
     hiview configure $windowToken -default $buttonToken
     hiview show $windowToken

The HiviewRects package

The AlphaTcl library contains a new package HiviewRects which defines utility procs designed to easily manipulate the frame of the subviews. It is useful to specify the positions of the subviews without making any explicit calculations on the bounds and to assemble the elements of a root window or the subelements of a container. All the procs are described in the file hiviewRects.tcl located in the SystemCode directory. They usually accept, as an optional argument, the name of a variable containing the coordinates of a rectangle and return the modified coordinates. One can also declare the name of a default rectangle at the beginning of a script and then all the procs will apply, by default, to this rectangle. Here is a series of instructions to demonstrate how these procs work:

 
      hi::defaultRect vb
     vb
      hi::initRect
     0 0 0 0
      hi::sizeRect 150 20
     0 0 20 150
      hi::moveRect 10 10
     10 10 30 160
      hi::lf
     43 10 63 160
      hi::centerRect 300 0
     43 75 63 225
      hi::incrRect 15 10
     43 75 73 240
      hi::vskip 50
     93 75 123 240
      hi::width
     165
      hi::height
     30

The [hi::lf] proc is the equivalent of a line feed: it moves the rectangle vertically by the amount of its previous height, augmented by an interspace (equal to 13 pixels by default and controlled, if necessary, by the [hi::margin] proc). This proc can also be applied horizontally: [hi::lf h] would move the rectangle horizontally by the amount of its previous width, augmented by the interspace. Here is, for example, how one could redefine the example given in the Quick Start section using the HiviewRects package. The default rectangle here is named vb and it is resized or moved for each subview contained in this window. The subviews are thus positionned relatively to each other:

 
     # Window bounds rect
     hi::setRect 150 150 580 450 wb

     # View bounds rect
     hi::defaultRect vb
     hi::initRect

     # Create a root window
     set root [hiview root document -bounds [hi::rect wb] -title "Hiview Sample" -resizable 0]

     # Create some subviews
     # A scroll view which will contain an image
     hi::lf
     hi::sizeRect 280 260
     hi::centerRect [hi::width wb] 0
     set scrv [hiview create scrollview -bounds [hi::rect]]
     set imgfile [file join $APPLICATION Contents Resources about.png]
     set imgv [hiview create imageview -iconFile $imgfile]

     # A combo box
     hi::lf
     hi::sizeRect 150 20
     hi::centerRect [hi::width wb] 0
     set cbbox [hiview create combobox -bounds [hi::rect] -items [list item1 item2 item3]]

     # A static text
     hi::lf
     hi::sizeRect 250 20
     hi::moveRect -10 0
     set sttxt [hiview create statictext -bounds [hi::rect] -text "http://alphatcl.sourceforge.net"]
     hiview configure $sttxt -color blue -style 4

     # A live clock!
     hi::lf
     hi::moveRect 50 0
     set clock [hiview create clock -bounds [hi::rect] -clockFlags 3 -clockType 1]

     # A button
     set okbut [hiview create pushbutton -bounds [hi::okButtonRect $wb] -title "Click"]

     # Embed the subviews into the window
     hiview add $root $okbut $scrv $cbbox $sttxt $clock

     # Embed the image into the scroll view
     hiview add $scrv $imgv

     # Display the window
     hiview show $root

Retrieved from http://alphatcl.sourceforge.net/wiki/pmwiki.php/Commands/HiviewReference
Page last modified on September 30, 2009, at 09:00 AM