You are on page 1of 9

Advanced GUI Code Example

This code example demonstrates how to create an advanced graphical user interface (GUI) in PowerBuilder, using native PowerBuilder ob ects as well as third!part" controls implemented using the PowerBuilder #ative Interface (PB#I)$ This application consists of a wor%space containing a standard PowerBuilder (&in'() target$ The target contains three PB)s* advguisample$pbl, advguicontrols$pbl, and advguiob ects$pbl$ This application contains examples of the following t"pes of ob ects* Button )ist Bar +hortcut Bar +tatic Text ,ontrol Tab +trip Toolbar +trip

-P )ist Bar Information on how to use each control is provided below$

Button List Bar


Usage .dd the following librar" to "our application librar" list* advguicontrols$pbl Place u/cst/buttonlistbar from advguicontrols$pbl on "our window$ Distribution 0ou need to distribute the canvas$pbx PowerBuilder extension file with "our application Functions of/additem (string as/text, string as/image) ! .dd an item to the list of/setsi1e (integer ai/si1e) ! +et button si1e ! for 23x23 pass +4.)) ! for (5x(5 pass 467IU4 ! for '(x'( pass ).8G6 ! for 59x59 pass -).8G6 of/selectbutton (long al/selected) of/selectbutton (string as/text) ! +elect a button b" index or text of/setenabled (long al/index, boolean ab/enabled) of/setenabled (string as/text, boolean ab/enabled) ! +et buttons enabled propert" b" index or text of/gettext (long al/index)

! Get Button text b" index of/setscrollspeed (long al/speed) ! +et the speed that the ob ect scrolls at$ Events ue/selectionchanged ( oldindex, newindex ) ! :ccurs when an item is selected$

