ListIconGadget() - How to color any field ???

Just starting out? Need help? Post your questions and find answers here.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

ListIconGadget() - How to color any field ???

Post by Ralf »

Hello. I need an appointment calendar and use for the representation a ListIconGadget (30 lines and 8 columns). During the inputs it concerns different categories, why each date entry must be coloured deposited! Is this possible with pure basic? Thus which one represents individual ranges (e.g. column 3, line 14-16) with red background and another range e.g. in blue etc..!? About a functioning routine and/or a Procedure e.g., I would be pleased much. Ralf

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

Hallo. Ich benötige einen Terminkalender und benutze für die Darstellung eine ListIconGadget (30 Zeilen und 8 Spalten). Bei den Eingaben handelt es sich um verschiedene Kategorien, weshalb jeder Termineintrag farblich hinterlegt werden muss! Ist dieses mit PureBasic möglich? Also das man einzelne Bereiche (z.b. Spalte 3, Zeile 14-16) mit roten Hintergrund darstellt und einen anderen Bereich z.b. in blau usw..!?

Über eine funktionierende Routine bzw eine Procedure z.b, würde ich mich sehr freuen.

Ralf
Last edited by Ralf on Fri May 30, 2003 10:39 pm, edited 2 times in total.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

This is the english forum, so you should place the english text first.

And maybe you should change the headline.

Ask for:

ListIconGadget() - How to color every Line in a diffrent color

or something like this. Because this is your problem, not the appointment calendar.

Wenn du Fragen in Deutsch stellen willst, dann meld dich doch bei
www.pure-board.de an.
Ralf
Enthusiast
Enthusiast
Posts: 203
Joined: Fri May 30, 2003 1:29 pm
Location: Germany

Post by Ralf »

GPI wrote:This is the english forum, so you should place the english text first.

And maybe you should change the headline.

Ask for:

ListIconGadget() - How to color every Line in a diffrent color

or something like this. Because this is your problem, not the appointment calendar.

Wenn du Fragen in Deutsch stellen willst, dann meld dich doch bei
www.pure-board.de an.
Ok, sorry... have noticed this!
Danke für die Info. Bin auch im deutschen Forum angemeldet.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Found something in the forum-codes.

Code: Select all

; Autor: RedZack
; Datum: 06.11.02
; Forum: Deutsches Forum


;
; ------------------------------------------------------------
;   Zeilen in einem ListIconGadget einfärben und
;   verschiedene Zeichensätze benutzen
; ------------------------------------------------------------
;

;
; Benötigte Strukturen und Konstanten
;


Structure NMCUSTOMDRAW
  hdr.NMHDR
  dwDrawStage.l
  hDC.l
  rc.RECT
  dwItemSpec.l
  uItemState.l
  lItemlParam.l
EndStructure

Structure NMLVCUSTOMDRAW
  nmcd.NMCUSTOMDRAW
  clrText.l
  clrTextBk.l
  iSubItem.w
EndStructure


#CDDS_PREPAINT       = $00000001
#CDRF_NOTIFYITEMDRAW = $00000020
#CDRF_NEWFONT        = $00000002
#CDDS_ITEM           = $00010000
#NM_CUSTOMDRAW       = $FFFFFFF4

#CDDS_ITEMPREPAINT   = #CDDS_ITEM |  #CDDS_PREPAINT

#LI_ICON_GADGET      = 1
#LI_ICON1_GADGET     = 2

;
;  Modulus
;

Procedure MOD( a,b )
  ProcedureReturn a-a/b*b
EndProcedure

;
; Hier werden die Zeile eingefärbt
;

Procedure Color_ListIconGadger ( lParam.l , color.l, colorbk.l)
Result.l = 0
*nml.NMLVCUSTOMDRAW = lParam
; CustomDraw Struktur kopieren

