{-----------------------------------------------------------------------------
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: JvExControls.macros, released on 2004-09-29

The Initial Developer of the Original Code is André Snepvangers [ASnepvangers att users.sourceforge.net]
Portions created by André Snepvangers are Copyright (C) 2004 André Snepvangers.
All Rights Reserved.

Contributor(s): Andreas Hausladen.

You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http:(jvcl.sourceforge.net

Description:

This file contains macro's needed to build the JvExVCL classes.
You need the Pascal PreProcessor (dpp) from Andreas Hausladen [Andreas dott Hausladen att gmx dott de]
to process these files. It is included with JVCL 3 (devtools\dpp32).

Known Issues:

-----------------------------------------------------------------------------}

// 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/JvExCLX/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.
 ****************************************************************************}
*)

(*$DEFINE UNITVERSION
const
  UnitVersion = '$Id: JvExControls.macros 8470 2004-11-01 01:19:09Z asnepvangers $';

initialization
  OutputDebugString(PChar('Opened' + RightStr(UnitVersion, Length(UnitVersion) - 4)));

finalization
  OutputDebugString(PChar('Closed' + RightStr(UnitVersion, Length(UnitVersion) - 4)));
EMPTYLINE
*)

{$UNDEF CREATE_CUSTOMCODE}
{$UNDEF DESTROY_CUSTOMCODE}
{$UNDEF IFISNOTCUSTOMFORM}
{$UNDEF PUBLISHAUTOSIZE}
{$UNDEF BOUNDSCHANGED_DIRECTIVE}
{$UNDEF BOUNDSCHANGED_CODE}

{$DEFINE EMPTYLINE}
{$DEFINE CREATE_CUSTOMCODE}
{$DEFINE DESTROY_CUSTOMCODE}
{$DEFINE IFISNOTCUSTOMFORM}
{$DEFINE PUBLISHAUTOSIZE}
{$DEFINE BOUNDSCHANGED_CODE}

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

(*$DEFINE JV_DECL_CONTROL
  { Control }
  private
    FAboutJVCL: TJVCLAboutInfo;
    FHintColor: TColor;
    FMouseOver: Boolean;
    FOnParentColorChanged: TNotifyEvent;
    FOnMouseEnter: TNotifyEvent;
    FOnMouseLeave: TNotifyEvent;
  protected
    procedure WndProc(var Mesg: TMessage); override;
    procedure ColorChanged; virtual;
    procedure EnabledChanged; virtual;
    procedure FocusChanged; virtual;
    procedure FontChanged; virtual;
//    function GetText: TCaption; virtual;
    function HintShow(var HintInf: THintInfo): Boolean; virtual;
    function HitTest(X, Y: Integer): Boolean; virtual;
    procedure MouseEnter(AControl: TControl); virtual;
    procedure MouseLeave(AControl: TControl); virtual;
    procedure ParentColorChanged; virtual;
    procedure ParentFontChanged; virtual;
    procedure ParentShowHintChanged; virtual;
    //    procedure SetText(Value: TCaption); virtual;
    procedure TextChanged; virtual;
    procedure VisibleChanged; virtual;
    function WantKey(Key: Integer; Shift: TShiftState;
      const KeyText: WideString): Boolean; virtual;
    {$IFNDEF COMPILER6_UP}
    function GetAutoSize: Boolean; virtual;
    procedure SetAutoSize(Value: Boolean); virtual;
    {$ENDIF !COMPILER6_UP}
    property MouseOver: Boolean read FMouseOver write FMouseOver;
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    property OnParentColorChange: TNotifyEvent read FOnParentColorChanged write FOnParentColorChanged;
    {$IFNDEF COMPILER6_UP}
  PUBLISHAUTOSIZE
    property AutoSize: Boolean read GetAutoSize write SetAutoSize;
    {$ENDIF !COMPILER6_UP}
  published
    property AboutJVCL: TJVCLAboutInfo read FAboutJVCL write FAboutJVCL stored False;
    property HintColor: TColor read FHintColor write FHintColor default clDefault;
*)

(*$DEFINE JV_CONTROL_BEGIN(ClassName)
  { Control begin }
  TJvEx##ClassName = class(T##ClassName)
  JV_DECL_CONTROL
*)