ShortcutBar
Usage .dd the following librar" to "our application librar" list* advguicontrols$pbl Place u/cst/shortcutbar from advguicontrols$pbl on "our window$ Distribution 0ou need to distribute the canvas$pbx PowerBuilder extension file with "our application Functions of/selectitem (string as/text) of/selectitem (long al/item) ! +elects an item b" text or index of/hideitem (string as/text) of/hideitem (long al/item) ! ;ide item b" text or index of/showitem (string as/text) of/showitem (long al/item) ! +how item b" text or index of/additem (dragob ect a/ob ect, string as/text, string as/image) ! .dds an ob ect to the control$ of/setini (string as/ini) ! +pecif" the ini or registr" entr" that will store user settings of/hideall () ! ;ide all items of/showall () ! +how all items of/displa"headerimage (boolean ab/switch) ! 7ispla" image in header (True displa", <alse do not displa") of/setst"le (integer ai/st"le)

! +et the shortcut bar st"le (-P, =I+T.64B:++67, =I+T.:8IGI#.), =I+T.G).++, ,U+T:4) of/setshadowtext (boolean ab/switch) ! 7ispla" shadow text (T8U6 displa", <alse do not displa") of/setpattern (long al/pattern) ! +et the shortcut bar pattern (#:P.TT68#, +:)I7,I8,)6, ;:)):&,I8,)6, +:)I7+>U.86, ;:)):&+>U.86, +T.8, &.=6, B.8, 7I.4:#7) of/displa"closebutton (boolean ab/displa") ! 7ispla" close button on shortcut items (T8U6 displa", <alse do not displa") of/setenabled (long al/item, boolean ab/enabled) of/setenabled (string as/text, boolean ab/enabled) ! 6nable a shortcut item b" text or index Events ue/selectionchanged ( string as/text, string as/image ) ! :ccurs when an items is selected$

Static ext
Usage .dd the following librar" to "our application librar" list* advguicontrols$pbl Place u/cst/statictext from advguicontrols$pbl on "our window$ 0ou can set properties from the I76$ If "ou need to set properties at run time, use the corrisponding ob ect function$ <or example* of/Text($$$) of/.lign)eft() of/.lign8ight() etc$ Distribution 0ou need to distribute the canvas$pbx PowerBuilder extension file with "our application Functions of/italic (boolean ab/italic) of/bold (boolean ab/bold) of/underline (boolean ab/underline) of/stri%eout (boolean ab/stri%eout) of/escapement (long al/escapement) of/ellipsis (boolean ab/ellipsis) of/wrap (boolean ab/wrap) of/alignleft () of/aligncenter ()

of/alignright () of/valigntop () of/valigncenter () of/valignbottom () of/bac%color (long al/color) of/bac%color( (long al/color) of/vgradient (boolean ab/vgradient) of/hgradient (boolean ab/hgradient) of/transparent (boolean ab/transparent) of/text (string as/text) of/fontname (string as/font) of/fontsi1e (long al/si1e) of/fontcolor (long al/color) Events #one

abStrip
Usage .dd the following librar" to "our application librar" list* advguicontrol$pbl Place u/cst/tabcontrol from advguicontrols$pbl on "our window$ If "ou are going to use images in the of/:penTab function "ou need to add the images to the controls image list$ This is done using the of/.ddImage function* <or example* of/.ddImage(?custom@@2A?) BBImage index 2 of/.ddImage(?custom@@(A?) BBImage index ( of/.ddImage(?custom@@'A?) BBImage index ' of/:penTab(iuo/2, ?Tab2?, 2) of/:penTab(iuo/(, ?Tab(?, () of/:penTab(iuo/', ?Tab'?, ') Distribution 0ou need to distribute the canvas$pbx PowerBuilder extension file with "our application Functions of/selecttab (long al/selected) of/selecttab (dragob ect ad/ob ect) ! +elects tab based on index or ob ect

of/addimage (string as/image) ! .dd an image to the tab controls image list ! 8eturns image index of/setst"le (long al/st"le) ! +et tab st"le (86GU).8, 6-,6), =+(@@C) of/settabposition (long al/position) ! +ets the tab position (T:P, B:TT:4) of/setenabled (long al/index, boolean ab/switch) of/setenabled (dragob ect ad/ob ect, boolean ab/switch) ! 6nables or disables the tab b" index or ob ect of/isenabled (long al/index) of/isenabled (dragob ect ad/ob ect) ! 8eturns the enable state of an item b" index or ob ect of/setvisible (long al/index, boolean ab/switch) of/setvisible (dragob ect ad/ob ect, boolean ab/switch) ! 4a%es a tab visible or invisible b" index or ob ect of/isvisible (long al/index) of/isvisible (dragob ect ad/ob ect) ! 8eturns the visible state of an item b" index or ob ect of/boldselected (boolean ab/bold) ! Bolds the selected tab text (True bold, <alse don?t bold) of/closetab (long al/index) of/closetab (dragob ect ad/ob ect) ! ,lose a tab b" index or ob ect of/closeselectedtab () ! ,lose the selected tab of/closealltabs () ! ,lose all tabs of/getselectedtab () ! 8eturns the index of the selected tab of/gettabcount ()

! 8eturns the number of open tabs of/getob ect (long al/index) ! 8eturns the ob ect for tab index provided of/settext (long al/index, string as/text) of/settext (dragob ect ad/ob ect, string as/text) ! +et tab text b" index or ob ect of/settextcolor (long al/index, )ong al/color) of/settextcolor (dragob ect ad/ob ect, al/color) ! +et tab text color b" index or ob ect of/settiptext (long al/index, string as/text) of/settiptext (dragob ect ad/ob ect, string as/text) ! +et tabs tooltip text b" index or ob ect of/opentab (ref dragob ect a/ob ect, string as/text, long al/picindex) ! :pen a tab ob ect of/gettext (long al/index) of/gettext (dragob ect ad/ob ect) ! Get text for index or ob ect of/gettiptext (long al/index) ! Get text for index or ob ect of/setimage (long al/index, long al/image) of/setimage (dragob ect ad/ob ect, long al/image) ! +et tab image b" index or ob ect of/hideclosebutton () ! ;ide the close button of/showclosebutton () ! +how the close button of/hidearrows () ! ;ide the arrow buttons of/showarrows () ! +how the arrow buttons

Events event t"pe long selectionchanging ( long oldindex, long newindex ) ! :ccurs before a tab is selected$ ! 8eturn @ to prevent tab from changing ! 8eturn 2 to allow tab to change event selectionchanged ( long oldindex, long newindex ) ! :ccurs when a tab has changed event t"pe long tabclosing ( long index ) ! :ccurs before a tab is closed ! 8eturn @ to prevent the tab from closing ! 8eturn 2 to allow the tab to close event tabclosed ( long index ) :ccurs when a tab has beeen closed

oolbar Strip
.dd the following librar" to "our application librar" list* advguicontrols$pbl Place u/cst/toolbarstrip from advguicontrols$pbl on "our window$ Distribution 0ou need to distribute the canvas$pbx PowerBuilder extension file with "our application Functions of/additem (string as/text, string as/image) ! .dd a toolbar item to the strip of/addob ect (string as/text, dragob ect ado/ob ect) ! .dd an ob ect to the toolbar strip of/addseparator () ! .dd a separator to the toolbar strip of/displa"text (boolean ab/displa") ! 7ispla" text (True displa", <alse do not displa") of/displa"border (boolean ab/border) ! 7ispla" border (True displa", <alse do not displa") of/setenabled (string as/item, boolean ab/switch) ! 7isable or enable a toolbar item (True enable, <alse, disable) of/setimage (string as/item, string as/image) ! +et an items image

of/getimage (string as/item) ! Get an items image Events ue/buttonclic%ed ( string as/button ) ! Triggered when a button item is clic%ed

!"ListBar
Usage .dd the following librar" to "our application librar" list* advguicontrols$pbl Place u/cst/xplistbar from advguicontrols$pbl on "our window$ Distribution 0ou need to distribute the canvas$pbx PowerBuilder extension file with "our application Functions of/addgroup (string as/label, string as/picture, long al/st"le) of/addgroup (string as/label, string as/picture) ! .dd a group to the list bar$ ! 8eturns handle for the other of/.dd$$$ functions ! :ptional st"le argument allows "ou to set the group headers st"le ! +P6,I.) ! :8IGI#.) (default) ! #:.88:& of/addline (long al/parent) ! .dd a line to the specified group of/addlin% (string as/label, string as/picture, long al/parent) ! .dd a lin% to the specified group ! )in%s are clic%able of/addlabel (string as/label, string as/picture, long al/parent) ! .dd a label to the specified group ! )abels are not clic%able of/addob ect (ref dragob ect a/ob ect, string as/picture, long al/parent) ! .dd a PB ob ect to the specified group of/collapseitem (long al/item) of/collapseitem (string as/item) ! ,ollapse a group b" index or name of/collapseall () ! ,ollapse all groups

of/expanditem (long al/item) of/expanditem (string as/item) ! 6xpand a group b" index or name of/expandall () ! 6xpand all groups of/setsmoothexpand(boolean ab/smooth) ! +ets the group expand and collapse st"le ! 7efault is T8U6, smooth expand and collapse Events itemselected ( string as/group, string as/item ) ! Triggered when a lin% item is clic%ed$

Special Contributions
The following was contributed b" +erge +amson* PB :b ects in group functionalit"$ Group header st"les$ +mooth expanding and collapsing$

Ac#no$ledgements
The following people contributed to the creation and enhancement of this code example* Gabriel .bulencia 7ela Torre (0e"i) 8oland +mith Brad &er" +erge +amson

For more in%ormation


<or more information about using advanced GUI controls please visit* http*BB%odigo$sourceforge$netB or https*BBadvanced!gui!development$codexchange$s"base$comB

You might also like