CS-Grid-Gadget: New Release V 2.3 / PB4

Developed or developing a new product in PureBasic? Tell the world about it.
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

SOURCES!!!!

Post by CSAUER »

You can find the sources here:
http://www.xideas.de/purebasic/CS-Grid2-1-SOURCE.RAR
or
http://www.xideas.de/purebasic/CS-Grid2-1-SOURCE.ZIP
(both similar, only different archieve)

It would be fine, if you can provide a Linux Lib.
If you should have any further questions, do not hesitate to contact me.

If anyone wants to continue development, please let me know.

Thanks and best regards

CSAUER
bender-rulez
User
User
Posts: 49
Joined: Mon Mar 14, 2005 11:30 am

Post by bender-rulez »

Hi,

a quick test with the source and the example from you I got the following error:

******************************************
PureBasic 3.94 (Linux - x86)
******************************************

Loading external modules...
Starting compilation...
Including source: grid_lib.pb
Error: Line 104 - in included file '/Develop/grid_lib.pb'
Line 103 - Constant not found: #LF_FACESIZE


I changed szFaceName.b[#LF_FACESIZE] ; Byte =>
to szFaceName.b[0] ; Byte =>



then the following error appears:

Loading external modules...
Starting compilation...
Including source: grid_lib.pb
Error: Line 222 - in included file '/Develop/grid_lib.pb'
Line 221 - Structure not found: TB_GadgetVT

This structure is not existent!


Any ideas?
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post by CSAUER »

These structures and missing types are Tailbite specific.
Maybe run the programm without compiling a lib with Linux version. This should be possible as it works on Mac OS X as well.

Best Regards
CSAUER
bender-rulez
User
User
Posts: 49
Joined: Mon Mar 14, 2005 11:30 am

Post by bender-rulez »

After commenting out these lines:

....
; TB_SetGadget(Gadget, CSGrid()\hWnd, @VT)
....

; Case #WM_LBUTTONUP
; If CSGrid()\InputMode <= 0
; ResetList(CSGrid())
; While NextElement(CSGrid())
; If CSGrid()\GridLock > -16 And CSGrid()\GridLock < 16
; ieventID.b = H_MoveCursorbyMouse(2)
; EndIf
; Wend
; EndIf

I can compile under gtk1 --> but I got these errors:

Gdk-ERROR **: BadMatch (invalid parameter attributes)
serial 132 error_code 8 request_code 56 minor_code 0
Gdk-ERROR **: BadDrawable (invalid Pixmap or Window parameter)
serial 134 error_code 9 request_code 62 minor_code 0

programm crashs

under gtk2 I got these errors while compiling:

Creating the executable.
Gadget.a(ScrollBarGadget.o): In function `ScrollBar_SetGadgetState':
ScrollBarGadget.c:(.text+0x2f1): undefined reference to `gtk_range_slider_update'
collect2: ld returned 1 exit status
Error: Linker
DoMi
User
User
Posts: 67
Joined: Sat Jan 10, 2004 5:41 pm
Location: France

Testing with PB4... gadgetExtension missing!?

Post by DoMi »

OK testing your helpFull Grid gadget with PB 1.94
With v4.02, after correcting minor differences, I got :
The following PureLibrary is missing : GadgetExtension


any idea?

thanks for your contribution
DoMi
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

The gadget internals have changed, and haven't been updated in TailBite yet, so this won't work until next TailBite release (soon, I hope).
El_Choni
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Excellent! Just a few initial observations/questions.

Post by USCode »

GREAT grid and a terrific contribution to PureBasic Christian, thanks!

Just a few initial observations/questions:

- Briefly looking at the source code for Demo.exe, it looks like I should be able to resize the columns with my mouse but I couldnt seem to get them to resize?

- Can I set the grid data and captions orientation/justification independent of the data type? For example, I might want a column caption to be left justified but the data in that column to be centered or right justified.

- Can I turn the horizontal and vertical grid lines on/off independently of each other? For example, I might not want any horizontal/row grid lines but might want vertical/column grid lines.

- Can I set the grid lines width in pixels AND the grid lines color (set color with CSGridGadget_SetColorGrid?) ?

- When I'm entering data in a cell I'd like to be able to just click somewhere on the grid outside that cell for the data to be accepted and not have to hit ENTER. This seems to be common grid behavior in other grids.

- It would be nice to also have a combo-box input where I can choose from a list OR freely enter data. This would be in addition to the existing 2 input types.

- Any possibility of giving the ability to set individual rows to different heights?

- Do you plan on updating your excellent grid soon for PB v4.0 anytime soon?

Thanks again Christian, excellent work AND documentation AND it's cross-platform! :D
USCode
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post by CSAUER »

Dear USCode,

sorry for the long waiting delay. I was long time away from PB.
So here I am back again. You should expect a port to PB4 and a new version in a few weeks.

You wrote:
- Briefly looking at the source code for Demo.exe, it looks like I should be able to resize the columns with my mouse but I couldnt seem to get them to resize?
Yes, you are able to. You can find the code of demo.exe in the examples folder of PB. You need to set following options:

Code: Select all

CSGridGadget_SetColsScaleable(Gadget.l, Enabled.b) 
Additionally you should not hide the column head.

Code: Select all

CSGridGadget_SetColCaptionVisibility(Gadget.l, Visible.b) 
- Can I set the grid data and captions orientation/justification independent of the data type? For example, I might want a column caption to be left justified but the data in that column to be centered or right justified.
Sorry, with the actual version not. It can be set only with data type. I will probably add this with the next version.
- Can I turn the horizontal and vertical grid lines on/off independently of each other? For example, I might not want any horizontal/row grid lines but might want vertical/column grid lines.
Sorry, with the actual version not. You can show/hide just the whole lines.
- Can I set the grid lines width in pixels AND the grid lines color (set color with CSGridGadget_SetColorGrid?) ?
Sorry, they are actually limited to one pixel. The color can be defined as follows:

Code: Select all

CSGridGadget_SetColorGrid(Gadget.l, Color.l) 
- When I'm entering data in a cell I'd like to be able to just click somewhere on the grid outside that cell for the data to be accepted and not have to hit ENTER. This seems to be common grid behavior in other grids.
This will come with the next version. I will create a "switch" to select, if Return and changing cell accepts content.
- It would be nice to also have a combo-box input where I can choose from a list OR freely enter data. This would be in addition to the existing 2 input types.
It should be possible with a ComboBoxGadget. Maybe I should add slider, etc. as well.
- Any possibility of giving the ability to set individual rows to different heights?
Actually not supported, but planned.
- Do you plan on updating your excellent grid soon for PB v4.0 anytime soon?
You should expect something within the next few weeks. It will be a PB4 version, as I switched already.
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

Thanks for getting back to me on all my questions CSAUER.
Once again, great work on your cross-platform grid and I'm also looking forward to the next version! 8)

What kept you away from PB so long? :wink:
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

Hi,

this Procedure is missing in your sourcecode (called once in the Procedure CSGridGadge() ).... :cry:

Code: Select all

TB_SetGadget(Gadget, CSGrid()\hWnd, @VT) 
The Missing Structure TB_GadgetVT I'd defined like that (from what I'd found in the source):

Code: Select all

Structure TB_GadgetVT
  FreeGadget.l 
  GetGadgetState.l
  SetGadgetState.l
  GetGadgetText.l
  SetGadgetText.l
  AddGadgetItem.l
  AddGadgetItem2.l
  RemoveGadgetItem.l
  ClearGadgetItemList.l
  ResizeGadget.l
  CountGadgetItems.l
  GetGadgetItemState.l
  SetGadgetItemState.l
  GetGadgetItemText.l
  SetGadgetItemText.l
EndStructure
The missing constants are:

Code: Select all

#LF_FACESIZE=32
#WM_LBUTTONUP=202
... but without knowing what the (missing) procedure does...it won't work on Linux :roll:
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

walker wrote:Hi,

this Procedure is missing in your sourcecode (called once in the Procedure CSGridGadge() ).... :cry:

Code: Select all

TB_SetGadget(Gadget, CSGrid()\hWnd, @VT) 
Is a function by TailBite (windows only)
walker wrote:
The Missing Structure TB_GadgetVT I'd defined like that (from what I'd found in the source):

Code: Select all

Structure TB_GadgetVT
  FreeGadget.l 
  GetGadgetState.l
  SetGadgetState.l
  GetGadgetText.l
  SetGadgetText.l
  AddGadgetItem.l
  AddGadgetItem2.l
  RemoveGadgetItem.l
  ClearGadgetItemList.l
  ResizeGadget.l
  CountGadgetItems.l
  GetGadgetItemState.l
  SetGadgetItemState.l
  GetGadgetItemText.l
  SetGadgetItemText.l
EndStructure
Installed by Tailbite
walker wrote: The missing constants are:

Code: Select all

#LF_FACESIZE=32
#WM_LBUTTONUP=202
WinAPI constands
walker wrote:
... but without knowing what the (missing) procedure does...it won't work on Linux :roll:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

@TS-Soft: .. tell me something new.... :wink:

If the provided code is altered by TailBite, there must be a source "before" Tailbite... right?

@CSauer: if this is correct, can you post this code?

I never used TailBite.. so if I'm wrong please advise me...
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post by CSAUER »

Yes, ts-soft is totally right.
You can just remove this, because this is only required to create a DLL file with Tailbite.
Here is an example code, which is working on MacOSX, so it should be cleared of all this Tailbite stuff:

Part 1:

Code: Select all

; *****************************************************************
; ** CS-GRID V1.1 *** (c)2005 Christian Walde-Sauer, 27.10.2005 ***
; *****************************************************************
; * Stand 28.11.2005                                              *
; * GRID-Objekt zur Darstellung von speziellen Daten-Tabellen     *
; *****************************************************************

; *************************************************************
;- Konstanten
; *************************************************************