(*$DEFINE JV_CONTROL_END(ClassName)
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

  { Control }
  TJvExPub##ClassName = class(TJvEx##ClassName)
  published
    property BiDiMode;
    property DragCursor;
    property DragKind;
    property DragMode;
    property ParentBiDiMode;
    property OnEndDock;
    property OnStartDock;
  end;
  EMPTYLINE
*)

(*$DEFINE JV_CONTROL(ClassName)
  JV_CONTROL_BEGIN(ClassName)
  JV_CONTROL_END(ClassName)
*)

// JvInplaceEdit BoundsChanged;
{$DEFINE BOUNDSCHANGED_DIRECTIVE virtual}

(*$DEFINE JV_DECL_WINCONTROL
  { WinControl }
  private
    FInputKeys: TJvInputKeys;
  protected
    procedure BoundsChanged; BOUNDSCHANGED_DIRECTIVE;
    procedure CursorChanged; virtual;
    procedure DoKillFocus(NextWnd: HWND); virtual;
    procedure DoSetFocus(PreviousWnd: HWND); virtual;
    function DoEraseBackground(ACanvas: TCanvas; LParam: Integer): Boolean; virtual;
    procedure ShowingChanged; virtual;
    procedure ShowHintChanged; virtual;
    property InputKeys: TJvInputKeys read FInputKeys write FInputKeys;
*)

(*$DEFINE JV_WINCONTROL_BEGIN(ClassName)
  { WinControl }
  TJvEx##ClassName = class(T##ClassName)
  JV_DECL_CONTROL
  JV_DECL_WINCONTROL
*)

(*$DEFINE JV_CUSTOMCONTROL_END(ClassName)
  { CustomControl }
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

  TJvExPub##ClassName = class(TJvEx##ClassName)
  published
    property BiDiMode;
    property DragCursor;
    property DragKind;
    property DragMode;
    property ParentBiDiMode;
    property OnEndDock;
    property OnStartDock;
  end;
  EMPTYLINE
*)

(*$DEFINE JV_WINCONTROL_END(ClassName)
  { WinControl }
  private
    FCanvas: TCanvas;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property Canvas: TCanvas read FCanvas;
  end;

  TJvExPub##ClassName = class(TJvEx##ClassName)
  published
    property BiDiMode;
    property DragCursor;
    property DragKind;
    property DragMode;
    property ParentBiDiMode;
    property OnEndDock;
    property OnStartDock;
  end;
  EMPTYLINE
*)

(*$DEFINE JV_CUSTOMCONTROL(ClassName)
  JV_WINCONTROL_BEGIN(ClassName)
  JV_CUSTOMCONTROL_END(ClassName)
*)

(*$DEFINE JV_WINCONTROL(ClassName)
  JV_WINCONTROL_BEGIN(ClassName)
  JV_WINCONTROL_END(ClassName)
*)

(*$DEFINE JV_DECL_EDITCONTROL
  { EditControl }
  private
    FClipboardCommands: TJvClipboardCommands;
  published
    property ClipboardCommands: TJvClipboardCommands read FClipboardCommands
      write FClipboardCommands default [caCopy..caUndo];
*)

(*$DEFINE JV_EDITCONTROL_BEGIN(ClassName)
  { EditControl Begin }
  TJvEx##ClassName = class(T##ClassName)
  JV_DECL_CONTROL
  JV_DECL_WINCONTROL
  JV_DECL_EDITCONTROL
*)

(*$DEFINE JV_EDITCONTROL_END(ClassName)
  { EditControl End }
  private
    FCanvas: TCanvas;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property Canvas: TCanvas read FCanvas;
  end;

  { EditControl }
  TJvExPub##ClassName = class(TJvEx##ClassName);
  EMPTYLINE
*)

(*$DEFINE JV_EDITCONTROL(ClassName)
  JV_EDITCONTROL_BEGIN(ClassName)
  JV_EDITCONTROL_END(ClassName)
*)

//
// CustomForm
//

(*$DEFINE JV_DECL_CUSTOMFORM
  { CustomForm }
  public
    constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
*)

(*$DEFINE JV_CUSTOMFORM_BEGIN(ClassName)
  { CustomForm }
  TJvEx##ClassName = class(T##ClassName)
  JV_DECL_CONTROL
  JV_DECL_WINCONTROL
  JV_DECL_CUSTOMFORM
*)

