From: Andreas H. <ah...@us...> - 2004-01-16 20:27:48
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1:/tmp/cvs-serv28644/run Added Files: JvExDBGrids.pas Log Message: Initial release --- NEW FILE: JvExDBGrids.pas --- {----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is: JvExDBGrids.pas, released on 2004-01-04 The Initial Developer of the Original Code is Andreas Hausladen [And...@gm...] Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen. All Rights Reserved. Contributor(s): - Last Modified: 2004-01-13 You may retrieve the latest version of this file at the Project JEDI's JVCL home page, located at http://jvcl.sourceforge.net Known Issues: -----------------------------------------------------------------------------} {$I jvcl.inc} unit JvExDBGrids; interface uses {$IFDEF VCL} Windows, Messages, Graphics, Controls, Forms, DBGrids, {$ENDIF VCl} {$IFDEF VisualCLX} Qt, QGraphics, QControls, QForms, QDBGrids, {$ENDIF VisualCLX} Classes, SysUtils, JvThemes, JvExControls; {$IFDEF VCL} {$DEFINE NeedMouseEnterLeave} {$ELSE} {$IF not declared(PatchedVCLX)} {$DEFINE NeedMouseEnterLeave} {$IFEND} {$ENDIF VCL} type TJvExCustomDBGrid = class(TCustomDBGrid, IJvWinControlEvents, IJvCustomControlEvents, IJvControlEvents) {$IFDEF VCL} protected // IJvControlEvents procedure VisibleChanged; dynamic; procedure EnabledChanged; dynamic; procedure TextChanged; dynamic; procedure FontChanged; dynamic; procedure ColorChanged; dynamic; procedure ParentFontChanged; dynamic; procedure ParentColorChanged; dynamic; procedure ParentShowHintChanged; dynamic; function WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; virtual; function HintShow(var HintInfo: THintInfo): Boolean; dynamic; function HitTest(X, Y: Integer): Boolean; dynamic; procedure MouseEnter(Control: TControl); dynamic; procedure MouseLeave(Control: TControl); dynamic; {$IFNDEF HASAUTOSIZE} {$IFNDEF COMPILER6_UP} procedure SetAutoSize(Value: Boolean); virtual; {$ENDIF !COMPILER6_UP} {$ENDIF !HASAUTOSIZE} public procedure Dispatch(var Msg); override; protected // IJvWinControlEvents procedure CursorChanged; dynamic; procedure ShowingChanged; dynamic; procedure ShowHintChanged; dynamic; procedure ControlsListChanging(Control: TControl; Inserting: Boolean); dynamic; procedure ControlsListChanged(Control: TControl; Inserting: Boolean); dynamic; {$IFDEF JVCLThemesEnabledD56} private function GetParentBackground: Boolean; protected procedure SetParentBackground(Value: Boolean); virtual; property ParentBackground: Boolean read GetParentBackground write SetParentBackground; {$ENDIF JVCLThemesEnabledD56} {$ENDIF VCL} {$IFDEF VisualCLX} protected {$IF not declared(PatchedVCLX)} procedure MouseEnter(Control: TControl); override; procedure MouseLeave(Control: TControl); override; {$IFEND} protected function NeedKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; override; procedure Painting(Sender: QObjectH; EventRegion: QRegionH); override; {$ENDIF VisualCLX} {$IFDEF NeedMouseEnterLeave} private FOnMouseEnter: TNotifyEvent; FOnMouseLeave: TNotifyEvent; protected property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter; property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave; {$ENDIF NeedMouseEnterLeave} protected procedure CMFocusChanged(var Msg: TCMFocusChanged); message CM_FOCUSCHANGED; procedure DoFocusChanged(Control: TWinControl); dynamic; function DoPaintBackground(Canvas: TCanvas; Param: Integer): Boolean; virtual; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; protected procedure DoGetDlgCode(var Code: TDlgCodes); virtual; procedure DoSetFocus(FocusedWnd: HWND); dynamic; procedure DoKillFocus(FocusedWnd: HWND); dynamic; end; TJvExDBGrid = class(TDBGrid, IJvWinControlEvents, IJvCustomControlEvents, IJvControlEvents) {$IFDEF VCL} protected // IJvControlEvents procedure VisibleChanged; dynamic; procedure EnabledChanged; dynamic; procedure TextChanged; dynamic; procedure FontChanged; dynamic; procedure ColorChanged; dynamic; procedure ParentFontChanged; dynamic; procedure ParentColorChanged; dynamic; procedure ParentShowHintChanged; dynamic; function WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; virtual; function HintShow(var HintInfo: THintInfo): Boolean; dynamic; function HitTest(X, Y: Integer): Boolean; dynamic; procedure MouseEnter(Control: TControl); dynamic; procedure MouseLeave(Control: TControl); dynamic; {$IFNDEF HASAUTOSIZE} {$IFNDEF COMPILER6_UP} procedure SetAutoSize(Value: Boolean); virtual; {$ENDIF !COMPILER6_UP} {$ENDIF !HASAUTOSIZE} public procedure Dispatch(var Msg); override; protected // IJvWinControlEvents procedure CursorChanged; dynamic; procedure ShowingChanged; dynamic; procedure ShowHintChanged; dynamic; procedure ControlsListChanging(Control: TControl; Inserting: Boolean); dynamic; procedure ControlsListChanged(Control: TControl; Inserting: Boolean); dynamic; {$IFDEF JVCLThemesEnabledD56} private function GetParentBackground: Boolean; protected procedure SetParentBackground(Value: Boolean); virtual; property ParentBackground: Boolean read GetParentBackground write SetParentBackground; {$ENDIF JVCLThemesEnabledD56} {$ENDIF VCL} {$IFDEF VisualCLX} protected {$IF not declared(PatchedVCLX)} procedure MouseEnter(Control: TControl); override; procedure MouseLeave(Control: TControl); override; {$IFEND} protected function NeedKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; override; procedure Painting(Sender: QObjectH; EventRegion: QRegionH); override; {$ENDIF VisualCLX} {$IFDEF NeedMouseEnterLeave} private FOnMouseEnter: TNotifyEvent; FOnMouseLeave: TNotifyEvent; protected property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter; property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave; {$ENDIF NeedMouseEnterLeave} protected procedure CMFocusChanged(var Msg: TCMFocusChanged); message CM_FOCUSCHANGED; procedure DoFocusChanged(Control: TWinControl); dynamic; function DoPaintBackground(Canvas: TCanvas; Param: Integer): Boolean; virtual; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; protected procedure DoGetDlgCode(var Code: TDlgCodes); virtual; procedure DoSetFocus(FocusedWnd: HWND); dynamic; procedure DoKillFocus(FocusedWnd: HWND); dynamic; end; implementation {$IFDEF VCL} procedure TJvExCustomDBGrid.Dispatch(var Msg); begin DispatchMsg(Self, Msg); end; procedure TJvExCustomDBGrid.VisibleChanged; begin InheritMsg(Self, CM_VISIBLECHANGED); end; procedure TJvExCustomDBGrid.EnabledChanged; begin InheritMsg(Self, CM_ENABLEDCHANGED); end; procedure TJvExCustomDBGrid.TextChanged; begin InheritMsg(Self, CM_TEXTCHANGED); end; procedure TJvExCustomDBGrid.FontChanged; begin InheritMsg(Self, CM_FONTCHANGED); end; procedure TJvExCustomDBGrid.ColorChanged; begin InheritMsg(Self, CM_COLORCHANGED); end; procedure TJvExCustomDBGrid.ParentColorChanged; begin InheritMsg(Self, CM_PARENTCOLORCHANGED); end; procedure TJvExCustomDBGrid.ParentFontChanged; begin InheritMsg(Self, CM_PARENTFONTCHANGED); end; procedure TJvExCustomDBGrid.ParentShowHintChanged; begin InheritMsg(Self, CM_PARENTSHOWHINTCHANGED); end; function TJvExCustomDBGrid.WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; begin Result := InheritMsg(Self, CM_DIALOGCHAR, Word(Key), ShiftStateToKeyData(Shift)) <> 0; end; function TJvExCustomDBGrid.HintShow(var HintInfo: THintInfo): Boolean; begin Result := InheritMsg(Self, CM_HINTSHOW, 0, Integer(@HintInfo)) <> 0; end; function TJvExCustomDBGrid.HitTest(X, Y: Integer): Boolean; begin Result := InheritMsg(Self, CM_HITTEST, 0, Integer(PointToSmallPoint(Point(X, Y)))) <> 0; end; procedure TJvExCustomDBGrid.MouseEnter(Control: TControl); begin InheritMsg(Self, CM_MOUSEENTER, 0, Integer(Control)); if Assigned(FOnMouseEnter) then FOnMouseEnter(Self); end; procedure TJvExCustomDBGrid.MouseLeave(Control: TControl); begin InheritMsg(Self, CM_MOUSELEAVE, 0, Integer(Control)); if Assigned(FOnMouseLeave) then FOnMouseLeave(Self); end; {$IFNDEF HASAUTOSIZE} {$IFNDEF COMPILER6_UP} procedure TJvExCustomDBGrid.SetAutoSize(Value: Boolean); begin TOpenControl_SetAutoSize(Self, Value); end; {$ENDIF !COMPILER6_UP} {$ENDIF !HASAUTOSIZE} procedure TJvExCustomDBGrid.CursorChanged; begin InheritMsg(Self, CM_CURSORCHANGED); end; procedure TJvExCustomDBGrid.ShowHintChanged; begin InheritMsg(Self, CM_SHOWHINTCHANGED); end; procedure TJvExCustomDBGrid.ShowingChanged; begin InheritMsg(Self, CM_SHOWINGCHANGED); end; procedure TJvExCustomDBGrid.ControlsListChanging(Control: TControl; Inserting: Boolean); begin Control_ControlsListChanging(Self, Control, Inserting); end; procedure TJvExCustomDBGrid.ControlsListChanged(Control: TControl; Inserting: Boolean); begin Control_ControlsListChanged(Self, Control, Inserting); end; {$IFDEF JVCLThemesEnabledD56} function TJvExCustomDBGrid.GetParentBackground: Boolean; begin Result := JvThemes.GetParentBackground(Self); end; procedure TJvExCustomDBGrid.SetParentBackground(Value: Boolean); begin JvThemes.SetParentBackground(Self, Value); end; {$ENDIF JVCLThemesEnabledD56} {$ENDIF VCL} {$IFDEF VisualCLX} {$IF not declared(PatchedVCLX)} procedure TJvExCustomDBGrid.MouseEnter(Control: TControl); begin inherited MouseEnter(Control); if Assigned(FOnMouseEnter) then FOnMouseEnter(Self); end; procedure TJvExCustomDBGrid.MouseLeave(Control: TControl); begin inherited MouseLeave(Control); if Assigned(FOnMouseLeave) then FOnMouseLeave(Self); end; {$IFEND} procedure TJvExCustomDBGrid.Painting(Sender: QObjectH; EventRegion: QRegionH); begin if WidgetControl_Painting(Self, Canvas, EventRegion) <> nil then begin // returns an interface DoPaintBackground(Canvas, 0); Paint; end; end; function TJvExCustomDBGrid.NeedKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; begin Result := TWidgetControl_NeedKey(Self, Key, Shift, KeyText, inherited NeedKey(Key, Shift, KeyText)); end; {$ENDIF VisualCLX} procedure TJvExCustomDBGrid.CMFocusChanged(var Msg: TCMFocusChanged); begin inherited; DoFocusChanged(Msg.Sender); end; procedure TJvExCustomDBGrid.DoFocusChanged(Control: TWinControl); begin end; function TJvExCustomDBGrid.DoPaintBackground(Canvas: TCanvas; Param: Integer): Boolean; begin {$IFDEF VCL} Result := InheritMsg(Self, WM_ERASEBKGND, Canvas.Handle, Param) <> 0; {$ELSE} Result := False; // Qt allways paints the background {$ENDIF VCL} end; procedure TJvExCustomDBGrid.DoGetDlgCode(var Code: TDlgCodes); begin end; procedure TJvExCustomDBGrid.DoSetFocus(FocusedWnd: HWND); begin end; procedure TJvExCustomDBGrid.DoKillFocus(FocusedWnd: HWND); begin end; constructor TJvExCustomDBGrid.Create(AOwner: TComponent); begin inherited Create(AOwner); end; destructor TJvExCustomDBGrid.Destroy; begin inherited Destroy; end; {$IFDEF VCL} procedure TJvExDBGrid.Dispatch(var Msg); begin DispatchMsg(Self, Msg); end; procedure TJvExDBGrid.VisibleChanged; begin InheritMsg(Self, CM_VISIBLECHANGED); end; procedure TJvExDBGrid.EnabledChanged; begin InheritMsg(Self, CM_ENABLEDCHANGED); end; procedure TJvExDBGrid.TextChanged; begin InheritMsg(Self, CM_TEXTCHANGED); end; procedure TJvExDBGrid.FontChanged; begin InheritMsg(Self, CM_FONTCHANGED); end; procedure TJvExDBGrid.ColorChanged; begin InheritMsg(Self, CM_COLORCHANGED); end; procedure TJvExDBGrid.ParentColorChanged; begin InheritMsg(Self, CM_PARENTCOLORCHANGED); end; procedure TJvExDBGrid.ParentFontChanged; begin InheritMsg(Self, CM_PARENTFONTCHANGED); end; procedure TJvExDBGrid.ParentShowHintChanged; begin InheritMsg(Self, CM_PARENTSHOWHINTCHANGED); end; function TJvExDBGrid.WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; begin Result := InheritMsg(Self, CM_DIALOGCHAR, Word(Key), ShiftStateToKeyData(Shift)) <> 0; end; function TJvExDBGrid.HintShow(var HintInfo: THintInfo): Boolean; begin Result := InheritMsg(Self, CM_HINTSHOW, 0, Integer(@HintInfo)) <> 0; end; function TJvExDBGrid.HitTest(X, Y: Integer): Boolean; begin Result := InheritMsg(Self, CM_HITTEST, 0, Integer(PointToSmallPoint(Point(X, Y)))) <> 0; end; procedure TJvExDBGrid.MouseEnter(Control: TControl); begin InheritMsg(Self, CM_MOUSEENTER, 0, Integer(Control)); if Assigned(FOnMouseEnter) then FOnMouseEnter(Self); end; procedure TJvExDBGrid.MouseLeave(Control: TControl); begin InheritMsg(Self, CM_MOUSELEAVE, 0, Integer(Control)); if Assigned(FOnMouseLeave) then FOnMouseLeave(Self); end; {$IFNDEF HASAUTOSIZE} {$IFNDEF COMPILER6_UP} procedure TJvExDBGrid.SetAutoSize(Value: Boolean); begin TOpenControl_SetAutoSize(Self, Value); end; {$ENDIF !COMPILER6_UP} {$ENDIF !HASAUTOSIZE} procedure TJvExDBGrid.CursorChanged; begin InheritMsg(Self, CM_CURSORCHANGED); end; procedure TJvExDBGrid.ShowHintChanged; begin InheritMsg(Self, CM_SHOWHINTCHANGED); end; procedure TJvExDBGrid.ShowingChanged; begin InheritMsg(Self, CM_SHOWINGCHANGED); end; procedure TJvExDBGrid.ControlsListChanging(Control: TControl; Inserting: Boolean); begin Control_ControlsListChanging(Self, Control, Inserting); end; procedure TJvExDBGrid.ControlsListChanged(Control: TControl; Inserting: Boolean); begin Control_ControlsListChanged(Self, Control, Inserting); end; {$IFDEF JVCLThemesEnabledD56} function TJvExDBGrid.GetParentBackground: Boolean; begin Result := JvThemes.GetParentBackground(Self); end; procedure TJvExDBGrid.SetParentBackground(Value: Boolean); begin JvThemes.SetParentBackground(Self, Value); end; {$ENDIF JVCLThemesEnabledD56} {$ENDIF VCL} {$IFDEF VisualCLX} {$IF not declared(PatchedVCLX)} procedure TJvExDBGrid.MouseEnter(Control: TControl); begin inherited MouseEnter(Control); if Assigned(FOnMouseEnter) then FOnMouseEnter(Self); end; procedure TJvExDBGrid.MouseLeave(Control: TControl); begin inherited MouseLeave(Control); if Assigned(FOnMouseLeave) then FOnMouseLeave(Self); end; {$IFEND} procedure TJvExDBGrid.Painting(Sender: QObjectH; EventRegion: QRegionH); begin if WidgetControl_Painting(Self, Canvas, EventRegion) <> nil then begin // returns an interface DoPaintBackground(Canvas, 0); Paint; end; end; function TJvExDBGrid.NeedKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; begin Result := TWidgetControl_NeedKey(Self, Key, Shift, KeyText, inherited NeedKey(Key, Shift, KeyText)); end; {$ENDIF VisualCLX} procedure TJvExDBGrid.CMFocusChanged(var Msg: TCMFocusChanged); begin inherited; DoFocusChanged(Msg.Sender); end; procedure TJvExDBGrid.DoFocusChanged(Control: TWinControl); begin end; function TJvExDBGrid.DoPaintBackground(Canvas: TCanvas; Param: Integer): Boolean; begin {$IFDEF VCL} Result := InheritMsg(Self, WM_ERASEBKGND, Canvas.Handle, Param) <> 0; {$ELSE} Result := False; // Qt allways paints the background {$ENDIF VCL} end; procedure TJvExDBGrid.DoGetDlgCode(var Code: TDlgCodes); begin end; procedure TJvExDBGrid.DoSetFocus(FocusedWnd: HWND); begin end; procedure TJvExDBGrid.DoKillFocus(FocusedWnd: HWND); begin end; constructor TJvExDBGrid.Create(AOwner: TComponent); begin inherited Create(AOwner); end; destructor TJvExDBGrid.Destroy; begin inherited Destroy; end; end. |