#EventID_Return = 98                    ; Ereignis-Kennung für die Return-Taste
#EventID_ESC = 99                       ; Ereignis-Kennung für die ESC-Taste
#EventID_Left = 100                     ; Ereignis-Kennung für die Pfeil-Links-Taste
#EventID_Up = 101                       ; Ereignis-Kennung für die Pfeil-Hoch-Taste
#EventID_Right = 102                    ; Ereignis-Kennung für die Pfeil-Rechts-Taste
#EventID_Down = 103                     ; Ereignis-Kennung für die Pfeil-Runter-Taste
#EventID_SLeft = 104                    ; Ereignis-Kennung für die Umschalt + Pfeil-Links-Taste
#EventID_SUp = 105                      ; Ereignis-Kennung für die Umschalt + Pfeil-Hoch-Taste
#EventID_SRight = 106                   ; Ereignis-Kennung für die Umschalt + Pfeil-Rechts-Taste
#EventID_SDown = 107                    ; Ereignis-Kennung für die Umschalt + Pfeil-Runter-Taste
#ScrollbarSize = 20                     ; Breite/Höhe der Scrollbars
#DefGridWidth = 72                      ; Standard-Zellenbreite
#DefGridHeight = 22                     ; Standard-Zellenhöhe
#DefColor_Grid = $BBBBBB                ; Standardfarbe für das Gitternetz
#DefColor_Backgr = $999999              ; Standardfarbe für den Hintergrund
#DefColor_CellBack = $FFFFFF            ; Standardfarbe für den Zellenhintergrund
#DefColor_CaptBack = $BBFFFF            ; Standardfarbe für den Überschrift/Beschriftungs-Hintergrund
#DefColor_CaptFocus = $A0FFFF           ; Standardfarbe für den Überschrift/Beschriftungs-Hintergrund, bei Fokus-Erhalt einer enthaltenen Zelle
#DefColor_CellLoFoc = $DFDF80           ; Standardfarbe für den Zellhintergrund bei Fokus-Erhalt und Sperr-Zustand -1
#DefColor_CellFore = $000000            ; Standardfarbe für den Zelleninhalt (Text)
#DefColor_CellFocus = $FFFF00           ; Standardfarbe für den Zellenhintergrund bei Fokus-Erhalt
#DefColor_CellLock = $E0E0E0            ; Standardfarbe für den Zellenhintergrund, wenn Zelle gesperrt ist
#DefColor_CellFocusInact = $FFFFDD      ; Standardfarbe für den Zellhintergrund der aktiven Zelle, wenn Grid nicht fokusiert ist
#DefColor_ColSumSymbol = $AADDDD        ; Standardfarbe für das Spalten-Summen-Zeichen
#DefColor_Symbols = $AADDDD             ; Standardfarbe für das Spalten-Sortierungs-Zeichen
#DefGridVisible = 1                     ; Standardmäßig werden Gitternetz-Linien angezeigt
#DefColCaptVisible = -1                 ; Standardmäßig werden Spaltenüberschriften nicht mit angezeigt
#DefRowCaptVisible = -1                 ; Standardmäßig werden Zeilenüberschriften nicht mit angezeigt
#DefColCaptWidth = 50                   ; Standardmäßige Spaltenbreite für die Zeilenüberschrift

; **************************************************************
;- Strukturen
; **************************************************************

Structure CSGrid_Type
  GadgetID.l                    ; Long    => Gadget-ID des Container-Objektes
  hWnd.l                        ; Long    => Handle des Container-Objektes
  hImage.l                      ; Long    => Handle für das Image
  hImageGadget.l                ; Long    => Handle für das Image-Gadget-Objekt
  hHscrollGadget.l              ; Long    => Handle für das horizontale Scroll-Gadget-Objekt
  hVscrollGadget.l              ; Long    => Handle für das vertikale Scroll-Gadget-Objekt
  hInputText.l                  ; Long    => Handle für das Eingabefeld "Text"
  hInputRollup.l                ; Long    => Handle für das Eingabefeld "Rollup/Pulldown"
  Left.l                        ; Word    => X-Position des Grid-Objektes
  Top.l                         ; Word    => Y-Position des Grid-Objektes
  Width.l                       ; Word    => Breite des Grid-Objektes
  Height.l                      ; Word    => Höhe des Grid-Objektes
  DefGridWidth.l                ; Word    => Standard-Spaltenbreite
  DefGridHeight.l               ; Word    => Standard-Spaltenhöhe
  ImgWidth.l                    ; Word    => Breite des Zeichenbereiches
  ImgHeight.l                   ; Word    => Höhe des Zeichenbereiches
  Cols.l                        ; Byte    => Anzahl der Spalten (+ 128 = 0 bis 255)
  Rows.l                        ; Word    => Anzahl der Zeilen (+32768 = 0 bis 65535)
  ScrollX.l                     ; Byte    => Scrollposition in der Spalte
  ScrollY.l                     ; Word    => Scrollposition in der Zeile
  ActColStart.l                 ; Byte    => Aktuelle Spalte (des Cursors, Startpos bei Bereich)
  ActRowStart.l                 ; Word    => Aktuelle Zeile (des Cursors, Startpos bei Bereich)
  ActColEnd.l                   ; Byte    => Aktuelle Spalte (des Cursors, Endpos bei Bereich)
  ActRowEnd.l                   ; Word    => Aktuelle Zeile (des Cursors, Endpos bei Bereich)
  ActXStart.l                   ; Word    => X-Position der aktuellen Zelle (bei Bereich Startpos)
  ActYStart.l                   ; Word    => Y-Position der aktuellen Zelle (bei Bereich Startpos)
  ActXEnd.l                     ; Word    => X-Position der aktuellen Zelle (bei Bereich Endpos)
  ActYEnd.l                     ; Word    => Y-Position der aktuellen Zelle (bei Bereich Endpos)
  LastVisCol.l                  ; Byte    => Letzte angezeigte Spalte
  LastVisRow.l                  ; Byte    => Letzte angezeigte Zeile
  Cells.l                       ; Long    => Anzahl der Zellen 
  Font.l                        ; Long    => Handle für Schriftart
  GridVisible.l                 ; Byte    => Anzeige des Gitters (1=angezeigt, -1=unsichtbar)
  ColCaptVisible.l              ; Byte    => Anzeige der Spaltenüberschrift (1=angezeigt, -1=unsichtbar)
  RowCaptVisible.l              ; Byte    => Anzeige der Zeilenüberschrift (1=angezeigt, -1=unsichtbar)
  RowCaptWidth.l                ; Byte    => Spaltenbreite der Zeilenüberschrift
  ColCustWidth.l                ; Byte    => Benutzerspezifische Spaltenbreiten-Anpassung (1=kann verändert werden, -1=fix)
  Color_Backgr.l                ; Long    => Hintergrundfarbe des Bereiches hinter den Zellen
  Color_Grid.l                  ; Long    => Farbe des Gitters
  Color_CellBack.l              ; Long    => Hintergrundfarbe in der Zelle
  Color_CellFore.l              ; Long    => Vordergrundfarbe in der Zelle
  Color_CaptBack.l              ; Long    => Hintergrundfarbe für die Überschrift/Beschriftung
  Color_CellFocus.l             ; Long    => Hintergrundfarbe der Zelle, bei Fokus-Erhalt
  Color_CaptFocus.l             ; Long    => Hintergrundfarbe der Überschrift/Beschriftung, bei Fokus-Erhalt einer enthaltenen Zelle
  Color_CellLock.l              ; Long    => Hintergrundfarbe der Zelle, wenn Zelle gesperrt ist
  Color_CellLoFoc.l             ; Long    => Hintergrundfarbe der Zelle, bei Fokus-Erhalt mit dem Sperr-Zustand -1
  Color_CellFocusInact.l        ; Long    => Hintergrundfarbe der aktuellen Zelle, wenn Grid nicht fokusiert ist
  InputMode.l                   ; Byte    => Eingabemodus 0=keine Eingabe, 1=Text, 16=Rollup 
  AutoRedraw.l                  ; Byte    => Automatische Darstellungsaktualisierung aktivieren (1=auto, -1=manual)
  CellMatrixStartID.l           ; Long    => Start-Nummer in der Liste der Zellen-Info, mit der die Zellen des jeweiligen Grids beginnen (+Zellenanzahl=End-Pos)
  ShowColSummary.l              ; Byte    => Anzeigen der Spalten-Summe
  AutoSort.l                    ; Byte    => Automatische Sortierung, wenn Sortierung vorgegeben bei neuer Zeile oder Inhaltsänderung in Sortierspalte
  SortCol.l                     ; Byte    => Spalte nach der aktuell sortiert wurde
  SortDir.l                     ; Byte    => Sortier-Richtung mit der aktuell sortiert wurde
  UserSort.l                    ; Byte    => Benutzerspezifische Sortierung (1=kann mit Doppelklick sortiert werden, -1=fix)
  GridLock.l                    ; Byte    => Sperrzustand der gesamten Tabelle, -1=nicht editierbar,-16=nicht auswählbar, 1 und 16 ist das gleiche, nur nicht grau hinterlegte Zellen
  ScrollBarHVis.l               ; Byte    => Sichtbarkeit des horizontalen Scrollbalken, -1=nicht sichtbar, 1=sichtbar
  ScrollBarVVis.l               ; Byte    => Sichtbarkeit des vertikalen Scrollbalken, -1=nicht sichtbar, 1=sichtbar
  RowExpand.l                   ; Byte    => Zeilen-Details zulassen, -1=nicht zugelassen, 1=zugelassen
  CommaSep.l                    ; Byte    => ASCII-Code für Komma-Separator
EndStructure


Structure CSGrid_TypeCell
  content.s                     ; String  => Inhalt der Zelle
  lock.l                        ; Byte    => Sperr-Status der Zelle, -1=nicht editierbar,-16=nicht auswählbar,0=Standard
  ;color_back.l                  ; Long    => Hintergrundfarbe der Zelle
EndStructure


Structure CSGrid_TypeCol
  hWnd.l                        ; Long    => Handle des Grids
  col.l                         ; Byte    => Nummer der Spalte
  width.l                       ; Word    => Breite der Spalte
  caption.s                     ; String  => Spaltenbeschriftung
  datatype.l                    ; Byte    => Datentyp der Zellen der Spalte, 0=Text, 1=Ganzzahl, 2=Boolean, 16=Fließkomma, 17=Fließkomma (2 Stellen), 32=EUR, 33=USD, 64=Prozent, 127=benutzerdefiniertes Ausgabeformat
  userNumberFormat.s            ; String  => Benutzerdefiniertes Zahlenausgabeformat
  summary.l                     ; Byte    => Spaltensumme wird erzeugt
  sumval.f                      ; Float   => Wert der Spaltensumme
  inputType.l                   ; Byte    => Eingabetyp 0=freie Texteingabe, 16=Rollup mit Wertliste, 17=Rollup mit Wertliste 2-spaltig, 32=Rollup mit SQL-String, 33=Rollup mit SQL-String 2-spaltig (Boolean-Datentyp setzt Eingabeformat automatisch)
  inputRessource.s              ; String  => Eingabe-Ressource (Eingabeformat, Werteliste, SQL-String) in Kombination mit inputType ausgewertet
  ;color_back.l                  ; Long    => Hintergrundfarbe der kompletten Spalte
EndStructure


