; --------------------------------------------------------------------------------
; @Title: Example for dialog with a DLISTBOX
; @Description: 
;   
;   Using special DIALOG functions :
;    - DIALOG.STRING(..)
;    - DIALOG.STRING2(..)
;   
;   Demonstrating color usage in AREA.
;   
; @Keywords: practice, dialog, area, color, dlistbox
; @Author:SME
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: dialog_dlistbox.cmm 7372 2014-07-08 10:28:08Z smeister $


  AREA.Create DlgArea 200. 100. ; Create a named area for the dialog 200 chars wide and 100 lines of content
  AREA.Select DlgArea           ; Select this area for all following output
  WinPOS 40% 40% 40. 8.         ; Set dialog 40. units wide and 10. units height
  WM.DIALOG.AREA DlgArea        ; set medium sized font with WM.
  (
    HEADER "DLISTBOX Demo"

    POS 1.0 0.0 38.0 1.0
    TEXT "DLISTBOX - Drag & Drop Listbox Demo"

    POS ,,21.0 4.5
LIST1: DLISTBOX "string1,string2,string3,string4,string5,string6,string7,string8,string9,stringA,stringB,stringC,stringD,stringE,stringF"
    (
      ;  Try using "print ""*""" as command for the listbox
      ;  The * will be replaced by the double clicked list entry
      ;
      ;  DIALOG.STRING(LIST1) retrieves the currently selected
      ;  string from the dialog element labeled LIST1
      ;
      PRINT %ATTR 0x62 "Double clicked: " %ATTR 0x64 DIALOG.STRing(LIST1)
    )

    POS 23.0 1.0 13.0 1.0
    BUTTON "Show list"
    (
      ;  DIALOG.STRING2(LIST1) retrieves the complete list from the listbox with label LIST1
      ;  The retieved list contains all list items as comma separated values
      ;
      LOCAL &list
      &list=DIALOG.STRING2(LIST1)
      PRINT %ATTR 0x90 "The list: " %ATTR 0x92 "&list"
    )

    BUTTON "Show selection"
    (
      ; Just show the currenlty selected list item
      ;
      LOCAL &sel
      &sel=DIALOG.STRing(LIST1)
      IF "&sel"==""
      (
        PRINT %ATTR 0xA0 "No selection"
      )
      ELSE
      (
        PRINT %ATTR 0xA0 "Selected: " %ATTR 0xA2 "&sel"
      )
    )

    POSY 1.5
    BUTTON "Close" "goto DlgExit"

    CLOSE "goto DlgExit"
  )

DlgInit:
  (
    LOCAL &col
    &col="%ATTR 0x08"
    PRINT &col ""+CONVert.CHAR(0x03)+"                                      "+CONVert.CHAR(0x06)
    PRINT &col ""+CONVert.CHAR(0x0a)+"  Drag & Drop elements within the     "+CONVert.CHAR(0x0a)
    PRINT &col ""+CONVert.CHAR(0x0a)+"  above listbox to reorder the list   "+CONVert.CHAR(0x0a)
    PRINT &col ""+CONVert.CHAR(0x0a)+"  then show the list.                 "+CONVert.CHAR(0x0a)
    PRINT &col ""+CONVert.CHAR(0x0a)+"                                      "+CONVert.CHAR(0x0a)
    PRINT &col ""+CONVert.CHAR(0x0a)+"  Double click on a list entry to     "+CONVert.CHAR(0x0a)
    PRINT &col ""+CONVert.CHAR(0x0a)+"  execute a command                   "+CONVert.CHAR(0x0a)
    PRINT &col ""+CONVert.CHAR(0x09)+"                                      "+CONVert.CHAR(0x0c)
  )
  STOP

DlgExit:
  DIALOG.END

  ENDDO
