Added shortcut keys to labels

Support for alphabetically sorting the properties
Standardize message and add shortcuts ala Kylix
Published BorderStyle, unpublished BorderWidth
ShowAccelChar and FocusControl
ShowAccelChar and FocusControl for TLabel, escaped ampersands now work.

git-svn-id: trunk@3278 -
This commit is contained in:
lazarus 2002-09-03 11:32:49 +00:00
parent c63ab4f76d
commit da2e467433
6 changed files with 234 additions and 148 deletions

View File

@ -316,6 +316,12 @@ implementation
const
ScrollBarWidth=0;
function SortGridRows(Item1, Item2 : pointer) : integer;
begin
Result:= AnsiCompareText(TOIPropertyGridRow(Item1).Name, TOIPropertyGridRow(Item2).Name);
end;
{ TOIPropertyGrid }
constructor TOIPropertyGrid.Create(AnOwner:TComponent;
@ -754,6 +760,8 @@ begin
FRows.Clear;
GetComponentProperties(FPropertyEditorHook,FComponentList,FFilter,
@AddPropertyEditor);
FRows.Sort(@SortGridRows);
SetItemsTops;
for a:=FExpandedProperties.Count-1 downto 0 do begin
CurRow:=GetRowByPath(FExpandedProperties[a]);

View File

@ -132,8 +132,9 @@ begin
Left:=8;
Top:=8;
Width:= 100;
Caption:='Text to Find';
Caption:='&Text to Find';
Visible:=true;
FocusControl:= TextToFindComboBox;
end;
ReplaceTextComboBox:=TComboBox.Create(Self);
@ -156,8 +157,9 @@ begin
Left:=8;
Top:=32;
Width:= 100;
Caption:='Replace With';
Caption:='&Replace With';
Visible:=true;
FocusControl:= ReplaceTextComboBox;
end;
OptionsGroupBox:=TGroupBox.Create(Self);

View File

@ -63,7 +63,6 @@ type
TIDesigner = class;
TCloseEvent = procedure(Sender: TObject; var Action: TCloseAction) of object;
TCloseQueryEvent = procedure(Sender : TObject; var CanClose : boolean) of object;
TFormState = set of (fsCreating, fsVisible, fsShowing, fsModal, fsCreatedMDIChild);
@ -77,6 +76,7 @@ type
FCanvas : TControlCanvas;
FDesigner : TIDesigner;
FFormStyle : TFormStyle;
FFormState: TFormState;
FIcon: TIcon;
FKeyPreview: Boolean;
FMenu : TMainMenu;
@ -92,46 +92,45 @@ type
FOnCloseQuery : TCloseQueryEvent;
FPosition : TPosition;
FWindowState : TWindowState;
Procedure ClientWndProc(var Message: TLMessage);
procedure ClientWndProc(var Message: TLMessage);
procedure CloseModal;
procedure DoCreate;
procedure DoDestroy;
Procedure SetActiveControl(Value : TWinControl);
Procedure SetBorderStyle(Value : TFORMBorderStyle);
Procedure SetDesigner(Value : TIDesigner);
Procedure SetMenu(Value : TMainMenu);
Procedure SetFormStyle(Value : TFormStyle);
procedure SetActiveControl(Value : TWinControl);
procedure SetBorderStyle(Value : TFORMBorderStyle);
procedure SetDesigner(Value : TIDesigner);
procedure SetMenu(Value : TMainMenu);
procedure SetFormStyle(Value : TFormStyle);
procedure SetIcon(AValue: TIcon);
Procedure SetPosition(Value : TPosition);
Procedure SetVisible(Value: boolean);
Procedure SetWindowState(Value : TWIndowState);
Function GetCanvas: TControlCanvas;
Function IsForm : Boolean;
procedure SetPosition(Value : TPosition);
procedure SetVisible(Value: boolean);
procedure SetWindowState(Value : TWIndowState);
function GetCanvas: TControlCanvas;
function IsForm : Boolean;
procedure IconChanged(Sender: TObject);
function IsIconStored: Boolean;
{ events }
Procedure WMActivate(var Message : TLMActivate); message LM_Activate;
procedure WMActivate(var Message : TLMActivate); message LM_Activate;
procedure WMPaint(var message: TLMPaint); message LM_PAINT;
procedure WMSize(var message: TLMSize); message LM_Size;
procedure WMShowWindow(var message: TLMShowWindow); message LM_SHOWWINDOW;
procedure WMCloseQuery(var message: TLMessage); message LM_CLOSEQUERY;
procedure WMDestroy(var message: TLMDestroy); message LM_DESTROY;
protected
FFormState: TFormState;
function CloseQuery : boolean; virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
Procedure DeActivate; dynamic;
procedure DeActivate; dynamic;
procedure DoClose(var Action: TCloseAction); dynamic;
procedure DoHide; dynamic;
procedure DoShow; dynamic;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
// Delphi needed GetClientRect for window specific things, LCL not
// Function GetClientRect : TRect ; Override;
Procedure Notification(AComponent: TComponent; Operation : TOperation);override;
procedure Notification(AComponent: TComponent; Operation : TOperation);override;
procedure Paint; dynamic;
Procedure PaintWindow(dc : Hdc); override;
Procedure RequestAlign; override;
procedure PaintWindow(dc : Hdc); override;
procedure RequestAlign; override;
procedure UpdateShowing; override;
procedure UpdateWindowState;
procedure ValidateRename(AComponent: TComponent;
@ -140,7 +139,6 @@ type
{events}
property ActiveControl : TWinControl read FActiveControl write SetActiveControl;
property Icon: TIcon read FIcon write SetIcon stored IsIconStored;
property FormStyle : TFormStyle read FFormStyle write SetFormStyle default fsNormal;
property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
property OnClose: TCloseEvent read FOnClose write FOnClose stored IsForm;
property OnCloseQuery : TCloseQueryEvent
@ -162,16 +160,17 @@ type
procedure Close;
procedure Hide;
function WantChildKey(Child : TControl; var MEssage : TLMessage): Boolean; virtual;
Procedure SetFocus; override;
procedure SetFocus; override;
function SetFocusedControl(Control : TWinControl): Boolean ; Virtual;
Procedure FocusControl(WinControl : TWinControl);
Function ShowModal : Integer;
procedure FocusControl(WinControl : TWinControl);
function ShowModal : Integer;
property Active : Boolean read FActive;
property BorderStyle : TFormBorderStyle
read FBorderStyle write SetBorderStyle default bsSizeable;
property Canvas: TControlCanvas read GetCanvas;
property Caption stored IsForm;
property Designer : TIDesigner read FDesigner write SetDesigner;
property FormStyle : TFormStyle read FFormStyle write SetFormStyle default fsNormal;
property FormState : TFormState read FFormState;
property KeyPreview: Boolean read FKeyPreview write FKeyPreview;
property Menu : TMainMenu read FMenu write SetMenu;
@ -181,67 +180,67 @@ type
end;
TForm = class(TCustomForm)
private
FClientHandle: HWND;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property ClientHandle: HWND read FClientHandle;
published
property ActiveCOntrol;
property Align;
property AutoSize;
property BorderWidth;
property Caption;
property Color;
property ClientHeight;
property ClientWidth;
property Constraints;
property Enabled;
property FormStyle;
property Icon;
property Menu;
property PopupMenu;
property Position;
property ShowHint;
property Visible;
// property WindowState;
property OnActivate;
property OnCreate;
property OnClose;
property OnCloseQuery;
property OnDeactivate;
property OnDestroy;
property OnShow;
property OnHide;
property OnPaint;
property OnResize;
end;
private
FClientHandle: HWND;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property ClientHandle: HWND read FClientHandle;
published
property ActiveCOntrol;
property Align;
property AutoSize;
property BorderStyle;
property Caption;
property Color;
property ClientHeight;
property ClientWidth;
property Constraints;
property Enabled;
property FormStyle;
property Icon;
property Menu;
property PopupMenu;
property Position;
property ShowHint;
property Visible;
property WindowState;
property OnActivate;
property OnCreate;
property OnClose;
property OnCloseQuery;
property OnDeactivate;
property OnDestroy;
property OnShow;
property OnHide;
property OnPaint;
property OnResize;
end;
TFormClass = class of TForm;
{THintWindow}
THintWindow = class(TCustomForm)
private
FActivating: Boolean;
FAutoHide : Boolean;
FAutoHideTimer : TComponent;
FHideInterval : Integer;
Procedure SetAutoHide(Value : Boolean);
Procedure AutoHideHint(Sender : TObject);
Procedure SetHideInterval(Value : Integer);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure ActivateHint(Rect: TRect; const AHint: String); virtual;
function CalcHintRect(MaxWidth: Integer; const AHint: String; AData: Pointer): TRect; virtual;
property Color;
property AutoHide : Boolean read FAutoHide write SetAutoHide;
property HideInterval : Integer read FHideInterval write SetHideInterval;
{THintWindow}
THintWindow = class(TCustomForm)
private
FActivating: Boolean;
FAutoHide : Boolean;
FAutoHideTimer : TComponent;
FHideInterval : Integer;
procedure SetAutoHide(Value : Boolean);
procedure AutoHideHint(Sender : TObject);
procedure SetHideInterval(Value : Integer);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure ActivateHint(Rect: TRect; const AHint: String); virtual;
function CalcHintRect(MaxWidth: Integer; const AHint: String; AData: Pointer): TRect; virtual;
property Color;
property AutoHide : Boolean read FAutoHide write SetAutoHide;
property HideInterval : Integer read FHideInterval write SetHideInterval;
end;
@ -250,15 +249,15 @@ type
FFormList: TList;
FHintFont : TFont;
FPixelsPerInch : integer;
Function GetFormCount: Integer;
Function GetForms(IIndex: Integer): TForm;
function GetFormCount: Integer;
function GetForms(IIndex: Integer): TForm;
function GetHeight : Integer;
function GetWidth : Integer;
procedure AddForm(FForm: TCustomForm);
procedure RemoveForm(FForm: TCustomForm);
public
constructor Create(AOwner : TComponent); override;
Destructor Destroy; Override;
destructor Destroy; Override;
property FormCount: Integer read GetFormCount;
property Forms[Index: Integer]: TForm read GetForms;
property PixelsPerInch : integer read FPixelsPerInch;

View File

@ -986,7 +986,7 @@ begin
try
Show;
try
CNSendMessage(LM_ShowModal, Self, nil);
CNSendMessage(LM_SHOWMODAL, Self, nil);
Repeat
{ Delphi calls Application.HandleMessage
But HandleMessage processes all pending events and then calls idle,
@ -1025,6 +1025,14 @@ end;
{ =============================================================================
$Log$
Revision 1.55 2002/09/03 11:32:49 lazarus
Added shortcut keys to labels
Support for alphabetically sorting the properties
Standardize message and add shortcuts ala Kylix
Published BorderStyle, unpublished BorderWidth
ShowAccelChar and FocusControl
ShowAccelChar and FocusControl for TLabel, escaped ampersands now work.
Revision 1.54 2002/09/03 08:07:19 lazarus
MG: image support, TScrollBox, and many other things from Andrew

View File

@ -18,68 +18,6 @@
*****************************************************************************
}
{------------------------------------------------------------------------------
Method: TCustomLabel.SetLayout
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetLayout(Value : TTextLayout);
begin
if FLayout <> Value then
begin
FLayout := Value;
CNSendMessage(LM_SETPROPERTIES,Self,nil);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetAlignment
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetAlignment(Value : TAlignment);
begin
if fAlignment <> value then
Begin
fAlignment := value;
handleneeded;
invalidate;
CNSendMessage(LM_SETPROPERTIES,Self,nil);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetWordWrap
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetWordWrap(Value : Boolean);
Begin
if fWordWrap <> value then
Begin
fWordWrap := value;
HandleNeeded;
invalidate;
CNSendMessage(LM_SETPROPERTIES,Self,nil);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.GetLabelText
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
function TCustomLabel.GetLabelText: String;
begin
GetLabelText := Caption;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.Create
Params: AOwner: the owner of the class
@ -92,15 +30,128 @@ begin
inherited Create(AOwner);
fCompStyle := csLabel;
FLayout := tlTop;
FShowAccelChar:= true;
ControlStyle := ControlStyle + [csOpaque, csReplicatable];
SetBounds(0, 0, 65, 17);
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.GetLabelText
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
function TCustomLabel.GetLabelText: String;
begin
GetLabelText:= Caption;
end;
procedure TCustomLabel.Notification(AComponent : TComponent; Operation : TOperation);
begin
inherited Notification(AComponent, Operation);
if (AComponent = FFocusControl) and (Operation = opRemove) then FFocusControl:= nil;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetAlignment
Params: Value - new proterty value
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetAlignment(Value : TAlignment);
begin
if fAlignment <> value then begin
fAlignment:= value;
HandleNeeded;
Invalidate;
CNSendMessage(LM_SETPROPERTIES, Self, nil);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetFocusControl
Params: Val - new property value
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetFocusControl(Val : TWinControl);
begin
if Val <> FFocusControl then begin
FFocusControl:= Val;
if Val <> nil then Val.FreeNotification(Self);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetLayout
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetLayout(Value : TTextLayout);
begin
if FLayout <> Value then begin
FLayout:= Value;
CNSendMessage(LM_SETPROPERTIES, Self, nil);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetShowAccelChar
Params: Val - new property value
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetShowAccelChar(Val : boolean);
begin
if Val <> FShowAccelChar then begin
FShowAccelChar:= Val;
CNSendMessage(LM_SETLABEL, Self, PChar(Caption));
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.SetWordWrap
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TCustomLabel.SetWordWrap(Value : Boolean);
begin
if fWordWrap <> value then begin
fWordWrap:= value;
HandleNeeded;
Invalidate;
CNSendMessage(LM_SETPROPERTIES, Self, nil);
end;
end;
{------------------------------------------------------------------------------
Method: TCustomLabel.WMActivate
Params: Message: Activation message
Returns: Nothing
Received when the label has a registered activation shortcut for focuscontrol.
------------------------------------------------------------------------------}
procedure TCustomLabel.WMActivate(var Message: TLMActivate);
begin
if (FFocusControl <> nil) and (FFocusControl.CanFocus) then
FFocusControl.SetFocus;
end;
// included by stdctrls.pp
{ =============================================================================
$Log$
Revision 1.5 2002/09/03 11:32:49 lazarus
Added shortcut keys to labels
Support for alphabetically sorting the properties
Standardize message and add shortcuts ala Kylix
Published BorderStyle, unpublished BorderWidth
ShowAccelChar and FocusControl
ShowAccelChar and FocusControl for TLabel, escaped ampersands now work.
Revision 1.4 2002/08/30 10:06:07 lazarus
Fixed alignment of multiline TLabel.
Simplified and prettified MessageBoxen.

View File

@ -423,13 +423,21 @@ type
FAlignment : TAlignment;
FWordWrap : Boolean;
FLayout : TTextLayout;
FFocusControl : TWinControl;
FShowAccelChar : boolean;
procedure SetAlignment(Value : TAlignment);
procedure SetLayout(Value : TTextLayout);
procedure SetWordWrap(Value : Boolean);
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
protected
function GetLabelText: String ; virtual;
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
procedure SetFocusControl(Val : TWinControl); virtual;
procedure SetShowAccelChar(Val : boolean); virtual;
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property FocusControl : TWinControl read FFocusControl write SetFocusControl;
property Layout: TTextLayout read FLayout write SetLayout default tlBottom;
property ShowAccelChar : boolean read FShowAccelChar write SetShowAccelChar default true;
property WordWrap: Boolean read FWordWrap write SetWordWrap default false;
public
constructor Create(AOwner : TComponent); override;
@ -445,9 +453,11 @@ type
property Anchors;
property Caption;
property Color;
property FocusControl;
property Font;
property Visible;
property Layout;
property ShowAccelChar;
property WordWrap;
end;
@ -612,7 +622,7 @@ Function DeleteAmpersands(var Str : String) : Longint;
implementation
uses LCLLinux, LCLType;
uses LCLLinux, LCLType, Interfaces;
type
@ -711,6 +721,14 @@ end.
{ =============================================================================
$Log$
Revision 1.40 2002/09/03 11:32:49 lazarus
Added shortcut keys to labels
Support for alphabetically sorting the properties
Standardize message and add shortcuts ala Kylix
Published BorderStyle, unpublished BorderWidth
ShowAccelChar and FocusControl
ShowAccelChar and FocusControl for TLabel, escaped ampersands now work.
Revision 1.39 2002/09/03 08:07:19 lazarus
MG: image support, TScrollBox, and many other things from Andrew