SG_Sort_ListIconGadget

Syntax:

SG_Sort_ListIconGadget(SG_GadgetID_L.l, Column_L.l, Typ_L.l, Options_L.l [, Start_L.l, Stop_L.l])

Parameters:

SG_GadgetID_L

=

The number of the gadget

Column_L

=

the Column which will be sorted. Started with 1

Typ_L

=

the y position of the gadget

Options_L

=

sort order; 0 for ascending and 1 for descending

Start_L

=

optional parameter for the first item to start sorting (the first item in the list has the index 0)

Stop_L

=

optional parameter for the last item to end sorting

The following constants can be used with Typ_L:

=

#PB_Sort_Byte : Typ Byte (.b)

=

#PB_Sort_Word : Typ Word (.w)

=

#PB_Sort_Long : Typ Long (.l)

=

#PB_Sort_String : Typ String (.s oder $)

=

#PB_Sort_Float : Typ Float (.f)

=

#PB_Sort_Double : Typ Double (.d)

=

#PB_Sort_Quad : Typ Quad (.q)

=

#PB_Sort_Character: Typ Character (.c)

=


Return Values:


Description:

Sort the Items of a listicon gadget.


Example:

If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse()= 0
  MessageRequester("Fehler", "init") 
  End 
EndIf

If OpenWindow(1, 0, 0, 1024, 768, "", #PB_Window_BorderLess)
  If OpenWindowedScreen(WindowID(1), 0, 0, 1024, 768, 0, 0, 0)
    ; create a mouse
    If CreateSprite(0, 8, 8) 
      If StartDrawing(SpriteOutput(0)) 
        Circle(4, 4, 4, RGB(255, 255, 255)) 
        StopDrawing()
      EndIf 
    EndIf
    Dim GadgNr.l(1)
    ;{ build Screengadgets
    GadgNr(0) = SG_ListIconGadget(#PB_Any, 230, 80, 350, 315, "Column0", 100, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines) ; 
    SG_AddGadgetColumn(GadgNr(0), 1, "Column1", 100)
    SG_AddGadgetColumn(GadgNr(0), 2, "Column2", 100)
    For x = 1 To 15
      SG_AddGadgetItem(GadgNr(0), -1, Chr(Random(25) + 65) + Chr(Random(25) + 65) + Chr(Random(25) + 65) + Chr(10) + Chr(Random(25) + 65) + Chr(Random(25) + 65) + Chr(Random(25) + 65) + Chr(10) + Chr(Random(25) + 65) + Chr(Random(25) + 65) + Chr(Random(25) + 65))
    Next
    SG_SetGadgetBackground(GadgNr(0), 0)
    SG_SetGadgetColor(GadgNr(0), $00FFFF)
    
    GadgNr(1) = SG_ButtonGadget(#PB_Any, 650, 660, 120, 40, "OK")
    ;} 
    
    ;{ Eventloop
    HeaderColumn_L = -1 ; for a change in the header
    HeaderState_L = -1
    Repeat ; Start of the event loop
      ClearScreen(0)
      SG_DrawGadgets()
      ExamineMouse () 
      DisplayTransparentSprite(0, MouseX(), MouseY())
      FlipBuffers(0)
      
      ;{ standard loop
      Event = SG_ScreenGadgetEvent() ; This line checks if an event happened
      GadgetID = SG_EventScreenGadgetID() ; Is it a gadget event?
      EventType = SG_EventType() ; The event type
      
      If Event = #PB_Event_Gadget
        If GadgetID = GadgNr(1)
          If EventType = #SG_EventType_LeftRelease
            SG_FreeAllGadgets()
            Event = #PB_Event_CloseWindow
          EndIf
          
        ElseIf GadgetID = GadgNr(0) ; listIcon
          If EventType = #SG_EventType_LeftRelease
            ; check header state
            For x = 0 To 2 ; test for each header column
              If SG_GetHeaderState(GadgNr(0), x) <> -1
                If (HeaderState_L <> SG_GetHeaderState(GadgNr(0), x) And HeaderColumn_L = x ) Or (HeaderState_L = SG_GetHeaderState(GadgNr(0), x) And HeaderColumn_L <> x ) Or (HeaderState_L <> SG_GetHeaderState(GadgNr(0), x) And HeaderColumn_L <> x )
                  HeaderColumn_L = x +1
                  HeaderState_L = SG_GetHeaderState(GadgNr(0), x)
                  If HeaderState_L <> -1
                    SG_Sort_ListIconGadget(GadgNr(0), HeaderColumn_L, #PB_Sort_String, HeaderState_L)
                  EndIf
                EndIf
              EndIf
            Next
          EndIf
          
        EndIf
        
      EndIf
      ;}
      Delay(30)
      
      ExamineMouse()
      
    Until Event = #PB_Event_CloseWindow ; End of the event loop
    ;}
  EndIf
EndIf
End

Remarks:



Supported OS:   Windows