Select *nml\nmcd\dwDrawStage
                             ; Windows mitteilen das jede Zeile einzeln gezeichnet werden
                             ; sollen
   Case #CDDS_PREPAINT     : Result = #CDRF_NOTIFYITEMDRAW

   Case #CDDS_ITEMPREPAINT :  ;Den 2ten Eintrag von #LI_ICON_GADGET gesondert einfärben
                              If *nml\nmcd\dwItemSpec = 2 And *nml\nmcd\hdr\idFrom = #LI_ICON_GADGET
                                *nml\clrTextBk = $00EAEA00
                                *nml\clrText = $00FF0000
                                ;
                                ; Einen neuen Zeichensatz
                                SelectObject_(*nml\nmcd\hDC, LoadFont (0, "Courier", 3));
                                ; Das Ganze zurück
                                Result = #CDRF_NEWFONT
                              Else
                              If MOD( *nml\nmcd\dwItemSpec, 2 ) = 0
                                *nml\clrTextBk = colorbk
                                *nml\clrText = color
                                ;
                                ; Einen neuen Zeichensatz
                                SelectObject_(*nml\nmcd\hDC, LoadFont (0, "Courier", 3));
                                ; Das Ganze zurück
                                Result = #CDRF_NEWFONT
                              Else
                              ;Bei jedem 4ten Listeneintrag die
                              ; Farbe und Font ändern
                               If MOD( *nml\nmcd\dwItemSpec, 4 ) = 1
                                 *nml\clrTextBk = color
                                 *nml\clrText = colorbk
                                 ; Einen neuen Zeichensatz
                                SelectObject_(*nml\nmcd\hDC, LoadFont (0, "Verdana", 6));
                                Result = #CDRF_NEWFONT
                               EndIf 
                              EndIf
                            EndIf   
EndSelect

ProcedureReturn Result 
EndProcedure

;
; Windows messages verarbeiten
;

Procedure.l WndProc(hWnd,Msg.l,wParam.l,lParam.l)
  Result.l = 0

  Select Msg
    ; MW_NOTIFY message auswerten
    Case #WM_NOTIFY : *hdr.NMHDR = lParam
                      ; Das ListIconGadget steht in wParam
                      ; EventGadgetID() funktioniert hier leider nicht
                      If wParam = #LI_ICON_GADGET Or wParam = #LI_ICON1_GADGET
                        Select wParam
                          Case #LI_ICON_GADGET  : colorbk = $00EAEAEA
                                                  color   = $00303030

                          Case #LI_ICON1_GADGET : colorbk = $00303030
                                                  color   = $0000FFFF
                         
                        EndSelect
                        ; Zeichnet das ListIconGadget ?
                        If *hdr\code = #NM_CUSTOMDRAW
                          ; Ja, dann einfärben
                          ; FakeEndSelect ist einfach Sch....., bei anderen
                          ; Programmiersprachen  geht das auch ohne!
                          ;FakeEndSelect
                          ProcedureReturn Color_ListIconGadger ( lParam, color, colorbk )
                        EndIf
                      EndIf

    Default :   ; FakeEndSelect
                 ProcedureReturn #PB_ProcessPureBasicEvents
  EndSelect
 

  ProcedureReturn 0
EndProcedure

;
; Programmstart
;

hWnd.l = OpenWindow(1, 250, 250, 420, 215, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Color - ListIconGadget Demo")

If hWnd
 
  SetWindowCallback(@WndProc())
  CreateGadgetList(WindowID())
 
  ListIconGadget(#LI_ICON1_GADGET,10,10, 95,191," Sonst was ",75, #PB_ListIcon_FullRowSelect)
  For x = 0 To 20
    AddGadgetItem(#LI_ICON1_GADGET ,-1, "Eintrag " + Str(x))
  Next

  ListIconGadget(#LI_ICON_GADGET ,110,10,300,191,"Spalte 1",100,#PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
    AddGadgetColumn(#LI_ICON_GADGET ,2, "Spalte 2", 100)
    AddGadgetColumn(#LI_ICON_GADGET ,3, "Spalte 3", 100)   
  For x = 0 To 20
    AddGadgetItem(#LI_ICON_GADGET ,-1, "Eintrag " + Str(x) + Chr(10) + "Irgendwas " + Chr(10) + "Irgendwas " )
  Next

  Repeat
    EventID.l = WaitWindowEvent()
  Until EventID = #PB_Event_CloseWindow

EndIf
End  
Post Reply