
// This comment is inserted into every JvExXxx.pas file
(*$DEFINE WARNINGHEADER
{*****************************************************************************
 * WARNING: Do not edit this file.
 * This file is autogenerated from the source in devtools/JvExVCL/src.
 * If you do it despite this warning your changes will be discarded by the next
 * update of this file. Do your changes in the template files.
 ****************************************************************************}
{$D-} // do not step into this unit
*)

// *************************************************************************
// *************************** INTERFACE MACROS ****************************
// *************************************************************************

(*$DEFINE COMMON_PUBLISHED
  published
    property BiDiMode;
    property DragCursor;
    property DragKind;
    property DragMode;
    property ParentBiDiMode;
    property OnEndDock;
    property OnStartDock;
*)

// ****************** Control ************************
(*$DEFINE CONTROL_DECL
  private
    // TODO:
    // FAboutJVCL: TJVCLAboutInfo;
    FHintColor: TColor;
    FMouseOver: Boolean;
    FHintWindowClass: THintWindowClass;
    FOnMouseEnter: TNotifyEvent;
    FOnMouseLeave: TNotifyEvent;
    FOnParentColorChanged: TNotifyEvent;
    function BaseWndProc(Msg: Integer; WParam: Integer = 0; LParam: Longint = 0): Integer; overload;
    function BaseWndProc(Msg: Integer; WParam: Integer; LParam: TControl): Integer; overload;
    function BaseWndProcEx(Msg: Integer; WParam: Integer; var LParam): Integer;
  protected
    procedure WndProc(var Msg: TLMessage); override;
    procedure FocusChanged(AControl: TWinControl); dynamic;
    procedure VisibleChanged; reintroduce; dynamic;
    procedure EnabledChanged; reintroduce; dynamic;
    procedure TextChanged; reintroduce; virtual;
    procedure ColorChanged; reintroduce; dynamic;
    procedure FontChanged; reintroduce; dynamic;
    procedure ParentFontChanged; reintroduce; dynamic;
    procedure ParentColorChanged; reintroduce; dynamic;
    procedure ParentShowHintChanged; reintroduce; dynamic;
    function WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; reintroduce; virtual;
    function HintShow(var HintInfo: THintInfo): Boolean; reintroduce; dynamic;
    function HitTest(X, Y: Integer): Boolean; reintroduce; virtual;
    procedure MouseEnter(AControl: TControl); reintroduce; dynamic;
    procedure MouseLeave(AControl: TControl); reintroduce; dynamic;
    property MouseOver: Boolean read FMouseOver write FMouseOver;
    property HintColor: TColor read FHintColor write FHintColor default clDefault;
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    property OnParentColorChange: TNotifyEvent read FOnParentColorChanged write FOnParentColorChanged;
    function GetCaption: TCaption; virtual;
    procedure SetCaption(Value: TCaption); virtual;
  public
    constructor Create(AOwner: TComponent); override;
    property Caption: TCaption read GetCaption write SetCaption;
    property HintWindowClass: THintWindowClass read FHintWindowClass write FHintWindowClass;
  published
    // TODO:
    // property AboutJVCL: TJVCLAboutInfo read FAboutJVCL write FAboutJVCL stored False;
*)