Structure CSGrid_TypeRow
  hWnd.l                        ; Long    => Handle des Grids
  row.l                         ; Word    => Nummer der Zeile
  caption.s                     ; String  => Zeilenbeschriftung
  hDetails.l                    ; Long    => Handle des Zeilen-Details-Objektes (kann auch ein CSGridGadget sein)
  DetailsHeight.l               ; Word    => Höhe des Zeilen-Details-Objektes
  DetailsVisible.l              ; Byte    => Status des Zeilen-Details (-1=nicht angezeigt, 1=angezeigt)
  ;color_back.l                  ; Long    => Hintergrundfarbe der kompletten Zeile
EndStructure


; **************************************************************
;- Variablen
; **************************************************************

Global CSGrid_ActGridhWnd.l    ; Long    => Handle des aktuellen, fokusierten Grid-Controls
NewList CSGrid.CSGrid_Type()
NewList CSGrid_Cell.CSGrid_TypeCell()
NewList CSGrid_Col.CSGrid_TypeCol()
NewList CSGrid_Row.CSGrid_TypeRow()


; **************************************************************
;- Deklaration von Funktionen und Hilfsfunktionen
; **************************************************************

; Öffentliche Funktionen:
Declare CSGridGadget(Gadget.l,x.l,y.l,width.l,height.l,cols.l,rows.l)                  ; PUBLIC-Funktion für das Erzeugen eines Grid-Gadgets
Declare.l CSGridGadget_GetActualGrid()                                                 ; PUBLIC-Funktion zum Ermitteln des aktuellen Grids
Declare CSGridGadget_SetAutoRedraw(Gadget.l,Enabled.l)                                 ; PUBLIC-Funktion zum Setzen der autom. Zeichnung bei Änderung
Declare.l CSGridGadget_GetAutoRedraw(Gadget.l)                                         ; PUBLIC-Funktion zum Ermitteln der autom. Zeichnung bei Änderung
Declare CSGridGadget_SetAutoSort(Gadget.l,Enabled.l)                                   ; PUBLIC-Funktion zur Aktivierung der automatischen Sortierung
Declare.l CSGridGadget_GetAutoSort(Gadget.l)                                           ; PUBLIC-Funktion zum Ermitteln der Aktivierung der automatischen Sortierung
Declare CSGridGadget_SetGridLockStatus(Gadget.l,Status.l)                              ; PUBLIC-Funktion zum Setzen des Sperr-Status der gesamten Tabelle
Declare.l CSGridGadget_GetGridLockStatus(Gadget.l)                                     ; PUBLIC-Funktion zum Ermitteln des Sperr-Status der gesamten Tabelle
Declare CSGridGadget_SetColDataType(Gadget.l,Col.l,DataType.l)                         ; PUBLIC-Funktion zum Setzen des Datentyps einer Spalte
Declare.l CSGridGadget_GetColDataType(Gadget.l,Col.l)                                  ; PUBLIC-Funktion zum Ermitteln des Datentyps einer Spalte
Declare CSGridGadget_SetColUserNumberFormat(Gadget.l,Col.l,UserNumberFormat.s)         ; PUBLIC-Funktion zum Setzen des Zahlen-Ausgabeformates für eine Spalte
Declare.s CSGridGadget_GetColUserNumberFormat(Gadget.l,Col.l)                          ; PUBLIC-Funktion zum Ermitteln des Zahlen-Ausgabeformates einer Spalte
Declare CSGridGadget_SetColSummary(Gadget.l,Col.l,Enabled.l)                           ; PUBLIC-Funktion zum Setzen der Spalten-Summen-Eigenschaft
Declare.l CSGridGadget_GetColSummary(Gadget.l,Col.l)                                   ; PUBLIC-Funktion zum Ermitteln der Spalten-Summen-Eigenschaft
;Declare.f CSGridGadget_GetColSummaryValue(Gadget.l,Col.l)                              ; PUBLIC-Funktion zum Ermitteln der Spalten-Summe (sofern Summierung aktiviert wurde)
Declare CSGridGadget_SetColWidth(Gadget.l,Col.l,Width.l)                               ; PUBLIC-Funktion zum Setzen einer Spaltenbreite
Declare.l CSGridGadget_GetColWidth(Gadget.l,Col.l)                                     ; PUBLIC-Funktion zum Ermitteln der Spaltenbreite
Declare CSGridGadget_SetColCaption(Gadget.l,Col.l,Caption.s)                           ; PUBLIC-Funktion zum Setzen einer Spaltenbeschriftung
Declare.s CSGridGadget_GetColCaption(Gadget.l,Col.l)                                   ; PUBLIC-Funktion zum Ermitteln einer Spaltenbeschriftung
Declare CSGridGadget_SetRowCaption(Gadget.l,Row.l,Caption.s)                           ; PUBLIC-Funktion zum Setzen einer Zeilenbeschriftung
Declare.s CSGridGadget_GetRowCaption(Gadget.l,Row.l)                                   ; PUBLIC-Funktion zum Ermitteln einer Zeilenbeschriftung
Declare CSGridGadget_SetRowsHeight(Gadget.l,Height.l)                                  ; PUBLIC-Funktion zum Setzen der Zellen/Zeilen-Höhe
Declare.l CSGridGadget_GetRowsHeight(Gadget.l)                                         ; PUBLIC-Funktion zum Ermitteln der Zellen/Zeilen-Höhe
Declare CSGridGadget_SetRowDetailsEnabled(Gadget.l,Enabled.l)                          ; PUBLIC-Funktion zum Setzen der Spalten-Summen-Eigenschaft
Declare.l CSGridGadget_GetRowDetailsEnabled(Gadget.l)                                  ; PUBLIC-Funktion zum Ermitteln der Spalten-Summen-Eigenschaft
Declare CSGridGadget_SetRowDetailsHandle(Gadget.l,Row.l,handle.l,height.l)             ; PUBLIC-Funktion zum Setzen eines Zeilen-Details-Objektes
Declare.l CSGridGadget_GetRowDetailsHandle(Gadget.l,Row.l)                             ; PUBLIC-Funktion zum Ermitteln einer Zeilenbeschriftung
Declare CSGridGadget_SetCellValue(Gadget.l,Col.l,Row.l,Value.s)                        ; PUBLIC-Funktion zum Setzen des Zell-Inhalts
Declare.s CSGridGadget_GetCellValue(Gadget.l,Col.l,Row.l)                              ; PUBLIC-Funktion zum Ermitteln eines Zellen-Inhalts
Declare CSGridGadget_SetCellLockStatus(Gadget.l,Col.l,Row.l,Status.l)                  ; PUBLIC-Funktion zum Setzen des Sperr-Zustandes einer Zelle
Declare.l CSGridGadget_GetCellLockStatus(Gadget.l,Col.l,Row.l)                         ; PUBLIC-Funktion zum Ermitteln des Sperr-Zustandes einer Zelle
Declare CSGridGadget_SetGridLinesVisibility(Gadget.l,Visible.l)                        ; PUBLIC-Funktion zum Setzen der Sichtbarkeit von Gitternetzlinien
Declare.l CSGridGadget_GetGridLinesVisibility(Gadget.l)                                ; PUBLIC-Funktion zum Ermitteln der Sichtbarkeit von Gitternetzlinien
Declare CSGridGadget_SetColCaptionVisibility(Gadget.l,Visible.l)                       ; PUBLIC-Funktion zum Setzen der Sichtbarkeit von Spaltenköpfen
Declare.l CSGridGadget_GetColCaptionVisibility(Gadget.l)                               ; PUBLIC-Funktion zum Ermitteln der Sichtbarkeit von Spaltenköpfen
Declare CSGridGadget_SetRowCaptionVisibility(Gadget.l,Visible.l)                       ; PUBLIC-Funktion zum Setzen der Sichtbarkeit von Zeilenköpfen
Declare.l CSGridGadget_GetRowCaptionVisibility(Gadget.l)                               ; PUBLIC-Funktion zum Ermitteln der Sichtbarkeit von Zeilenköpfen
Declare CSGridGadget_SetColsScaleable(Gadget.l,Enabled.l)                              ; PUBLIC-Funktion zum Setzen der Abänderbarkeit von Spaltenbreiten
Declare.l CSGridGadget_GetColsScaleable(Gadget.l)                                      ; PUBLIC-Funktion zum Ermitteln der Abänderbarkeit von Spaltenbreiten
Declare CSGridGadget_SetColsUserSort(Gadget.l,Enabled.l)                               ; PUBLIC-Funktion zum Setzen der Abänderbarkeit von Spaltensortierungen
Declare.l CSGridGadget_GetColsUserSort(Gadget.l)                                       ; PUBLIC-Funktion zum Ermitteln der Abänderbarkeit von Spaltensortierungen
Declare CSGridGadget_SetColorBackground(Gadget.l,Color.l)                              ; PUBLIC-Funktion zum Setzen der Hintergrundfarbe
Declare.l CSGridGadget_GetColorBackground(Gadget.l)                                    ; PUBLIC-Funktion zum Ermitteln der Hintergrundfarbe
Declare CSGridGadget_SetColorGrid(Gadget.l,Color.l)                                    ; PUBLIC-Funktion zum Setzen der Farbe der Gitternetzlinien
Declare.l CSGridGadget_GetColorGrid(Gadget.l)                                          ; PUBLIC-Funktion zum Ermitteln der Farbe der Gitternetzlinien
Declare CSGridGadget_SetColorCellBackDef(Gadget.l,Color.l)                             ; PUBLIC-Funktion zum Setzen der Standard Hintergrundfarbe der Zellen
Declare.l CSGridGadget_GetColorCellBackDef(Gadget.l)                                   ; PUBLIC-Funktion zum Ermitteln der Standard Hintergrundfarbe der Zellen
Declare CSGridGadget_SetColorCellTextDef(Gadget.l,Color.l)                             ; PUBLIC-Funktion zum Setzen der Standard Schrift-Farbe der Zellen
Declare.l CSGridGadget_GetColorCellTextDef(Gadget.l)                                   ; PUBLIC-Funktion zum Ermitteln der Standard Schrift-Farbe der Zellen
Declare CSGridGadget_SetColorColRowCapt(Gadget.l,Color.l)                              ; PUBLIC-Funktion zum Setzen der Farbe für die Spalten-/Zeilen-Überschriften
Declare.l CSGridGadget_GetColorColRowCapt(Gadget.l)                                    ; PUBLIC-Funktion zum Ermitteln der Farbe für die Spalten-/Zeilen-Überschriften
Declare CSGridGadget_SetColorCellBackFocus(Gadget.l,Color.l)                           ; PUBLIC-Funktion zum Setzen der Farbe für fokusierte Zellen
Declare.l CSGridGadget_GetColorCellBackFocus(Gadget.l)                                 ; PUBLIC-Funktion zum Ermitteln der Farbe für fokusierte Zellen
Declare CSGridGadget_SetColorColRowCaptFocus(Gadget.l,Color.l)                         ; PUBLIC-Funktion zum Setzen der Farbe für Spalten-/Zeilen-Überschriften von fokusierte Zellen
Declare.l CSGridGadget_GetColorColRowCaptFocus(Gadget.l)                               ; PUBLIC-Funktion zum Ermitteln der Farbe für Spalten-/Zeilen-Überschriften von fokusierte Zellen
Declare CSGridGadget_SetColorCellBackLock(Gadget.l,Color.l)                            ; PUBLIC-Funktion zum Setzen der Farbe für eine gesperrte Zelle
Declare.l CSGridGadget_GetColorCellBackLock(Gadget.l)                                  ; PUBLIC-Funktion zum Ermitteln der Farbe für eine gesperrte Zelle
Declare CSGridGadget_SetColorCellBackLockFocus(Gadget.l,Color.l)                       ; PUBLIC-Funktion zum Setzen der Farbe für eine gesperrte, fokusierte Zelle
Declare.l CSGridGadget_GetColorCellBackLockFocus(Gadget.l)                             ; PUBLIC-Funktion zum Ermitteln der Farbe für eine gesperrte, fokusierte Zelle
Declare CSGridGadget_SetColorCellBackFocusInactive(Gadget.l,Color.l)                   ; PUBLIC-Funktion zum Setzen der Farbe für eine fokusierte Zelle eines inaktiven Gadgets
Declare.l CSGridGadget_GetColorCellBackFocusInactive(Gadget.l)                         ; PUBLIC-Funktion zum Ermitteln der Farbe für eine fokusierte Zelle eines inaktiven Gadgets
Declare CSGridGadget_SetFormatComma(Gadget.l,Char.s)                                   ; PUBLIC-Funktion zum Definieren des Komma-Zeichens für die formatierte Zahlenausgabe
Declare.s CSGridGadget_GetFormatComma(Gadget.l)                                        ; PUBLIC-Funktion zum Ermitteln des Komma-Zeichens für die formatierte Zahlenausgabe
Declare.l CSGridGadget_GetRowsCount(Gadget.l)                                          ; PUBLIC-Funktion zum Ermitteln der Zeilenanzahl
Declare.l CSGridGadget_GetColsCount(Gadget.l)                                          ; PUBLIC-Funktion zum Ermitteln der Spaltenanzahl
Declare CSGridGadget_SetActualCellValue(Gadget.l,Value.s)                              ; PUBLIC-Funktion zum Setzen des Inhaltes der aktuellen Zelle
Declare.s CSGridGadget_GetActualCellValue(Gadget.l)                                    ; PUBLIC-Funktion zum Ermitteln des Inhaltes der aktuellen Zelle
Declare CSGridGadget_SetActualCellState(Gadget.l,State.l)                              ; PUBLIC-Funktion zum Setzen des Status der aktuellen Zelle
Declare.l CSGridGadget_GetActualCellState(Gadget.l)                                    ; PUBLIC-Funktion zum Ermitteln des Status der aktuellen Zelle
Declare CSGridGadget_SetFont(Gadget.l,Font.l)                                          ; PUBLIC-Funktion zum Setzen der Schriftart
Declare.l CSGridGadget_GetFont(Gadget.l)                                               ; PUBLIC-Funktion zum Ermitteln der Schriftart
Declare.l CSGridGadget_GetActualRow(Gadget.l)                                          ; PUBLIC-Funktion zum Ermitteln der aktuellen Zeilen-Position des Cursors
Declare.l CSGridGadget_GetActualCol(Gadget.l)                                          ; PUBLIC-Funktion zum Ermitteln der aktuellen Spalten-Position des Cursors
Declare CSGridGadget_SetCursor(Gadget.l,Col.l,Row.l,)                                  ; PUBLIC-Funktion zum Setzen des Cursors
Declare CSGridGadget_SetCursorRange(Gadget.l,StartCol.l,StartRow.l,EndCol.l,EndRow.l)  ; PUBLIC-Funktion zum Setzen eines Markierungsbereichs
Declare CSGridGadget_CopySelectionToClipboard(Gadget.l)                                ; PUBLIC-Funktion zum Kopieren der aktuellen Markierung in die Zwischenablage
Declare CSGridGadget_AddRow(Gadget.l,Position.l)                                       ; PUBLIC-Funktion zum Hinzufügen einer Zeile zu einem CS-Grid-Gadget
Declare CSGridGadget_AddRowWithContent(Gadget.l,Position.l,Text$,ImageID.l)            ; PUBLIC-Funktion zum Hinzufügen einer Zeile mit Inhalt (Spalten mit Tab [ASC10] getrennt) zu einem CS-Grid-Gadget
Declare CSGridGadget_RemoveRow(Gadget.l,Position.l)                                    ; PUBLIC-Funktion zum Enternen einer Zeile
Declare CSGridGadget_AddCol(Gadget.l,Position.l)                                       ; PUBLIC-Funktion zum Hinzufügen einer Spalte zu einem CS-Grid-Gadget
Declare CSGridGadget_AddColWithContent(Gadget.l,Position.l,Content.s,ImageID.l)        ; PUBLIC-Funktion zum Hinzufügen einer Spalte mit Inhalt (Spalten mit Tab [ASC10] getrennt) zu einem CS-Grid-Gadget
Declare CSGridGadget_RemoveCol(Gadget.l,Position.l)                                    ; PUBLIC-Funktion zum Entfernen einer Spalte 
Declare CSGridGadget_RemoveAllCells(Gadget.l)                                          ; PUBLIC-Funktion zum Entfernen sämtlicher Zeilen
Declare CSGridGadget_ColSort(Gadget.l,Col.l,Direction.l)                               ; PUBLIC-Funktion zum Sortieren einer Tabelle nach einer bestimmten Spalte
Declare.l CSGridGadget_EventHandling(eventID)                                          ; PUBLIC-Funktion zum Verarbeiten eines Purebasic-Events
Declare CSGridGadget_SetFocus(Gadget.l)                                                ; PUBLIC-Funktion zum Setzen des Fokus eines CS-Grid-Gadgets
Declare CSGridGadget_Resize(Gadget.l,x.l,y.l,width.l,height.l)                         ; PUBLIC-Funktion zum Positionieren und Skalieren eines CS-Grid-Objektes
Declare CSGridGadget_Redraw(Gadget.l)                                                  ; PUBLIC-Funktion zum manuellen Neuzeichnen eines Grid-Objektes
Declare CSGridGadget_FreeGadget(Gadget.l)                                              ; PUBLIC-Funktion zum Entfernen eines CS-Grid-Objektes

