TreeView
Previous topic  First topic  Next topic





Define and Properties


Properties
Status
Default
Planned
Started
Ready
Comments
CREATE TREEVIEW cName | (cVarName) | &(cExpression) 
      [ ; OF cWindow | (cVarName) | &(cExpression) ]
Parent.Name
  
A reference to the Parent Window
      [ ROW nRow ]
0
  
Row position on container window in pixels coordinates
      [ COL nCol ]
0
  
Col position on container window in pixels coordinates
      [ WIDTH nWidth ]
?
  
The desired width size of the Control in pixels
      [ HEIGHT nHeight ]
?
  
The desired height size of the Control in pixels
      [ ROWBOTTOM nRow ]
n/a
  
Bottom Row position on container window in pixels coordinates. This property adjust the HEIGHT property according the ROW property.
      [ COLRIGHT nCol ]
n/a
  
Right Col position on container window in pixels coordinates. This property adjust the WIDTH property according the COL property.
      [ AUTOSIZE .T. | .F. ]
.F.
  
Auto adjust control size to text
      [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  
Set background color
      [ FONTCOLOR {aFontColor} | aVarFontColor ]
OS.FontColor
  
Set foreground color (text color)
      [ FONTNAME "cFontName" ]
Parent.Fontname
  
Font family for control text
      [ FONTSIZE nPoints ]
Parent.FontSize
  
Font size for control text
      [ FONTBOLD .T. | .F. ]
.F.
  
Set Bold attribute to control text
      [ FONTITALIC .T. | .F. ]
.F.
  
Set Italic attribute to control text
      [ FONTUNDERLINE .T. | .F. ]
.F.
  
Set Underline attribute to control text
      [ FONTSTRIKEOUT .T. | .F. ]
.F.
  
Set Strikeout attribute to control text
      [ TOOLTIP cToolTip ]
NIL
  
Text for display into tooltip
      [ VISIBLE .T. | .F. ]
.T.
  
Show or hide control (like methods SHOW and HIDE)
      [ MULTISELECT .T. | .F. ]
.F.
  
It allow user to select one or more items
      [ VALUE nValue ]
1
  
Item to display. If MULTISELECT clause is used VALUE must be a numeric array, containing the index position of selected items.
      [ ITEM nItemPos [ , cText ] ]
NIL
  
Value text of item nItemPos (ONLY available for mg_Get() and mg_Set() functions)
      [ ITEMCOUNT ]   
Only for mg_Get() function. It returns the total amount of items in control
      [ ITEMICON nItemPos | cItemName , cIconName ]
NIL
  
Icon name for item nItemPos | cItemName. The item must already exist. (ONLY available for mg_Get() and mg_Set() functions)
      [ ENABLED .T. | .F. ]
.T.
  
Enable or Disable control
      [ NOTABSTOP .T. | .F. ]
.F.
  
This property force that TAB key doesn't stop in this control
      [ FORCEACTION .T. | .F. ]
.F.
  
It force the execution of the actions defined by methods like ACTION, ONENTER, ONCLICK, ONDBLCLICK, etc. when NOTABSTOP property was set '.T.'. This property is useful when application focus is over a control when a VALID clause and it doesn't permit lostfocus.
      [ PARENT cParentName ]
NIL
  
Parent window for this widget
      [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
      [ ONDBLCLICK cOnDblClick | {BOnDblClick} ]
NIL
  
An action to be performed when user press double mouse click
      [ ONENTER cOnEnter | {BOnEnter} ]
NIL
  
An action to be performed when user press ENTER or RETURN keys. You can interrupt the ENTER key propagate to the control returning the __MG_KEY_NO_PROPAGATE constant, e.g. to disable ENTERTAB behavior.
      [ ONCHANGE cOnChange | {BOnChange} ]
NIL
  
An action to be performed when control value is changed
      [ ONGOTFOCUS cOnGotFocus | {BOnGotFocus} ]
NIL
  
An action to be performed when control is focused
      [ ONLOSTFOCUS cOnLostFocus | {BOnLostFocus} ]
NIL
  
An action to be performed when control is lost focused
      [ HASFOCUS ]   
Only for mg_Get() function. This property returns .T. if control has the application focus
      [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the control. Go to to learn more about it.
      [ CONTEXTMENUSUPRESSED .T. | .F. ]
.F.
  
Disable the display of the Context Menu of control.
      [ CREATE TREEITEM cName ]   
Name of Item
                  [ PICTURE cImageName ]
NIL
  
Image for display in Popup Name
                  [ ITEMNAME cName ]
NIL
  
Item name for mg_Set()/mg_Get() properties or mg_Do() Methods
                  [ FONTNAME "cFontName" ]
Parent.Fontname
  
Font family for control text
                  [ FONTSIZE nPoints ]
Parent.FontSize
  
Font size for control text
                  [ FONTBOLD .T. | .F. ]
.F.
  
Set Bold attribute to control text
                  [ FONTITALIC .T. | .F. ]
.F.
  
Set Italic attribute to control text
                  [ FONTUNDERLINE .T. | .F. ]
.F.
  
Set Underline attribute to control text
                  [ FONTSTRIKEOUT .T. | .F. ]
.F.
  
Set Strikeout attribute to control text
                  [ FONTCOLOR {aFontColor} | aVarFontColor ]
OS.FontColor
  Set foreground color (text color)
                  [ BACKCOLOR {aBackColor} | aVarBackColor ]
OS.BackColor
  Set background color
                  [ ENABLED .T. | .F. ]
.T.
  Enable or Disable popup
                  [ TOOLTIP cToolTip ]
NIL
 
 Text for display into tooltip
                  [ CURSOR ]
Qt_ArrowCursor
  
Change the cursor pointer shape for the control. Go to to learn more about it.
                  [ PARENT cParentName ]
NIL
  
Parent item (not parent window) for this item
                  [ PARENTTYPE n/a ]   
Only for mg_get() function, this property returns the PARENT control type or "" if the parent was not set.
            [ END TREEITEM ]   
 
            [ CREATE TREEITEM ]   
 
                   .........    
 
                   .........    
 
            [ END TREEITEM ]   
 
            [ CREATE TREEITEM ]   
 
                   .........    
 
                   .........    
 
                  [ CREATE TREEITEM ]   
 
                         .........    
 
                         .........    
 
                  [ END TREEITEM ]   
 
                  [ CREATE TREEITEM ]   
 
                         .........    
 
                         .........    
 
                  [ END TREEITEM ]   
 
            [ END TREEITEM ]   
 
            [ CREATE TREEITEM ]   
 
             .........    
 
                  [ CREATE TREEITEM ]   
 
                         .........    
 
                         .........    
 
                  [ END TREEITEM ]   
 
                  [ CREATE TREEITEM ]   
 
                         .........    
 
                         .........    
 
                  [ END TREEITEM ]   
 
            [ END TREEITEM ]   
 
      [ ......... ]   
 
      [ ......... ]   
 
      [ END TREEITEM ]   
 
      [ CREATE CONTEXT MENU [ cName ] ]   
CONTEXT MENU for control
            [ ......... ]   
You can see properties for this menu in CONTEXT MENU topic
      [ END MENU ]   
 
END TREEVIEW 

Jump to Context Menu topic



Methods for TreeView


Methods
Status
Default
Planned
Started
Ready
Comments
    COLLAPSEITEM nItem
n/a
  
This method is used to collapse only an item of control
    COLLAPSEALL
n/a
  
This method is used to collapse all brands of control
    EXPANDITEM nItem
n/a
  
This method is used to expand only an item of control
    EXPANDALL
n/a
  
This method is used to expand all brands of control
    FIND cText [ , nMode ] [ , nCaseSensitive ]
n/a
  
This method is used to find all items of control that is name match with 'cText' parameter. This method returns a numeric array containing the position of items that match the find. In addition, you can use 'cMode' parameter [optional] to specify the mode of search:
0=Exactly (Default)
1=Contain
2=Starts with
3=Ends width
The third parameter is also optional and is used to specify the case sensitive behavior:
0=Case sensitive (Default)
1=Case in-sensitive
    RELEASE
n/a
  
This method is used to destroy the control.
    SETFOCUS
n/a
  
This method put the program focus into control
    ADDITEM cText [ , nItemPosParent ] [ , cAssignNewItemName ]
NIL
  
Add a new item to control from nItemPosParent (default is root, item will be added after last item). You can assign a name to item with optional parameter cAssignNewItemName. When the item was added, you can add ICON to item by ITEMICON property with cAssignNewItemName name (mg_Set() function). This method return the position of new item.
    INSERTITEM cText [ , nItemPos ] [ , cAssignNewItemName ]
NIL
  
Add a new item to control at nItemPos position (default is ITEMCOUNT + 1, item will be added after last item). You can assign a name to item with optional parameter cAssignNewItemName. When the item was added, you can add ICON to item by ITEMICON property with cAssignNewItemName name (mg_Set() function). This method return the position of new item.
    GETITEMNAME nItemPos
NIL
  
Return the Item Name of nItemPos position.
    DELETEITEM nItemPos
NIL
  
Delete item number nItemPos from control
    DELETEALLITEMS
n/a
  
Delete ALL items from control
    HIDE
n/a
  
This method HIDE the control
    SHOW
n/a
  
This method SHOW the control
    UNSETCURSOR
n/a
  
Reset the cursor pointer shape for the control to default (Qt_ArrowCursor). Go to to learn more about it.
    GETCHILDREN
n/a
  
This method return an array containing a list of controls that have this control as parent
    ONDBLCLICK
n/a
  
Execute ONDBLCLICK block coded in CREATE or seted by mg_Set
    ONENTER
n/a
  
Execute ONENTER block coded in CREATE or seted by mg_Set
    ONCHANGE
n/a
  
Execute ONCHANGE block coded in CREATE or seted by mg_Set
    ONGOTFOCUS
n/a
  
Execute ONGOTFOCUS block coded in CREATE or seted by mg_Set
    ONLOSTFOCUS
n/a
  
Execute ONLOSTFOCUS block coded in CREATE or seted by mg_Set



Methods for TreeItem


Methods
Status
Default
Planned
Started
Ready
Comments
    GETCHILDREN
n/a
  
This method return an array containing a list of controls that have this control as parent
    GETITEMPOS
NIL
  
Return the Item Position of Item (control).
    UNSETCURSOR
n/a
  
Reset the cursor pointer shape for the window to default (Qt_ArrowCursor). Go to to learn more about it.



Example:

File: d_treeview.prg


#include "marinas-gui.ch"

Function main()

   SET APPLSTYLE TO "MarinasLooks"

   CREATE WINDOW d_window
      ROW 0 ; COL 0
      WIDTH 820 ; HEIGHT 480
      CAPTION "Marinas-GUI Sample for TreeView Control"
      ICON "../resource/d_test.ico"
      BACKCOLOR {216,237,236}
      MAIN .T.

      d_treeview_def()

   END WINDOW

   mg_Do( "d_window" , "center" )

   mg_Do( "d_window" , "activate" )

Return .T.


File: d_treeview_def.prg

#include "marinas-gui.ch"

Function d_treeview_def()

     CREATE LABEL TreeView_1_Label
            ROW    19
            COL    150
            HEIGHT 20
            VALUE  ""
            FONTSIZE 12
            WIDTH  139
            FONTITALIC .T.
            FONTCOLOR {0,0,255}
     END LABEL

     CREATE IMAGE TreeView_1Image
        ROW       40
        COL       105
        WIDTH     32
        HEIGHT    32
        PICTURE   "../resource/d_focus_off.png"
        TOOLTIP   "TreeView Focus"
     END IMAGE

     CREATE TREEVIEW TreeView_1
            ROW    40
            COL    150
            WIDTH  300
            HEIGHT 380
            VALUE 16
            FONTNAME "mg_monospace"
            FONTSIZE 14
            TOOLTIP "TreeView with FONT attributes"
            FONTCOLOR {255,255,255}
            FONTBOLD .T.
            BACKCOLOR {200,000,255}
            ONDBLCLICK mg_MsgInfo( "Item (dblclick): " + mg_AllStr( mg_Get( "d_window" , "TreeView_1" , "value" ) ) + " (" + mg_Get( "d_window" , "TreeView_1" , "item" , mg_Get( "d_window" , "TreeView_1" , "value" ) ) + ")" )
            ONENTER    mg_MsgInfo( "Item (enter): " + mg_AllStr( mg_Get( "d_window" , "TreeView_1" , "value" ) ) + " (" + mg_Get( "d_window" , "TreeView_1" , "item" , mg_Get( "d_window" , "TreeView_1" , "value" ) ) + ")" )
            ONCHANGE   mg_Set( "d_window" , "TreeView_1_Label" , "value" , mg_Get( "d_window" , "TreeView_1" , "item" , mg_Get( "d_window" , "TreeView_1" , "value" ) ) )
            ONGOTFOCUS mg_Set( "d_window" , "TreeView_1Image" , "picture" , "../resource/d_focus_on.png" )
            ONLOSTFOCUS mg_Set( "d_window" , "TreeView_1Image" , "picture" , "../resource/d_focus_off.png" )

            CREATE TREEITEM "Argentina"
               PICTURE   "../resource/d_banner_argentina.png"
               FONTITALIC .T.

               CREATE TREEITEM "Buenos Aires"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Ramallo"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 36
               END TREEITEM

               CREATE TREEITEM "Quilmes"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 36

                  CREATE TREEITEM "Quilmes Centro"
                  END TREEITEM

                  CREATE TREEITEM "Quilmes Oeste"
                  END TREEITEM

                  CREATE TREEITEM "Bernal"
                     FONTSIZE 36
                  END TREEITEM

                  CREATE TREEITEM "Don Bosco"
                     PICTURE   "../resource/d_test.png"
                  END TREEITEM

                  CREATE TREEITEM "Ezpeleta"
                     PICTURE   "../resource/d_test.png"
                  END TREEITEM

               END TREEITEM

               CREATE TREEITEM "El Calafate"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "S�enz Pe�a"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

            END TREEITEM

            CREATE TREEITEM "Bulgary"
               PICTURE   "../resource/d_banner_bulgary.png"

               CREATE TREEITEM "Sofia"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Burgas"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 36
               END TREEITEM

               CREATE TREEITEM "Dobrich"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM
            END TREEITEM

            CREATE TREEITEM "Hungary"
               FONTSIZE 24
               PICTURE   "../resource/d_banner_hungary.png"

               CREATE TREEITEM "Budapest"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "P�cs"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 36
               END TREEITEM

               CREATE TREEITEM "Debrecen"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 74
               END TREEITEM

            END TREEITEM

            CREATE TREEITEM "Poland"
               FONTBOLD .T.
               FONTSIZE 24
               PICTURE   "../resource/d_banner_poland.png"
               FONTNAME "mg_monospace"

               CREATE TREEITEM "Varsovia"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Radom"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 36
               END TREEITEM

               CREATE TREEITEM "Kielce"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 12
               END TREEITEM

            END TREEITEM

            CREATE TREEITEM "India"
               PICTURE   "../resource/d_banner_india.png"
               FONTUNDERLINE .T.

               CREATE TREEITEM "Nueva Delhi"
                  PICTURE   "../resource/d_test.png"
               END TREEITEM

               CREATE TREEITEM "Pune"
                  PICTURE   "../resource/d_test.png"
                  FONTUNDERLINE .F.
               END TREEITEM

               CREATE TREEITEM "Jaipur"
                  PICTURE   "../resource/d_test.png"
                  FONTSIZE 36
               END TREEITEM

            END TREEITEM

            CREATE CONTEXT MENU

               CREATE ITEM "Item 1 from TreeView"
                  ONCLICK { || mg_MsgInfo( "Item 1 from TreeView" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

               CREATE ITEM "Item 2 from TreeView"
                  ONCLICK { || mg_MsgInfo( "Item 2 from TreeView" ) }
                  PICTURE "../resource/d_test.png"
               END ITEM

            END MENU

     END TREEVIEW

     CREATE RADIOGROUP TreeView_1_RadioGroup
            ROW    435
            COL    180
            ITEMS {'Expand All','Collapse All'}
            VALUE 2
            FONTCOLOR {0,0,255}
            FONTBOLD .T.
            HORIZONTAL .T.
            TOOLTIP "Expand or collapse all brands of TreeView"
            WIDTH  250
            ONGOTFOCUS mg_Do( "d_window" , "TreeView_1" , "setfocus" )
            ONCHANGE   if( mg_Get( "d_window" , "TreeView_1_RadioGroup" , "value" ) == 1 , mg_Do( "d_window" , "TreeView_1" , "expandall" ) , mg_Do( "d_window" , "TreeView_1" , "collapseall" ) )
     END RADIOGROUP

     CREATE IMAGE TreeView_2Image
        ROW       40
        COL       470
        WIDTH     32
        HEIGHT    32
        PICTURE   "../resource/d_focus_off.png"
        TOOLTIP   "TreeView Focus"
     END IMAGE

     CREATE TREEVIEW TreeView_2
            ROW    40
            COL    520
            WIDTH  180
            HEIGHT 380
            MULTISELECT .T.
            VALUE { 2 , 4 }
            TOOLTIP "TreeView with MULTISELECT"
            BACKCOLOR {135,218,61}
            ONENTER    mg_MsgInfo( "Items: " + mg_AllStr( mg_Get( "d_window" , "TreeView_2" , "value" ) ) )
            ONDBLCLICK mg_MsgInfo( "Items: " + mg_AllStr( mg_Get( "d_window" , "TreeView_2" , "value" ) ) )
            ONGOTFOCUS mg_Set( "d_window" , "TreeView_2Image" , "picture" , "../resource/d_focus_on.png" )
            ONLOSTFOCUS mg_Set( "d_window" , "TreeView_2Image" , "picture" , "../resource/d_focus_off.png" )

            CREATE TREEITEM "Pritpal Bedi"
               CREATE TREEITEM "Alpha"
               END TREEITEM
               CREATE TREEITEM "Beta"
               END TREEITEM
               CREATE TREEITEM "Gamma"
                  CREATE TREEITEM "One"
                  END TREEITEM
                  CREATE TREEITEM "Two"
                  END TREEITEM
                  CREATE TREEITEM "Tree"
                  END TREEITEM
               END TREEITEM
               CREATE TREEITEM "Epsilon"
               END TREEITEM
            END TREEITEM

            CREATE TREEITEM "Viktor Szakáts"
               CREATE TREEITEM "Alpha"
               END TREEITEM
               CREATE TREEITEM "Beta"
               END TREEITEM
               CREATE TREEITEM "Gamma"
               END TREEITEM
            END TREEITEM

            CREATE TREEITEM "Przemyslaw Czerpak"
               CREATE TREEITEM "Alpha"
               END TREEITEM
               CREATE TREEITEM "Beta"
               END TREEITEM
               CREATE TREEITEM "Gamma"
               END TREEITEM
            END TREEITEM

            CREATE TREEITEM "Bruno Luciani"
               CREATE TREEITEM "Alpha"
               END TREEITEM
               CREATE TREEITEM "Beta"
               END TREEITEM
               CREATE TREEITEM "Gamma"
               END TREEITEM
            END TREEITEM

            CREATE TREEITEM "Carozo De Quilmes"
               CREATE TREEITEM "Alpha"
               END TREEITEM
               CREATE TREEITEM "Beta"
               END TREEITEM
               CREATE TREEITEM "Gamma"
               END TREEITEM
            END TREEITEM

     END TREEVIEW

     CREATE RADIOGROUP TreeView_2_RadioGroup
            ROW    435
            COL    520
            ITEMS {'Expand All','Collapse All'}
            VALUE 2
            FONTCOLOR {255,0,0}
            FONTBOLD .T.
            HORIZONTAL .T.
            TOOLTIP "Expand or collapse all brands of TreeView"
            WIDTH  200
            ONGOTFOCUS mg_Do( "d_window" , "TreeView_2" , "setfocus" )
            ONCHANGE   if( mg_Get( "d_window" , "TreeView_2_RadioGroup" , "value" ) == 1 , mg_Do( "d_window" , "TreeView_2" , "expandall" ) , mg_Do( "d_window" , "TreeView_2" , "collapseall" ) )
     END RADIOGROUP

Return .T.



Marinas-GUI Version 03.06 and
Marinas-IDE Version 05.06 and
LEX Files Version 02.06


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
last update: April 27
2017
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------




A Harbour/QT framework to make multiplatform programs

(©) Copyright 2009-2017 by Fernando Santolin (aka CarozoDeQuilmes)
CarozoDeQuilmes@gmail.com

2009-2017 Beta tester and full English translator: Bruno Luciani
Bruno.Luciani@gmail.com

2014-2015 Final English corrector: David Worboys
DavidWorboys@hotmail.com

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

www.marinas-gui.org


www.marinas-gui.org  

Previous topic  First topic  Next topic