mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 12:29:29 +02:00
MG: added clicked event to TButton, MessageDialog reacts to return key
git-svn-id: trunk@351 -
This commit is contained in:
parent
2f68152c95
commit
9c0893ff5e
@ -58,7 +58,9 @@ type
|
||||
Procedure SetDefault(Value : Boolean);
|
||||
procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
|
||||
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
|
||||
procedure WMDefaultClicked(var Message: TMessage); message LM_CLICKED;
|
||||
protected
|
||||
procedure AttachSignals; override;
|
||||
procedure Click; override;
|
||||
//TODO: make this compatible
|
||||
procedure CreateWnd; override;
|
||||
@ -235,6 +237,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.10 2001/10/16 10:51:09 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.9 2001/06/14 14:57:58 lazarus
|
||||
MG: small bugfixes and less notes
|
||||
|
||||
|
@ -2,6 +2,21 @@
|
||||
TButton
|
||||
******************************************************************************)
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TButton.AttachSignals
|
||||
Params: none
|
||||
Returns: Nothing
|
||||
|
||||
Gets called after the window is created but before the controls are created
|
||||
and the cached propeties are set.
|
||||
This is the only place where a call to SetCallBack is made.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TButton.AttachSignals;
|
||||
begin
|
||||
inherited AttachSignals;
|
||||
SetCallback(LM_CLICKED);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ TButton Constructor }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -94,9 +109,24 @@ begin
|
||||
FOnLeave(Self);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TButton.CMDefaultClicked
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
|
||||
Handles the event when the button Leaves
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TButton.WMDefaultClicked(var Message: TMessage);
|
||||
begin
|
||||
Click;
|
||||
end;
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.4 2001/10/16 10:51:10 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.3 2001/06/06 12:30:41 lazarus
|
||||
MG: bugfixes
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
{******************************************************************************
|
||||
TNBPages
|
||||
******************************************************************************}
|
||||
|
||||
{ $DEFINE NOTEBOOK_DEBUG}
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
TNBPages Constructor
|
||||
------------------------------------------------------------------------------}
|
||||
@ -53,7 +56,13 @@ begin
|
||||
Msg.Child := TPage(fPageList[Index]);
|
||||
Msg.fCompStyle := fNotebook.fCompStyle;
|
||||
Msg.Str := S;
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TNBPages.Put] A ',Index,' ',S);
|
||||
{$ENDIF}
|
||||
CNSendMessage(LM_SETTEXT, fNotebook, @Msg);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TNBPages.Put] B ');
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -78,8 +87,10 @@ var
|
||||
NewPageIndex: integer;
|
||||
begin
|
||||
// Make sure Index is in the range of valid pages to delete
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
//writeln('TNBPages.Delete A Index=',Index);
|
||||
//writeln('TNBPages.Delete B Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
|
||||
writeln('TNBPages.Delete B Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
|
||||
{$ENDIF}
|
||||
if (Index >= 0) and
|
||||
(Index < fPageList.Count) then
|
||||
begin
|
||||
@ -109,7 +120,9 @@ begin
|
||||
if NewPageIndex>=Index then
|
||||
fNoteBook.PageIndex:=NewPageIndex-1;
|
||||
end;
|
||||
//writeln('TNBPages.Delete END Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('TNBPages.Delete END Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
|
||||
@ -148,7 +161,13 @@ begin
|
||||
Msg.fCompStyle := fNotebook.fCompStyle;
|
||||
Msg.Page := Index;
|
||||
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TNBPages.InsertPage] A ',Index);
|
||||
{$ENDIF}
|
||||
CNSendMessage(LM_ADDPAGE, fNotebook, @Msg);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TNBPages.InsertPage] B ');
|
||||
{$ENDIF}
|
||||
|
||||
fNoteBook.PageIndex := Index;
|
||||
end;
|
||||
@ -209,7 +228,13 @@ var
|
||||
n: Integer;
|
||||
Msg: TLMNotebookEvent;
|
||||
begin
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.CreateWnd] A');
|
||||
{$ENDIF}
|
||||
inherited CreateWnd;
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.CreateWnd] B');
|
||||
{$ENDIF}
|
||||
|
||||
Assert(False, 'Trace:[TCustomNotebook.CreateWnd] add pages');
|
||||
for n := 0 to FPageList.Count -1 do
|
||||
@ -220,7 +245,13 @@ begin
|
||||
Msg.Child := TControl(FPageList[n]);
|
||||
Msg.fCompStyle := FCompStyle;
|
||||
Msg.Page := n;
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.CreateWnd] C ',n);
|
||||
{$ENDIF}
|
||||
CNSendMessage(LM_ADDPAGE, Self, @Msg);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.CreateWnd] D');
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
SetShowTabs(FShowTabs);
|
||||
@ -228,6 +259,9 @@ begin
|
||||
SetPageIndex(FPageIndex);
|
||||
|
||||
SetCallback(LM_CHANGED);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.CreateWnd] END');
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -283,7 +317,13 @@ begin
|
||||
Msg.Parent := Self;
|
||||
Msg.fCompStyle := fCompStyle;
|
||||
Msg.Page := Value;
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.SetPageIndex] A');
|
||||
{$ENDIF}
|
||||
CNSendMessage(LM_SETITEMINDEX, Self, @Msg);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.SetPageIndex] B');
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -335,7 +375,13 @@ begin
|
||||
Msg.Parent := Self;
|
||||
Msg.fCompStyle := fCompStyle;
|
||||
Msg.ShowTabs := fShowTabs;
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.SetShowTabs] A');
|
||||
{$ENDIF}
|
||||
CNSendMessage(LM_SHOWTABS, Self, @Msg);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.SetShowTabs] B');
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -353,7 +399,13 @@ begin
|
||||
Msg.fCompStyle := fCompStyle;
|
||||
Msg.TabPosition := @fTabPosition;
|
||||
//InterfaceObject.IntCNSendMessage2(LM_SETTABPOSITION, Self, nil, @fTabPosition);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.SetTabPosition] A');
|
||||
{$ENDIF}
|
||||
CNSendMessage(LM_SETTABPOSITION, Self, @Msg);
|
||||
{$IFDEF NOTEBOOK_DEBUG}
|
||||
writeln('[TCustomNotebook.SetTabPosition] B');
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -436,7 +488,11 @@ Begin
|
||||
Change;
|
||||
end;
|
||||
else
|
||||
writeln('[TCustomNotebook.CNNotify]');
|
||||
begin
|
||||
writeln('');
|
||||
writeln('[TCustomNotebook.CNNotify]');
|
||||
writeln('');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -444,6 +500,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.10 2001/10/16 10:51:10 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.9 2001/09/30 08:34:49 lazarus
|
||||
MG: fixed mem leaks and fixed range check errors
|
||||
|
||||
|
@ -45,6 +45,7 @@ type
|
||||
constructor Create (AOwner : TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Paint; override;
|
||||
procedure FormActivate(Sender: TObject);
|
||||
property TheMessage : string read GetMessage write SetMessage;
|
||||
property DialogType : TMsgDlgType write SetDialogType;
|
||||
property Buttons : TMsgDlgButtons write SetButtons;
|
||||
@ -86,6 +87,7 @@ begin
|
||||
FButtons := [mbOk];
|
||||
FRelayoutNeeded := false;
|
||||
FUpdateCounter := 0;
|
||||
OnActivate:=@FormActivate;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -102,6 +104,24 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TMessageBox.FormActivate
|
||||
Params: ---
|
||||
Returns: Nothing
|
||||
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TMessageBox.FormActivate(Sender: TObject);
|
||||
var i: integer;
|
||||
begin
|
||||
for i:=0 to ComponentCount-1 do begin
|
||||
if (Components[i] is TBitBtn) and (TBitBtn(Components[i]).Default) then begin
|
||||
// TBitBtn(Components[i]).SetFocus;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TMessageBox.Paint
|
||||
Params: ---
|
||||
@ -231,7 +251,8 @@ var
|
||||
LabelHeight : integer;
|
||||
TempLabel : TLabel; // temporary label components
|
||||
LabelIndex : integer;
|
||||
i, j : integer;
|
||||
i, j : integer;
|
||||
ButtonIndex : integer;
|
||||
begin
|
||||
if FUpdateCounter>0 then exit;
|
||||
|
||||
@ -257,7 +278,7 @@ begin
|
||||
reqWidth:=reqBtnWidth;
|
||||
if reqWidth < LabelWidth then reqWidth:=LabelWidth;
|
||||
LabelLeft := ((reqWidth - LabelWidth) div 2) + cMinLeft;
|
||||
ButtonLeft := ((reqWidth - reqBtnWidth) div 2) + cMinLeft + (25 div 2);
|
||||
ButtonLeft := cMinLeft + ((reqWidth - reqBtnWidth) div 2) + (25 div 2);
|
||||
|
||||
// set size of form
|
||||
SetBounds(Left,Top,reqWidth+cMinLeft+cLabelSpacing,
|
||||
@ -297,8 +318,10 @@ begin
|
||||
end;
|
||||
|
||||
// create the buttons
|
||||
ButtonIndex := -1;
|
||||
for curBtn := low(TMsgDlgBtn) to high(TMsgDlgBtn) do begin
|
||||
if curBtn in FButtons then begin
|
||||
inc(ButtonIndex);
|
||||
aButton := TBitBtn.Create(self);
|
||||
With aButton do begin
|
||||
Parent := Self;
|
||||
@ -314,11 +337,20 @@ begin
|
||||
Glyph := aBitmap;
|
||||
ModalResult := cMbResult[curBtn];
|
||||
Caption := cMbCaption[curBtn];
|
||||
if ButtonIndex=0 then Default := true;
|
||||
if curbtn in [mbOK, mbYes] then Default := true;
|
||||
Visible:=true;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
for i:=0 to ComponentCount-1 do begin
|
||||
if (Components[i] is TBitBtn) and (TBitBtn(Components[i]).Default) then begin
|
||||
TBitBtn(Components[i]).SetFocus;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
FRelayoutNeeded:=false;
|
||||
end;
|
||||
|
||||
@ -431,6 +463,9 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.7 2001/10/16 10:51:10 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.6 2001/10/07 07:35:28 lazarus
|
||||
MG: minor fix
|
||||
|
||||
|
@ -462,16 +462,15 @@ begin
|
||||
end;
|
||||
|
||||
function gtkclickedCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
|
||||
//var
|
||||
// Mess : TLMessage;
|
||||
var
|
||||
Mess : TLMessage;
|
||||
begin
|
||||
(*
|
||||
Result := True;
|
||||
EventTrace('clicked', data);
|
||||
Assert(False, Format('Trace:OBSOLETE: [gtkclickedCB] ', []));
|
||||
Mess.msg := LM_CLICKED;
|
||||
Result:= DeliverMessage(Data, Mess) = 0;
|
||||
*)
|
||||
writeln('[gtkclickedCB] ',TObject(Data).ClassName);
|
||||
EventTrace('clicked', data);
|
||||
Assert(False, Format('Trace:OBSOLETE: [gtkclickedCB] ', []));
|
||||
Mess.Msg := LM_CLICKED;
|
||||
Result:= DeliverMessage(Data, Mess) = 0;
|
||||
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
@ -1157,8 +1156,8 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.36 2001/10/10 17:55:04 lazarus
|
||||
MG: fixed caret lost, gtk cleanup, bracket lvls, bookmark saving
|
||||
Revision 1.37 2001/10/16 10:51:10 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.35 2001/10/09 09:46:58 lazarus
|
||||
MG: added codetools, fixed synedit unindent, fixed MCatureHandle
|
||||
|
@ -670,7 +670,7 @@ activate_time : the time at which the activation event occurred.
|
||||
|
||||
LM_SETFOCUS:
|
||||
begin
|
||||
writeln('[TgtkObject.IntSendMessage3] ',TObject(Sender).ClassName);
|
||||
writeln('[TgtkObject.IntSendMessage3] LM_SETFOCUS ',TObject(Sender).ClassName);
|
||||
if GTK_WIDGET_CAN_FOCUS(PgtkWidget(Handle)) then
|
||||
gtk_widget_grab_focus(PgtkWidget(handle))
|
||||
else
|
||||
@ -1451,7 +1451,6 @@ begin
|
||||
gFixed := PGTKObject(GetFixedWidget(gObject));
|
||||
if gFixed = nil then gFixed := gObject;
|
||||
|
||||
|
||||
case Msg of
|
||||
LM_SHOWWINDOW :
|
||||
begin
|
||||
@ -1499,7 +1498,6 @@ begin
|
||||
|
||||
LM_CLICKED :
|
||||
begin
|
||||
Assert(False, 'Trace:OBSOLETE: [TGTKObject.SetCallback] LM_CLICKED');
|
||||
ConnectSignal(gObject, 'clicked', @gtkclickedCB);
|
||||
end;
|
||||
|
||||
@ -3094,8 +3092,8 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.61 2001/10/10 17:55:05 lazarus
|
||||
MG: fixed caret lost, gtk cleanup, bracket lvls, bookmark saving
|
||||
Revision 1.62 2001/10/16 10:51:10 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.60 2001/10/09 09:46:59 lazarus
|
||||
MG: added codetools, fixed synedit unindent, fixed MCatureHandle
|
||||
|
@ -2314,6 +2314,7 @@ end;
|
||||
|
||||
function MessageButtonClicked(Widget : PGtkWidget; data: gPointer) : GBoolean; cdecl;
|
||||
begin
|
||||
writeln('[MessageButtonClicked] ',Integer(data^),' ',Integer(gtk_object_get_data(PGtkObject(Widget), 'modal_result')));
|
||||
if Integer(data^) = 0 then
|
||||
Integer(data^):= Integer(gtk_object_get_data(PGtkObject(Widget), 'modal_result'));
|
||||
Result:=false;
|
||||
@ -2411,7 +2412,7 @@ begin
|
||||
gtk_window_set_modal(PGtkWindow(Dialog), true);
|
||||
gtk_widget_show_all(Dialog);
|
||||
while ADialogResult = 0 do begin
|
||||
Application.ProcessMessages;
|
||||
Application.HandleMessage;
|
||||
end;
|
||||
gtk_widget_destroy(Dialog);
|
||||
Result:= ADialogResult;
|
||||
@ -3106,7 +3107,9 @@ begin
|
||||
then begin
|
||||
//writeln('> TgtkObject.SetFocus E');
|
||||
gtk_window_set_focus(PGTKWindow(TopLevel), PGTKWidget(hWND));
|
||||
end;
|
||||
//writeln('> TgtkObject.SetFocus F ',HexStr(Cardinal(GetFocus),8)
|
||||
//,' ',HexStr(Cardinal(TopLevel),8),' ',HexStr(Cardinal(hWnd),8));
|
||||
end;
|
||||
end;
|
||||
//writeln('> TgtkObject.SetFocus End');
|
||||
end;
|
||||
@ -3493,6 +3496,7 @@ function TgtkObject.StretchBlt(DestDC: HDC; X, Y, Width, Height: Integer;
|
||||
begin
|
||||
Assert(True, Format('trace:> [TgtkObject.StretchBlt] DestDC:0x%x; X:%d, Y:%d, Width:%d, Height:%d; SrcDC:0x%x; XSrc:%d, YSrc:%d, SrcWidth:%d, SrcHeight:%d; Rop:0x%x', [DestDC, X, Y, Width, Height, SrcDC, XSrc, YSrc, SrcWidth, SrcHeight, Rop]));
|
||||
Result := IsValidDC(DestDC) and IsValidDC(SrcDC);
|
||||
//writeln('[TgtkObject.StretchBlt] ',Result);
|
||||
if Result then begin
|
||||
gdk_gc_set_function(PDeviceContext(DestDC)^.GC, GDK_COPY);
|
||||
// TODO: Add scaling and ROP
|
||||
@ -3505,6 +3509,7 @@ begin
|
||||
gdk_draw_pixmap(PDeviceContext(DestDC)^.Drawable,PDeviceContext(DestDC)^.GC,
|
||||
PgdkDrawable(pixmapwid^.window),
|
||||
XSrc, YSrc, X, Y, SrcWidth, SrcHeight);}
|
||||
//writeln('[TgtkObject.StretchBlt] B ');
|
||||
gdk_draw_pixmap(PDeviceContext(DestDC)^.Drawable,
|
||||
PDeviceContext(DestDC)^.GC, PDeviceContext(SrcDC)^.Drawable,
|
||||
XSrc, YSrc, X, Y, SrcWidth, SrcHeight);
|
||||
@ -3513,6 +3518,7 @@ begin
|
||||
PDeviceContext(DestDC)^.GC, PDeviceContext(SrcDC)^.Drawable,
|
||||
XSrc, YSrc, X, Y, SrcWidth, SrcHeight);
|
||||
end;
|
||||
//writeln('[TgtkObject.StretchBlt] C ');
|
||||
end;
|
||||
Assert(True, Format('trace:< [TgtkObject.StretchBlt] DestDC:0x%x --> %s', [DestDC, BOOL_TEXT[Result]]));
|
||||
end;
|
||||
@ -3598,8 +3604,8 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.42 2001/10/10 17:55:06 lazarus
|
||||
MG: fixed caret lost, gtk cleanup, bracket lvls, bookmark saving
|
||||
Revision 1.43 2001/10/16 10:51:10 lazarus
|
||||
MG: added clicked event to TButton, MessageDialog reacts to return key
|
||||
|
||||
Revision 1.41 2001/09/30 08:34:52 lazarus
|
||||
MG: fixed mem leaks and fixed range check errors
|
||||
|
Loading…
Reference in New Issue
Block a user