IncludeFile "CS-Grid2-1H.pb"

; *************************************************************
;- Oeffentliche Funktionen
; *************************************************************


Procedure CSGridGadget(Gadget.l,x.l,y.l,width.l,height.l,cols.l,rows.l) ; Creates a CS-Grid Gadget
  ; PUBLIC-Funktion für das Erzeugen eines Grid-Gadgets
  Protected n.l
  H_InitShortCuts()
  AddElement(CSGrid())
  ;Debug CountList(CSGrid())
  ;CSGrid()\Font = CSGrid_Font.l
  CSGrid()\DefGridWidth = #DefGridWidth                       ; Standard-Zellenbreite
  CSGrid()\DefGridHeight = #DefGridHeight                     ; Standard-Zellenhöhe
  CSGrid()\Color_Grid = #DefColor_Grid                        ; Standardfarbe für das Gitternetz
  CSGrid()\Color_Backgr = #DefColor_Backgr                    ; Standardfarbe für den Hintergrund
  CSGrid()\Color_CellBack = #DefColor_CellBack                ; Standardfarbe für den Zellenhintergrund
  CSGrid()\Color_CaptBack = #DefColor_CaptBack                ; Standardfarbe für den Überschrift/Beschriftungs-Hintergrund
  CSGrid()\Color_CaptFocus = #DefColor_CaptFocus              ; Standardfarbe für den Überschrift/Beschriftungs-Hintergrund, bei Fokus-Erhalt einer enthaltenen Zelle
  CSGrid()\Color_CellLoFoc = #DefColor_CellLoFoc              ; Standardfarbe für den Zellhintergrund bei Fokus-Erhalt und Sperr-Zustand -1
  CSGrid()\Color_CellFore = #DefColor_CellFore                ; Standardfarbe für den Zelleninhalt (Text)
  CSGrid()\Color_CellFocus = #DefColor_CellFocus              ; Standardfarbe für den Zellenhintergrund bei Fokus-Erhalt
  CSGrid()\Color_CellLock = #DefColor_CellLock                ; Standardfarbe für den Zellenhintergrund, wenn Zelle gesperrt ist
  CSGrid()\Color_CellFocusInact = #DefColor_CellFocusInact    ; Standardfarbe für den Zellenhintergrund der aktiven Zelle, wenn Grid nicht fokusiert ist
  CSGrid()\GridVisible = #DefGridVisible                      ; Standardmäßig werden Gitternetz-Linien angezeigt
  CSGrid()\ColCaptVisible = #DefColCaptVisible                ; Standardmäßig werden Spaltenüberschriften mit angezeigt
  CSGrid()\RowCaptVisible = #DefRowCaptVisible                ; Standardmäßig werden Zeilenüberschriften mit angezeigt
  CSGrid()\RowCaptWidth = #DefColCaptWidth                    ; Standardmäßige Spaltenbreite für die Zeilenüberschrift    
  CSGrid()\AutoRedraw = 1
  CSGrid()\AutoSort = -1
  CSGrid()\SortCol = -1
  CSGrid()\UserSort = -1
  CSGrid()\Left = x.l
  CSGrid()\Top = y.l
  CSGrid()\Width = width.l
  CSGrid()\Height = height.l
  CSGrid()\Cols = cols.l
  CSGrid()\Rows = rows.l
  CSGrid()\Cells = CSGrid()\Cols * CSGrid()\Rows
  CSGrid()\CellMatrixStartID = CountList(CSGrid_Cell())
  LastElement(CSGrid_Cell())
  For n = 1 To CSGrid()\Cells
    AddElement(CSGrid_Cell())
  Next
  CSGrid()\ImgWidth = CSGrid()\Width-#ScrollbarSize-3
  CSGrid()\ImgHeight = CSGrid()\Height-#ScrollbarSize-3
  CSGrid()\hImage = CreateImage(#PB_Any, CSGrid()\ImgWidth,CSGrid()\ImgHeight)
  CSGrid()\hWnd = ContainerGadget(Gadget,CSGrid()\Left,CSGrid()\Top,CSGrid()\Width,CSGrid()\Height,CSGrid()\hImage)
  If Gadget <> #PB_Any
    CSGrid()\GadgetID = Gadget
    ;CSGrid()\hWnd = IsGadget(CSGrid()\hWnd)
    CSGrid()\hWnd = GadgetID(CSGrid()\GadgetID)
  EndIf
    CSGrid()\hImageGadget = ImageGadget(#PB_Any,0,0,CSGrid()\ImgWidth,CSGrid()\ImgHeight,CSGrid()\hImage)
    CSGrid()\hVscrollGadget = ScrollBarGadget(#PB_Any,CSGrid()\Width-#ScrollbarSize-3,0,#ScrollbarSize,CSGrid()\Height-#ScrollbarSize,0,CSGrid()\Rows,1,#PB_ScrollBar_Vertical)
    CSGrid()\hHscrollGadget = ScrollBarGadget(#PB_Any,0,CSGrid()\Height-#ScrollbarSize-3,CSGrid()\Width-#ScrollbarSize,#ScrollbarSize,0,CSGrid()\Cols,1)
  CloseGadgetList()
  H_DrawGrid(-1)
  H_DrawScrollbars(1)  
  ProcedureReturn CSGrid()\hWnd
EndProcedure


Procedure.l CSGridGadget_GetActualGrid() ; Returns the hWnd of the actual / focused CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des aktuellen Grids
  ProcedureReturn CSGrid_ActGridhWnd
EndProcedure


Procedure CSGridGadget_Redraw(Gadget.l) ; Redraws a CS-Grid-Gadget
  ; PUBLIC-Funktion zum manuellen Neuzeichnen eines Grid-Objektes
  If H_GetGadget(Gadget.l) = 1
    H_DrawGrid(1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetActualRow(Gadget.l) ; Returns the ID of cursor's row position of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der aktuellen Zeilen-Position des Cursors
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\ActRowEnd
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetActualCol(Gadget.l) ; Returns the ID of cursor's col position of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der aktuellen Spalten-Position des Cursors
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\ActColEnd
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetRowsCount(Gadget.l) ; Returns the count of Rows of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Zeilenanzahl
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Rows
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColsCount(Gadget.l) ; Returns the count of Cols of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Spaltenanzahl
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Cols
  EndIf
EndProcedure


Procedure.s CSGridGadget_GetActualCellValue(Gadget.l) ; Returns the content of the actual cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Inhaltes der aktuellen Zelle
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn H_GetCellValue(CSGrid()\ActColEnd,CSGrid()\ActRowEnd)
  EndIf
EndProcedure


Procedure CSGridGadget_SetActualCellValue(Gadget.l,Value.s) ; Sets the content of the actual cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Inhaltes der aktuellen Zelle
  If H_GetGadget(Gadget.l) = 1
    CSGridGadget_SetCellValue(Gadget.l,CSGrid()\ActColEnd,CSGrid()\ActRowEnd,Value.s)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetActualCellState(Gadget.l) ; Returns the state of the actual cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Status der aktuellen Zelle
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn H_GetCellLockStatus(CSGrid()\ActColEnd,CSGrid()\ActRowEnd)
  EndIf
EndProcedure


Procedure CSGridGadget_SetActualCellState(Gadget.l,State.l) ; Sets the state of the actual cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Status der aktuellen Zelle
  If H_GetGadget(Gadget.l) = 1
    CSGridGadget_SetCellLockStatus(Gadget.l,CSGrid()\ActColEnd,CSGrid()\ActRowEnd,State.l)
  EndIf
EndProcedure


Procedure CSGridGadget_SetColDataType(Gadget.l,Col.l,DataType.l) ; Sets the datatype for a column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Datentyps einer Spalte
  ; Datentyp der Zellen der Spalte, 0=Text, 1=Ganzzahl, 2=Boolean, 16=Fließkomma, 17=Fließkomma (2 Stellen), 32=EUR, 33=USD, 64=Prozent, 127=benutzerdefiniertes Ausgabeformat
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      H_SetColDataType(Gadget.l,Col.l,DataType.l)
    EndIf    
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColDataType(Gadget.l,Col.l) ; Returns the datatype of a column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Datentyps einer Spalte
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetColDataType(Col.l)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetColUserNumberFormat(Gadget.l,Col.l,UserNumberFormat.s) ; Sets the user numberformat for a column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Zahlen-Ausgabeformates für eine Spalte
  ; Datentyp der Zellen der Spalte, 0=Text, 1=Ganzzahl, 2=Boolean, 16=Fließkomma, 17=Fließkomma (2 Stellen), 32=EUR, 33=USD, 64=Prozent, 127=benutzerdefiniertes Ausgabeformat
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      H_SetColUserNumberFormat(Gadget.l,Col.l,UserNumberFormat.s)
    EndIf    
  EndIf
EndProcedure


Procedure.s CSGridGadget_GetColUserNumberFormat(Gadget.l,Col.l) ; Returns the user numberformat string of a column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Zahlen-Ausgabeformates einer Spalte
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetColUserNumberFormat(Col.l)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetColSummary(Gadget.l,Col.l,Enabled.l) ; Sets the summary-flag for a column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Spalten-Summen-Eigenschaft
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      H_SetColSummaryFlag(Gadget.l,Col.l,Enabled.l)
    EndIf    
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColSummary(Gadget.l,Col.l) ; Returns the value of the summary-flag of a column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Spalten-Summen-Eigenschaft
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetColSummaryFlag(Col.l)
    EndIf
  EndIf
EndProcedure


Procedure.f CSGridGadget_GetColSummaryValue(Gadget.l,Col.l) ; Returns the value/sum of a summarized column of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Spalten-Summe (sofern Summierung aktiviert wurde)
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      If H_GetColSummaryFlag(Col.l) = 1      
        ProcedureReturn CSGrid_Col()\sumval
      Else
        ProcedureReturn 0.0
      EndIf
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetRowDetailsEnabled(Gadget.l,Enabled.l) ; Enables showing row details (if available) of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Spalten-Summen-Eigenschaft
  If H_GetGadget(Gadget.l) = 1
    If CSGrid()\hWnd <> 0
      CSGrid()\RowExpand = Enabled.l
    EndIf    
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetRowDetailsEnabled(Gadget.l) ; Returns the value of the row-details-flag of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Spalten-Summen-Eigenschaft
  If H_GetGadget(Gadget.l) = 1
    If CSGrid()\hWnd <> 0
      ProcedureReturn CSGrid()\RowExpand
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetGridLockStatus(Gadget.l,Status.l) ; Sets the lock-status of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Sperr-Status der gesamten Tabelle
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\GridLock = Status.l
    If Status.l <= -16 Or Status.l >= 16
      CSGrid()\ActColStart = -1 
      CSGrid()\ActRowStart = -1
      CSGrid()\ActColEnd = -1 
      CSGrid()\ActRowEnd = -1
    EndIf
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetGridLockStatus(Gadget.l) ; Returns the lock-status of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Sperr-Status der gesamten Tabelle
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\GridLock
  EndIf
EndProcedure


Procedure CSGridGadget_SetRowsHeight(Gadget.l,Height.l) ; Sets the row/cell's height of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Zellen/Zeilen-Höhe
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\DefGridHeight = Height.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetRowsHeight(Gadget.l) ; Returns the row/cell's height of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Zellen/Zeilen-Höhe
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\DefGridHeight
  EndIf
EndProcedure


Procedure CSGridGadget_SetColWidth(Gadget.l,Col.l,Width.l) ; Sets a Column-Width of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen einer Spaltenbreite
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      H_SetColWidth(Gadget.l,Col.l,Width.l)
    EndIf
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColWidth(Gadget.l,Col.l) ; Returns a Column-Width of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Spaltenbreite
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetColWidth(Col.l)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetColCaption(Gadget.l,Col.l,Caption.s) ; Sets a Column-Caption of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen einer Spaltenbeschriftung
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      If H_CheckIfColSetExists(Col.l) < 1
        LastElement(CSGrid_Col())
        AddElement(CSGrid_Col())
        CSGrid_Col()\hWnd = Gadget.l
        CSGrid_Col()\col = Col.l
      EndIf
      CSGrid_Col()\caption = Caption.s
      H_DrawGrid(-1)
    EndIf
  EndIf
EndProcedure


Procedure.s CSGridGadget_GetColCaption(Gadget.l,Col.l) ; Returns a Column-Caption of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln einer Spaltenbeschriftung
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetColCaption(Col.l)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_ColSort(Gadget.l,Col.l,Direction.l) ; Sorts a CS-Grid-Gadget according to a Column
  ; PUBLIC-Funktion zum Sortieren einer Tabelle nach einer bestimmten Spalte
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0 And (Direction.l = 1 Or Direction.l = -1)
      H_DoColSorting(Col.l,Direction.l)
      H_DrawGrid(-1)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetRowCaption(Gadget.l,Row.l,Caption.s) ; Sets a Row-Caption of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen einer Zeilenbeschriftung
  If H_GetGadget(Gadget.l) = 1
    If Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      If H_CheckIfRowSetExists(Row.l) < 1
        LastElement(CSGrid_Row())
        AddElement(CSGrid_Row())
        CSGrid_Row()\hWnd = Gadget.l
        CSGrid_Row()\row = Row.l
      EndIf
      CSGrid_Row()\caption = Caption.s
      H_DrawGrid(-1)
    EndIf
  EndIf
EndProcedure


Procedure.s CSGridGadget_GetRowCaption(Gadget.l,Row.l) ; Returns a Row-Caption of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln einer Zeilenbeschriftung
  If H_GetGadget(Gadget.l) = 1
    If Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetRowCaption(Row.l)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetRowDetailsHandle(Gadget.l,Row.l,handle.l,height.l) ; Sets a Row-Details-Object-Handle of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen eines Zeilen-Details-Objektes
  If IsGadget(handle.l) Or handle.l = 0
    If H_GetGadget(Gadget.l) = 1
      If Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
        If H_CheckIfRowSetExists(Row.l) < 1
          LastElement(CSGrid_Row())
          AddElement(CSGrid_Row())
          CSGrid_Row()\hWnd = Gadget.l
          CSGrid_Row()\row = Row.l
        EndIf
        CSGrid_Row()\hDetails = handle.l
        If handle.l > 0
          CSGrid_Row()\DetailsHeight = height.l
          HideGadget(handle,1)
          CSGrid_Row()\DetailsVisible = -1
        Else
          CSGrid_Row()\DetailsHeight = 0
        EndIf
        H_DrawGrid(-1)
      EndIf
    EndIf
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetRowDetailsHandle(Gadget.l,Row.l) ; Returns a Row-Details-Object-Handle of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln einer Zeilenbeschriftung
  If H_GetGadget(Gadget.l) = 1
    If Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetRowDetailsHandle(Row.l)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetCellValue(Gadget.l,Col.l,Row.l,Value.s) ; Sets a Cell-Value of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Zell-Inhalts
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      H_SetCellValue(Col.l,Row.l,Value.s)
    EndIf
  EndIf
EndProcedure


Procedure.s CSGridGadget_GetCellValue(Gadget.l,Col.l,Row.l) ; Returns a Cell-Value of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln eines Zellen-Inhalts
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetCellValue(Col.l,Row.l)
    EndIf  
  EndIf
EndProcedure


Procedure CSGridGadget_SetCellLockStatus(Gadget.l,Col.l,Row.l,Status.l) ; Sets the Lock-Status of a Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Sperr-Zustandes einer Zelle
  Protected tcell.l
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      tcell.l = (CSGrid()\Cols * Row.l) + Col.l + CSGrid()\CellMatrixStartID
      If tCell.l >= 0
        SelectElement(CSGrid_Cell(),tcell.l)
        CSGrid_Cell()\lock = Status.l
        H_DrawGrid(-1)
      EndIf
    EndIf
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetCellLockStatus(Gadget.l,Col.l,Row.l) ; Returns the Lock-Status of a Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Sperr-Zustandes einer Zelle
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn H_GetCellLockStatus(Col.l,Row.l)
    EndIf  
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorBackground(Gadget.l,Color.l) ; Sets the Background-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Hintergrundfarbe
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_Backgr = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorBackground(Gadget.l) ; Returns Background-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Hintergrundfarbe
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_Backgr 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorGrid(Gadget.l,Color.l) ; Sets the Gridlines-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe der Gitternetzlinien
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_Grid = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorGrid(Gadget.l) ; Returns Gridlines-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe der Gitternetzlinien
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_Grid 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorCellBackDef(Gadget.l,Color.l) ; Sets the Cell's default Background-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Standard Hintergrundfarbe der Zellen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CellBack = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorCellBackDef(Gadget.l) ; Returns Cell's default Background-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Standard Hintergrundfarbe der Zellen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CellBack 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorCellTextDef(Gadget.l,Color.l) ; Sets the Cell's default Text-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Standard Schrift-Farbe der Zellen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CellFore = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorCellTextDef(Gadget.l) ; Returns Cell's default Text-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Standard Schrift-Farbe der Zellen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CellFore 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorColRowCapt(Gadget.l,Color.l) ; Sets the Color of the Column/Row-Header of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe für die Spalten-/Zeilen-Überschriften
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CaptBack = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorColRowCapt(Gadget.l) ; Returns Cell's default Text-Color of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe für die Spalten-/Zeilen-Überschriften
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CaptBack 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorCellBackFocus(Gadget.l,Color.l) ; Sets the Color of a focused Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe für fokusierte Zellen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CellFocus = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorCellBackFocus(Gadget.l) ; Returns the Color of a focused Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe für fokusierte Zellen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CellFocus 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorColRowCaptFocus(Gadget.l,Color.l) ; Sets the Color of the Header of a focused Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe für Spalten-/Zeilen-Überschriften von fokusierte Zellen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CaptFocus = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorColRowCaptFocus(Gadget.l) ; Returns the Color of the Header of a focused Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe für Spalten-/Zeilen-Überschriften von fokusierte Zellen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CaptFocus 
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorCellBackLock(Gadget.l,Color.l) ; Sets the Color of a locked Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe für eine gesperrte Zelle
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CellLock = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorCellBackLock(Gadget.l) ; Returns the Color of a locked Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe für eine gesperrte Zelle
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CellLock
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorCellBackLockFocus(Gadget.l,Color.l) ; Sets the Color of a locked, focused Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe für eine gesperrte, fokusierte Zelle
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CellLoFoc = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorCellBackLockFocus(Gadget.l) ; Returns the Color of a locked, focused Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe für eine gesperrte, fokusierte Zelle
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CellLoFoc
  EndIf
EndProcedure


Procedure CSGridGadget_SetColorCellBackFocusInactive(Gadget.l,Color.l) ; Sets the Color of a focused Cell of a inactive CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Farbe für eine fokusierte Zelle eines inaktiven Gadgets
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Color_CellFocusInact = Color.l
    H_DrawGrid(-1)
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetColorCellBackFocusInactive(Gadget.l) ; Returns the Color of a focused Cell of a inactive CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Farbe für eine fokusierte Zelle eines inaktiven Gadgets
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Color_CellFocusInact
  EndIf
EndProcedure


Procedure CSGridGadget_SetGridLinesVisibility(Gadget.l,Visible.l) ; Sets the flag for visibility of the Grid-Lines of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Sichtbarkeit von Gitternetzlinien
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\GridVisible = Visible.l
    H_DrawGrid(-1)
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetGridLinesVisibility(Gadget.l) ; Returns the flag for visibility of the Grid-Lines of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Sichtbarkeit von Gitternetzlinien
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\GridVisible
  EndIf  
EndProcedure


Procedure CSGridGadget_SetColCaptionVisibility(Gadget.l,Visible.l) ; Sets the flag for visibility of the Column-Headers of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Sichtbarkeit von Spaltenköpfen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\ColCaptVisible = Visible.l
    H_DrawGrid(-1)
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetColCaptionVisibility(Gadget.l) ; Returns the flag for visibility of the Column-Headers of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Sichtbarkeit von Spaltenköpfen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\ColCaptVisible
  EndIf  
EndProcedure


Procedure CSGridGadget_SetRowCaptionVisibility(Gadget.l,Visible.l) ; Sets the flag for visibility of the Row-Headers of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Sichtbarkeit von Zeilenköpfen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\RowCaptVisible = Visible.l
    H_DrawGrid(-1)
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetRowCaptionVisibility(Gadget.l) ; Returns the flag for visibility of the Row-Headers of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Sichtbarkeit von Zeilenköpfen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\RowCaptVisible
  EndIf  
EndProcedure


Procedure CSGridGadget_SetColsScaleable(Gadget.l,Enabled.l) ; Sets the flag for customizing width of Columns of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Abänderbarkeit von Spaltenbreiten
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\ColCustWidth = Enabled.l
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetColsScaleable(Gadget.l) ; Returns the flag for customizing width of Columns of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Abänderbarkeit von Spaltenbreiten
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\ColCustWidth
  EndIf  
EndProcedure


Procedure CSGridGadget_SetColsUserSort(Gadget.l,Enabled.l) ; Sets the flag for customizing sorting of Columns of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Abänderbarkeit von Spaltensortierungen
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\UserSort = Enabled.l
    H_DrawGrid(-1)
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetColsUserSort(Gadget.l) ; Returns the flag for customizing sorting of Columns of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Abänderbarkeit von Spaltensortierungen
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\UserSort
  EndIf  
EndProcedure


Procedure CSGridGadget_SetAutoSort(Gadget.l,Enabled.l) ; Sets a auto-sort flag for a CS-Grid-Gadget
  ; PUBLIC-Funktion zur Aktivierung der automatischen Sortierung
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      CSGrid()\AutoSort = Enabled.l
    EndIf
  EndIf
EndProcedure


Procedure.l CSGridGadget_GetAutoSort(Gadget.l) ; Returns a the auto-sort flag of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Aktivierung der automatischen Sortierung
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And CSGrid()\hWnd <> 0
      ProcedureReturn CSGrid()\AutoSort
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetAutoRedraw(Gadget.l,Enabled.l) ; Sets the flag for auto-redraw of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der autom. Zeichnung bei Änderung
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\AutoRedraw = Enabled.l
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetAutoRedraw(Gadget.l) ; Returns the flag for auto-redraw of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der autom. Zeichnung bei Änderung
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\AutoRedraw
  EndIf  
EndProcedure


Procedure CSGridGadget_SetFont(Gadget.l,Font.l) ; Sets the font of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen der Schriftart
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Font = Font.l
    H_DrawGrid(-1)
  EndIf  
EndProcedure


Procedure.l CSGridGadget_GetFont(Gadget.l) ; Returns the font of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln der Schriftart
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn CSGrid()\Font
  EndIf  
EndProcedure


Procedure CSGridGadget_SetFormatComma(Gadget.l,Char.s) ; Sets the comma-symbol for a formatted output of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Definieren des Komma-Zeichens für die formatierte Zahlenausgabe
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\CommaSep = Asc(Char.s)-127
  EndIf  
EndProcedure


Procedure.s CSGridGadget_GetFormatComma(Gadget.l) ; Returns the comma-symbol of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Ermitteln des Komma-Zeichens für die formatierte Zahlenausgabe
  If H_GetGadget(Gadget.l) = 1
    ProcedureReturn Chr(CSGrid()\CommaSep+127)
  EndIf  
EndProcedure


Procedure CSGridGadget_SetCursor(Gadget.l,Col.l,Row.l) ; Sets the cursor to a Cell of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Cursors
  If H_GetGadget(Gadget.l) = 1
    If Col.l < CSGrid()\Cols And Col.l >= 0 And Row.l < CSGrid()\Rows And Row.l >= 0 And CSGrid()\hWnd <> 0
      If H_GetCellLockStatus(Col.l,Row.l) > -16
        H_SetCursor(0,Col.l,Row.l)
      EndIf
    EndIf  
  EndIf
EndProcedure


Procedure CSGridGadget_SetCursorRange(Gadget.l,StartCol.l,StartRow.l,EndCol.l,EndRow.l) ; Sets the cursor to a range of Cells of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen eines Markierungsbereichs
  If H_GetGadget(Gadget.l) = 1
    If StartCol.l < CSGrid()\Cols And StartCol.l >= 0 And StartRow.l < CSGrid()\Rows And StartRow.l >= 0 And EndCol.l < CSGrid()\Cols And EndCol.l >= 0 And EndRow.l < CSGrid()\Rows And EndRow.l >= 0 And CSGrid()\hWnd <> 0
      If H_GetCellLockStatus(StartCol.l,StartRow.l) > -16
        H_SetCursor(0,StartCol.l,StartRow.l)
      EndIf
      If H_GetCellLockStatus(EndCol.l,EndRow.l) > -16      
        H_SetCursor(0,EndCol.l,EndRow.l)
      EndIf    
    EndIf
  EndIf
EndProcedure  


Procedure CSGridGadget_CopySelectionToClipboard(Gadget.l) ; Copies the actual cursor selection of a CS-Grid-Gadget to the clipboard
  ; PUBLIC-Funktion zum Kopieren der aktuellen Markierung in die Zwischenablage
  Protected tx.l,ty.l, tclip.s
  If H_GetGadget(Gadget.l) = 1
    If StartCol.l < CSGrid()\Cols And StartCol.l >= 0 And StartRow.l < CSGrid()\Rows And StartRow.l >= 0 And EndCol.l < CSGrid()\Cols And EndCol.l >= 0 And EndRow.l < CSGrid()\Rows And EndRow.l >= 0 And CSGrid()\hWnd <> 0
      If CSGrid()\ColCaptVisible = 1
        tclip = Chr(7)
        For tx = CSGrid()\ActColStart To CSGrid()\ActColEnd
          If H_GetColWidth(tx) > 0
            tclip + H_GetColCaption(tx)
            If tx < CSGrid()\ActColEnd
              tclip + Chr(9)
            EndIf            
          EndIf          
        Next
        tclip + Chr(13) + Chr(10)
      EndIf
      For ty = CSGrid()\ActRowStart To CSGrid()\ActRowEnd
        For tx = CSGrid()\ActColStart To CSGrid()\ActColEnd
          If H_GetColWidth(tx) > 0
            If H_GetCellLockStatus(tx,ty) > -16
              tclip + H_FormatCell(H_GetCellValue(tx,ty),H_GetColDataType(tx))
            EndIf
            If tx < CSGrid()\ActColEnd
              tclip + Chr(9)
            EndIf            
          EndIf
        Next
        If ty < CSGrid()\ActRowEnd
          tclip + Chr(13) + Chr(10)
        EndIf
      Next
      SetClipboardText(tclip)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_PasteClipboardToSelection(Gadget.l) ; Pastes the clipboard content to the actual cursor of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Einfügen des Inhaltes aus der Zwischenablage an die Cursor-Position
  Protected tClip.s,tpos.l, tline.s, tx.l, ty.l, fRedraw.l
  If H_GetGadget(Gadget.l) = 1
    tClip = GetClipboardText()
    fRedraw = CSGrid()\AutoRedraw
    CSGrid()\AutoRedraw = -1
    ; Spaltenköpfe ausblenden
    If Left(tClip.s,1) = Chr(7) 
      tpos = FindString(tClip,Chr(13)+Chr(10),2)
      If tpos > 0
        tClip = Right(tClip,Len(tClip)-tpos-1)
      EndIf
    EndIf    
    While Len(tClip.s) > 0 And (ty+CSGrid()\ActRowEnd) < CSGrid()\Rows
      tpos = FindString(tClip,Chr(13)+Chr(10),1)
      If tpos > 0
        tline = Left(tClip,tpos-1)
        tClip = Right(tClip,Len(tClip)-tpos-1)
      Else
        tline = tClip
        tClip = ""
      EndIf
      tx = 0
      While Len(tline) > 0 And (tx+CSGrid()\ActColEnd) < CSGrid()\Cols
        tpos = FindString(tline,Chr(9),1)
        If tpos > 0 
          H_SetCellValue(CSGrid()\ActColEnd+tx,CSGrid()\ActRowEnd+ty,Left(tline,tpos-1))
          tline = Right(tline,Len(tline)-tpos)
          tx + 1
        Else
          H_SetCellValue(CSGrid()\ActColEnd+tx,CSGrid()\ActRowEnd+ty,tline)
          tline = ""
        EndIf
      Wend        
      ty + 1
    Wend
    CSGrid()\AutoRedraw = fRedraw
    H_DrawGrid(-1)
  EndIf  
EndProcedure
to be continued...
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post by CSAUER »

Part 2:

Code: Select all

Procedure.l CSGridGadget_EventHandling(eventID) ; Needs to be called for CS-Grid-Gadgets, if Windows-Event is rising
  ; PUBLIC-Funktion zum Verarbeiten eines Purebasic-Events
  Protected teventtype.l, teventgadget.l, ieventID.l
  teventtype.l = EventType()
  teventgadget.l = EventGadgetID()
  Select teventtype.l
    Case #PB_EventType_Focus
      If H_GetGadget(teventgadget.l) = 0
        If CSGrid()\GridLock > -16 And CSGrid()\GridLock < 16 
          teventgadget.l = 0
        EndIf
      EndIf
    Case #PB_EventType_LeftClick
      H_GetFocusedGrid()
  EndSelect
  Select eventID 
    Case #PB_EventGadget
      ResetList(CSGrid())
      While NextElement(CSGrid())  
        Select teventgadget.l
          Case CSGrid()\hHscrollGadget
            H_Scroll(GetGadgetState(CSGrid()\hHscrollGadget),0)
            ieventID.l = 16
            ;Break
          Case CSGrid()\hVscrollGadget
            H_Scroll(GetGadgetState(CSGrid()\hVscrollGadget),1)
            ieventID.l = 17
            ;Break
           Case CSGrid()\hImageGadget
            ;Debug "TABLE: MouseX:"+Str(WindowMouseX())+"  MouseY:"+Str(WindowMouseY())
            If CSGrid()\GridLock > -16 And CSGrid()\GridLock < 16 
              Select teventtype.l
                Case #PB_EventType_LeftDoubleClick
                  If H_SortColbyMouse() = -1
                    ; *** TODO: Abhängig vom Zell-Eingabeformat
                    H_CellInput(1)
                    ieventID.l = 32
                  Else
                    ieventID.l = 18
                  EndIf
                Default
                  ieventID.l = H_MoveCursorbyMouse(0)
              EndSelect
            EndIf
;             Break       ; **** DIESER BREAK BRINGT EINEN INVALID MEMORY ACCESS
        EndSelect
      Wend 
  EndSelect
  If H_GetGadget(CSGrid_ActGridhWnd) = 1
    If CSGrid()\GridLock > -16 And CSGrid()\GridLock < 16 
      Select eventID
        Case #PB_Event_Menu
          Select EventMenuID()
            Case #EventID_Left
              H_MoveCursor(0,-1,0)
              ieventID.l = 64
            Case #EventID_Up
              H_MoveCursor(0,0,-1)
              ieventID.l = 64
            Case #EventID_Right
              H_MoveCursor(0,1,0)
              ieventID.l = 64
            Case #EventID_Down
              H_MoveCursor(0,0,1)
              ieventID.l = 64
            Case #EventID_SLeft
              H_MoveCursor(2,-1,0)
              ieventID.l = 64
            Case #EventID_SUp
              H_MoveCursor(2,0,-1)
              ieventID.l = 64
            Case #EventID_SRight
              H_MoveCursor(2,1,0)
              ieventID.l = 64
            Case #EventID_SDown
              H_MoveCursor(2,0,1)
              ieventID.l = 64
            Case #EventID_Return
              If CSGrid()\InputMode > 0
                H_CellInput(0)
                ieventID.l = 33
              Else
                ; *** TODO: Abhängig vom Zell-Eingabeformat  
                H_CellInput(1)
                ieventID.l = 32
              EndIf
            Case #EventID_ESC
              H_CellInput(-1)
              ieventID.l = 34
          EndSelect
      EndSelect
    EndIf
  Else
    teventgadget.l = 0
  EndIf
  ProcedureReturn ieventID.l
EndProcedure


Procedure CSGridGadget_AddRow(Gadget.l,Position.l) ; Adds a new row to a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Hinzufügen einer Zeile zu einem CS-Grid-Gadget
  If H_GetGadget(Gadget.l) = 1
    CSGridGadget_AddRowWithContent(Gadget.l,Position.l,"",0)
  EndIf
EndProcedure


Procedure CSGridGadget_AddRowWithContent(Gadget.l,Position.l,Text$,ImageID.l) ; Adds a new row with content like AddGadgetItem to a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Hinzufügen einer Zeile mit Inhalt (Spalten mit Tab [ASC10] getrennt) zu einem CS-Grid-Gadget
  Protected tActMatrixPos.l, tCols.l, tpos.l, x.l
  If H_GetGadget(Gadget.l) = 1
    Position.l - 1
    If Position.l >= CSGrid()\Rows
      Position.l = CSGrid()\Rows-1
    EndIf
    tCols = CSGrid()\Cols
    If H_GetCell(tCols-1,Position.l) <= -1
      tpos.l = CSGrid()\CellMatrixStartID-1
      If tpos > 0
        SelectElement(CSGrid_Cell(),tpos)
      Else
        ResetList(CSGrid_Cell())
      EndIf
    EndIf
    For x = 0 To tCols-1
      AddElement(CSGrid_Cell())
      If Len(text$) > 0
        tpos = FindString(Text$,Chr(10),1)
        If tpos > 0
          CSGrid_Cell()\content = Left(Text$,tpos-1)
          Text$ = Right(Text$,Len(Text$)-tpos)
        Else
          CSGrid_Cell()\content = Text$
          Text$ = ""
        EndIf
      EndIf
    Next
    CSGrid()\rows + 1
    CSGrid()\cells = tCols * CSGrid()\Rows
    tActMatrixPos.l = CSGrid()\CellMatrixStartID
    If CSGrid()\AutoSort > -1 
      H_DoColSorting(CSGrid()\SortCol,CSGrid()\SortDir)
    EndIf            
    ResetList(CSGrid())
    While NextElement(CSGrid())
      If CSGrid()\CellMatrixStartID > tActMatrixPos.l
        CSGrid()\CellMatrixStartID + tCols
      EndIf
    Wend
    ResetList(CSGrid_Row())
    While NextElement(CSGrid_Row())
      If CSGrid_Row()\row > Position.l
        CSGrid_Row()\row+1
      EndIf
    Wend
    H_DrawScrollbars(-1)
  EndIf
EndProcedure


Procedure CSGridGadget_RemoveRow(Gadget.l,Position.l) ; Removes a row of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Enternen einer Zeile
  Protected tActMatrixPos.l, tCols.l, tpos.l, x.l
  If H_GetGadget(Gadget.l) = 1
    If Position.l > CSGrid()\Rows
      Position.l = CSGrid()\Rows-1
    EndIf
    tCols = CSGrid()\Cols
    If H_GetCell(tCols-1,Position.l) > -1
      For x = 0 To tCols-1
        DeleteElement(CSGrid_Cell())
      Next
      CSGrid()\rows - 1
      CSGrid()\cells = tCols * CSGrid()\Rows
      tActMatrixPos.l = CSGrid()\CellMatrixStartID
      H_DrawGrid(-1)
      ResetList(CSGrid())
      While NextElement(CSGrid())
        If CSGrid()\CellMatrixStartID > tActMatrixPos.l
          CSGrid()\CellMatrixStartID - tCols
        EndIf
      Wend  
      ResetList(CSGrid_Row())
      While NextElement(CSGrid_Row())
        If CSGrid_Row()\row >= Position.l
          CSGrid_Row()\row-1
        EndIf
      Wend
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_AddCol(Gadget.l,Position.l) ; Adds a new col to a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Hinzufügen einer Spalte zu einem CS-Grid-Gadget
  If H_GetGadget(Gadget.l) = 1
    CSGridGadget_AddColWithContent(Gadget.l,Position.l,"",0)
  EndIf
EndProcedure


Procedure CSGridGadget_AddColWithContent(Gadget.l,Position.l,Content.s,ImageID.l) ; Adds a new col with content to a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Hinzufügen einer Spalte mit Inhalt (Spalten mit Tab [ASC10] getrennt) zu einem CS-Grid-Gadget
  Protected tActMatrixPos.l, tpos.l, y.l, tActCell.l, tRows.l
  If H_GetGadget(Gadget.l) = 1
    position.l - 1
    If Position.l >= CSGrid()\Cols
      Position.l = CSGrid()\Cols-1
    EndIf
    If CSGrid()\Cols > 0
      For y = 0 To CSGrid()\Rows-1
        If H_GetCell(Position.l+y.l,y.l) <= -1
          tpos.l = CSGrid()\CellMatrixStartID-1
          If tpos > 0
            SelectElement(CSGrid_Cell(),tpos)
          Else
            ResetList(CSGrid_Cell())
          EndIf          
        EndIf
        AddElement(CSGrid_Cell())
        If Len(Content.s) > 0
          tpos = FindString(Content.s,Chr(10),1)
          If tpos > 0
            CSGrid_Cell()\content = Left(Content.s,tpos-1)
            Content.s = Right(Content.s,Len(Content.s)-tpos)
          Else
            CSGrid_Cell()\content = Content.s
            Content.s = ""
          EndIf
        EndIf
      Next
      CSGrid()\cols + 1
      tRows = CSGrid()\rows
      CSGrid()\cells = CSGrid()\Cols * CSGrid()\Rows
      tActMatrixPos.l = CSGrid()\CellMatrixStartID
      H_DrawScrollbars(-1)
      ResetList(CSGrid())
      While NextElement(CSGrid())
        If CSGrid()\CellMatrixStartID > tActMatrixPos.l
          CSGrid()\CellMatrixStartID + tRows
        EndIf
      Wend
      ResetList(CSGrid_Col())
      While NextElement(CSGrid_Col())
        If CSGrid_Col()\col > Position.l
          CSGrid_Col()\col+1
        EndIf
      Wend
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_RemoveCol(Gadget.l,Position.l) ; Removes a col of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Entfernen einer Spalte 
  Protected tActMatrixPos.l, tpos.l, y.l, tActCell.l, tRows.l
  If H_GetGadget(Gadget.l) = 1
    If Position.l > CSGrid()\Cols
      Position.l = CSGrid()\Cols-1
    EndIf
    If CSGrid()\Cols > 0
      For y = 0 To CSGrid()\Rows-1
        If H_GetCell(Position.l-y.l,y.l) > -1
          DeleteElement(CSGrid_Cell())
        EndIf
      Next
      CSGrid()\cols - 1
      tRows = CSGrid()\rows
      CSGrid()\cells = CSGrid()\Cols * CSGrid()\Rows
      tActMatrixPos.l = CSGrid()\CellMatrixStartID
      H_DrawGrid(-1)
      ResetList(CSGrid())
      While NextElement(CSGrid())
        If CSGrid()\CellMatrixStartID > tActMatrixPos.l
          CSGrid()\CellMatrixStartID - tRows
        EndIf
      Wend
      ResetList(CSGrid_Col())
      While NextElement(CSGrid_Col())
        If CSGrid_Col()\col >= Position.l
          CSGrid_Col()\col-1
        EndIf
      Wend      
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_RemoveAllCells(Gadget.l) ; Removes all existing columns of a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Entfernen sämtlicher Zellen
  Protected c.l
  If H_GetGadget(Gadget.l) = 1
    If H_GetCell(0,0) > -1
      For c = 0 To CSGrid()\cells
        DeleteElement(CSGrid_Cell())
      Next
      CSGrid()\cells = 0
      CSGrid()\cols = 0
      CSGrid()\rows = 0
      CSGrid()\ActColStart = -1
      CSGrid()\ActRowStart = -1
      CSGrid()\ActColEnd = -1
      CSGrid()\ActRowEnd = -1
      CSGrid()\ActXStart = 0
      CSGrid()\ActYStart = 0
      CSGrid()\ActXEnd = 0
      CSGrid()\ActYEnd = 0
      CSGrid()\ScrollX = 0
      CSGrid()\ScrollY = 0
      H_DrawGrid(-1)
    EndIf
  EndIf
EndProcedure


Procedure CSGridGadget_SetFocus(Gadget.l) ; Sets Focus to a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Setzen des Fokus eines CS-Grid-Gadgets
  CSGrid_ActGridhWnd.l = Gadget.l
  ResetList(CSGrid())
  While NextElement(CSGrid())
    H_DrawGrid(-1)
  Wend  
EndProcedure


Procedure CSGridGadget_Resize(Gadget.l,x.l,y.l,width.l,height.l) ; Resizes a CS-Grid-Gadget
  ; PUBLIC-Funktion zum Positionieren und Skalieren eines CS-Grid-Objektes
  If H_GetGadget(Gadget.l) = 1
    CSGrid()\Left = x.l
    CSGrid()\Top = y.l
    CSGrid()\Width = width.l
    CSGrid()\Height = height.l
    ResizeGadget(CSGrid()\hWnd,CSGrid()\Left,CSGrid()\Top,CSGrid()\Width,CSGrid()\Height)
    If CSGrid()\hInputText <> 0
      ResizeGadget(CSGrid()\hInputText,CSGrid()\Left+CSGrid()\ActXStart,CSGrid()\Top+CSGrid()\ActYStart,H_GetColWidth(CSGrid()\ActColStart)-1,CSGrid()\DefGridHeight-1)
    EndIf
    H_DrawScrollbars(1) 
    H_GetLastVisColRow()
  EndIf
EndProcedure


Procedure CSGridGadget_FreeGadget(Gadget.l) ; Removes a CS-Grid-Gadget and frees memory
  ; PUBLIC-Funktion zum Entfernen eines CS-Grid-Objektes
  If CSGrid()\hWnd <> 0
    FreeImage(CSGrid()\hImage)
    FreeGadget(CSGrid()\hImageGadget)
    FreeGadget(CSGrid()\hVscrollGadget)
    FreeGadget(CSGrid()\hHscrollGadget)
    FreeGadget(CSGrid()\hWnd)
    If CSGrid()\hInputText <> 0
      FreeGadget(CSGrid()\hInputText)
    EndIf
    CSGrid()\hImage = 0
    CSGrid()\hImageGadget = 0
    CSGrid()\hVscrollGadget = 0
    CSGrid()\hHscrollGadget = 0
    CSGrid()\hWnd = 0
    CSGrid()\hInputText = 0
    ClearList(CSGrid_Cell())
    ClearList(CSGrid_Col())
    H_RemoveShortCuts(0)
  EndIf
EndProcedure
For all non Germans: Sorry for commenting in German.
I hope, that this helped so far.

I commented one "break" command inside procedure "CSGridGadget_EventHandling", as this brings an "Invalid Memory Access" error on Mac only. It is not really required, but can bring a tiny speed improvement.
Additionally I changed some procedurereturn types, as they were unsupported on the first version of 3.94 on Mac.
Last edited by CSAUER on Wed May 03, 2006 8:22 pm, edited 1 time in total.
CSAUER
Enthusiast
Enthusiast
Posts: 188
Joined: Mon Oct 18, 2004 7:23 am
Location: Germany

Post by CSAUER »

And here is my Mac OS test program:

Code: Select all

; ************************************************************************
; ** DEMO CS-GRID V1.0 *** (c) 2005 Christian Walde-Sauer,  27.10.2005 ***
; ************************************************************************
; * Last Edit 11.11.2005                                                 *
; * Demo-Routing for multiple Edit-Grid-Gadgets with easy implementation *
; ************************************************************************


IncludeFile "CS-Grid2-1.pb"                            ; Adds Grid-Gadget-Library (should be done automatically in case of LIB

hWnd = OpenWindow(0, 100, 100, 640, 240, #PB_Window_SystemMenu,"Demo CS-Grid-Gadget")

If CreateGadgetList(WindowID())
  
  test = CSGridGadget(#PB_Any,10,10,600,200,20,4)         ; Creates a CS-Grid-Gadget with 2 x 2 cells
  CSGridGadget_SetAutoRedraw(test,-1)                    ; Turns off Auto-Redraw for Grid for faster setup  
  CSGridGadget_SetRowCaptionVisibility(test,1)           ; Shows a row header (default numbered caption)
  CSGridGadget_SetColWidth(test,0,100)                   ; Defines Column-Width for Column 0
  CSGridGadget_SetColWidth(test,1,300)                   ; Defines Column-Width for Column 1
  CSGridGadget_SetCellValue(test,0,0,"Name")             ; Labels cell C:0 R:0
  CSGridGadget_SetCellValue(test,0,1,"Address")          ; Labels cell C:0 R:1
  CSGridGadget_SetCellValue(test,0,2,"ZIP")              ; Labels cell C:0 R:2
  CSGridGadget_SetCellValue(test,0,3,"City")             ; Labels cell C:0 R:3
  For y = 0 To 3
    CSGridGadget_SetCellLockStatus(test,0,y,-1)          ; Locks cells in column 0 for input (not for access)
  Next
  ;test2 = StringGadget(#PB_Any,0,0,200,50,"Dies ist ein Test")
  
  CSGridGadget_SetRowDetailsHandle(test,2,test2,50)      ; Links an object or object-container or CSGridGadget as a sub-component to row 2 of CS-Grid-Gadget
  CSGridGadget_SetRowDetailsEnabled(test,1)              ; Enables showing row details / row sub-container
  CSGridGadget_SetAutoRedraw(test,1)                     ; Turns on Auto-Redraw for Grid 1 after setup
  CSGridGadget_Redraw(test)                              ; Redraws the Grid
  
  AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_C , 1)
  AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_V , 2)
  
  Repeat 
      main_EventID = WaitWindowEvent()
      CSevent = CSGridGadget_EventHandling(main_EventID)                    ; Processes all Grid-Gadget events (for all CS-Grid-Gadgets)
      Select CSevent
        Case 32 ; Start input
          ;Debug "START INPUT"
        Case 33 ; End input
          ;Debug "END INPUT"
        Case 34 ; Cancel input
          ;Debug "CANCEL INPUT"
      EndSelect
      If main_EventID = #PB_Event_Menu
        Select EventMenuID()
          Case 1 ; Ctrl + C
            CSGridGadget_CopySelectionToClipboard(CSGridGadget_GetActualGrid())
          Case 2 ; Ctrl + V
            CSGridGadget_PasteClipboardToSelection(CSGridGadget_GetActualGrid())
        EndSelect
      EndIf
  Until main_EventID = #PB_Event_CloseWindow
  CSGridGadget_FreeGadget(test)                     ; Removes the Grid 1 with all sub-objects and frees memory
  End
EndIf
Good luck on Linux.
Post Reply