(*$DEFINE JV_CUSTOMFORM_END(ClassName)
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

  { CustomForm }
  TJvExPub##ClassName = class(TJvEx##ClassName)
  published
    property BiDiMode;
    property DragCursor;
    property DragKind;
    property DragMode;
    property ParentBiDiMode;
    property OnEndDock;
    property OnStartDock;
  end;
  EMPTYLINE
*)

(*$DEFINE JV_CUSTOMFORM(ClassName)
  JV_CUSTOMFORM_BEGIN(ClassName)
  JV_CUSTOMFORM_END(ClassName)
*)


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

(*$DEFINE JV_IMPL_CONTROL_MESSAGES
    { Control Messages }
      CM_COLORCHANGED       : ColorChanged;
      CM_ENABLEDCHANGED     : EnabledChanged;
      CM_FOCUSCHANGED       : FocusChanged;
      CM_FONTCHANGED        : FontChanged;
      CM_TEXTCHANGED        : TextChanged ;
      CM_MOUSEENTER         : MouseEnter(Self);
      CM_MOUSELEAVE         : MouseLeave(Self);
      CM_PARENTCOLORCHANGED : ParentColorChanged;
      CM_PARENTFONTCHANGED  : ParentFontChanged;
      CM_HITTEST            : if HitTest(XPos, YPos) then
                                Result := HTCLIENT;

*)

(*
      WM_GETTEXT:
      begin
        GetText;
      end;

      WM_SETTEXT:
      begin
        (*
        The return value is TRUE if the text is set.
        It is FALSE (for an edit control),
        LB_ERRSPACE (for a list box), or
        CB_ERRSPACE (for a combo box)
        if insufficient space is available to set the text in the edit control.
        It is CB_ERR if this message is sent to a combo box without an edit control.
        *)
        if Value = Self.Text then
          Handled := True
        else
        begin
          SetText(TJvMessage(Mesg).Text);
          if GetText <> TJvMessage(Mesg).Text then
          begin
            if Self is TCustomEdit then
              Handled := False
            else
              Result := LB_ERRSPACE; { CB_ERRSPACE = LB_ERRSPACE }
          end
          else
            Handled := True;
        end;
        Exit;
      end;
*)


(*$DEFINE JV_IMPL_CONTROL(ClassName)
{ Control }
procedure TJvEx##ClassName.WndProc(var Mesg: TMessage);
begin
  with TJvMessage(Mesg) do
  begin
    case Msg of
      JV_IMPL_CONTROL_MESSAGES

      CM_HINTSHOW:
      begin
        case FHintColor of
          clNone   : HintInfo^.HintColor := Application.HintColor;
	  clDefault: HintInfo^.HintColor := GetHintColor(Parent);
        else
          HintInfo^.HintColor := FHintcolor;   
        end;
        Handled := HintShow(HintInfo^);
      end;
    end;
  end;
  if Mesg.Result = 0  then
    inherited WndProc(Mesg);
end;
 EMPTYLINE
*)

(*$DEFINE JV_IMPL_CONTROL_COMMON(ClassName)
{ Control Common }
{$IFNDEF COMPILER6_UP}
procedure TJvEx##ClassName.SetAutoSize(Value: Boolean);
begin
  inherited AutoSize := Value;
end;

function TJvEx##ClassName.GetAutoSize: Boolean;
begin
  Result := inherited AutoSize;
end;
{$ENDIF !COMPILER6_UP}

procedure TJvEx##ClassName.ColorChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.EnabledChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.FocusChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.FontChanged;
begin
  { notification }
end;

function TJvEx##ClassName.HintShow(var HintInf: THintInfo): Boolean;
var
  Mesg: TMessage;
begin
  with TJvMessage(Mesg) do
  begin
    Msg := CM_HINTSHOW;
    HintInfo := @HintInf;
    Handled := False;
  end;
  inherited WndProc(Mesg);
  Result := Mesg.Result <> 0;
end;

function TJvEx##ClassName.HitTest(X, Y: Integer): Boolean;
var
  Mesg: TMessage;
begin
  with TJvMessage(Mesg) do
  begin
    msg := CM_HITTEST;
    XPos := X;
    YPos := Y;
    Mesg.Result := 0;
  end;
  inherited WndProc(Mesg);
  Result := Mesg.Result = HTCLIENT;
end;

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

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

procedure TJvEx##ClassName.ParentColorChanged;
begin
  if Assigned(FOnParentColorChanged) then
    FOnParentColorChanged(Self);
end;

procedure TJvEx##ClassName.ParentFontChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.ParentShowHintChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.TextChanged;
begin
  { notification }
end;
procedure TJvEx##ClassName.VisibleChanged;
begin
  { notification }
end;

function TJvEx##ClassName.WantKey(Key: Integer; Shift: TShiftState;
  const KeyText: WideString): Boolean;
