convert LM_BTNDEFAULT_CHANGED message to interface method

git-svn-id: trunk@5970 -
This commit is contained in:
micha 2004-09-11 14:54:01 +00:00
parent b09d407049
commit 9331f9ce12
7 changed files with 59 additions and 32 deletions

View File

@ -61,7 +61,7 @@ end;
procedure TCustomButton.DoSendBtnDefault;
begin
if HandleAllocated then
CNSendMessage(LM_BTNDEFAULT_CHANGED,Self,nil);
TWSButtonClass(WidgetSetClass).DefaultButtonChanged(Self);
end;
procedure TCustomButton.ControlKeyDown(var Key: Word; Shift: TShiftState);
@ -224,6 +224,9 @@ end;
{ =============================================================================
$Log$
Revision 1.35 2004/09/11 14:54:01 micha
convert LM_BTNDEFAULT_CHANGED message to interface method
Revision 1.34 2004/08/26 19:09:34 mattias
moved navigation key handling to TApplication and added options for custom navigation

View File

@ -3164,21 +3164,6 @@ begin
handle := hwnd(ObjectToGtkObject(Sender));
Case LM_Message of
LM_BTNDEFAULT_CHANGED :
Begin
if (TCustomButton(Sender).Default)
and (GTK_WIDGET_CAN_DEFAULT(pgtkwidget(handle))) then
//gtk_widget_grab_default(pgtkwidget(handle))
else begin
{DebugLn('LM_BTNDEFAULT_CHANGED ',TCustomButton(Sender).Name,':',Sender.ClassName,' widget can not grab default ',
' visible=',GTK_WIDGET_VISIBLE(PGtkWidget(Handle)),
' realized=',GTK_WIDGET_REALIZED(PGtkWidget(Handle)),
' mapped=',GTK_WIDGET_MAPPED(PGtkWidget(Handle)),
'');}
// gtk_widget_Draw_Default(pgtkwidget(Handle)); //this isn't right but I'm not sure what to call
end;
end;
LM_DESTROY :
DestroyLCLComponent(Sender);
@ -8651,6 +8636,9 @@ end;
{ =============================================================================
$Log$
Revision 1.552 2004/09/11 14:54:01 micha
convert LM_BTNDEFAULT_CHANGED message to interface method
Revision 1.551 2004/09/11 13:38:37 micha
convert LM_BRINGTOFRONT message to interface method
NOTE: was only used for tapplication, not from other controls

View File

@ -57,7 +57,8 @@ type
protected
class procedure SetCallbacks(const AGtkWidget: PGtkWidget; const AWidgetInfo: PWidgetInfo); virtual;
public
class function CreateHandle(const AComponent: TComponent; const AParams: TCreateParams): THandle; override;
class function CreateHandle(const AComponent: TComponent; const AParams: TCreateParams): THandle; override;
class procedure DefaultButtonChanged(const AButton: TCustomButton); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
end;
@ -132,6 +133,21 @@ begin
SetCallbacks(PGtkWidget(Result), WidgetInfo);
end;
procedure TGtkWSButton.DefaultButtonChanged(const AButton: TCustomButton);
begin
if (AButton.Default)
and (GTK_WIDGET_CAN_DEFAULT(pgtkwidget(AButton.Handle))) then
//gtk_widget_grab_default(pgtkwidget(handle))
else begin
{DebugLn('LM_BTNDEFAULT_CHANGED ',TCustomButton(Sender).Name,':',Sender.ClassName,' widget can not grab default ',
' visible=',GTK_WIDGET_VISIBLE(PGtkWidget(Handle)),
' realized=',GTK_WIDGET_REALIZED(PGtkWidget(Handle)),
' mapped=',GTK_WIDGET_MAPPED(PGtkWidget(Handle)),
'');}
// gtk_widget_Draw_Default(pgtkwidget(Handle)); //this isn't right but I'm not sure what to call
end;
end;
function TGtkWSButton.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
begin
// The button text is static, so let the LCL fallback to FCaption

View File

@ -308,15 +308,6 @@ Begin
Exit;
End;
Case LM_Message of
LM_BTNDEFAULT_CHANGED:
Begin
WindowStyle := Windows.GetWindowLong(Handle, GWL_STYLE) and not (BS_DEFPUSHBUTTON or BS_PUSHBUTTON);
If TCustomButton(Sender).Default then
WindowStyle := WindowStyle or BS_DEFPUSHBUTTON
else
WindowStyle := WindowStyle or BS_PUSHBUTTON;
Windows.SendMessage(Handle, BM_SETSTYLE, WindowStyle, 1);
End;
LM_DESTROY:
Begin
If (Sender Is TWinControl) Or (Sender Is TCommonDialog) Then
@ -2575,6 +2566,9 @@ End;
{
$Log$
Revision 1.244 2004/09/11 14:54:01 micha
convert LM_BTNDEFAULT_CHANGED message to interface method
Revision 1.243 2004/09/11 13:38:37 micha
convert LM_BRINGTOFRONT message to interface method
NOTE: was only used for tapplication, not from other controls

View File

@ -45,6 +45,7 @@ type
private
protected
public
class procedure DefaultButtonChanged(const AButton: TCustomButton); override;
end;
{ TWin32WSBitBtn }
@ -71,6 +72,20 @@ implementation
uses
Win32Int, InterfaceBase;
{ TWin32WSButton }
procedure TWin32WSButton.DefaultButtonChanged(const AButton: TCustomButton);
var
WindowStyle: dword;
begin
WindowStyle := Windows.GetWindowLong(AButton.Handle, GWL_STYLE) and not (BS_DEFPUSHBUTTON or BS_PUSHBUTTON);
If AButton.Default then
WindowStyle := WindowStyle or BS_DEFPUSHBUTTON
else
WindowStyle := WindowStyle or BS_PUSHBUTTON;
Windows.SendMessage(AButton.Handle, BM_SETSTYLE, WindowStyle, 1);
end;
{ TWin32WSBitBtn }
const
@ -346,7 +361,7 @@ initialization
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TCustomButton, TWin32WSButton);
RegisterWSComponent(TCustomButton, TWin32WSButton);
RegisterWSComponent(TCustomBitBtn, TWin32WSBitBtn);
// RegisterWSComponent(TCustomSpeedButton, TWin32WSSpeedButton);
////////////////////////////////////////////////////

View File

@ -74,8 +74,6 @@ const
LM_INSERTTOOLBUTTON = LM_ComUser+46;
LM_DELETETOOLBUTTON = LM_ComUser+47;
LM_BTNDEFAULT_CHANGED = LM_ComUser+51;
LM_DRAGINFOCHANGED = LM_COMUSER+53;
//LM_SETENABLED = LM_COMUSER+54;
@ -873,8 +871,6 @@ begin
LM_INSERTTOOLBUTTON :Result:='LM_INSERTTOOLBUTTON';
LM_DELETETOOLBUTTON :Result:='LM_DELETETOOLBUTTON';
LM_BTNDEFAULT_CHANGED :Result:='LM_BTNDEFAULT_CHANGED';
LM_DRAGINFOCHANGED :Result:='LM_DRAGINFOCHANGED';
//LM_SETENABLED :Result:='LM_SETENABLED';
@ -1015,6 +1011,9 @@ end.
{
$Log$
Revision 1.86 2004/09/11 14:54:01 micha
convert LM_BTNDEFAULT_CHANGED message to interface method
Revision 1.85 2004/09/11 13:38:37 micha
convert LM_BRINGTOFRONT message to interface method
NOTE: was only used for tapplication, not from other controls

View File

@ -49,10 +49,14 @@ uses
WSLCLClasses, WSStdCtrls, WSControls;
type
{ TWSButton }
TWSButton = class(TWSButtonControl)
public
class procedure DefaultButtonChanged(const AButton: TCustomButton); virtual;
end;
TWSButtonClass = class of TWSButton;
{ TWSBitBtn }
@ -74,6 +78,14 @@ implementation
// TODO: Can't be virtual abstract ?
{ TWSButton }
procedure TWSButton.DefaultButtonChanged(const AButton: TCustomButton);
begin
end;
{ TWSCustomBitBtn }
procedure TWSBitBtn.SetGlyph(const ABitBtn: TCustomBitBtn;
const AValue: TBitmap);
begin
@ -101,7 +113,7 @@ initialization
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(CustomTButton, TWSButton);
// RegisterWSComponent(TCustomButton, TWSButton);
// RegisterWSComponent(TCustomBitBtn, TWSBitBtn);
// RegisterWSComponent(TCustomSpeedButton, TWSSpeedButton);
////////////////////////////////////////////////////