// ****************** WinControl *********************
((*$DEFINE WINCONTROL_DECL
  CONTROL_DECL
  private
    FDotNetHighlighting: Boolean;
  protected
    procedure BoundsChanged; reintroduce; virtual;
    procedure CursorChanged; reintroduce; dynamic;
    procedure ShowingChanged; reintroduce; dynamic;
    procedure ShowHintChanged; reintroduce; dynamic;
    procedure ControlsListChanging(Control: TControl; Inserting: Boolean); reintroduce; dynamic;
    procedure ControlsListChanged(Control: TControl; Inserting: Boolean); reintroduce; dynamic;
    procedure GetDlgCode(var Code: TDlgCodes); virtual;
    procedure FocusSet(PrevWnd: THandle); virtual;
    procedure FocusKilled(NextWnd: THandle); virtual;
    function DoEraseBackground(ACanvas: TCanvas; Param: Integer): Boolean; virtual;
  published
    property DotNetHighlighting: Boolean read FDotNetHighlighting write FDotNetHighlighting default False;
*)

// ****************** EditControl ********************
(*$DEFINE EDITCONTROL_DECL
  WINCONTROL_DECL
  private
    FClipboardCommands: TJvClipboardCommands;
  protected
    procedure SetClipboardCommands(const Value: TJvClipboardCommands); virtual;
    property ClipboardCommands: TJvClipboardCommands read FClipboardCommands write SetClipboardCommands default [caCopy..caUndo];
*)

// *************************************************************************
// *************************************************************************

// ****************** Default-Helpers ********************

//  TJvEx##ClassName = class(T##ClassName, IJvExControl)
(*$DEFINE CONTROL_DECL_DEFAULT(ClassName)
  TJvEx##ClassName = class(T##ClassName)
  CONTROL_DECL
  end;
*)

// TJvEx##ClassName = class(T##ClassName, IJvExControl)
(*$DEFINE WINCONTROL_DECL_DEFAULT(ClassName)
  TJvEx##ClassName = class(T##ClassName)
  WINCONTROL_DECL
  end;
*)

// TJvEx##ClassName = class(T##ClassName, IJvExControl)
(*$DEFINE EDITCONTROL_DECL_DEFAULT(ClassName)
  TJvEx##ClassName = class(T##ClassName)
  EDITCONTROL_DECL
  end;
*)

// *************************************************************************
// ************************ IMPLEMENTATION MACROS **************************
// *************************************************************************

// ****************** Constructors *******************
(*$DEFINE BEGIN_CONTROL_CONSTRUCTOR(ClassName)
constructor TJvEx##ClassName.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FHintColor := clDefault;
*)

(*$DEFINE BEGIN_WINCONTROL_CONSTRUCTOR(ClassName)
BEGIN_CONTROL_CONSTRUCTOR(ClassName)
*)

(*$DEFINE BEGIN_EDITCONTROL_CONSTRUCTOR(ClassName)
BEGIN_WINCONTROL_CONSTRUCTOR(ClassName)
  FClipboardCommands := [caCopy..caUndo];
*)

(*$DEFINE END_CONSTRUCTOR
end;
*)

// ****************** Control implementation *******************
(*$DEFINE CONTROL_IMPL(ClassName)
function TJvEx##ClassName.BaseWndProc(Msg: Integer; WParam: Integer = 0; LParam: Longint = 0): Integer;
var
  Mesg: TLMessage;
begin
  Mesg := CreateWMMessage(Msg, WParam, LParam);
  inherited WndProc(Mesg);
  Result := Mesg.Result;
end;

function TJvEx##ClassName.BaseWndProc(Msg: Integer; WParam: Integer; LParam: TControl): Integer;
var
  Mesg: TLMessage;
begin
  Mesg := CreateWMMessage(Msg, WParam, LParam);
  inherited WndProc(Mesg);
  Result := Mesg.Result;
end;

function TJvEx##ClassName.BaseWndProcEx(Msg: Integer; WParam: Integer; var LParam): Integer;
var
  Mesg: TStructPtrMessage;
begin
  Mesg := TStructPtrMessage.Create(Msg, WParam, LParam);
  try
    inherited WndProc(Mesg.Msg);
  finally
    Result := Mesg.Msg.Result;
    Mesg.Free;
  end;
end;

procedure TJvEx##ClassName.VisibleChanged;
begin
  BaseWndProc(CM_VISIBLECHANGED);
end;

procedure TJvEx##ClassName.EnabledChanged;
begin
  BaseWndProc(CM_ENABLEDCHANGED);
end;

procedure TJvEx##ClassName.TextChanged;
begin
  BaseWndProc(CM_TEXTCHANGED);
end;

procedure TJvEx##ClassName.FontChanged;
begin
  BaseWndProc(CM_FONTCHANGED);
end;

procedure TJvEx##ClassName.ColorChanged;
begin
  BaseWndProc(CM_COLORCHANGED);
end;

procedure TJvEx##ClassName.ParentFontChanged;
begin
  // LCL doesn't send this message but left it in case
  //BaseWndProc(CM_PARENTFONTCHANGED);
end;

procedure TJvEx##ClassName.ParentColorChanged;
begin
  BaseWndProc(CM_PARENTCOLORCHANGED);
  if Assigned(OnParentColorChange) then
    OnParentColorChange(Self);
end;

procedure TJvEx##ClassName.ParentShowHintChanged;
begin
  BaseWndProc(CM_PARENTSHOWHINTCHANGED);
end;

function TJvEx##ClassName.WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean;
begin
  Result := BaseWndProc(CM_DIALOGCHAR, Word(Key), ShiftStateToKeyData(Shift)) <> 0;
end;

function TJvEx##ClassName.HitTest(X, Y: Integer): Boolean;
begin
  Result := BaseWndProc(CM_HITTEST, 0, SmallPointToLong(PointToSmallPoint(Point(X, Y)))) <> 0;
end;

function TJvEx##ClassName.HintShow(var HintInfo: THintInfo): Boolean;
begin
  GetHintColor(HintInfo, Self, FHintColor);
  if FHintWindowClass <> nil then
    HintInfo.HintWindowClass := FHintWindowClass;
  Result := BaseWndProcEx(CM_HINTSHOW, 0, HintInfo) <> 0;
end;

procedure TJvEx##ClassName.MouseEnter(AControl: TControl);
begin
  FMouseOver := True;
  if Assigned(FOnMouseEnter) then
    FOnMouseEnter(Self);
  BaseWndProc(CM_MOUSEENTER, 0, AControl);
end;

procedure TJvEx##ClassName.MouseLeave(AControl: TControl);
begin
  FMouseOver := False;
  BaseWndProc(CM_MOUSELEAVE, 0, AControl);
  if Assigned(FOnMouseLeave) then
    FOnMouseLeave(Self);
end;

procedure TJvEx##ClassName.FocusChanged(AControl: TWinControl);
begin
  BaseWndProc(CM_FOCUSCHANGED, 0, AControl);
end;

function TJvEx##ClassName.GetCaption: TCaption;
begin
  Result := inherited Caption;
end;

// 25.09.2007 - SESS:
// I have done this because TextChanged wasn't fired as expected.
// I still don't shure if this problem is only for this reintroduced
// method because the way LCL treats Caption or will have the same
// problem with other reintroduced methods. So far, I tested some
// other events and seems not.
procedure TJvEx##ClassName.SetCaption(Value: TCaption);
begin
  inherited Caption := Value;
  TextChanged;
end;
*)

// ****************** WinControl implementation *******************
((*$DEFINE WINCONTROL_IMPL(ClassName)
CONTROL_IMPL(ClassName)

procedure TJvEx##ClassName.BoundsChanged;
begin
end;

procedure TJvEx##ClassName.CursorChanged;
begin
  BaseWndProc(CM_CURSORCHANGED);
end;

procedure TJvEx##ClassName.ShowingChanged;
begin
  BaseWndProc(CM_SHOWINGCHANGED);
end;

procedure TJvEx##ClassName.ShowHintChanged;
begin
  BaseWndProc(CM_SHOWHINTCHANGED);
end;

{ VCL sends CM_CONTROLLISTCHANGE and CM_CONTROLCHANGE in a different order than
  the CLX methods are used. So we must correct it by evaluating "Inserting". }
procedure TJvEx##ClassName.ControlsListChanging(Control: TControl; Inserting: Boolean);
begin
  if Inserting then
    BaseWndProc(CM_CONTROLLISTCHANGE, Integer(Control), Integer(Inserting))
  else
    BaseWndProc(CM_CONTROLCHANGE, Integer(Control), Integer(Inserting));
end;

procedure TJvEx##ClassName.ControlsListChanged(Control: TControl; Inserting: Boolean);
begin
  if not Inserting then
    BaseWndProc(CM_CONTROLLISTCHANGE, Integer(Control), Integer(Inserting))
  else
    BaseWndProc(CM_CONTROLCHANGE, Integer(Control), Integer(Inserting));
end;

procedure TJvEx##ClassName.GetDlgCode(var Code: TDlgCodes);
begin
end;

procedure TJvEx##ClassName.FocusSet(PrevWnd: THandle);
begin
  BaseWndProc(LM_SETFOCUS, Integer(PrevWnd), 0);
end;

procedure TJvEx##ClassName.FocusKilled(NextWnd: THandle);
begin
  BaseWndProc(LM_KILLFOCUS, Integer(NextWnd), 0);
end;

function TJvEx##ClassName.DoEraseBackground(ACanvas: TCanvas; Param: Integer): Boolean;
begin
  Result := BaseWndProc(LM_ERASEBKGND, ACanvas.Handle, Param) <> 0;
end;
*)


// ****************** EditControl implementation *******************
(*$DEFINE EDITCONTROL_IMPL(ClassName)
WINCONTROL_IMPL(ClassName)

procedure TJvEx##ClassName.SetClipboardCommands(const Value: TJvClipboardCommands);
begin
  FClipboardCommands := Value;
end;
*)

// *********************************************************************
// *********************************************************************

// ****************** Control WndProc implementation *******************
(*$DEFINE CONTROL_WNDPROC_CASES
    {
    // TODO: do we need this? I think not...
    CM_DENYSUBCLASSING:
      Msg.Result := Ord(GetInterfaceEntry(IJvDenySubClassing) <> nil);
    }
    CM_DIALOGCHAR:
      with TCMDialogChar(Msg) do
        Result := Ord(WantKey(CharCode, KeyDataToShiftState(KeyData), WideChar(CharCode)));
    CM_HINTSHOW:
      with TCMHintShow(Msg) do
        Result := Integer(HintShow(HintInfo^));
    CM_HITTEST:
      with TCMHitTest(Msg) do
        Result := Integer(HitTest(XPos, YPos));
    CM_MOUSEENTER:
      MouseEnter(TControl(Msg.LParam));
    CM_MOUSELEAVE:
      MouseLeave(TControl(Msg.LParam));
    CM_VISIBLECHANGED:
      VisibleChanged;
    CM_ENABLEDCHANGED:
      EnabledChanged;
    // LCL doesn't send this message but left it in case
    CM_TEXTCHANGED:
      TextChanged;
    CM_FONTCHANGED:
      FontChanged;
    CM_COLORCHANGED:
      ColorChanged;
    CM_FOCUSCHANGED:
      FocusChanged(TWinControl(Msg.LParam));
    // LCL doesn't send this message but left it in case
    //CM_PARENTFONTCHANGED:
    //  ParentFontChanged;
    CM_PARENTCOLORCHANGED:
      ParentColorChanged;
    CM_PARENTSHOWHINTCHANGED:
      ParentShowHintChanged;
*)

(*$DEFINE CONTROL_WNDPROC(ClassName)
procedure TJvEx##ClassName.WndProc(var Msg: TLMessage);
begin
  if not DispatchIsDesignMsg(Self, Msg) then
  case Msg.Msg of
    CONTROL_WNDPROC_CASES
  else
    inherited WndProc(Msg);
  end;
end;
*)

// ****************** WinControl WndProc implementation *******************
(*$DEFINE WINCONTROL_WNDPROC_CASES
    CONTROL_WNDPROC_CASES
    CM_CURSORCHANGED:
      CursorChanged;
    CM_SHOWINGCHANGED:
      ShowingChanged;
    CM_SHOWHINTCHANGED:
      ShowHintChanged;
    CM_CONTROLLISTCHANGE:
      if Msg.LParam <> 0 then
        ControlsListChanging(TControl(Msg.WParam), True)
      else
        ControlsListChanged(TControl(Msg.WParam), False);
    CM_CONTROLCHANGE:
      if Msg.LParam = 0 then
        ControlsListChanging(TControl(Msg.WParam), False)
      else
        ControlsListChanged(TControl(Msg.WParam), True);
    LM_SETFOCUS:
      FocusSet(THandle(Msg.WParam));
    LM_KILLFOCUS:
      FocusKilled(THandle(Msg.WParam));
    LM_SIZE:
      begin
        inherited WndProc(Msg);
        BoundsChanged;
      end;
    LM_ERASEBKGND:
      if Msg.WParam <> 0 then
      begin
        IdSaveDC := SaveDC(HDC(Msg.WParam)); // protect DC against Stock-Objects from Canvas
        WCanvas := TCanvas.Create;
        try
          WCanvas.Handle := HDC(Msg.WParam);
          Msg.Result := Ord(DoEraseBackground(WCanvas, Msg.LParam));
        finally
          WCanvas.Handle := 0;
          WCanvas.Free;
          RestoreDC(HDC(Msg.WParam), IdSaveDC);
        end;
      end
      else
        inherited WndProc(Msg);
    LM_GETDLGCODE:
      begin
        inherited WndProc(Msg);
        DlgCodes := [dcNative] + DlgcToDlgCodes(Msg.Result);
        GetDlgCode(DlgCodes);
        if not (dcNative in DlgCodes) then
          Msg.Result := DlgCodesToDlgc(DlgCodes);
      end;
*)

(*$DEFINE WINCONTROL_WNDPROC(ClassName)
procedure TJvEx##ClassName.WndProc(var Msg: TLMessage);
var
  IdSaveDC: Integer;
  DlgCodes: TDlgCodes;
  WCanvas: TCanvas;
begin
  if not DispatchIsDesignMsg(Self, Msg) then
  begin
    case Msg.Msg of
      WINCONTROL_WNDPROC_CASES
    else
      inherited WndProc(Msg);
    end;
    // TODO:
    // LM_NCPAINT isn't send by LCL, may be .Net highlighting can't be implemented.
    case Msg.Msg of // precheck message to prevent access violations on released controls
      CM_MOUSEENTER, CM_MOUSELEAVE, LM_KILLFOCUS, LM_SETFOCUS, LM_NCPAINT:
        if DotNetHighlighting then
          HandleDotNetHighlighting(Self, Msg, MouseOver, Color);
    end;
  end;
end;
*)

// ****************** EditControl WndProc implementation *******************
(*$DEFINE EDITCONTROL_WNDPROC_CASES
    WINCONTROL_WNDPROC_CASES
    {
    // TODO: convert to LCL messages
    WM_CLEAR:
      if caClear in ClipboardCommands then
        inherited WndProc(Msg)
      else
        Msg.Result := 1;
    WM_UNDO, EM_UNDO:
      if caUndo in ClipboardCommands then
        inherited WndProc(Msg)
      else
        Msg.Result := 1;
    WM_COPY:
      if caCopy in ClipboardCommands then
        inherited WndProc(Msg)
      else
        Msg.Result := 1;
    WM_CUT:
      if caCut in ClipboardCommands then
        inherited WndProc(Msg)
      else
        Msg.Result := 1;
    WM_PASTE:
      if caPaste in ClipboardCommands then
        inherited WndProc(Msg)
      else
        Msg.Result := 1;
    }
*)

(*$DEFINE EDITCONTROL_WNDPROC(ClassName)
procedure TJvEx##ClassName.WndProc(var Msg: TLMessage);
var
  IdSaveDC: Integer;
  DlgCodes: TDlgCodes;
  WCanvas: TCanvas;
begin
  if not DispatchIsDesignMsg(Self, Msg) then
  begin
    case Msg.Msg of
      EDITCONTROL_WNDPROC_CASES
    else
      inherited WndProc(Msg);
    end;
    // TODO:
    // LM_NCPAINT isn't send by LCL, may be .Net highlighting can't be implemented.
    case Msg.Msg of // precheck message to prevent access violations on released controls
      CM_MOUSEENTER, CM_MOUSELEAVE, LM_KILLFOCUS, LM_SETFOCUS, LM_NCPAINT:
        if DotNetHighlighting then
          HandleDotNetHighlighting(Self, Msg, MouseOver, Color);
    end;
  end;
end;
*)

// *************************************************************************
// *************************************************************************

// ****************** Default-Helpers ********************

(*$DEFINE CONTROL_IMPL_DEFAULT(ClassName)
BEGIN_CONTROL_CONSTRUCTOR(ClassName)
END_CONSTRUCTOR

CONTROL_IMPL(ClassName)

CONTROL_WNDPROC(ClassName)

//============================================================================

*)

(*$DEFINE WINCONTROL_IMPL_DEFAULT(ClassName)
BEGIN_WINCONTROL_CONSTRUCTOR(ClassName)
END_CONSTRUCTOR

WINCONTROL_IMPL(ClassName)

WINCONTROL_WNDPROC(ClassName)

//============================================================================

*)

(*$DEFINE EDITCONTROL_IMPL_DEFAULT(ClassName)
BEGIN_EDITCONTROL_CONSTRUCTOR(ClassName)
END_CONSTRUCTOR

EDITCONTROL_IMPL(ClassName)

EDITCONTROL_WNDPROC(ClassName)

//============================================================================

*)

