It is currently Thu Dec 12, 2019 5:03 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Sat Oct 26, 2013 9:12 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 450
Location: Canada
Hello everyone,

A little change I made to kenmo original code but this modification will only work with PureBasic version supporting BindGadgetEvent().
The events are now managed in background and the program main event loop become more simple.

Code:
; +--------------+----------+
; | RatingGadget | by kenmo |
; +--------------+----------+
; |  8.01.2013 . Creation (PB 5.11)
; |   .02.     . Fixed Hover below 1 bug
; | 10.15.     . Embedded star icons in code
; |   .16.     . Cleaned up demo code
; |   .26.     . Minor optimization to SetRatingGadget()

;-
;EnableExplicit

;- Constants - Public

; Attribute constants
Enumeration
  #RG_OnImageID
  #RG_OffImageID
  #RG_Background
  #RG_State
  #RG_AllowZero
  #RG_Maximum
EndEnumeration

;- Structures - Private

Structure RATINGGADGET
  State.i
  Max.i
  Hover.i
  OnImageID.i
  OffImageID.i
  Background.i
  AllowZero.i
EndStructure

;-
;- Procedures - Private

Procedure.i xRatingGadgetDefault(Attribute.i)
  CompilerIf (#PB_Compiler_OS = #PB_OS_Windows)
    Select (Attribute)
      Case #RG_Background
        ProcedureReturn (GetSysColor_(#COLOR_BTNFACE))
    EndSelect
  CompilerElse
    Select (Attribute)
      Case #RG_Background
        ProcedureReturn ($EAEAEA)
    EndSelect
  CompilerEndIf
EndProcedure

Procedure xRatingGadgetRedraw(Gadget.i, *RG.RATINGGADGET, Empty.i = #False)
  Protected i.i, w.i, h.i
 
  If (IsGadget(Gadget) And *RG)
    If (*RG\Max < 1)
      *RG\Max = 1
    EndIf
    If (*RG\State > *RG\Max)
      *RG\State = *RG\Max
    Else
      If (*RG\AllowZero And (*RG\State < 0))
        *RG\State = 0
      ElseIf ((Not *RG\AllowZero) And (*RG\State < 1))
        *RG\State = 1
      EndIf
    EndIf
   
    If (StartDrawing(CanvasOutput(Gadget)))
      w = OutputWidth()
      h = OutputHeight()
      Box(0, 0, w, h, *RG\Background)
      DrawingMode(#PB_2DDrawing_AlphaBlend)
     
      If (*RG\OnImageID)
        For i = 0 To *RG\Max - 1
          If ((Not Empty) And ((*RG\Hover And (i < *RG\Hover)) Or ((Not *RG\Hover) And (i < *RG\State))))
            DrawImage(*RG\OnImageID, i * w / *RG\Max, 0)
          ElseIf (*RG\OffImageID)
            DrawImage(*RG\OffImageID, i * w / *RG\Max, 0)
          EndIf
        Next i
      EndIf
     
      StopDrawing()
    EndIf
  EndIf
EndProcedure

Procedure xRatingGadgetEvent()
 
  Protected *RG.RATINGGADGET
  Protected Hover.i, Gadget.i
 
  Gadget = EventGadget()
 
  If IsGadget(Gadget) And GadgetType(Gadget) = #PB_GadgetType_Canvas
   
    *RG = GetGadgetData(Gadget)
    If (*RG)
      Hover = *RG\Hover
      Select EventType()
        Case #PB_EventType_LeftClick
          If (*RG\Hover)
            *RG\State = *RG\Hover
            xRatingGadgetRedraw(Gadget, *RG)
            PostEvent(#PB_Event_Gadget, -1, Gadget, #PB_EventType_Change)
          EndIf
        Case #PB_EventType_RightClick
          If (*RG\AllowZero)
            *RG\State = 0
            xRatingGadgetRedraw(Gadget, *RG, #True)
            PostEvent(#PB_Event_Gadget, -1, Gadget, #PB_EventType_Change)
          EndIf
        Case #PB_EventType_MouseEnter, #PB_EventType_MouseMove
          Hover = 1 + *RG\Max * GetGadgetAttribute(Gadget, #PB_Canvas_MouseX) / GadgetWidth(Gadget)
          If (Hover < 1)
            Hover = 1
          ElseIf (Hover > *RG\Max)
            Hover = *RG\Max
          EndIf
        Case #PB_EventType_MouseLeave
          Hover = 0
      EndSelect
     
      If (Hover <> *RG\Hover)
        *RG\Hover = Hover
        xRatingGadgetRedraw(Gadget, *RG)
      EndIf
     
    EndIf
   
  EndIf
 
EndProcedure

;-
;- Procedures - Public

Procedure ResizeRatingGadget(Gadget.i, x.i, y.i, Width.i, Height.i)
  ResizeGadget(Gadget, x, y, Width, Height)
  xRatingGadgetRedraw(Gadget, GetGadgetData(Gadget))
EndProcedure

Procedure.i FreeRatingGadget(Gadget.i)
  Protected *RG.RATINGGADGET
 
  If (IsGadget(Gadget))
    *RG = GetGadgetData(Gadget)
    If (*RG)
      UnbindGadgetEvent(Gadget, @xRatingGadgetEvent())
      ClearStructure(*RG, RATINGGADGET)
      FreeMemory(*RG)
    EndIf
    FreeGadget(Gadget)
  EndIf
 
  ProcedureReturn (#Null)
EndProcedure

Procedure SetRatingGadget(Gadget.i, Attribute.i, Value.i)
  Protected *RG.RATINGGADGET
 
  If (IsGadget(Gadget))
    *RG = GetGadgetData(Gadget)
    If (*RG)
      Select (Attribute)
        Case #RG_OnImageID
          *RG\OnImageID = Value
        Case #RG_OffImageID
          *RG\OffImageID = Value
        Case #RG_Background
          *RG\Background = Value
        Case #RG_State
          If (Value < 0)
            Value = 0
          EndIf
          If (Value > *RG\Max)
            Value = *RG\Max
          EndIf
          *RG\State = Value
        Case #RG_AllowZero
          *RG\AllowZero = Bool(Value)
        Case #RG_Maximum
          *RG\Max = Value
      EndSelect
      xRatingGadgetRedraw(Gadget, *RG)
    EndIf
  EndIf
EndProcedure

Procedure.i GetRatingGadget(Gadget.i, Attribute.i)
  Protected Result = #Null
  Protected *RG.RATINGGADGET
 
  If (IsGadget(Gadget))
    *RG = GetGadgetData(Gadget)
    If (*RG)
      Select (Attribute)
        Case #RG_OnImageID
          Result = *RG\OnImageID
        Case #RG_OffImageID
          Result = *RG\OffImageID
        Case #RG_Background
          Result = *RG\Background
        Case #RG_State
          Result = *RG\State
        Case #RG_AllowZero
          Result = Bool(*RG\AllowZero)
        Case #RG_Maximum
          Result = *RG\Max
      EndSelect
    EndIf
  EndIf
 
  ProcedureReturn (Result)
EndProcedure

Procedure.i RatingGadget(Gadget.i, x.i, y.i, Width.i, Height.i, Max.i, OnImageID.i, OffImageID.i = #Null)
  Protected Result.i = #Null
  Protected Canvas.i
  Protected *RG.RATINGGADGET
 
  Canvas = CanvasGadget(Gadget, x, y, Width, Height)
  If (Canvas)
    If (Gadget = #PB_Any)
      Gadget = Canvas
    EndIf
    *RG = AllocateMemory(SizeOf(RATINGGADGET))
    If (*RG)
      InitializeStructure(*RG, RATINGGADGET)
      *RG\State = 0
      *RG\Max   = Max
      *RG\Hover = 0
      *RG\OnImageID  =  OnImageID
      *RG\OffImageID =  OffImageID
      *RG\Background =  xRatingGadgetDefault(#RG_Background)
      *RG\AllowZero  = #True
      SetGadgetData(Gadget, *RG)
      xRatingGadgetRedraw(Gadget, *RG)
      BindGadgetEvent(Gadget, @xRatingGadgetEvent())
      Result = Gadget
    Else
      FreeGadget(Gadget)
    EndIf
  EndIf
 
  ProcedureReturn (Result)
EndProcedure

;-
;- Demo Program

CompilerIf ((#True) And (#PB_Compiler_IsMainFile))
  DisableExplicit
 
  If (OpenWindow(0, 0, 0, 320, 110, "RatingGadget", #PB_Window_ScreenCentered|#PB_Window_SystemMenu))
    UsePNGImageDecoder()
    CatchImage(0, ?GrayStart, ?GrayEnd - ?GrayStart)
    CatchImage(1, ?StarStart, ?StarEnd - ?StarStart)
   
    RatingGadget(0, 30, 10 + 0*26, 160, 16, 10, ImageID(1), ImageID(0))
    SetRatingGadget(0, #RG_State, 5)
    TextGadget(0+3, 210, 10 + 0*26, 110, 20, "Right-click to clear")
    RatingGadget(1, 30, 10 + 1*26, 160, 16, 10, ImageID(1), ImageID(0))
    SetRatingGadget(1, #RG_State, 5)
    SetRatingGadget(1, #RG_AllowZero, #False)
    TextGadget(1+3, 210, 10 + 1*26, 110, 20, "No clearing allowed")
    RatingGadget(2, 30, 10 + 2*26, 160, 16, 10, ImageID(1))
    SetRatingGadget(2, #RG_State, 5)
    SetRatingGadget(2, #RG_Background, $FFE0D0)
    TextGadget(2+3, 210, 10 + 2*26, 110, 20, "Color, no 'off' image")
    TextGadget(6, 0, WindowHeight(0)-22, WindowWidth(0), 22, "", #PB_Text_Center)
   
    Repeat
     
      EventID = WaitWindowEvent()
     
      Select EventID
         
        Case #PB_Event_Menu
         
          Select EventMenu()
             
          EndSelect
         
        Case #PB_Event_Gadget
         
          Select EventGadget()
             
            Case 0,1,2
             
              If EventType() = #PB_EventType_Change
                Rated = GetRatingGadget(EventGadget(), #RG_State)
                If (Rated > 0)
                  SetGadgetText(6, "Gadget " + Str(EventGadget()) + " set to " + Str(Rated) + " / " + Str(GetRatingGadget(EventGadget(), #RG_Maximum)))
                Else
                  SetGadgetText(6, "Gadget " + Str(EventGadget()) + " cleared!")
                EndIf
              EndIf
             
          EndSelect
         
      EndSelect
     
    Until EventID = #PB_Event_CloseWindow
  EndIf
 
  DataSection
    StarStart:
    Data.a 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16
    Data.a 0,0,0,16,8,6,0,0,0,31,243,255,97,0,0,0,25,116,69,88
    Data.a 116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103
    Data.a 101,82,101,97,100,121,113,201,101,60,0,0,2,5,73,68,65,84,120,218
    Data.a 164,83,207,75,84,81,20,254,238,125,211,115,28,25,13,108,108,176,169,8
    Data.a 154,33,93,100,49,105,131,66,32,73,180,16,137,150,45,134,8,134,126,64
    Data.a 127,128,27,161,63,161,93,38,82,89,180,104,213,198,141,45,90,20,12,36
    Data.a 129,99,82,84,26,161,146,76,47,181,134,153,166,177,251,206,237,220,231,12
    Data.a 168,205,19,162,11,223,123,223,189,247,59,223,61,247,156,247,160,181,134,223
    Data.a 248,122,191,247,42,227,182,223,190,23,187,155,65,41,123,221,45,190,204,232
    Data.a 221,12,164,223,102,126,60,121,203,142,157,151,13,135,7,61,238,167,147,245
    Data.a 83,79,133,100,99,235,72,96,127,59,12,12,255,39,3,87,169,59,161,206
    Data.a 11,160,181,103,30,12,207,143,159,122,80,79,27,48,15,103,162,111,66,187
    Data.a 234,184,38,213,5,114,121,53,8,59,26,5,253,124,227,137,236,232,49,192
    Data.a 10,166,243,99,39,211,144,22,132,12,228,132,101,205,242,86,218,51,32,162
    Data.a 139,45,125,87,154,26,142,36,193,70,156,87,43,104,229,17,72,209,102,154
    Data.a 149,28,34,151,238,177,112,21,2,21,252,90,120,222,85,152,158,58,106,12
    Data.a 132,169,164,16,226,196,242,88,247,212,222,206,67,17,123,95,11,52,113,160
    Data.a 230,219,9,171,90,110,206,74,16,79,37,54,156,2,126,188,93,116,14,100
    Data.a 94,157,227,216,153,90,13,102,98,153,233,129,249,236,167,73,35,144,141,9
    Data.a 110,145,203,70,106,19,204,101,40,129,202,202,58,230,179,11,147,28,60,96
    Data.a 98,118,22,113,246,244,112,238,38,253,230,91,89,205,124,40,109,135,104,2
    Data.a 149,45,24,141,209,214,237,194,210,104,119,106,79,91,28,170,240,142,79,118
    Data.a 77,117,60,24,78,197,15,8,68,226,88,186,219,147,242,109,99,73,161,95
    Data.a 134,130,208,27,14,7,148,81,154,91,244,96,56,85,28,88,97,27,197,178
    Data.a 234,247,53,8,183,199,134,168,248,25,149,229,117,56,115,95,222,31,188,252
    Data.a 162,199,192,112,179,166,213,119,132,35,109,67,127,255,16,213,177,246,116,80
    Data.a 59,15,123,221,209,107,137,27,60,237,216,34,235,48,107,223,30,159,113,87
    Data.a 159,156,213,91,99,107,109,172,173,37,171,239,143,140,194,142,143,174,153,17
    Data.a 175,242,215,219,12,254,103,252,17,96,0,49,255,2,185,111,125,142,173,0
    Data.a 0,0,0,73,69,78,68,174,66,96,130
    StarEnd:
   
    GrayStart:
    Data.a 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16
    Data.a 0,0,0,16,8,6,0,0,0,31,243,255,97,0,0,0,6,98,75,71
    Data.a 68,0,255,0,255,0,255,160,189,167,147,0,0,0,9,112,72,89,115,0
    Data.a 0,11,19,0,0,11,19,1,0,154,156,24,0,0,0,7,116,73,77,69
    Data.a 7,221,10,16,0,17,55,147,185,108,112,0,0,2,10,73,68,65,84,56
    Data.a 203,149,147,193,75,27,81,16,198,127,111,221,69,220,64,23,97,151,156,114
    Data.a 145,22,65,72,45,20,36,87,65,60,10,246,232,33,215,30,68,26,136,185
    Data.a 10,66,142,201,66,34,148,94,219,255,193,75,239,57,73,193,120,16,36,171
    Data.a 7,241,178,174,32,148,77,12,89,223,188,30,106,74,43,174,212,15,134,247
    Data.a 134,153,247,49,51,223,27,140,49,228,161,219,237,126,236,118,187,157,188,184
    Data.a 49,6,155,103,80,42,149,62,107,173,45,224,83,94,142,149,23,8,195,112
    Data.a 127,113,113,209,90,90,90,34,12,195,253,23,17,116,58,29,215,117,221,61
    Data.a 207,243,240,60,15,215,117,247,94,68,112,127,127,255,165,92,46,19,69,17
    Data.a 81,20,81,46,151,9,195,240,235,83,185,54,192,193,193,193,55,173,245,91
    Data.a 17,89,22,17,28,199,193,243,60,46,46,46,0,88,88,88,192,182,237,106
    Data.a 187,221,174,42,165,152,153,153,233,91,150,117,2,84,109,0,17,249,80,169
    Data.a 84,10,165,82,9,17,97,110,110,142,126,191,143,136,0,16,199,49,91,91
    Data.a 91,220,221,221,161,181,102,48,24,44,159,158,158,190,6,170,202,24,131,82
    Data.a 234,93,171,213,250,94,44,22,131,66,161,128,136,160,148,194,178,126,119,40
    Data.a 34,24,99,176,44,139,209,104,68,28,199,73,189,94,95,55,198,28,79,103
    Data.a 112,188,187,187,187,118,126,126,126,56,26,141,240,125,31,17,65,107,141,214
    Data.a 26,17,193,247,125,210,52,37,138,162,195,122,189,190,6,28,63,30,226,73
    Data.a 179,217,220,81,74,49,59,59,139,49,230,31,115,28,7,128,102,179,185,3
    Data.a 156,60,169,66,171,213,170,4,65,192,245,245,245,159,178,141,49,136,8,55
    Data.a 55,55,4,65,64,187,221,174,228,202,152,101,217,170,227,56,12,135,67,38
    Data.a 147,9,73,146,144,36,9,147,201,132,225,112,136,109,219,140,199,227,213,92
    Data.a 2,223,247,55,110,111,111,73,211,148,56,142,207,106,181,218,74,173,86,91
    Data.a 137,227,248,44,77,83,198,227,49,243,243,243,27,185,4,34,82,188,186,186
    Data.a 146,94,175,183,221,104,52,54,179,44,59,202,178,236,168,209,104,108,246,122
    Data.a 189,237,203,203,75,17,145,226,223,111,166,50,78,253,247,15,231,0,248,249
    Data.a 232,211,189,2,222,60,220,127,76,183,81,61,183,206,255,131,95,222,246,11
    Data.a 2,206,203,196,96,0,0,0,0,73,69,78,68,174,66,96,130
    GrayEnd:
   
  EndDataSection
 
CompilerEndIf


Best regards
StarBootics

_________________
The Stone Age did not end due to a shortage of stones !


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Sat Nov 09, 2013 8:38 am 
Offline
Addict
Addict
User avatar

Joined: Thu Feb 09, 2006 11:27 pm
Posts: 2456
Well done, thanks!

Maybe a *RG\Min extension for the structure would also allow to set zero stars by double clicking and moving the cursor outside the canvas gadget, if needed.


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Thu Apr 23, 2015 11:46 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jul 07, 2013 11:35 am
Posts: 450
Location: Canada
Hello everyone,

Another update, this time a Module version.

Best regards
StarBootics

Code:
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : RatingGadget - Module
; File Name : RatingGadget - Module.pb
; File version: 1.0.0
; Programming : OK
; Programmed by : kenmo
; Updated by : StarBootics
; Date : 23-04-2015
; Last Update : 23-04-2015
; PureBasic code : V5.31
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

DeclareModule Rating
 
  Enumeration
   
    #ON_IMAGE_ID
    #OFF_IMAGE_ID
    #BACKGROUND
    #STATE
    #ALLOW_ZERO
    #MAXIMUM
   
  EndEnumeration

  Declare SetAttribute(GadgetID.i, Attribute.i, Value.i)
  Declare.i GetAttribute(GadgetID.i, Attribute.i)
  Declare Gadget(GadgetID.i, x.i, y.i, Width.i, Height.i, Max.i, OnImageID.i = -1, OffImageID.i = -1)
  Declare Resize(GadgetID.i, x.i, y.i, Width.i, Height.i)
  Declare Free(GadgetID.i)
 
EndDeclareModule

Module Rating
 
  Structure Rating
   
    State.i
    Max.i
    Hover.i
    OnImageID.i
    OffImageID.i
    Background.i
    AllowZero.i
   
  EndStructure
 
  Procedure.i Private_Rating_Default(Attribute.i)
   
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
     
      Select Attribute
         
        Case #BACKGROUND
          ProcedureReturn GetSysColor_(#COLOR_BTNFACE)
         
      EndSelect
     
    CompilerElse
     
      Select Attribute
         
        Case #BACKGROUND
          ProcedureReturn $EAEAEA
         
      EndSelect
     
    CompilerEndIf
   
  EndProcedure
 
  Procedure Private_Rating_Redraw(GadgetID.i, *RatingGadgetA.Rating, Empty.i = #False)
   
    Protected i.i, w.i, h.i
   
    If IsGadget(GadgetID) And *RatingGadgetA <> #Null
     
      If *RatingGadgetA\Max < 1
        *RatingGadgetA\Max = 1
      EndIf
     
      If *RatingGadgetA\State > *RatingGadgetA\Max
        *RatingGadgetA\State = *RatingGadgetA\Max
      Else
       
        If *RatingGadgetA\AllowZero And *RatingGadgetA\State < 0
          *RatingGadgetA\State = 0
        ElseIf Not *RatingGadgetA\AllowZero And *RatingGadgetA\State < 1
          *RatingGadgetA\State = 1
        EndIf
       
      EndIf
     
      If StartDrawing(CanvasOutput(GadgetID))
       
        w = OutputWidth()
        h = OutputHeight()
        Box(0, 0, w, h, *RatingGadgetA\Background)
        DrawingMode(#PB_2DDrawing_AlphaBlend)
       
        If *RatingGadgetA\OnImageID
         
          For RateID = 0 To *RatingGadgetA\Max - 1
            If ((Not Empty) And ((*RatingGadgetA\Hover And (RateID < *RatingGadgetA\Hover)) Or ((Not *RatingGadgetA\Hover) And (RateID < *RatingGadgetA\State))))
              DrawImage(*RatingGadgetA\OnImageID, RateID * w / *RatingGadgetA\Max, 0)
            ElseIf *RatingGadgetA\OffImageID
              DrawImage(*RatingGadgetA\OffImageID, RateID * w / *RatingGadgetA\Max, 0)
            EndIf
          Next
         
        EndIf
       
        StopDrawing()
       
      EndIf
     
    EndIf
   
  EndProcedure
 
  Procedure.i Private_Rating_Event()
   
    Protected GadgetID.i
    Protected *RatingGadgetA.Rating
    Protected Hover.i
   
    GadgetID = EventGadget()
   
    If IsGadget(GadgetID) And GadgetType(GadgetID) = #PB_GadgetType_Canvas
     
      *RatingGadgetA = GetGadgetData(GadgetID)
     
      If *RatingGadgetA <> #Null
       
        Hover = *RatingGadgetA\Hover
       
        Select EventType()
           
          Case #PB_EventType_LeftClick
            If *RatingGadgetA\Hover
              *RatingGadgetA\State = *RatingGadgetA\Hover
              Private_Rating_Redraw(GadgetID, *RatingGadgetA)
              PostEvent(#PB_Event_Gadget, -1, GadgetID, #PB_EventType_Change)
            EndIf
           
          Case #PB_EventType_RightClick
            If *RatingGadgetA\AllowZero
              *RatingGadgetA\State = 0
              Private_Rating_Redraw(GadgetID, *RatingGadgetA, #True)
              PostEvent(#PB_Event_Gadget, -1, GadgetID, #PB_EventType_Change)
            EndIf
           
          Case #PB_EventType_MouseEnter, #PB_EventType_MouseMove
            Hover = 1 + *RatingGadgetA\Max * GetGadgetAttribute(GadgetID, #PB_Canvas_MouseX) / GadgetWidth(GadgetID)
            If Hover < 1
              Hover = 1
            ElseIf Hover > *RatingGadgetA\Max
              Hover = *RatingGadgetA\Max
            EndIf
           
          Case #PB_EventType_MouseLeave
            Hover = 0
           
        EndSelect
       
        If Hover <> *RatingGadgetA\Hover
          *RatingGadgetA\Hover = Hover
          Private_Rating_Redraw(GadgetID, *RatingGadgetA)
        EndIf
       
      EndIf
     
    EndIf
   
  EndProcedure
 
  Procedure SetAttribute(GadgetID.i, Attribute.i, Value.i)
   
    Protected *RatingGadgetA.Rating
   
    If IsGadget(GadgetID)
     
      *RatingGadgetA = GetGadgetData(GadgetID)
     
      If *RatingGadgetA <> #Null
       
        Select Attribute
           
          Case #ON_IMAGE_ID
            *RatingGadgetA\OnImageID = Value
           
          Case #OFF_IMAGE_ID
            *RatingGadgetA\OffImageID = Value
           
          Case #BACKGROUND
            *RatingGadgetA\Background = Value
           
          Case #STATE
           
            If Value < 0
              Value = 0
            EndIf
           
            If Value > *RatingGadgetA\Max
              Value = *RatingGadgetA\Max
            EndIf
           
            *RatingGadgetA\State = Value
           
          Case #ALLOW_ZERO
            *RatingGadgetA\AllowZero = Bool(Value)
           
          Case #MAXIMUM
            *RatingGadgetA\Max = Value
           
        EndSelect
       
        Private_Rating_Redraw(GadgetID, *RatingGadgetA)
       
      EndIf
     
    EndIf
   
  EndProcedure
 
  Procedure.i GetAttribute(GadgetID.i, Attribute.i)
   
    Protected Result = #Null
    Protected *RatingGadgetA.Rating
   
    If IsGadget(GadgetID)
     
      *RatingGadgetA = GetGadgetData(GadgetID)
     
      If *RatingGadgetA <> #Null
       
        Select Attribute
           
          Case #ON_IMAGE_ID
            Result = *RatingGadgetA\OnImageID
           
          Case #OFF_IMAGE_ID
            Result = *RatingGadgetA\OffImageID
           
          Case #BACKGROUND
            Result = *RatingGadgetA\Background
           
          Case #STATE
            Result = *RatingGadgetA\State
           
          Case #ALLOW_ZERO
            Result = Bool(*RatingGadgetA\AllowZero)
           
          Case #MAXIMUM
            Result = *RatingGadgetA\Max
           
        EndSelect
       
      EndIf
     
    EndIf
   
    ProcedureReturn Result
  EndProcedure

  Procedure.i Gadget(GadgetID.i, x.i, y.i, Width.i, Height.i, Max.i, OnImageID.i = -1, OffImageID.i = -1)
   
    GadgetHandle = CanvasGadget(GadgetID, x, y, Width, Height)
   
    If GadgetID = #PB_Any
      GadgetID = GadgetHandle
    EndIf
   
    *RatingGadgetA.Rating = AllocateMemory(SizeOf(Rating))
   
    If *RatingGadgetA <> #Null
     
      *RatingGadgetA\State = 0
      *RatingGadgetA\Max = Max
      *RatingGadgetA\Hover = 0
     
      If OnImageID = -1 Or OffImageID = -1
        UsePNGImageDecoder()
      EndIf
     
      If OnImageID = -1
        *RatingGadgetA\OnImageID = ImageID(CatchImage(#PB_Any, ?StarStart, ?StarEnd - ?StarStart))
      Else
        *RatingGadgetA\OnImageID = OnImageID
      EndIf
     
      If OffImageID = -1
        *RatingGadgetA\OffImageID = ImageID(CatchImage(#PB_Any, ?GrayStart, ?GrayEnd - ?GrayStart))
      Else
        *RatingGadgetA\OffImageID = OffImageID
      EndIf
     
      *RatingGadgetA\Background = Private_Rating_Default(#BACKGROUND)
      *RatingGadgetA\AllowZero = #True
      SetGadgetData(GadgetID, *RatingGadgetA)
      BindGadgetEvent(GadgetID, @Private_Rating_Event())
     
    EndIf
   
    ProcedureReturn GadgetID
  EndProcedure
 
  Procedure Resize(GadgetID.i, x.i, y.i, Width.i, Height.i)
   
    ResizeGadget(GadgetID, x, y, Width, Height)
    Private_Rating_Redraw(GadgetID, GetGadgetData(GadgetID))
   
  EndProcedure
 
  Procedure Free(GadgetID.i)
   
    Protected *RatingGadgetA.Rating
   
    If IsGadget(GadgetID)
     
      *RatingGadgetA = GetGadgetData(GadgetID)
     
      If *RatingGadgetA <> #Null
       
        UnbindGadgetEvent(GadgetID, @Private_Rating_Event())
       
        *RatingGadgetA\State = 0
        *RatingGadgetA\Max = 0
        *RatingGadgetA\Hover = 0
       
        If IsImage(*RatingGadgetA\OnImageID)
          FreeImage(*RatingGadgetA\OnImageID)
          *RatingGadgetA\OnImageID = 0
        EndIf
       
        If IsImage(*RatingGadgetA\OffImageID)
          FreeImage(*RatingGadgetA\OffImageID)
          *RatingGadgetA\OffImageID = 0
        EndIf
       
        *RatingGadgetA\Background = 0
        *RatingGadgetA\AllowZero = 0
        FreeMemory(*RatingGadgetA)
       
      EndIf
     
      FreeGadget(GadgetID)
     
    EndIf
   
  EndProcedure
 
  DataSection
   
    StarStart:
    Data.a 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16
    Data.a 0,0,0,16,8,6,0,0,0,31,243,255,97,0,0,0,25,116,69,88
    Data.a 116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103
    Data.a 101,82,101,97,100,121,113,201,101,60,0,0,2,5,73,68,65,84,120,218
    Data.a 164,83,207,75,84,81,20,254,238,125,211,115,28,25,13,108,108,176,169,8
    Data.a 154,33,93,100,49,105,131,66,32,73,180,16,137,150,45,134,8,134,126,64
    Data.a 127,128,27,161,63,161,93,38,82,89,180,104,213,198,141,45,90,20,12,36
    Data.a 129,99,82,84,26,161,146,76,47,181,134,153,166,177,251,206,237,220,231,12
    Data.a 168,205,19,162,11,223,123,223,189,247,59,223,61,247,156,247,160,181,134,223
    Data.a 248,122,191,247,42,227,182,223,190,23,187,155,65,41,123,221,45,190,204,232
    Data.a 221,12,164,223,102,126,60,121,203,142,157,151,13,135,7,61,238,167,147,245
    Data.a 83,79,133,100,99,235,72,96,127,59,12,12,255,39,3,87,169,59,161,206
    Data.a 11,160,181,103,30,12,207,143,159,122,80,79,27,48,15,103,162,111,66,187
    Data.a 234,184,38,213,5,114,121,53,8,59,26,5,253,124,227,137,236,232,49,192
    Data.a 10,166,243,99,39,211,144,22,132,12,228,132,101,205,242,86,218,51,32,162
    Data.a 139,45,125,87,154,26,142,36,193,70,156,87,43,104,229,17,72,209,102,154
    Data.a 149,28,34,151,238,177,112,21,2,21,252,90,120,222,85,152,158,58,106,12
    Data.a 132,169,164,16,226,196,242,88,247,212,222,206,67,17,123,95,11,52,113,160
    Data.a 230,219,9,171,90,110,206,74,16,79,37,54,156,2,126,188,93,116,14,100
    Data.a 94,157,227,216,153,90,13,102,98,153,233,129,249,236,167,73,35,144,141,9
    Data.a 110,145,203,70,106,19,204,101,40,129,202,202,58,230,179,11,147,28,60,96
    Data.a 98,118,22,113,246,244,112,238,38,253,230,91,89,205,124,40,109,135,104,2
    Data.a 149,45,24,141,209,214,237,194,210,104,119,106,79,91,28,170,240,142,79,118
    Data.a 77,117,60,24,78,197,15,8,68,226,88,186,219,147,242,109,99,73,161,95
    Data.a 134,130,208,27,14,7,148,81,154,91,244,96,56,85,28,88,97,27,197,178
    Data.a 234,247,53,8,183,199,134,168,248,25,149,229,117,56,115,95,222,31,188,252
    Data.a 162,199,192,112,179,166,213,119,132,35,109,67,127,255,16,213,177,246,116,80
    Data.a 59,15,123,221,209,107,137,27,60,237,216,34,235,48,107,223,30,159,113,87
    Data.a 159,156,213,91,99,107,109,172,173,37,171,239,143,140,194,142,143,174,153,17
    Data.a 175,242,215,219,12,254,103,252,17,96,0,49,255,2,185,111,125,142,173,0
    Data.a 0,0,0,73,69,78,68,174,66,96,130
    StarEnd:
   
    GrayStart:
    Data.a 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16
    Data.a 0,0,0,16,8,6,0,0,0,31,243,255,97,0,0,0,6,98,75,71
    Data.a 68,0,255,0,255,0,255,160,189,167,147,0,0,0,9,112,72,89,115,0
    Data.a 0,11,19,0,0,11,19,1,0,154,156,24,0,0,0,7,116,73,77,69
    Data.a 7,221,10,16,0,17,55,147,185,108,112,0,0,2,10,73,68,65,84,56
    Data.a 203,149,147,193,75,27,81,16,198,127,111,221,69,220,64,23,97,151,156,114
    Data.a 145,22,65,72,45,20,36,87,65,60,10,246,232,33,215,30,68,26,136,185
    Data.a 10,66,142,201,66,34,148,94,219,255,193,75,239,57,73,193,120,16,36,171
    Data.a 7,241,178,174,32,148,77,12,89,223,188,30,106,74,43,174,212,15,134,247
    Data.a 134,153,247,49,51,223,27,140,49,228,161,219,237,126,236,118,187,157,188,184
    Data.a 49,6,155,103,80,42,149,62,107,173,45,224,83,94,142,149,23,8,195,112
    Data.a 127,113,113,209,90,90,90,34,12,195,253,23,17,116,58,29,215,117,221,61
    Data.a 207,243,240,60,15,215,117,247,94,68,112,127,127,255,165,92,46,19,69,17
    Data.a 81,20,81,46,151,9,195,240,235,83,185,54,192,193,193,193,55,173,245,91
    Data.a 17,89,22,17,28,199,193,243,60,46,46,46,0,88,88,88,192,182,237,106
    Data.a 187,221,174,42,165,152,153,153,233,91,150,117,2,84,109,0,17,249,80,169
    Data.a 84,10,165,82,9,17,97,110,110,142,126,191,143,136,0,16,199,49,91,91
    Data.a 91,220,221,221,161,181,102,48,24,44,159,158,158,190,6,170,202,24,131,82
    Data.a 234,93,171,213,250,94,44,22,131,66,161,128,136,160,148,194,178,126,119,40
    Data.a 34,24,99,176,44,139,209,104,68,28,199,73,189,94,95,55,198,28,79,103
    Data.a 112,188,187,187,187,118,126,126,126,56,26,141,240,125,31,17,65,107,141,214
    Data.a 26,17,193,247,125,210,52,37,138,162,195,122,189,190,6,28,63,30,226,73
    Data.a 179,217,220,81,74,49,59,59,139,49,230,31,115,28,7,128,102,179,185,3
    Data.a 156,60,169,66,171,213,170,4,65,192,245,245,245,159,178,141,49,136,8,55
    Data.a 55,55,4,65,64,187,221,174,228,202,152,101,217,170,227,56,12,135,67,38
    Data.a 147,9,73,146,144,36,9,147,201,132,225,112,136,109,219,140,199,227,213,92
    Data.a 2,223,247,55,110,111,111,73,211,148,56,142,207,106,181,218,74,173,86,91
    Data.a 137,227,248,44,77,83,198,227,49,243,243,243,27,185,4,34,82,188,186,186
    Data.a 146,94,175,183,221,104,52,54,179,44,59,202,178,236,168,209,104,108,246,122
    Data.a 189,237,203,203,75,17,145,226,223,111,166,50,78,253,247,15,231,0,248,249
    Data.a 232,211,189,2,222,60,220,127,76,183,81,61,183,206,255,131,95,222,246,11
    Data.a 2,206,203,196,96,0,0,0,0,73,69,78,68,174,66,96,130
    GrayEnd:
   
  EndDataSection
 
EndModule

CompilerIf #PB_Compiler_IsMainFile
 
  If OpenWindow(0, 0, 0, 350, 110, "RatingGadget", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
   
    Rating::Gadget(0, 30, 10 + 0*26, 160, 16, 10)
    Rating::SetAttribute(0, Rating::#STATE, 5)
    TextGadget(0+3, 210, 10 + 0*26, 110, 20, "Right-click to clear")
   
    Rating::Gadget(1, 30, 10 + 1*26, 160, 16, 10)
    Rating::SetAttribute(1, Rating::#STATE, 5)
    Rating::SetAttribute(1, Rating::#ALLOW_ZERO, #False)
    TextGadget(1+3, 210, 10 + 1*26, 110, 20, "No clearing allowed")
   
    Rating::Gadget(2, 30, 10 + 2*26, 160, 16, 10, -1, 0)
    Rating::SetAttribute(2, Rating::#STATE, 5)
    Rating::SetAttribute(2, Rating::#BACKGROUND, $FFE0D0)
    TextGadget(2+3, 210, 10 + 2*26, 110, 20, "Color, no 'off' image")
   
    TextGadget(6, 0, WindowHeight(0)-22, WindowWidth(0), 22, "", #PB_Text_Center)
   
    Repeat
     
      EventID = WaitWindowEvent()
     
      Select EventID
         
        Case #PB_Event_Menu
         
          Select EventMenu()
             
          EndSelect
         
        Case #PB_Event_Gadget
         
          Select EventGadget()
             
            Case 0,1,2
             
              If EventType() = #PB_EventType_Change
                Rated = Rating::GetAttribute(EventGadget(), Rating::#STATE)
                If (Rated > 0)
                  SetGadgetText(6, "Gadget " + Str(EventGadget()) + " set to " + Str(Rated) + " / " + Str(Rating::GetAttribute(EventGadget(), Rating::#MAXIMUM)))
                Else
                  SetGadgetText(6, "Gadget " + Str(EventGadget()) + " cleared!")
                EndIf
              EndIf
             
          EndSelect
         
      EndSelect
     
    Until EventID = #PB_Event_CloseWindow
   
   
    Rating::Free(0)
    Rating::Free(1)
    Rating::Free(2)
   
  EndIf
 
CompilerEndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<

_________________
The Stone Age did not end due to a shortage of stones !


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Sat Apr 25, 2015 11:13 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2057
Location: Germany
Very nice :D

Runs on Mac Yosemite

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Sun Jan 10, 2016 12:18 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1687
Did a quick rewrite of this RatingGadget in PB 5.41.

Takes advantages of some PB changes since 5.11 (BindGadget, etc.)

Look at the demo at the bottom for some examples of usage and customizing.

EDIT: Added ReadOnly flag

Code:
; +--------------+-------+
; | RatingGadget | kenmo |
; +--------------+-------+
; | 2016.01.09 . Rewrite (PureBasic 5.41)
; |        .11 . All attributes now support #PB_Default
; |     .02.26 . Added ReadOnly creation flag, and SetReadOnly() macro

; Default star images by FatCow (http://www.fatcow.com/free-icons)


CompilerIf (Not Defined(_RatingGadget_Included, #PB_Constant))
#_RatingGadget_Included = #True

CompilerIf (#PB_Compiler_IsMainFile)
  EnableExplicit
CompilerEndIf


;-
;- Constants (Public)

; RatingGadget Image Constants
#RatingGadget_Default = #PB_Default
#RatingGadget_None    = #RatingGadget_Default - 1

Enumeration ; RatingGadget Creation Flags
  #RatingGadget_Border       = $01
  #RatingGadget_NoRightClick = $02
  #RatingGadget_ReadOnly     = $04
EndEnumeration

; Define #RatingGadget_DisablePNGDecoder to #True (before including this file)
; to disable the UsePNGImageDecoder() call.
CompilerIf (Not Defined(RatingGadget_DisablePNGDecoder, #PB_Constant))
  #RatingGadget_DisablePNGDecoder = #False
CompilerEndIf

; Define #RatingGadget_DisableDefaultImages to #True (before including this file)
; to disable the default star images from the build.
CompilerIf (Not Defined(RatingGadget_DisableDefaultImages, #PB_Constant))
  #RatingGadget_DisableDefaultImages = #False
CompilerEndIf

;-
;- Constants (Private)

Enumeration ; Internal Flags
  #_RG_MouseOver = $01 << 16
  #_RG_MouseDown = $02 << 16
  #_RG_Drawing   = $04 << 16
EndEnumeration

Enumeration ; Dynamic Attributes
  #_RG_State    = $01
  #_RG_OffImage = $02
  #_RG_OnImage  = $03
  #_RG_Color    = $04
  #_RG_Maximum  = $05
  #_RG_ReadOnly = $06
EndEnumeration


;-
;- Structures (Private)

Structure _RatingGadget
  Gadget.i
  State.i
  Maximum.i
  Flags.i
  HoverItem.i
  DrawItem.i
  OffImage.i
  OnImage.i
  ItemWidth.i
  ItemHeight.i
  TotalWidth.i
  TotalHeight.i
  Window.i
  Background.i
EndStructure


;-
;- Globals (Private)

CompilerIf (Not #RatingGadget_DisablePNGDecoder)
  UsePNGImageDecoder()
CompilerEndIf
Global _RG_DefaultOffImage.i = CatchImage(#PB_Any, ?_RG_StarOff_Start, ?_RG_StarOff_End - ?_RG_StarOff_Start)
If (Not _RG_DefaultOffImage)
  _RG_DefaultOffImage = #RatingGadget_None
EndIf
Global _RG_DefaultOnImage.i  = CatchImage(#PB_Any, ?_RG_StarOn_Start, ?_RG_StarOn_End - ?_RG_StarOn_Start)
If (Not _RG_DefaultOnImage)
  _RG_DefaultOnImage = #RatingGadget_None
EndIf

;-
;- Macros (Public)

Macro RatingGadget_Bind(Gadget, Callback)
  BindGadgetEvent((Gadget), (Callback), #PB_EventType_Change)
EndMacro

Macro RatingGadget_SetState(Gadget, State)
  _RG_Set((Gadget), #_RG_State, (State))
EndMacro
Macro RatingGadget_SetColor(Gadget, Color)
  _RG_Set((Gadget), #_RG_Color, (Color))
EndMacro
Macro RatingGadget_SetOnImage(Gadget, Image)
  _RG_Set((Gadget), #_RG_OnImage, (Image))
EndMacro
Macro RatingGadget_SetOffImage(Gadget, Image)
  _RG_Set((Gadget), #_RG_OffImage, (Image))
EndMacro
Macro RatingGadget_SetMaximum(Gadget, Maximum)
  _RG_Set((Gadget), #_RG_Maximum, (Maximum))
EndMacro
Macro RatingGadget_SetReadOnly(Gadget, State)
  _RG_Set((Gadget), #_RG_ReadOnly, (State))
EndMacro

Macro RatingGadget_GetState(Gadget)
  _RG_Get((Gadget), #_RG_State)
EndMacro
Macro RatingGadget_GetMaximum(Gadget)
  _RG_Get((Gadget), #_RG_Maximum)
EndMacro


;-
;- Procedures (Private)

Procedure _RG_UpdateSizes(*RG._RatingGadget)
  With *RG
    If (\Maximum < 1)
      \Maximum = 1
    EndIf
    \ItemWidth = 1
    If (IsImage(\OffImage) And (ImageWidth(\OffImage) > \ItemWidth))
      \ItemWidth = ImageWidth(\OffImage)
    EndIf
    If (IsImage(\OnImage) And (ImageWidth(\OnImage) > \ItemWidth))
      \ItemWidth = ImageWidth(\OnImage)
    EndIf
    \ItemHeight = 1
    If (IsImage(\OffImage) And (ImageHeight(\OffImage) > \ItemHeight))
      \ItemHeight = ImageHeight(\OffImage)
    EndIf
    If (IsImage(\OnImage) And (ImageHeight(\OnImage) > \ItemHeight))
      \ItemHeight = ImageHeight(\OnImage)
    EndIf
    \TotalWidth  = \Maximum * \ItemWidth
    \TotalHeight = \ItemHeight
  EndWith
EndProcedure

Procedure _RG_Redraw(*RG._RatingGadget)
  With *RG
    If (Not (\Flags & #_RG_Drawing))
      If (StartDrawing(CanvasOutput(\Gadget)))
        \Flags | #_RG_Drawing
        Box(0, 0, OutputWidth(), OutputHeight(), \Background)
        DrawingMode(#PB_2DDrawing_AlphaBlend)
        Protected i.i
        If ((\OnImage <> #RatingGadget_None) And (\DrawItem > 0))
          For i = 1 To \DrawItem
            DrawImage(ImageID(\OnImage), (OutputWidth() - \TotalWidth)/2 + (i-1) * \ItemWidth, (OutputHeight() - \TotalHeight)/2)
          Next i
        EndIf
        If ((\OffImage <> #RatingGadget_None) And (\DrawItem < \Maximum))
          For i = \DrawItem + 1 To \Maximum
            DrawImage(ImageID(\OffImage), (OutputWidth() - \TotalWidth)/2 + (i-1) * \ItemWidth, (OutputHeight() - \TotalHeight)/2)
          Next i
        EndIf
        StopDrawing()
        \Flags & ~#_RG_Drawing
      EndIf
    EndIf
  EndWith
EndProcedure

Procedure _RG_HandleEvent(Gadget.i, Type.i, Window.i = -1)
  Protected *RG._RatingGadget
  *RG = GetGadgetData(Gadget)
  If (*RG)
    If ((*RG\Window = -1) And (Window <> -1))
      *RG\Window = Window
    EndIf
    Protected NewHover.i = *RG\HoverItem
    Protected NewDraw.i  = *RG\DrawItem
    Protected x0.i, y0.i
    Protected x.i, y.i
    Select (Type)
      Case #PB_EventType_MouseMove
        x = GetGadgetAttribute(Gadget, #PB_Canvas_MouseX)
        y = GetGadgetAttribute(Gadget, #PB_Canvas_MouseY)
        x0 = GadgetWidth(Gadget)/2  - *RG\TotalWidth/2
        y0 = GadgetHeight(Gadget)/2 - *RG\TotalHeight/2
        If (((x >= x0) And (y >= y0)) And
            (x < x0 + *RG\TotalWidth) And
            (y < y0 + *RG\TotalHeight) And
            (Not (*RG\Flags & #RatingGadget_ReadOnly)))
          *RG\Flags | #_RG_MouseOver
          NewHover = (x - x0) / *RG\ItemWidth + 1
          If (NewHover <> *RG\HoverItem)
            *RG\HoverItem = NewHover
            NewDraw = NewHover
          EndIf
        Else
          _RG_HandleEvent(Gadget, #PB_EventType_MouseLeave, Window)
          NewDraw = *RG\DrawItem
        EndIf
      Case #PB_EventType_MouseLeave
        *RG\Flags & ~(#_RG_MouseOver | #_RG_MouseDown)
        *RG\HoverItem = #RatingGadget_None
        NewDraw = *RG\State
      Case #PB_EventType_LeftButtonDown
        If ((*RG\Flags & #_RG_MouseOver) And (Not (*RG\Flags & #RatingGadget_ReadOnly)))
          *RG\Flags | #_RG_MouseDown
        EndIf
      Case #PB_EventType_LeftButtonUp
        If (*RG\Flags & #_RG_MouseDown)
          *RG\Flags & ~#_RG_MouseDown
          *RG\State = *RG\HoverItem
          NewDraw = *RG\State
          If (*RG\Window <> -1)
            PostEvent(#PB_Event_Gadget, *RG\Window, Gadget, #PB_EventType_Change, *RG\State)
          EndIf
        EndIf
      Case #PB_EventType_RightButtonDown
        If ((Not (*RG\Flags & #RatingGadget_NoRightClick)) And (Not (*RG\Flags & #RatingGadget_ReadOnly)))
          If (*RG\Flags & #_RG_MouseOver)
            *RG\State = 0
            NewDraw = 0
            If (*RG\Window <> -1)
              PostEvent(#PB_Event_Gadget, *RG\Window, Gadget, #PB_EventType_Change, *RG\State)
            EndIf
          EndIf
        EndIf
    EndSelect
    If (NewDraw <> *RG\DrawItem)
      *RG\DrawItem = NewDraw
      _RG_Redraw(*RG)
    EndIf
  EndIf
EndProcedure

Procedure _RG_Callback()
  _RG_HandleEvent(EventGadget(), EventType(), EventWindow())
EndProcedure

Procedure.i _RG_Default(Attribute.i)
  Protected Result.i = #Null
  Select (Attribute)
    Case #_RG_State
      Result = 0
    Case #_RG_OffImage
      Result = _RG_DefaultOffImage
    Case #_RG_OnImage
      Result = _RG_DefaultOnImage
    Case #_RG_Color
      CompilerIf (#PB_Compiler_OS = #PB_OS_Windows)
        Result = GetSysColor_(#COLOR_3DFACE)
      CompilerElse
        Result = $EAEAEA
      CompilerEndIf
    Case #_RG_Maximum
      Result = 5
    Case #_RG_ReadOnly
      Result = #False
  EndSelect
  ProcedureReturn (Result)
EndProcedure

Procedure _RG_Set(Gadget.i, Attribute.i, Value.i)
  If (IsGadget(Gadget))
    Protected *RG._RatingGadget
    *RG = GetGadgetData(Gadget)
    If (*RG)
      Select (Attribute)
        Case #_RG_State
          If (Value < 1)
            *RG\State = 0
          ElseIf (Value > *RG\Maximum)
            *RG\State = *RG\Maximum
          Else
            *RG\State = Value
          EndIf
          *RG\DrawItem = *RG\State
          _RG_Redraw(*RG)
        Case #_RG_Color
          If (Value = #PB_Default)
            *RG\Background = _RG_Default(#_RG_Color)
          Else
            *RG\Background = Value & $FFFFFF
          EndIf
          _RG_Redraw(*RG)
        Case #_RG_OnImage
          If (Value = #RatingGadget_Default)
            *RG\OnImage = _RG_Default(#_RG_OnImage)
          Else
            *RG\OnImage = Value
          EndIf
          _RG_UpdateSizes(*RG)
          _RG_Redraw(*RG)
        Case #_RG_OffImage
          If (Value = #RatingGadget_Default)
            *RG\OffImage = _RG_Default(#_RG_OffImage)
          Else
            *RG\OffImage = Value
          EndIf
          _RG_UpdateSizes(*RG)
          _RG_Redraw(*RG)
        Case #_RG_Maximum
          If (Value = #PB_Default)
            *RG\Maximum = _RG_Default(#_RG_Maximum)
          Else
            *RG\Maximum = Value
          EndIf
          _RG_UpdateSizes(*RG)
          _RG_Set(Gadget, #_RG_State, *RG\State)
        Case #_RG_ReadOnly
          If (Value = #PB_Default)
            Value = _RG_Default(#_RG_ReadOnly)
          EndIf
          If (Value)
            *RG\Flags | #RatingGadget_ReadOnly
            _RG_HandleEvent(*RG\Gadget, #PB_EventType_MouseLeave, *RG\Window)
          Else
            *RG\Flags & ~#RatingGadget_ReadOnly
          EndIf
          _RG_Redraw(*RG)
      EndSelect
    EndIf
  EndIf
EndProcedure

Procedure.i _RG_Get(Gadget.i, Attribute.i)
  Protected Result.i = #Null
  If (IsGadget(Gadget))
    Protected *RG._RatingGadget
    *RG = GetGadgetData(Gadget)
    If (*RG)
      Select (Attribute)
        Case #_RG_State
          Result = *RG\State
        Case #_RG_Color
          Result = *RG\Background
        Case #_RG_Maximum
          Result = *RG\Maximum
      EndSelect
    EndIf
  EndIf
  ProcedureReturn (Result)
EndProcedure

;-
;- Procedures (Public)

Procedure.i RatingGadget(Gadget.i, x.i, y.i, Width.i, Height.i, Flags.i = #PB_Default, Callback.i = #Null)
  Protected Result.i
  If (Flags = #PB_Default)
    Flags = #Null
  EndIf
  Protected CanvasFlags.i
  If (Flags & #RatingGadget_Border)
    CanvasFlags | #PB_Canvas_Border
  EndIf
  Result = CanvasGadget(Gadget, x, y, Width, Height, CanvasFlags)
  If (Result)
    If (Gadget = #PB_Any)
      Gadget = Result
    EndIf
    Protected *RG._RatingGadget
    *RG = AllocateMemory(SizeOf(_RatingGadget))
    If (*RG)
      *RG\Gadget     =  Gadget
      *RG\Flags      =  Flags
      *RG\Window     = -1
      *RG\State      = _RG_Default(#_RG_State)
      *RG\OffImage   = _RG_Default(#_RG_OffImage)
      *RG\OnImage    = _RG_Default(#_RG_OnImage)
      *RG\Background = _RG_Default(#_RG_Color)
      *RG\Maximum    = _RG_Default(#_RG_Maximum)
      _RG_UpdateSizes(*RG)
      SetGadgetData(Gadget, *RG)
      _RG_Redraw(*RG)
      BindGadgetEvent(Gadget, @_RG_Callback())
    Else
      FreeGadget(Gadget)
      Result = #Null
    EndIf
  EndIf
  If (Result And Callback)
    RatingGadget_Bind(Gadget, Callback)
  EndIf
  ProcedureReturn (Result)
EndProcedure

Procedure.i RatingGadget_Free(Gadget.i)
  If (IsGadget(Gadget))
    Protected *RG._RatingGadget
    *RG = GetGadgetData(Gadget)
    If (*RG)
      SetGadgetData(Gadget, #Null)
      FreeMemory(*RG)
    EndIf
    FreeGadget(Gadget)
  EndIf
  ProcedureReturn (#Null)
EndProcedure


;-
;- Data Section

DataSection
  _RG_StarOff_Start:
  CompilerIf (Not #RatingGadget_DisableDefaultImages)
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $06, $62, $4B, $47, $44, $00, $FF, $00, $FF, $00, $FF, $A0
    Data.b $BD, $A7, $93, $00, $00, $00, $09, $70, $48, $59, $73, $00, $00, $0B, $13, $00
    Data.b $00, $0B, $13, $01, $00, $9A, $9C, $18, $00, $00, $00, $07, $74, $49, $4D, $45
    Data.b $07, $E0, $01, $09, $16, $32, $07, $F1, $47, $C9, $08, $00, $00, $02, $14, $49
    Data.b $44, $41, $54, $38, $CB, $95, $93, $4F, $4B, $1B, $51, $14, $C5, $7F, $33, $26
    Data.b $44, $A6, $58, $C2, $68, $34, $B8, $50, $DB, $B4, $AE, $82, $16, $0A, $A2, $4B
    Data.b $41, $BA, $14, $EC, $52, $21, $DB, $2E, $06, $12, $F2, $05, $04, $BF, $81, $E3
    Data.b $40, $92, $6D, $BB, $CB, $07, $70, $D3, $55, $F6, $52, $B0, $81, $80, $92, $90
    Data.b $92, $3F, $64, $53, $99, $48, $04, $C3, $24, $BE, $FB, $BA, $31, $A5, $29, $1D
    Data.b $A9, $07, $2E, $EF, $F1, $EE, $BD, $87, $CB, $39, $F7, $A1, $B5, $26, $0C, $C5
    Data.b $62, $F1, $53, $B1, $58, $74, $C3, $F2, $5A, $6B, $22, $3C, $81, $B5, $B5, $B5
    Data.b $82, $52, $CA, $04, $72, $61, $35, $66, $58, $C2, $F3, $BC, $93, $54, $2A, $65
    Data.b $AE, $AF, $AF, $E3, $79, $DE, $C9, $B3, $08, $0A, $85, $82, $65, $59, $D6, $B1
    Data.b $6D, $DB, $D8, $B6, $8D, $65, $59, $C7, $CF, $22, $78, $78, $78, $28, $A5, $D3
    Data.b $69, $DA, $ED, $36, $ED, $76, $9B, $74, $3A, $8D, $E7, $79, $9F, $FF, $55, $1B
    Data.b $01, $28, $95, $4A, $5F, $94, $52, $1B, $22, $B2, $29, $22, $44, $A3, $51, $6C
    Data.b $DB, $A6, $D7, $EB, $01, $B0, $BC, $BC, $4C, $24, $12, $C9, $9C, $9D, $9D, $65
    Data.b $0C, $C3, $60, $66, $66, $E6, $BB, $69, $9A, $55, $20, $13, $01, $10, $91, $8F
    Data.b $3B, $3B, $3B, $2F, $56, $57, $57, $51, $4A, $11, $8B, $C5, $B8, $BA, $BA, $42
    Data.b $29, $05, $80, $EF, $FB, $1C, $1E, $1E, $12, $04, $01, $22, $42, $A3, $D1, $D8
    Data.b $AC, $56, $AB, $6F, $80, $8C, $A1, $B5, $C6, $30, $8C, $77, $AE, $EB, $7E, $5D
    Data.b $59, $59, $49, $CC, $CD, $CD, $31, $B1, $D6, $30, $8C, $DF, $76, $01, $98, $A6
    Data.b $C9, $60, $30, $A0, $D3, $E9, $FC, $CC, $66, $B3, $1F, $B4, $D6, $97, $13, $0D
    Data.b $2E, $73, $B9, $DC, $5E, $AD, $56, $3B, $BF, $BB, $BB, $23, $1E, $8F, $23, $22
    Data.b $53, $11, $8F, $C7, $E9, $F7, $FB, $D4, $6A, $B5, $F3, $6C, $36, $BB, $07, $5C
    Data.b $02, $4C, $26, $00, $20, $1A, $8D, $BE, $2A, $97, $CB, $CD, $54, $2A, $45, $AF
    Data.b $D7, $9B, $9A, $20, $99, $4C, $52, $AF, $D7, $39, $3A, $3A, $7A, $3D, $1E, $8F
    Data.b $7F, $4C, $DE, $A7, $5C, $38, $3D, $3D, $DD, $4E, $24, $12, $DC, $DC, $DC, $20
    Data.b $22, $68, $AD, $D1, $5A, $23, $22, $F4, $FB, $7D, $16, $16, $16, $70, $5D, $77
    Data.b $3B, $D4, $C6, $F1, $78, $BC, $1B, $8B, $C5, $18, $0E, $87, $04, $41, $40, $B7
    Data.b $DB, $A5, $DB, $ED, $12, $04, $01, $F7, $F7, $F7, $CC, $CE, $CE, $32, $1C, $0E
    Data.b $77, $43, $09, $16, $17, $17, $F7, $6F, $6F, $6F, $F1, $7D, $9F, $56, $AB, $75
    Data.b $ED, $38, $CE, $96, $E3, $38, $5B, $AD, $56, $EB, $DA, $F7, $7D, $82, $20, $60
    Data.b $7E, $7E, $7E, $3F, $94, $40, $29, $B5, $D4, $6C, $36, $A5, $52, $A9, $38, $F9
    Data.b $7C, $FE, $60, $34, $1A, $5D, $8C, $46, $A3, $8B, $7C, $3E, $7F, $50, $A9, $54
    Data.b $9C, $46, $A3, $21, $22, $B2, $F4, $67, $CF, $94, $88, $C0, $FB, $C7, $B3, $0E
    Data.b $0C, $FE, $5A, $BA, $97, $C0, $DB, $C7, $FB, $B7, $89, $88, $C6, $53, $DF, $F9
    Data.b $7F, $F0, $0B, $DB, $C0, $0C, $E4, $92, $AD, $2F, $68, $00, $00, $00, $00, $49
    Data.b $45, $4E, $44, $AE, $42, $60, $82
  CompilerElse
    Data.b #NUL
  CompilerEndIf
  _RG_StarOff_End:
 
  _RG_StarOn_Start:
  CompilerIf (Not #RatingGadget_DisableDefaultImages)
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $19, $74, $45, $58, $74, $53, $6F, $66, $74, $77, $61, $72
    Data.b $65, $00, $41, $64, $6F, $62, $65, $20, $49, $6D, $61, $67, $65, $52, $65, $61
    Data.b $64, $79, $71, $C9, $65, $3C, $00, $00, $02, $05, $49, $44, $41, $54, $78, $DA
    Data.b $A4, $53, $CF, $4B, $54, $51, $14, $FE, $EE, $7D, $D3, $73, $1C, $19, $0D, $6C
    Data.b $6C, $B0, $A9, $08, $9A, $21, $5D, $64, $31, $69, $83, $42, $20, $49, $B4, $10
    Data.b $89, $96, $2D, $86, $08, $86, $7E, $40, $7F, $80, $1B, $A1, $3F, $A1, $5D, $26
    Data.b $52, $59, $B4, $68, $D5, $C6, $8D, $2D, $5A, $14, $0C, $24, $81, $63, $52, $54
    Data.b $1A, $A1, $92, $4C, $2F, $B5, $86, $99, $A6, $B1, $FB, $CE, $ED, $DC, $E7, $0C
    Data.b $A8, $CD, $13, $A2, $0B, $DF, $7B, $DF, $BD, $F7, $3B, $DF, $3D, $F7, $9C, $F7
    Data.b $A0, $B5, $86, $DF, $F8, $7A, $BF, $F7, $2A, $E3, $B6, $DF, $BE, $17, $BB, $9B
    Data.b $41, $29, $7B, $DD, $2D, $BE, $CC, $E8, $DD, $0C, $A4, $DF, $66, $7E, $3C, $79
    Data.b $CB, $8E, $9D, $97, $0D, $87, $07, $3D, $EE, $A7, $93, $F5, $53, $4F, $85, $64
    Data.b $63, $EB, $48, $60, $7F, $3B, $0C, $0C, $FF, $27, $03, $57, $A9, $3B, $A1, $CE
    Data.b $0B, $A0, $B5, $67, $1E, $0C, $CF, $8F, $9F, $7A, $50, $4F, $1B, $30, $0F, $67
    Data.b $A2, $6F, $42, $BB, $EA, $B8, $26, $D5, $05, $72, $79, $35, $08, $3B, $1A, $05
    Data.b $FD, $7C, $E3, $89, $EC, $E8, $31, $C0, $0A, $A6, $F3, $63, $27, $D3, $90, $16
    Data.b $84, $0C, $E4, $84, $65, $CD, $F2, $56, $DA, $33, $20, $A2, $8B, $2D, $7D, $57
    Data.b $9A, $1A, $8E, $24, $C1, $46, $9C, $57, $2B, $68, $E5, $11, $48, $D1, $66, $9A
    Data.b $95, $1C, $22, $97, $EE, $B1, $70, $15, $02, $15, $FC, $5A, $78, $DE, $55, $98
    Data.b $9E, $3A, $6A, $0C, $84, $A9, $A4, $10, $E2, $C4, $F2, $58, $F7, $D4, $DE, $CE
    Data.b $43, $11, $7B, $5F, $0B, $34, $71, $A0, $E6, $DB, $09, $AB, $5A, $6E, $CE, $4A
    Data.b $10, $4F, $25, $36, $9C, $02, $7E, $BC, $5D, $74, $0E, $64, $5E, $9D, $E3, $D8
    Data.b $99, $5A, $0D, $66, $62, $99, $E9, $81, $F9, $EC, $A7, $49, $23, $90, $8D, $09
    Data.b $6E, $91, $CB, $46, $6A, $13, $CC, $65, $28, $81, $CA, $CA, $3A, $E6, $B3, $0B
    Data.b $93, $1C, $3C, $60, $62, $76, $16, $71, $F6, $F4, $70, $EE, $26, $FD, $E6, $5B
    Data.b $59, $CD, $7C, $28, $6D, $87, $68, $02, $95, $2D, $18, $8D, $D1, $D6, $ED, $C2
    Data.b $D2, $68, $77, $6A, $4F, $5B, $1C, $AA, $F0, $8E, $4F, $76, $4D, $75, $3C, $18
    Data.b $4E, $C5, $0F, $08, $44, $E2, $58, $BA, $DB, $93, $F2, $6D, $63, $49, $A1, $5F
    Data.b $86, $82, $D0, $1B, $0E, $07, $94, $51, $9A, $5B, $F4, $60, $38, $55, $1C, $58
    Data.b $61, $1B, $C5, $B2, $EA, $F7, $35, $08, $B7, $C7, $86, $A8, $F8, $19, $95, $E5
    Data.b $75, $38, $73, $5F, $DE, $1F, $BC, $FC, $A2, $C7, $C0, $70, $B3, $A6, $D5, $77
    Data.b $84, $23, $6D, $43, $7F, $FF, $10, $D5, $B1, $F6, $74, $50, $3B, $0F, $7B, $DD
    Data.b $D1, $6B, $89, $1B, $3C, $ED, $D8, $22, $EB, $30, $6B, $DF, $1E, $9F, $71, $57
    Data.b $9F, $9C, $D5, $5B, $63, $6B, $6D, $AC, $AD, $25, $AB, $EF, $8F, $8C, $C2, $8E
    Data.b $8F, $AE, $99, $11, $AF, $F2, $D7, $DB, $0C, $FE, $67, $FC, $11, $60, $00, $31
    Data.b $FF, $02, $B9, $6F, $7D, $8E, $AD, $00, $00, $00, $00, $49, $45, $4E, $44, $AE
    Data.b $42, $60, $82
  CompilerElse
    Data.b #NUL
  CompilerEndIf
  _RG_StarOn_End:
EndDataSection



;-
;-
;- Demo Program
CompilerIf (#PB_Compiler_IsMainFile)
  DisableExplicit
 
  Procedure ChangeCallback()
    AddGadgetItem(9, 0,  "#" + Str(EventGadget()) + "  -->  " + Str(EventData()) + " / " + Str(RatingGadget_GetMaximum(EventGadget())))
  EndProcedure
 
  OpenWindow(0, 0, 0, 320, 240, "RatingGadget Demo", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
  EditorGadget(9, 160, 10, 150, 220)
 
  ; Example gadget #0
  RatingGadget(0, 10, 10, 120, 30, #PB_Default, @ChangeCallback())
 
  ; Example gadget #1
  RatingGadget(1, 10, 50, 120, 30, #RatingGadget_Border | #RatingGadget_NoRightClick)
  RatingGadget_SetState(1, 3)
  RatingGadget_SetColor(1, $FFFFFF)
  RatingGadget_Bind(1, @ChangeCallback())
 
  ; Example gadget #2
  RatingGadget(2, 10, 90, 120, 30, #Null, @ChangeCallback())
  RatingGadget_SetState(2, 1)
  RatingGadget_SetColor(2, $20A020)
  RatingGadget_SetOnImage(2, CreateImage(#PB_Any, 16, 16, 32, $00FF00))
  RatingGadget_SetOffImage(2, #RatingGadget_None)
  RatingGadget_SetMaximum(2, 3)
  GadgetToolTip(2, "Custom 'on' image, no 'off' image")
 
  ; Example gadget #3
  RatingGadget(3, 10, 130, 120, 30, #RatingGadget_ReadOnly)
  RatingGadget_SetState(3, 4)
  GadgetToolTip(3, "ReadOnly, no events")
 
  Repeat
    ;
    ; If you don't want to use the Bind event method,
    ; you can also watch for #PB_Event_Gadget/#PB_EventType_Change window events.
    ;
  Until (WaitWindowEvent() = #PB_Event_CloseWindow)
  For i = 0 To 3
    RatingGadget_Free(i)
  Next i
 
CompilerEndIf

CompilerEndIf
;-

_________________
On GitHub: PB Includes - IDE Tools - Color Themes


Last edited by kenmo on Fri Feb 26, 2016 11:43 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Sun Jan 10, 2016 12:02 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1108
Location: Berlin (Germany)
Nice code, thank you for sharing. :)

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (ie. stars) via CanvasGadget
PostPosted: Sun Jan 10, 2016 11:51 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1704
Location: Germany (Saxony, Deutscheinsiedel)
Yes, a nice and useful code! Thank you! :D

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (stars) via CanvasGadget
PostPosted: Thu Feb 21, 2019 7:34 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4505
Location: Not Sydney!!! (Bad water, no goats)
Question after all these years. In addition to making the rating gadget on a form (Looks greats till after all this time, I use it in one of my programs), could someone add the ability to create a bitmap on the fly to be able to add items to a listicongadget?

In many recipe programs, I see a rating field composed of stars of different length depending on the rating and it would be great f I could load this into a column in the list. I already have code to load icons into other columns but not sure if you can have different length bitmaps in columns for that gadget?

_________________
Amateur Radio, D-STAR/VK3HAF


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (stars) via CanvasGadget
PostPosted: Fri Feb 22, 2019 5:48 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Feb 09, 2006 11:27 pm
Posts: 2456
When using bitmaps you could work with constant widths by using an empty/transparent background.

For listviewgadgets you may use text only, the unicode characters Chr($2605) and Chr($2729) are not the worst choice...
(+) easy implementation, also simplifies sorting
(-) you should use a larger size for the text


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (stars) via CanvasGadget
PostPosted: Thu Feb 28, 2019 5:10 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4505
Location: Not Sydney!!! (Bad water, no goats)
Michael Vogel wrote:
When using bitmaps you could work with constant widths by using an empty/transparent background.

For listviewgadgets you may use text only, the unicode characters Chr($2605) and Chr($2729) are not the worst choice...
(+) easy implementation, also simplifies sorting
(-) you should use a larger size for the text


Thanks Michael but I rather like the graphic stars as used in the recipe programs I have. I remember somewhere that RASHAD showed how you can have more than one icon in a single column so maybe this can be applied for a single bitmap of 'x' length. X being the static length of the image predetermined by how many stars you will use as your maximum.

_________________
Amateur Radio, D-STAR/VK3HAF


Top
 Profile  
Reply with quote  
 Post subject: Re: RatingGadget (stars) via CanvasGadget
PostPosted: Thu Feb 28, 2019 10:44 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3476
Hi Fang
This is a very quick hack you should make it better
- Select Row
- Select Rating

# 1:
Code:
 #HDF_IMAGE           = 2048
 #HDI_IMAGE           = 32

Global oldproc,Header,Header_1, header_h , ILwnd ,Icwnd

UsePNGImageDecoder()

Procedure InsertImg(row,img)
  var.lv_item   
  Var\mask     =  #LVIF_IMAGE
  Var\iItem    = row
  Var\iSubItem = 0
  Var\iImage   = Img ;Index of image in the list
  SendMessage_(GadgetID(1), #LVM_SETITEM, 0, @Var)
EndProcedure

Procedure Hheight(hwnd, msg, wParam, lParam)
   Select msg
      Case #HDM_LAYOUT
        result = CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
        *hdlayout.HD_LAYOUT = lParam
        If *hdlayout\prc <> 0
            *rect.RECT = *hdlayout\prc
            *rect\top = header_h
        EndIf
        If *hdlayout\pwpos <> 0
            *windowpos.WINDOWPOS = *hdlayout\pwpos
            *windowpos\cy = header_h
        EndIf
     
      Default
        result = CallWindowProc_(oldproc, hWnd, Msg, wParam, lParam)
   
    EndSelect
    ProcedureReturn result
EndProcedure

Procedure CreateIcon()
  iinf.ICONINFO
  iinf\hbmMask = ImageID(10)
  iinf\hbmColor = ImageID(10) 
  Icwnd = CreateIconIndirect_(iinf)
  ImageList_AddIcon_(ILwnd,Icwnd)
  DestroyIcon_(Icwnd)
EndProcedure

rHeight = 24 ;16,24,32,48,64
LoadFont(0,"Broadway",16)

OpenWindow(0,0,0,800,600, "Test", #PB_Window_ScreenCentered |#PB_Window_SystemMenu)

ContainerGadget(100,10,10,780,540,#PB_Container_Flat)     
  ListIconGadget(0,0,0,600,540,"Column 0",145,#PB_ListIcon_MultiSelect| #PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines)
  Header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  SetGadgetFont(0,FontID(0))
 
  SetWindowLongPtr_(GadgetID(0),#GWL_EXSTYLE,0)
  SetWindowPos_(GadgetID(0),0,0,0,600,540,#SWP_FRAMECHANGED)
 
  ListIconGadget(1,600,0,195,540,"Rating",195,#PB_ListIcon_GridLines)
  Header_1 = SendMessage_(GadgetID(1), #LVM_GETHEADER, 0, 0)
  SetGadgetFont(1,FontID(0))
 
  SetWindowLongPtr_(GadgetID(1),#GWL_EXSTYLE,0)
  SetWindowPos_(GadgetID(1),0,600,0,200,540,#SWP_FRAMECHANGED)
CloseGadgetList()

SetGadgetFont(0,FontID(0))
AddGadgetColumn(0, 1, "Column 1",150)
AddGadgetColumn(0, 2, "Column 2",150)
AddGadgetColumn(0, 3, "Column 3",150)

SendMessage_(GadgetID(1), #LVM_SETEXTENDEDLISTVIEWSTYLE , #LVS_EX_SUBITEMIMAGES, #LVS_EX_SUBITEMIMAGES)

imgWidth = 6*rHeight
ILwnd = ImageList_Create_(imgWidth,rHeight,#ILC_COLOR32, 0, 6)

CatchImage(0,?gray,?endgray-?gray)
CatchImage(1,?gold,?endgold-?gold)

CreateImage(10,imgWidth,rHeight,32,#PB_Image_Transparent)

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(0),4,2)
  DrawAlphaImage(ImageID(0),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(0),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(1),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(1),52,2)
  DrawAlphaImage(ImageID(1),68,2)
StopDrawing()
CreateIcon()

FreeImage(10)
 
For i = 0 To 5
  AddGadgetItem(0, -1, "000"+Chr(10)+"  111"+Chr(10)+ "  222"+Chr(10)+"  333")
Next

For i = 0 To 5
  AddGadgetItem(1, -1, "")
Next

SendMessage_(GadgetID(1), #LVM_SETIMAGELIST, #LVSIL_SMALL, ILwnd)

ButtonGadget(3,10,570,60,24,"Rating 0")
ButtonGadget(4,80,570,60,24,"Rating 1")
ButtonGadget(5,150,570,60,24,"Rating 2")
ButtonGadget(6,220,570,60,24,"Rating 3")
ButtonGadget(7,290,570,60,24,"Rating 4")
ButtonGadget(8,360,570,60,24,"Rating 5")

oldproc = SetWindowLongPtr_(Header, #GWL_WNDPROC, @Hheight())
oldproc = SetWindowLongPtr_(Header_1, #GWL_WNDPROC, @Hheight())

header_h = 40

Repeat
  Select WaitWindowEvent()     
    Case #PB_Event_CloseWindow
          Quit = 1         
         
    Case #PB_Event_Gadget
      Select EventGadget()
       Case 0

       Case 1
           SetActiveGadget(0)
           
       Case 3 To 8
            row = GetGadgetState(0)
            InsertImg(row,EventGadget()-3)
           
      EndSelect             
  EndSelect
Until Quit = 1
End

DataSection
  gray:
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $06, $62, $4B, $47, $44, $00, $FF, $00, $FF, $00, $FF, $A0
    Data.b $BD, $A7, $93, $00, $00, $00, $09, $70, $48, $59, $73, $00, $00, $0B, $13, $00
    Data.b $00, $0B, $13, $01, $00, $9A, $9C, $18, $00, $00, $00, $07, $74, $49, $4D, $45
    Data.b $07, $E0, $01, $09, $16, $32, $07, $F1, $47, $C9, $08, $00, $00, $02, $14, $49
    Data.b $44, $41, $54, $38, $CB, $95, $93, $4F, $4B, $1B, $51, $14, $C5, $7F, $33, $26
    Data.b $44, $A6, $58, $C2, $68, $34, $B8, $50, $DB, $B4, $AE, $82, $16, $0A, $A2, $4B
    Data.b $41, $BA, $14, $EC, $52, $21, $DB, $2E, $06, $12, $F2, $05, $04, $BF, $81, $E3
    Data.b $40, $92, $6D, $BB, $CB, $07, $70, $D3, $55, $F6, $52, $B0, $81, $80, $92, $90
    Data.b $92, $3F, $64, $53, $99, $48, $04, $C3, $24, $BE, $FB, $BA, $31, $A5, $29, $1D
    Data.b $A9, $07, $2E, $EF, $F1, $EE, $BD, $87, $CB, $39, $F7, $A1, $B5, $26, $0C, $C5
    Data.b $62, $F1, $53, $B1, $58, $74, $C3, $F2, $5A, $6B, $22, $3C, $81, $B5, $B5, $B5
    Data.b $82, $52, $CA, $04, $72, $61, $35, $66, $58, $C2, $F3, $BC, $93, $54, $2A, $65
    Data.b $AE, $AF, $AF, $E3, $79, $DE, $C9, $B3, $08, $0A, $85, $82, $65, $59, $D6, $B1
    Data.b $6D, $DB, $D8, $B6, $8D, $65, $59, $C7, $CF, $22, $78, $78, $78, $28, $A5, $D3
    Data.b $69, $DA, $ED, $36, $ED, $76, $9B, $74, $3A, $8D, $E7, $79, $9F, $FF, $55, $1B
    Data.b $01, $28, $95, $4A, $5F, $94, $52, $1B, $22, $B2, $29, $22, $44, $A3, $51, $6C
    Data.b $DB, $A6, $D7, $EB, $01, $B0, $BC, $BC, $4C, $24, $12, $C9, $9C, $9D, $9D, $65
    Data.b $0C, $C3, $60, $66, $66, $E6, $BB, $69, $9A, $55, $20, $13, $01, $10, $91, $8F
    Data.b $3B, $3B, $3B, $2F, $56, $57, $57, $51, $4A, $11, $8B, $C5, $B8, $BA, $BA, $42
    Data.b $29, $05, $80, $EF, $FB, $1C, $1E, $1E, $12, $04, $01, $22, $42, $A3, $D1, $D8
    Data.b $AC, $56, $AB, $6F, $80, $8C, $A1, $B5, $C6, $30, $8C, $77, $AE, $EB, $7E, $5D
    Data.b $59, $59, $49, $CC, $CD, $CD, $31, $B1, $D6, $30, $8C, $DF, $76, $01, $98, $A6
    Data.b $C9, $60, $30, $A0, $D3, $E9, $FC, $CC, $66, $B3, $1F, $B4, $D6, $97, $13, $0D
    Data.b $2E, $73, $B9, $DC, $5E, $AD, $56, $3B, $BF, $BB, $BB, $23, $1E, $8F, $23, $22
    Data.b $53, $11, $8F, $C7, $E9, $F7, $FB, $D4, $6A, $B5, $F3, $6C, $36, $BB, $07, $5C
    Data.b $02, $4C, $26, $00, $20, $1A, $8D, $BE, $2A, $97, $CB, $CD, $54, $2A, $45, $AF
    Data.b $D7, $9B, $9A, $20, $99, $4C, $52, $AF, $D7, $39, $3A, $3A, $7A, $3D, $1E, $8F
    Data.b $7F, $4C, $DE, $A7, $5C, $38, $3D, $3D, $DD, $4E, $24, $12, $DC, $DC, $DC, $20
    Data.b $22, $68, $AD, $D1, $5A, $23, $22, $F4, $FB, $7D, $16, $16, $16, $70, $5D, $77
    Data.b $3B, $D4, $C6, $F1, $78, $BC, $1B, $8B, $C5, $18, $0E, $87, $04, $41, $40, $B7
    Data.b $DB, $A5, $DB, $ED, $12, $04, $01, $F7, $F7, $F7, $CC, $CE, $CE, $32, $1C, $0E
    Data.b $77, $43, $09, $16, $17, $17, $F7, $6F, $6F, $6F, $F1, $7D, $9F, $56, $AB, $75
    Data.b $ED, $38, $CE, $96, $E3, $38, $5B, $AD, $56, $EB, $DA, $F7, $7D, $82, $20, $60
    Data.b $7E, $7E, $7E, $3F, $94, $40, $29, $B5, $D4, $6C, $36, $A5, $52, $A9, $38, $F9
    Data.b $7C, $FE, $60, $34, $1A, $5D, $8C, $46, $A3, $8B, $7C, $3E, $7F, $50, $A9, $54
    Data.b $9C, $46, $A3, $21, $22, $B2, $F4, $67, $CF, $94, $88, $C0, $FB, $C7, $B3, $0E
    Data.b $0C, $FE, $5A, $BA, $97, $C0, $DB, $C7, $FB, $B7, $89, $88, $C6, $53, $DF, $F9
    Data.b $7F, $F0, $0B, $DB, $C0, $0C, $E4, $92, $AD, $2F, $68, $00, $00, $00, $00, $49
    Data.b $45, $4E, $44, $AE, $42, $60, $82
  endgray:
 
  gold:
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $19, $74, $45, $58, $74, $53, $6F, $66, $74, $77, $61, $72
    Data.b $65, $00, $41, $64, $6F, $62, $65, $20, $49, $6D, $61, $67, $65, $52, $65, $61
    Data.b $64, $79, $71, $C9, $65, $3C, $00, $00, $02, $05, $49, $44, $41, $54, $78, $DA
    Data.b $A4, $53, $CF, $4B, $54, $51, $14, $FE, $EE, $7D, $D3, $73, $1C, $19, $0D, $6C
    Data.b $6C, $B0, $A9, $08, $9A, $21, $5D, $64, $31, $69, $83, $42, $20, $49, $B4, $10
    Data.b $89, $96, $2D, $86, $08, $86, $7E, $40, $7F, $80, $1B, $A1, $3F, $A1, $5D, $26
    Data.b $52, $59, $B4, $68, $D5, $C6, $8D, $2D, $5A, $14, $0C, $24, $81, $63, $52, $54
    Data.b $1A, $A1, $92, $4C, $2F, $B5, $86, $99, $A6, $B1, $FB, $CE, $ED, $DC, $E7, $0C
    Data.b $A8, $CD, $13, $A2, $0B, $DF, $7B, $DF, $BD, $F7, $3B, $DF, $3D, $F7, $9C, $F7
    Data.b $A0, $B5, $86, $DF, $F8, $7A, $BF, $F7, $2A, $E3, $B6, $DF, $BE, $17, $BB, $9B
    Data.b $41, $29, $7B, $DD, $2D, $BE, $CC, $E8, $DD, $0C, $A4, $DF, $66, $7E, $3C, $79
    Data.b $CB, $8E, $9D, $97, $0D, $87, $07, $3D, $EE, $A7, $93, $F5, $53, $4F, $85, $64
    Data.b $63, $EB, $48, $60, $7F, $3B, $0C, $0C, $FF, $27, $03, $57, $A9, $3B, $A1, $CE
    Data.b $0B, $A0, $B5, $67, $1E, $0C, $CF, $8F, $9F, $7A, $50, $4F, $1B, $30, $0F, $67
    Data.b $A2, $6F, $42, $BB, $EA, $B8, $26, $D5, $05, $72, $79, $35, $08, $3B, $1A, $05
    Data.b $FD, $7C, $E3, $89, $EC, $E8, $31, $C0, $0A, $A6, $F3, $63, $27, $D3, $90, $16
    Data.b $84, $0C, $E4, $84, $65, $CD, $F2, $56, $DA, $33, $20, $A2, $8B, $2D, $7D, $57
    Data.b $9A, $1A, $8E, $24, $C1, $46, $9C, $57, $2B, $68, $E5, $11, $48, $D1, $66, $9A
    Data.b $95, $1C, $22, $97, $EE, $B1, $70, $15, $02, $15, $FC, $5A, $78, $DE, $55, $98
    Data.b $9E, $3A, $6A, $0C, $84, $A9, $A4, $10, $E2, $C4, $F2, $58, $F7, $D4, $DE, $CE
    Data.b $43, $11, $7B, $5F, $0B, $34, $71, $A0, $E6, $DB, $09, $AB, $5A, $6E, $CE, $4A
    Data.b $10, $4F, $25, $36, $9C, $02, $7E, $BC, $5D, $74, $0E, $64, $5E, $9D, $E3, $D8
    Data.b $99, $5A, $0D, $66, $62, $99, $E9, $81, $F9, $EC, $A7, $49, $23, $90, $8D, $09
    Data.b $6E, $91, $CB, $46, $6A, $13, $CC, $65, $28, $81, $CA, $CA, $3A, $E6, $B3, $0B
    Data.b $93, $1C, $3C, $60, $62, $76, $16, $71, $F6, $F4, $70, $EE, $26, $FD, $E6, $5B
    Data.b $59, $CD, $7C, $28, $6D, $87, $68, $02, $95, $2D, $18, $8D, $D1, $D6, $ED, $C2
    Data.b $D2, $68, $77, $6A, $4F, $5B, $1C, $AA, $F0, $8E, $4F, $76, $4D, $75, $3C, $18
    Data.b $4E, $C5, $0F, $08, $44, $E2, $58, $BA, $DB, $93, $F2, $6D, $63, $49, $A1, $5F
    Data.b $86, $82, $D0, $1B, $0E, $07, $94, $51, $9A, $5B, $F4, $60, $38, $55, $1C, $58
    Data.b $61, $1B, $C5, $B2, $EA, $F7, $35, $08, $B7, $C7, $86, $A8, $F8, $19, $95, $E5
    Data.b $75, $38, $73, $5F, $DE, $1F, $BC, $FC, $A2, $C7, $C0, $70, $B3, $A6, $D5, $77
    Data.b $84, $23, $6D, $43, $7F, $FF, $10, $D5, $B1, $F6, $74, $50, $3B, $0F, $7B, $DD
    Data.b $D1, $6B, $89, $1B, $3C, $ED, $D8, $22, $EB, $30, $6B, $DF, $1E, $9F, $71, $57
    Data.b $9F, $9C, $D5, $5B, $63, $6B, $6D, $AC, $AD, $25, $AB, $EF, $8F, $8C, $C2, $8E
    Data.b $8F, $AE, $99, $11, $AF, $F2, $D7, $DB, $0C, $FE, $67, $FC, $11, $60, $00, $31
    Data.b $FF, $02, $B9, $6F, $7D, $8E, $AD, $00, $00, $00, $00, $49, $45, $4E, $44, $AE
    Data.b $42, $60, $82
  endgold:
EndDataSection


# 2:
Code:
 #HDF_IMAGE           = 2048
 #HDI_IMAGE           = 32

Global oldproc,oldCallback,Header,Header_1, header_h , ILwnd ,Icwnd

UsePNGImageDecoder()

Procedure InsertImg(row,img)
  var.lv_item   
  Var\mask     =  #LVIF_IMAGE
  Var\iItem    = row
  Var\iSubItem = 0
  Var\iImage   = Img ;Index of image in the list
  SendMessage_(GadgetID(1), #LVM_SETITEM, 0, @Var)
EndProcedure

Procedure Hheight(hwnd, msg, wParam, lParam)
   Select msg
      Case #HDM_LAYOUT
        result = CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
        *hdlayout.HD_LAYOUT = lParam
        If *hdlayout\prc <> 0
            *rect.RECT = *hdlayout\prc
            *rect\top = header_h
        EndIf
        If *hdlayout\pwpos <> 0
            *windowpos.WINDOWPOS = *hdlayout\pwpos
            *windowpos\cy = header_h
        EndIf
     
      Default
        result = CallWindowProc_(oldproc, hWnd, Msg, wParam, lParam)
   
    EndSelect
    ProcedureReturn result
EndProcedure

Procedure CreateIcon()
  iinf.ICONINFO
  iinf\hbmMask = ImageID(10)
  iinf\hbmColor = ImageID(10) 
  Icwnd = CreateIconIndirect_(iinf)
  ImageList_AddIcon_(ILwnd,Icwnd)
  DestroyIcon_(Icwnd)
EndProcedure

Procedure LVcallback(hWnd, uMsg, wParam, lParam)
  result = CallWindowProc_(oldCallback, hWnd, uMsg, wParam, lParam)
  Select uMsg       
    Case #WM_VSCROLL,#WM_MOUSEWHEEL
      If hwnd = GadgetID(1)
        Item_Sp = SendMessage_(GadgetID(1), #LVM_GETITEMSPACING, 1, 0) >> 16
        SelItem = GetScrollPos_(GadgetID(1),#SB_VERT) - GetScrollPos_(GadgetID(0),#SB_VERT)
        SendMessage_(GadgetID(0), #LVM_SCROLL, 0, SelItem * Item_Sp)
      ElseIf hwnd = GadgetID(0)
        Item_Sp = SendMessage_(GadgetID(0), #LVM_GETITEMSPACING, 1, 0) >> 16
        SelItem = GetScrollPos_(GadgetID(0),#SB_VERT) - GetScrollPos_(GadgetID(1),#SB_VERT)
        SendMessage_(GadgetID(1), #LVM_SCROLL, 0, SelItem * Item_Sp)
      EndIf
   
    Case #WM_HSCROLL
      If hwnd = GadgetID(1)
        SelItem = GetScrollPos_(GadgetID(1),#SB_HORZ) - GetScrollPos_(GadgetID(0),#SB_HORZ)
        SendMessage_(GadgetID(0), #LVM_SCROLL, SelItem , 0)
      ElseIf hwnd = GadgetID(0)
        SelItem = GetScrollPos_(GadgetID(0),#SB_HORZ) - GetScrollPos_(GadgetID(1),#SB_HORZ)
        SendMessage_(GadgetID(1), #LVM_SCROLL, SelItem , 0)
      EndIf         
         
    Case #WM_KEYDOWN ,#WM_MENUSELECT
      If wParam=#VK_UP Or wParam=#VK_DOWN
        If hwnd = GadgetID(1)
          Item_Sp = SendMessage_(GadgetID(1), #LVM_GETITEMSPACING, 1, 0) >> 16
          SelItem = GetScrollPos_(GadgetID(1),#SB_VERT) - GetScrollPos_(GadgetID(0),#SB_VERT)
          SendMessage_(GadgetID(0), #LVM_SCROLL, 0, SelItem * Item_Sp)
        ElseIf hwnd = GadgetID(0)
          Item_Sp = SendMessage_(GadgetID(0), #LVM_GETITEMSPACING, 1, 0) >> 16
          SelItem = GetScrollPos_(GadgetID(0),#SB_VERT) - GetScrollPos_(GadgetID(1),#SB_VERT)
          SendMessage_(GadgetID(1), #LVM_SCROLL, 0, SelItem * Item_Sp)
        EndIf             
      ElseIf wParam=#VK_LEFT Or wParam=#VK_RIGHT
        If hwnd = GadgetID(1)
          SelItem = GetScrollPos_(GadgetID(1),#SB_HORZ) - GetScrollPos_(GadgetID(0),#SB_HORZ)
          SendMessage_(GadgetID(0), #LVM_SCROLL, SelItem , 0)
        ElseIf hwnd = GadgetID(0)
          SelItem = GetScrollPos_(GadgetID(0),#SB_HORZ) - GetScrollPos_(GadgetID(1),#SB_HORZ)
          SendMessage_(GadgetID(1), #LVM_SCROLL, SelItem , 0)
        EndIf
      EndIf
  EndSelect 
  ProcedureReturn result
EndProcedure

rHeight = 24 ;16,24,32,48,64
LoadFont(0,"Broadway",16)

OpenWindow(0,0,0,800,600, "Test", #PB_Window_ScreenCentered |#PB_Window_SystemMenu)

ContainerGadget(100,10,10,780,540,#PB_Container_Flat)     
  ListIconGadget(0,0,0,0,0,"Column 0",145,#PB_ListIcon_MultiSelect| #PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines)
  Header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  SetGadgetFont(0,FontID(0))
 
  SetWindowLongPtr_(GadgetID(0),#GWL_EXSTYLE,0)
  SetWindowPos_(GadgetID(0),0,0,0,600,540,#SWP_FRAMECHANGED)
 
  ListIconGadget(1,0,0,0,0,"Rating",190,#PB_ListIcon_GridLines)
  Header_1 = SendMessage_(GadgetID(1), #LVM_GETHEADER, 0, 0)
  SetGadgetFont(1,FontID(0))

  SetWindowLongPtr_(GadgetID(1),#GWL_EXSTYLE,0)
  SetWindowPos_(GadgetID(1),0,600,0,210,540,#SWP_FRAMECHANGED)
CloseGadgetList()

SetGadgetFont(0,FontID(0))
AddGadgetColumn(0, 1, "Column 1",140)
AddGadgetColumn(0, 2, "Column 2",145)
AddGadgetColumn(0, 3, "Column 3",145)

SendMessage_(GadgetID(1), #LVM_SETEXTENDEDLISTVIEWSTYLE , #LVS_EX_SUBITEMIMAGES, #LVS_EX_SUBITEMIMAGES)

imgWidth = 6*rHeight
ILwnd = ImageList_Create_(imgWidth,rHeight,#ILC_COLOR32, 0, 6)

CatchImage(0,?gray,?endgray-?gray)
CatchImage(1,?gold,?endgold-?gold)

CreateImage(10,imgWidth,rHeight,32,#PB_Image_Transparent)

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(0),4,2)
  DrawAlphaImage(ImageID(0),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(0),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(1),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(1),52,2)
  DrawAlphaImage(ImageID(1),68,2)
StopDrawing()
CreateIcon()

FreeImage(10)
 
For i = 0 To 25
  AddGadgetItem(0, -1, Str(i) + Chr(10)+"  111"+Chr(10)+ "  222"+Chr(10)+"  333")
Next

For i = 0 To 25
  AddGadgetItem(1, -1, "")
Next

SendMessage_(GadgetID(1), #LVM_SETIMAGELIST, #LVSIL_SMALL, ILwnd)

ButtonGadget(3,10,570,60,24,"Rating 0")
ButtonGadget(4,80,570,60,24,"Rating 1")
ButtonGadget(5,150,570,60,24,"Rating 2")
ButtonGadget(6,220,570,60,24,"Rating 3")
ButtonGadget(7,290,570,60,24,"Rating 4")
ButtonGadget(8,360,570,60,24,"Rating 5")

oldproc = SetWindowLongPtr_(Header, #GWL_WNDPROC, @Hheight())
oldproc = SetWindowLongPtr_(Header_1, #GWL_WNDPROC, @Hheight())
oldCallback = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @LVcallback())
oldCallback = SetWindowLongPtr_(GadgetID(1), #GWL_WNDPROC, @LVcallback())

header_h = 40

Repeat
  Select WaitWindowEvent()     
    Case #PB_Event_CloseWindow
          Quit = 1         
         
    Case #PB_Event_Gadget
      Select EventGadget()
       Case 0
       
       Case 1
        SetActiveGadget(-1)
           
       Case 3 To 8
            row = GetGadgetState(0)
            InsertImg(row,EventGadget()-3)
           
      EndSelect             
  EndSelect
Until Quit = 1
End

DataSection
  gray:
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $06, $62, $4B, $47, $44, $00, $FF, $00, $FF, $00, $FF, $A0
    Data.b $BD, $A7, $93, $00, $00, $00, $09, $70, $48, $59, $73, $00, $00, $0B, $13, $00
    Data.b $00, $0B, $13, $01, $00, $9A, $9C, $18, $00, $00, $00, $07, $74, $49, $4D, $45
    Data.b $07, $E0, $01, $09, $16, $32, $07, $F1, $47, $C9, $08, $00, $00, $02, $14, $49
    Data.b $44, $41, $54, $38, $CB, $95, $93, $4F, $4B, $1B, $51, $14, $C5, $7F, $33, $26
    Data.b $44, $A6, $58, $C2, $68, $34, $B8, $50, $DB, $B4, $AE, $82, $16, $0A, $A2, $4B
    Data.b $41, $BA, $14, $EC, $52, $21, $DB, $2E, $06, $12, $F2, $05, $04, $BF, $81, $E3
    Data.b $40, $92, $6D, $BB, $CB, $07, $70, $D3, $55, $F6, $52, $B0, $81, $80, $92, $90
    Data.b $92, $3F, $64, $53, $99, $48, $04, $C3, $24, $BE, $FB, $BA, $31, $A5, $29, $1D
    Data.b $A9, $07, $2E, $EF, $F1, $EE, $BD, $87, $CB, $39, $F7, $A1, $B5, $26, $0C, $C5
    Data.b $62, $F1, $53, $B1, $58, $74, $C3, $F2, $5A, $6B, $22, $3C, $81, $B5, $B5, $B5
    Data.b $82, $52, $CA, $04, $72, $61, $35, $66, $58, $C2, $F3, $BC, $93, $54, $2A, $65
    Data.b $AE, $AF, $AF, $E3, $79, $DE, $C9, $B3, $08, $0A, $85, $82, $65, $59, $D6, $B1
    Data.b $6D, $DB, $D8, $B6, $8D, $65, $59, $C7, $CF, $22, $78, $78, $78, $28, $A5, $D3
    Data.b $69, $DA, $ED, $36, $ED, $76, $9B, $74, $3A, $8D, $E7, $79, $9F, $FF, $55, $1B
    Data.b $01, $28, $95, $4A, $5F, $94, $52, $1B, $22, $B2, $29, $22, $44, $A3, $51, $6C
    Data.b $DB, $A6, $D7, $EB, $01, $B0, $BC, $BC, $4C, $24, $12, $C9, $9C, $9D, $9D, $65
    Data.b $0C, $C3, $60, $66, $66, $E6, $BB, $69, $9A, $55, $20, $13, $01, $10, $91, $8F
    Data.b $3B, $3B, $3B, $2F, $56, $57, $57, $51, $4A, $11, $8B, $C5, $B8, $BA, $BA, $42
    Data.b $29, $05, $80, $EF, $FB, $1C, $1E, $1E, $12, $04, $01, $22, $42, $A3, $D1, $D8
    Data.b $AC, $56, $AB, $6F, $80, $8C, $A1, $B5, $C6, $30, $8C, $77, $AE, $EB, $7E, $5D
    Data.b $59, $59, $49, $CC, $CD, $CD, $31, $B1, $D6, $30, $8C, $DF, $76, $01, $98, $A6
    Data.b $C9, $60, $30, $A0, $D3, $E9, $FC, $CC, $66, $B3, $1F, $B4, $D6, $97, $13, $0D
    Data.b $2E, $73, $B9, $DC, $5E, $AD, $56, $3B, $BF, $BB, $BB, $23, $1E, $8F, $23, $22
    Data.b $53, $11, $8F, $C7, $E9, $F7, $FB, $D4, $6A, $B5, $F3, $6C, $36, $BB, $07, $5C
    Data.b $02, $4C, $26, $00, $20, $1A, $8D, $BE, $2A, $97, $CB, $CD, $54, $2A, $45, $AF
    Data.b $D7, $9B, $9A, $20, $99, $4C, $52, $AF, $D7, $39, $3A, $3A, $7A, $3D, $1E, $8F
    Data.b $7F, $4C, $DE, $A7, $5C, $38, $3D, $3D, $DD, $4E, $24, $12, $DC, $DC, $DC, $20
    Data.b $22, $68, $AD, $D1, $5A, $23, $22, $F4, $FB, $7D, $16, $16, $16, $70, $5D, $77
    Data.b $3B, $D4, $C6, $F1, $78, $BC, $1B, $8B, $C5, $18, $0E, $87, $04, $41, $40, $B7
    Data.b $DB, $A5, $DB, $ED, $12, $04, $01, $F7, $F7, $F7, $CC, $CE, $CE, $32, $1C, $0E
    Data.b $77, $43, $09, $16, $17, $17, $F7, $6F, $6F, $6F, $F1, $7D, $9F, $56, $AB, $75
    Data.b $ED, $38, $CE, $96, $E3, $38, $5B, $AD, $56, $EB, $DA, $F7, $7D, $82, $20, $60
    Data.b $7E, $7E, $7E, $3F, $94, $40, $29, $B5, $D4, $6C, $36, $A5, $52, $A9, $38, $F9
    Data.b $7C, $FE, $60, $34, $1A, $5D, $8C, $46, $A3, $8B, $7C, $3E, $7F, $50, $A9, $54
    Data.b $9C, $46, $A3, $21, $22, $B2, $F4, $67, $CF, $94, $88, $C0, $FB, $C7, $B3, $0E
    Data.b $0C, $FE, $5A, $BA, $97, $C0, $DB, $C7, $FB, $B7, $89, $88, $C6, $53, $DF, $F9
    Data.b $7F, $F0, $0B, $DB, $C0, $0C, $E4, $92, $AD, $2F, $68, $00, $00, $00, $00, $49
    Data.b $45, $4E, $44, $AE, $42, $60, $82
  endgray:
 
  gold:
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $19, $74, $45, $58, $74, $53, $6F, $66, $74, $77, $61, $72
    Data.b $65, $00, $41, $64, $6F, $62, $65, $20, $49, $6D, $61, $67, $65, $52, $65, $61
    Data.b $64, $79, $71, $C9, $65, $3C, $00, $00, $02, $05, $49, $44, $41, $54, $78, $DA
    Data.b $A4, $53, $CF, $4B, $54, $51, $14, $FE, $EE, $7D, $D3, $73, $1C, $19, $0D, $6C
    Data.b $6C, $B0, $A9, $08, $9A, $21, $5D, $64, $31, $69, $83, $42, $20, $49, $B4, $10
    Data.b $89, $96, $2D, $86, $08, $86, $7E, $40, $7F, $80, $1B, $A1, $3F, $A1, $5D, $26
    Data.b $52, $59, $B4, $68, $D5, $C6, $8D, $2D, $5A, $14, $0C, $24, $81, $63, $52, $54
    Data.b $1A, $A1, $92, $4C, $2F, $B5, $86, $99, $A6, $B1, $FB, $CE, $ED, $DC, $E7, $0C
    Data.b $A8, $CD, $13, $A2, $0B, $DF, $7B, $DF, $BD, $F7, $3B, $DF, $3D, $F7, $9C, $F7
    Data.b $A0, $B5, $86, $DF, $F8, $7A, $BF, $F7, $2A, $E3, $B6, $DF, $BE, $17, $BB, $9B
    Data.b $41, $29, $7B, $DD, $2D, $BE, $CC, $E8, $DD, $0C, $A4, $DF, $66, $7E, $3C, $79
    Data.b $CB, $8E, $9D, $97, $0D, $87, $07, $3D, $EE, $A7, $93, $F5, $53, $4F, $85, $64
    Data.b $63, $EB, $48, $60, $7F, $3B, $0C, $0C, $FF, $27, $03, $57, $A9, $3B, $A1, $CE
    Data.b $0B, $A0, $B5, $67, $1E, $0C, $CF, $8F, $9F, $7A, $50, $4F, $1B, $30, $0F, $67
    Data.b $A2, $6F, $42, $BB, $EA, $B8, $26, $D5, $05, $72, $79, $35, $08, $3B, $1A, $05
    Data.b $FD, $7C, $E3, $89, $EC, $E8, $31, $C0, $0A, $A6, $F3, $63, $27, $D3, $90, $16
    Data.b $84, $0C, $E4, $84, $65, $CD, $F2, $56, $DA, $33, $20, $A2, $8B, $2D, $7D, $57
    Data.b $9A, $1A, $8E, $24, $C1, $46, $9C, $57, $2B, $68, $E5, $11, $48, $D1, $66, $9A
    Data.b $95, $1C, $22, $97, $EE, $B1, $70, $15, $02, $15, $FC, $5A, $78, $DE, $55, $98
    Data.b $9E, $3A, $6A, $0C, $84, $A9, $A4, $10, $E2, $C4, $F2, $58, $F7, $D4, $DE, $CE
    Data.b $43, $11, $7B, $5F, $0B, $34, $71, $A0, $E6, $DB, $09, $AB, $5A, $6E, $CE, $4A
    Data.b $10, $4F, $25, $36, $9C, $02, $7E, $BC, $5D, $74, $0E, $64, $5E, $9D, $E3, $D8
    Data.b $99, $5A, $0D, $66, $62, $99, $E9, $81, $F9, $EC, $A7, $49, $23, $90, $8D, $09
    Data.b $6E, $91, $CB, $46, $6A, $13, $CC, $65, $28, $81, $CA, $CA, $3A, $E6, $B3, $0B
    Data.b $93, $1C, $3C, $60, $62, $76, $16, $71, $F6, $F4, $70, $EE, $26, $FD, $E6, $5B
    Data.b $59, $CD, $7C, $28, $6D, $87, $68, $02, $95, $2D, $18, $8D, $D1, $D6, $ED, $C2
    Data.b $D2, $68, $77, $6A, $4F, $5B, $1C, $AA, $F0, $8E, $4F, $76, $4D, $75, $3C, $18
    Data.b $4E, $C5, $0F, $08, $44, $E2, $58, $BA, $DB, $93, $F2, $6D, $63, $49, $A1, $5F
    Data.b $86, $82, $D0, $1B, $0E, $07, $94, $51, $9A, $5B, $F4, $60, $38, $55, $1C, $58
    Data.b $61, $1B, $C5, $B2, $EA, $F7, $35, $08, $B7, $C7, $86, $A8, $F8, $19, $95, $E5
    Data.b $75, $38, $73, $5F, $DE, $1F, $BC, $FC, $A2, $C7, $C0, $70, $B3, $A6, $D5, $77
    Data.b $84, $23, $6D, $43, $7F, $FF, $10, $D5, $B1, $F6, $74, $50, $3B, $0F, $7B, $DD
    Data.b $D1, $6B, $89, $1B, $3C, $ED, $D8, $22, $EB, $30, $6B, $DF, $1E, $9F, $71, $57
    Data.b $9F, $9C, $D5, $5B, $63, $6B, $6D, $AC, $AD, $25, $AB, $EF, $8F, $8C, $C2, $8E
    Data.b $8F, $AE, $99, $11, $AF, $F2, $D7, $DB, $0C, $FE, $67, $FC, $11, $60, $00, $31
    Data.b $FF, $02, $B9, $6F, $7D, $8E, $AD, $00, $00, $00, $00, $49, $45, $4E, $44, $AE
    Data.b $42, $60, $82
  endgold:
EndDataSection


# 3:
Code:
 #HDF_IMAGE           = 2048
 #HDI_IMAGE           = 32

Global oldproc,Header,header_h , ILwnd ,Icwnd

UsePNGImageDecoder()

Procedure InsertImg(row,img)
  var.lv_item   
  Var\mask     =  #LVIF_IMAGE
  Var\iItem    = row
  Var\iSubItem = 5
  Var\iImage   = Img ;Index of image in the list
  SendMessage_(GadgetID(0), #LVM_SETITEM, 0, @Var)
EndProcedure

Procedure Hheight(hwnd, msg, wParam, lParam)
   Select msg
      Case #HDM_LAYOUT
        result = CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
        *hdlayout.HD_LAYOUT = lParam
        If *hdlayout\prc <> 0
            *rect.RECT = *hdlayout\prc
            *rect\top = header_h
        EndIf
        If *hdlayout\pwpos <> 0
            *windowpos.WINDOWPOS = *hdlayout\pwpos
            *windowpos\cy = header_h
        EndIf
     
      Default
        result = CallWindowProc_(oldproc, hWnd, Msg, wParam, lParam)
   
    EndSelect
    ProcedureReturn result
EndProcedure

Procedure CreateIcon()
  iinf.ICONINFO
  iinf\hbmMask = ImageID(10)
  iinf\hbmColor = ImageID(10) 
  Icwnd = CreateIconIndirect_(iinf)
  ImageList_AddIcon_(ILwnd,Icwnd)
  DestroyIcon_(Icwnd)
EndProcedure

Procedure WinCallback(hWnd, uMsg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
  Select uMsg
   Case #WM_NOTIFY
    *NMHDR.NMHDR = lParam
       If *NMHDR\hWndFrom = GetWindow_(GadgetID(0),#GW_CHILD)
          *phdn.NMHEADER = lParam                 
          If  *phdn\iItem = 0                          ; Column 0 fixed
              ProcedureReturn 1
          EndIf
       EndIf
  EndSelect
  ProcedureReturn result
EndProcedure

rHeight = 24 ;16,24,32,48,64
LoadFont(0,"Broadway",16)

OpenWindow(0,0,0,800,600, "Test", #PB_Window_ScreenCentered |#PB_Window_SystemMenu)
 
  ListIconGadget(0,10,10,780,540,"",0,#PB_ListIcon_MultiSelect |#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
  Header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  SetGadgetFont(0,FontID(0))
 
SetGadgetFont(0,FontID(0))
AddGadgetColumn(0, 1, "Column 1",140)
AddGadgetColumn(0, 2, "Column 2",145)
AddGadgetColumn(0, 3, "Column 3",145)
AddGadgetColumn(0, 4, "Column 3",145)
AddGadgetColumn(0, 5, "Rating",190)

SendMessage_(GadgetID(0), #LVM_SETEXTENDEDLISTVIEWSTYLE , #LVS_EX_SUBITEMIMAGES, #LVS_EX_SUBITEMIMAGES)

imgWidth = 5*16+8  ;No.of stars * 16 + (Row height - 16)
ILwnd = ImageList_Create_(imgWidth,rHeight,#ILC_COLOR32, 0, 6)

CatchImage(0,?gray,?endgray-?gray)
CatchImage(1,?gold,?endgold-?gold)

CreateImage(10,imgWidth,rHeight,32,#PB_Image_Transparent)

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(0),4,2)
  DrawAlphaImage(ImageID(0),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(0),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(0),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(0),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(1),52,2)
  DrawAlphaImage(ImageID(0),68,2)
StopDrawing()
CreateIcon()

StartDrawing(ImageOutput(10))
  DrawAlphaImage(ImageID(1),4,2)
  DrawAlphaImage(ImageID(1),20,2)
  DrawAlphaImage(ImageID(1),36,2)
  DrawAlphaImage(ImageID(1),52,2)
  DrawAlphaImage(ImageID(1),68,2)
StopDrawing()
CreateIcon()

FreeImage(10)
 
For i = 0 To 25
  AddGadgetItem(0, -1, Str(i) + Chr(10)+"  111"+Chr(10)+ "  222"+Chr(10)+"  333")
Next

SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL, ILwnd)

ButtonGadget(3,10,570,60,24,"Rating 0")
ButtonGadget(4,80,570,60,24,"Rating 1")
ButtonGadget(5,150,570,60,24,"Rating 2")
ButtonGadget(6,220,570,60,24,"Rating 3")
ButtonGadget(7,290,570,60,24,"Rating 4")
ButtonGadget(8,360,570,60,24,"Rating 5")

oldproc = SetWindowLongPtr_(Header, #GWL_WNDPROC, @Hheight())

header_h = 40
SetWindowCallback(@WinCallback())
Repeat
  Select WaitWindowEvent()     
    Case #PB_Event_CloseWindow
          Quit = 1         
         
    Case #PB_Event_Gadget
      Select EventGadget()
       Case 0
          ;row = GetGadgetState(0)
           
       Case 3 To 8
          row = GetGadgetState(0)
          InsertImg(row,EventGadget()-3)         
          SetActiveGadget(-1)
           
      EndSelect             
  EndSelect
Until Quit = 1
End

DataSection
  gray:
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $06, $62, $4B, $47, $44, $00, $FF, $00, $FF, $00, $FF, $A0
    Data.b $BD, $A7, $93, $00, $00, $00, $09, $70, $48, $59, $73, $00, $00, $0B, $13, $00
    Data.b $00, $0B, $13, $01, $00, $9A, $9C, $18, $00, $00, $00, $07, $74, $49, $4D, $45
    Data.b $07, $E0, $01, $09, $16, $32, $07, $F1, $47, $C9, $08, $00, $00, $02, $14, $49
    Data.b $44, $41, $54, $38, $CB, $95, $93, $4F, $4B, $1B, $51, $14, $C5, $7F, $33, $26
    Data.b $44, $A6, $58, $C2, $68, $34, $B8, $50, $DB, $B4, $AE, $82, $16, $0A, $A2, $4B
    Data.b $41, $BA, $14, $EC, $52, $21, $DB, $2E, $06, $12, $F2, $05, $04, $BF, $81, $E3
    Data.b $40, $92, $6D, $BB, $CB, $07, $70, $D3, $55, $F6, $52, $B0, $81, $80, $92, $90
    Data.b $92, $3F, $64, $53, $99, $48, $04, $C3, $24, $BE, $FB, $BA, $31, $A5, $29, $1D
    Data.b $A9, $07, $2E, $EF, $F1, $EE, $BD, $87, $CB, $39, $F7, $A1, $B5, $26, $0C, $C5
    Data.b $62, $F1, $53, $B1, $58, $74, $C3, $F2, $5A, $6B, $22, $3C, $81, $B5, $B5, $B5
    Data.b $82, $52, $CA, $04, $72, $61, $35, $66, $58, $C2, $F3, $BC, $93, $54, $2A, $65
    Data.b $AE, $AF, $AF, $E3, $79, $DE, $C9, $B3, $08, $0A, $85, $82, $65, $59, $D6, $B1
    Data.b $6D, $DB, $D8, $B6, $8D, $65, $59, $C7, $CF, $22, $78, $78, $78, $28, $A5, $D3
    Data.b $69, $DA, $ED, $36, $ED, $76, $9B, $74, $3A, $8D, $E7, $79, $9F, $FF, $55, $1B
    Data.b $01, $28, $95, $4A, $5F, $94, $52, $1B, $22, $B2, $29, $22, $44, $A3, $51, $6C
    Data.b $DB, $A6, $D7, $EB, $01, $B0, $BC, $BC, $4C, $24, $12, $C9, $9C, $9D, $9D, $65
    Data.b $0C, $C3, $60, $66, $66, $E6, $BB, $69, $9A, $55, $20, $13, $01, $10, $91, $8F
    Data.b $3B, $3B, $3B, $2F, $56, $57, $57, $51, $4A, $11, $8B, $C5, $B8, $BA, $BA, $42
    Data.b $29, $05, $80, $EF, $FB, $1C, $1E, $1E, $12, $04, $01, $22, $42, $A3, $D1, $D8
    Data.b $AC, $56, $AB, $6F, $80, $8C, $A1, $B5, $C6, $30, $8C, $77, $AE, $EB, $7E, $5D
    Data.b $59, $59, $49, $CC, $CD, $CD, $31, $B1, $D6, $30, $8C, $DF, $76, $01, $98, $A6
    Data.b $C9, $60, $30, $A0, $D3, $E9, $FC, $CC, $66, $B3, $1F, $B4, $D6, $97, $13, $0D
    Data.b $2E, $73, $B9, $DC, $5E, $AD, $56, $3B, $BF, $BB, $BB, $23, $1E, $8F, $23, $22
    Data.b $53, $11, $8F, $C7, $E9, $F7, $FB, $D4, $6A, $B5, $F3, $6C, $36, $BB, $07, $5C
    Data.b $02, $4C, $26, $00, $20, $1A, $8D, $BE, $2A, $97, $CB, $CD, $54, $2A, $45, $AF
    Data.b $D7, $9B, $9A, $20, $99, $4C, $52, $AF, $D7, $39, $3A, $3A, $7A, $3D, $1E, $8F
    Data.b $7F, $4C, $DE, $A7, $5C, $38, $3D, $3D, $DD, $4E, $24, $12, $DC, $DC, $DC, $20
    Data.b $22, $68, $AD, $D1, $5A, $23, $22, $F4, $FB, $7D, $16, $16, $16, $70, $5D, $77
    Data.b $3B, $D4, $C6, $F1, $78, $BC, $1B, $8B, $C5, $18, $0E, $87, $04, $41, $40, $B7
    Data.b $DB, $A5, $DB, $ED, $12, $04, $01, $F7, $F7, $F7, $CC, $CE, $CE, $32, $1C, $0E
    Data.b $77, $43, $09, $16, $17, $17, $F7, $6F, $6F, $6F, $F1, $7D, $9F, $56, $AB, $75
    Data.b $ED, $38, $CE, $96, $E3, $38, $5B, $AD, $56, $EB, $DA, $F7, $7D, $82, $20, $60
    Data.b $7E, $7E, $7E, $3F, $94, $40, $29, $B5, $D4, $6C, $36, $A5, $52, $A9, $38, $F9
    Data.b $7C, $FE, $60, $34, $1A, $5D, $8C, $46, $A3, $8B, $7C, $3E, $7F, $50, $A9, $54
    Data.b $9C, $46, $A3, $21, $22, $B2, $F4, $67, $CF, $94, $88, $C0, $FB, $C7, $B3, $0E
    Data.b $0C, $FE, $5A, $BA, $97, $C0, $DB, $C7, $FB, $B7, $89, $88, $C6, $53, $DF, $F9
    Data.b $7F, $F0, $0B, $DB, $C0, $0C, $E4, $92, $AD, $2F, $68, $00, $00, $00, $00, $49
    Data.b $45, $4E, $44, $AE, $42, $60, $82
  endgray:
 
  gold:
    Data.b $89, $50, $4E, $47, $0D, $0A, $1A, $0A, $00, $00, $00, $0D, $49, $48, $44, $52
    Data.b $00, $00, $00, $10, $00, $00, $00, $10, $08, $06, $00, $00, $00, $1F, $F3, $FF
    Data.b $61, $00, $00, $00, $19, $74, $45, $58, $74, $53, $6F, $66, $74, $77, $61, $72
    Data.b $65, $00, $41, $64, $6F, $62, $65, $20, $49, $6D, $61, $67, $65, $52, $65, $61
    Data.b $64, $79, $71, $C9, $65, $3C, $00, $00, $02, $05, $49, $44, $41, $54, $78, $DA
    Data.b $A4, $53, $CF, $4B, $54, $51, $14, $FE, $EE, $7D, $D3, $73, $1C, $19, $0D, $6C
    Data.b $6C, $B0, $A9, $08, $9A, $21, $5D, $64, $31, $69, $83, $42, $20, $49, $B4, $10
    Data.b $89, $96, $2D, $86, $08, $86, $7E, $40, $7F, $80, $1B, $A1, $3F, $A1, $5D, $26
    Data.b $52, $59, $B4, $68, $D5, $C6, $8D, $2D, $5A, $14, $0C, $24, $81, $63, $52, $54
    Data.b $1A, $A1, $92, $4C, $2F, $B5, $86, $99, $A6, $B1, $FB, $CE, $ED, $DC, $E7, $0C
    Data.b $A8, $CD, $13, $A2, $0B, $DF, $7B, $DF, $BD, $F7, $3B, $DF, $3D, $F7, $9C, $F7
    Data.b $A0, $B5, $86, $DF, $F8, $7A, $BF, $F7, $2A, $E3, $B6, $DF, $BE, $17, $BB, $9B
    Data.b $41, $29, $7B, $DD, $2D, $BE, $CC, $E8, $DD, $0C, $A4, $DF, $66, $7E, $3C, $79
    Data.b $CB, $8E, $9D, $97, $0D, $87, $07, $3D, $EE, $A7, $93, $F5, $53, $4F, $85, $64
    Data.b $63, $EB, $48, $60, $7F, $3B, $0C, $0C, $FF, $27, $03, $57, $A9, $3B, $A1, $CE
    Data.b $0B, $A0, $B5, $67, $1E, $0C, $CF, $8F, $9F, $7A, $50, $4F, $1B, $30, $0F, $67
    Data.b $A2, $6F, $42, $BB, $EA, $B8, $26, $D5, $05, $72, $79, $35, $08, $3B, $1A, $05
    Data.b $FD, $7C, $E3, $89, $EC, $E8, $31, $C0, $0A, $A6, $F3, $63, $27, $D3, $90, $16
    Data.b $84, $0C, $E4, $84, $65, $CD, $F2, $56, $DA, $33, $20, $A2, $8B, $2D, $7D, $57
    Data.b $9A, $1A, $8E, $24, $C1, $46, $9C, $57, $2B, $68, $E5, $11, $48, $D1, $66, $9A
    Data.b $95, $1C, $22, $97, $EE, $B1, $70, $15, $02, $15, $FC, $5A, $78, $DE, $55, $98
    Data.b $9E, $3A, $6A, $0C, $84, $A9, $A4, $10, $E2, $C4, $F2, $58, $F7, $D4, $DE, $CE
    Data.b $43, $11, $7B, $5F, $0B, $34, $71, $A0, $E6, $DB, $09, $AB, $5A, $6E, $CE, $4A
    Data.b $10, $4F, $25, $36, $9C, $02, $7E, $BC, $5D, $74, $0E, $64, $5E, $9D, $E3, $D8
    Data.b $99, $5A, $0D, $66, $62, $99, $E9, $81, $F9, $EC, $A7, $49, $23, $90, $8D, $09
    Data.b $6E, $91, $CB, $46, $6A, $13, $CC, $65, $28, $81, $CA, $CA, $3A, $E6, $B3, $0B
    Data.b $93, $1C, $3C, $60, $62, $76, $16, $71, $F6, $F4, $70, $EE, $26, $FD, $E6, $5B
    Data.b $59, $CD, $7C, $28, $6D, $87, $68, $02, $95, $2D, $18, $8D, $D1, $D6, $ED, $C2
    Data.b $D2, $68, $77, $6A, $4F, $5B, $1C, $AA, $F0, $8E, $4F, $76, $4D, $75, $3C, $18
    Data.b $4E, $C5, $0F, $08, $44, $E2, $58, $BA, $DB, $93, $F2, $6D, $63, $49, $A1, $5F
    Data.b $86, $82, $D0, $1B, $0E, $07, $94, $51, $9A, $5B, $F4, $60, $38, $55, $1C, $58
    Data.b $61, $1B, $C5, $B2, $EA, $F7, $35, $08, $B7, $C7, $86, $A8, $F8, $19, $95, $E5
    Data.b $75, $38, $73, $5F, $DE, $1F, $BC, $FC, $A2, $C7, $C0, $70, $B3, $A6, $D5, $77
    Data.b $84, $23, $6D, $43, $7F, $FF, $10, $D5, $B1, $F6, $74, $50, $3B, $0F, $7B, $DD
    Data.b $D1, $6B, $89, $1B, $3C, $ED, $D8, $22, $EB, $30, $6B, $DF, $1E, $9F, $71, $57
    Data.b $9F, $9C, $D5, $5B, $63, $6B, $6D, $AC, $AD, $25, $AB, $EF, $8F, $8C, $C2, $8E
    Data.b $8F, $AE, $99, $11, $AF, $F2, $D7, $DB, $0C, $FE, $67, $FC, $11, $60, $00, $31
    Data.b $FF, $02, $B9, $6F, $7D, $8E, $AD, $00, $00, $00, $00, $49, $45, $4E, $44, $AE
    Data.b $42, $60, $82
  endgold:
EndDataSection


Edit : Enough :P

_________________
Egypt my love


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye