************************************************** *-- Class: gridcheckbox (d:\vfp5apps\gis\classes\baseclass.vcx) *-- ParentClass: control *-- BaseClass: control *-- Time Stamp: 03/01/01 11:04:07 AM * DEFINE CLASS gridcheckbox AS control Width = 40 Height = 18 BackStyle = 0 BorderWidth = 0 Name = "gridcheckbox" *-- Specifies if the user can edit a control, or *-- specifies if a table or view associated with *-- a Cursor object allows updates. readonly = .F. *-- Contains the current value of the checkbox value = .F. ADD OBJECT chkbox AS checkbox WITH ; Top = 1, ; Left = 1, ; Height = 16, ; Width = 16, ; Caption = "", ; Name = "chkBox" PROCEDURE enabled_assign LPARAMETERS vNewVal THIS.Enabled = m.vNewVal THIS.chkBox.Refresh() ENDPROC PROCEDURE readonly_assign LPARAMETERS vNewVal THIS.readonly = m.vNewVal THIS.chkBox.Refresh() ENDPROC *-- Sets the ControlSource of the checkbox PROCEDURE setcontrolsource if not empty(This.Parent.ControlSource) This.chkBox.ControlSource = This.Parent.ControlSource endif ENDPROC PROCEDURE Init with This .Resize() .SetControlSource() .chkBox.Refresh() endwith ENDPROC PROCEDURE Resize if upper(This.Parent.Parent.BaseClass) = "GRID" with This .Width = .Parent.Width .Height = .Parent.Parent.RowHeight .chkBox.Left = max(0, int((.Width - .chkBox.Width) / 2)) .chkBox.Top = max(0, int((.Height - .chkBox.Height) / 2)) endwith endif ENDPROC PROCEDURE Refresh This.chkBox.Refresh() ENDPROC *-- Called by the InteractiveChange of *-- the CheckBox of this Control PROCEDURE intactchange ENDPROC PROCEDURE chkbox.Click DoDefault() This.Parent.Value = This.Value This.Parent.Click() ENDPROC PROCEDURE chkbox.Refresh if upper(This.Parent.Parent.Parent.BaseClass) <> "GRID" return endif This.Enabled = This.Parent.Parent.Enabled This.ReadOnly = This.Parent.Parent.ReadOnly * * Next commands are designed to over-ride the column settings * This.Enabled = This.Parent.Enabled This.ReadOnly = This.Parent.ReadOnly ENDPROC PROCEDURE chkbox.KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl local llEnabled llEnabled = .t. if !This.Enabled llEnabled = .f. endif if This.ReadOnly llEnabled = .f. endif do case case nKeyCode = 5 && up arrow skip -1 if !bof() This.Parent.SetFocus() else locate endif nodefault case nKeyCode = 24 && down arrow skip if !eof() This.Parent.SetFocus() else skip -1 endif nodefault case inlist(nKeyCode, 13, 32) and llEnabled *!* Enter or Spacebar pressed This.Click() otherwise if type("nShiftAltCtrl") <> "N" or isnull(nShiftAltCtrl) nShiftAltCtrl = 0 endif DoDefault(nKeyCode, nShiftAltCtrl) endcase This.Parent.Parent.Parent.GridRowChange() ENDPROC PROCEDURE chkbox.InteractiveChange DoDefault() This.Parent.IntActChange() ENDPROC ENDDEFINE * *-- EndDefine: gridcheckbox **************************************************