var
  Mesg: TMessage;
begin
  with TJvMessage(Mesg) do
  begin
    Msg := CM_DIALOGCHAR;
    CharCode := Key;
    KeyData := ShiftStateToKeyData(Shift);
    Handled := False;
  end;
  inherited WndProc(Mesg);
  Result := Mesg.Result <> 0 ;
end;
  EMPTYLINE
*) // MACRO END JV_IMPL_CONTROL_COMMON

(*
function TJvEx##ClassName.NeedKey(Key: Integer; Shift: TShiftState;
  const KeyText: WideString): Boolean;
begin
  Result := (csDesigning in ComponentState) or
    DoCheckInputKeys(FInputKeys, Key, Shift, KeyText);
end;


function TJvEx##ClassName.GetText: TCaption;
var
  Len: Integer;
  Mesg: TMessage;
begin
  Len := Perform(WM_GETTEXTLENGTH, 0, 0);
  SetString(Result, PChar(nil), Len);
  if Len <> 0 then
  begin
    Mesg.Msg := WM_GETTEXT;
    Mesg.WParam := Len + 1;
    TJvMessage(Mesg).Text := PChar(Result);
    Mesg.Result := 0;
    inherited WndProc(Mesg);
  end
  else
    Result := '';
end;

procedure TJvEx##ClassName.SetText(const Value: TCaption);
var
  Mesg: TMessage;
begin
  Mesg.Msg := WM_SETTEXT;
  Mesg.LParam := 0;
  TJvMessage(Mesg).Text := PChar(Value);
  Mesg.Result := 0;
  inherited WndProc(Mesg);
end;
 EMPTYLINE
*)

(*$DEFINE JV_IMPL_CONTROL_CREATE(ClassName)
{ Control Create }
constructor TJvEx##ClassName.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FHintColor := clDefault;
  CREATE_CUSTOMCODE
end;

destructor TJvEx##ClassName.Destroy;
begin
  DESTROY_CUSTOMCODE
  inherited Destroy;
end;
 EMPTYLINE
*)

(*$DEFINE JV_CONTROL_IMPL(ClassName)
JV_IMPL_CONTROL_CREATE(ClassName)
JV_IMPL_CONTROL(ClassName)
JV_IMPL_CONTROL_COMMON(ClassName)
*)

(*$DEFINE JV_IMPL_WINCONTROL_MESSAGES
      { WinControl Messages }
      WM_SETFOCUS   : DoSetFocus(FocusedWnd);
      WM_KILLFOCUS  : if not (csFocusing in ControlState) then
                        DoKillFocus(FocusedWnd);
      WM_GETDLGCODE : if not (ikNative in FInputKeys) then
                        Result := InputKeysToDlgCodes(FInputKeys);
      WM_ERASEBKGND :
      begin
        Canvas.Lock;
        try
          Canvas.Handle := DC;
          try
            Handled := DoEraseBackGround(Canvas, LParam);
          finally
            Canvas.Handle := 0;
          end;
        finally
          Canvas.Unlock;
        end;
      end;
      CM_HINTSHOW: 
      begin
        HintInfo^.HintColor := GetHintcolor(Self);   
        Handled := HintShow(HintInfo^);
      end;
*)

(*$DEFINE JV_IMPL_WINCONTROL(ClassName)
{ WinControl }
procedure TJvEx##ClassName.WndProc(var Mesg: TMessage);
begin
  with TJvMessage(Mesg) do
  begin
    case Msg of
      JV_IMPL_CONTROL_MESSAGES
      JV_IMPL_WINCONTROL_MESSAGES
    end;
  end;
  if Mesg.Result = 0 then
    inherited WndProc(Mesg);
end;
 EMPTYLINE
*)

(*$DEFINE JV_IMPL_WINCONTROL_COMMON(ClassName)
{ WinControl Common}
procedure TJvEx##ClassName.DoSetFocus(PreviousWnd: HWND);
begin
  { notification }
end;

procedure TJvEx##ClassName.DoKillFocus(NextWnd: HWND);
begin
  { notification }
end;

function TJvEx##ClassName.DoEraseBackground(ACanvas: TCanvas; LParam: Integer): Boolean;
begin
  Result := false;
end;

procedure TJvEx##ClassName.BoundsChanged;
begin
  { notification }
  BOUNDSCHANGED_CODE
end;

procedure TJvEx##ClassName.CursorChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.FocusChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.ShowingChanged;
begin
  { notification }
end;

procedure TJvEx##ClassName.ShowHintChanged;
begin
  { notification }
end;
  EMPTYLINE
*) // MACRO END WINCONTROL

(*$DEFINE JV_IMPL_WINCONTROL_CREATE(ClassName)
{ WinControl Create }
constructor TJvEx##ClassName.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FHintColor := clDefault;
  FInputKeys := [ikNative];
  FCanvas := TControlCanvas.Create;
  TControlCanvas(FCanvas).Control := Self;
  CREATE_CUSTOMCODE
end;

destructor TJvEx##ClassName.Destroy;
begin
  DESTROY_CUSTOMCODE
  FCanvas.Free;
  inherited Destroy;
end;
 EMPTYLINE
*)

(*$DEFINE JV_WINCONTROL_IMPL(ClassName)
JV_IMPL_WINCONTROL_CREATE(ClassName)
JV_IMPL_WINCONTROL(ClassName)
JV_IMPL_WINCONTROL_COMMON(ClassName)
JV_IMPL_CONTROL_COMMON(ClassName)
*)

(*$DEFINE JV_IMPL_CUSTOMCONTROL_CREATE(ClassName)
{ CustomControl Create }
constructor TJvEx##ClassName.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FHintColor := clDefault;
  FInputKeys := [ikNative];
  CREATE_CUSTOMCODE
end;

destructor TJvEx##ClassName.Destroy;
begin
  DESTROY_CUSTOMCODE
  inherited Destroy;
end;
 EMPTYLINE
*)

(*$DEFINE JV_CUSTOMCONTROL_IMPL(ClassName)
JV_IMPL_CUSTOMCONTROL_CREATE(ClassName)
JV_IMPL_WINCONTROL(ClassName)
JV_IMPL_WINCONTROL_COMMON(ClassName)
JV_IMPL_CONTROL_COMMON(ClassName)
*)

(*$DEFINE JV_IMPL_EDITCONTROL(ClassName)
{ EditControl }
procedure TJvEx##ClassName.WndProc(var Mesg: TMessage);
begin
  with TJvMessage(Mesg) do
  begin
    case Msg of
      JV_IMPL_CONTROL_MESSAGES
      JV_IMPL_WINCONTROL_MESSAGES

      WM_CLEAR, WM_COPY, WM_CUT,
      WM_PASTE, WM_UNDO, EM_UNDO:
        Handled := DoClipBoardCommands(msg, FClipBoardCommands);
    end;
  end;
  if Mesg.Result = 0  then
    inherited WndProc(Mesg);
end;
  EMPTYLINE
*) // end of JV_IMPL_EDITCONTROL

(*$DEFINE JV_EDITCONTROL_IMPL(ClassName)
JV_IMPL_WINCONTROL_CREATE(ClassName)
JV_IMPL_EDITCONTROL(ClassName)
JV_IMPL_WINCONTROL_COMMON(ClassName)
JV_IMPL_CONTROL_COMMON(ClassName)
*)

// ********************** CUSTOMFORM **************************

(*$DEFINE JV_IMPL_CUSTOMFORM(ClassName)
{ CustomForm }
constructor TJvEx##ClassName.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
  inherited CreateNew(AOwner, Dummy);
  FHintColor := clDefault;
  FInputKeys := [ikNative];
  CREATE_CUSTOMCODE
end;
  EMPTYLINE
*) // MACRO END JV_IMPL_CUSTOMFORM

(*$DEFINE JV_CUSTOMFORM_IMPL(ClassName)
JV_IMPL_CUSTOMCONTROL_CREATE(ClassName)
JV_IMPL_CUSTOMFORM(ClassName)
JV_IMPL_WINCONTROL(ClassName)
JV_IMPL_WINCONTROL_COMMON(ClassName)
JV_IMPL_CONTROL_COMMON(ClassName)
*)

