mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-22 13:59:16 +02:00
merged r50811 #873b3e4baa: LCL: DefaultQuestionDialog fixes: memo width, background color, border and dialog height
git-svn-id: branches/fixes_1_6@50823 -
This commit is contained in:
parent
5480ffe02a
commit
31c9b0d4ff
@ -597,16 +597,15 @@ var
|
|||||||
Flags: Cardinal;
|
Flags: Cardinal;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
CurButton: TBitBtn;
|
CurButton: TBitBtn;
|
||||||
reqBtnWidth: Integer;
|
reqBtnWidth, reqBtnHeight: Integer;
|
||||||
reqWidth: LongInt;
|
reqWidth, reqHeight: Integer;
|
||||||
cMinLeft: Integer;
|
cMinLeft: Integer;
|
||||||
ButtonLeft: Integer;
|
ButtonLeft: Integer;
|
||||||
reqHeight: LongInt;
|
|
||||||
CurBtnPos: Integer;
|
CurBtnPos: Integer;
|
||||||
CurBtnSize: TPoint;
|
CurBtnSize: TPoint;
|
||||||
MinBtnWidth: Integer; // minimum width for a single button
|
MinBtnWidth: Integer; // minimum width for a single button
|
||||||
MinBtnHeight, MaxHeight,
|
MinBtnHeight, MaxHeight, cBtnYSpacing,
|
||||||
ScrollBarWidth: Integer; // minimum height for a single button
|
ScrollBarWidth, cBorderWidth: Integer; // minimum height for a single button
|
||||||
|
|
||||||
function GetButtonSize(AButton: TBitBtn): TPoint;
|
function GetButtonSize(AButton: TBitBtn): TPoint;
|
||||||
begin
|
begin
|
||||||
@ -642,8 +641,27 @@ begin
|
|||||||
SelectObject(Canvas.Handle, Screen.SystemFont.Reference.Handle);
|
SelectObject(Canvas.Handle, Screen.SystemFont.Reference.Handle);
|
||||||
DrawText(Canvas.Handle, PChar(MessageTxt), Length(MessageTxt), TextBox, Flags);
|
DrawText(Canvas.Handle, PChar(MessageTxt), Length(MessageTxt), TextBox, Flags);
|
||||||
|
|
||||||
MaxHeight:=200;//Min(Screen.Height-100,(Screen.Height*4) div 5);
|
MaxHeight:=Monitor.WorkareaRect.Bottom-Monitor.WorkareaRect.Top
|
||||||
if TextBox.Bottom>MaxHeight then
|
-GetSystemMetrics(SM_CYCAPTION)-GetSystemMetrics(SM_CYSIZEFRAME)*2
|
||||||
|
-GetSystemMetrics(SM_CYDLGFRAME)*2; // LCL needs client size of form
|
||||||
|
|
||||||
|
// calculate the width we need to display the buttons
|
||||||
|
MinBtnWidth:=Max(25,MinimumDialogButtonWidth);
|
||||||
|
MinBtnHeight:=Max(15,MinimumDialogButtonHeight);
|
||||||
|
reqBtnWidth := 0;
|
||||||
|
reqBtnHeight := 0;
|
||||||
|
if (FButtons <> nil) and (FButtons.Count > 0) then
|
||||||
|
for i := 0 to FButtons.Count - 1 do
|
||||||
|
begin
|
||||||
|
CurButton := TBitBtn(FButtons[i]);
|
||||||
|
CurBtnSize:=GetButtonSize(CurButton);
|
||||||
|
if i > 0 then Inc(reqBtnWidth, cBtnDist);
|
||||||
|
Inc(reqBtnWidth, CurBtnSize.X);
|
||||||
|
reqBtnHeight:=Max(reqBtnHeight, CurBtnSize.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
cBtnYSpacing := reqBtnHeight + 3 * cLabelSpacing;
|
||||||
|
if TextBox.Bottom>(MaxHeight-cBtnYSpacing) then
|
||||||
begin
|
begin
|
||||||
// does not fit onto the screen => use a TMemo
|
// does not fit onto the screen => use a TMemo
|
||||||
TextBox.Bottom:=MaxHeight;
|
TextBox.Bottom:=MaxHeight;
|
||||||
@ -658,10 +676,13 @@ begin
|
|||||||
Text:=MessageTxt;
|
Text:=MessageTxt;
|
||||||
Anchors:=[akLeft,akTop,akRight,akBottom];
|
Anchors:=[akLeft,akTop,akRight,akBottom];
|
||||||
Parent:=Self;
|
Parent:=Self;
|
||||||
|
BorderStyle:=bsNone;
|
||||||
|
Color:=ColorToRGB(clBtnFace); // Gtk2 needs ColorToRGB
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ScrollBarWidth:=LCLIntf.GetSystemMetrics(SM_CXVSCROLL);
|
ScrollBarWidth:=LCLIntf.GetSystemMetrics(SM_CXVSCROLL);
|
||||||
inc(TextBox.Right,ScrollBarWidth);
|
cBorderWidth:=LCLIntf.GetSystemMetrics(SM_CXBORDER)*12; // there is some memo text padding I don't know how to exactly get - use approximate border (better more then less)
|
||||||
|
inc(TextBox.Right,ScrollBarWidth+cBorderWidth);
|
||||||
FMsgMemo.Visible:=true;
|
FMsgMemo.Visible:=true;
|
||||||
BorderStyle := bsSizeable;
|
BorderStyle := bsSizeable;
|
||||||
end else if FMsgMemo<>nil then
|
end else if FMsgMemo<>nil then
|
||||||
@ -670,20 +691,6 @@ begin
|
|||||||
BorderStyle := bsDialog;
|
BorderStyle := bsDialog;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// calculate the width we need to display the buttons
|
|
||||||
MinBtnWidth:=Max(25,MinimumDialogButtonWidth);
|
|
||||||
MinBtnHeight:=Max(15,MinimumDialogButtonHeight);
|
|
||||||
reqBtnWidth := 0;
|
|
||||||
|
|
||||||
if FButtons <> nil then
|
|
||||||
for i := 0 to FButtons.Count - 1 do
|
|
||||||
begin
|
|
||||||
CurButton := TBitBtn(FButtons[i]);
|
|
||||||
CurBtnSize:=GetButtonSize(CurButton);
|
|
||||||
if i > 0 then Inc(reqBtnWidth, cBtnDist);
|
|
||||||
Inc(reqBtnWidth, CurBtnSize.X);
|
|
||||||
end;
|
|
||||||
|
|
||||||
// calculate the width of the dialog
|
// calculate the width of the dialog
|
||||||
if FBitmap <> nil then
|
if FBitmap <> nil then
|
||||||
cMinLeft := cLabelSpacing + max(20, FBitmap.Width) + cLabelSpacing
|
cMinLeft := cLabelSpacing + max(20, FBitmap.Width) + cLabelSpacing
|
||||||
@ -691,15 +698,22 @@ begin
|
|||||||
cMinLeft := cLabelSpacing;
|
cMinLeft := cLabelSpacing;
|
||||||
reqWidth:= reqBtnWidth + 2 * cBtnDist;
|
reqWidth:= reqBtnWidth + 2 * cBtnDist;
|
||||||
if reqWidth < (TextBox.Right + cMinLeft + cLabelSpacing) then
|
if reqWidth < (TextBox.Right + cMinLeft + cLabelSpacing) then
|
||||||
reqWidth:= TextBox.Right + cMinLeft + cLabelSpacing;
|
reqWidth:= TextBox.Right + cMinLeft + cLabelSpacing
|
||||||
|
else
|
||||||
|
TextBox.Right := reqWidth - cMinLeft - cLabelSpacing;
|
||||||
ButtonLeft := ((reqWidth - reqBtnWidth) div 2);
|
ButtonLeft := ((reqWidth - reqBtnWidth) div 2);
|
||||||
|
|
||||||
// calculate the height of the dialog
|
// calculate the height of the dialog
|
||||||
reqHeight:= TextBox.Bottom;
|
reqHeight:= TextBox.Bottom;
|
||||||
if (FBitmap <> nil) and (FBitmap.Height > reqHeight) then
|
if (FBitmap <> nil) and (FBitmap.Height > reqHeight) then
|
||||||
reqHeight := FBitmap.Height;
|
reqHeight := FBitmap.Height;
|
||||||
// ToDo: CurBtnSize may not be initialized.
|
|
||||||
inc(reqHeight, CurBtnSize.Y + 3 * cLabelSpacing);
|
inc(reqHeight, cBtnYSpacing);
|
||||||
|
if reqHeight > MaxHeight then
|
||||||
|
begin
|
||||||
|
Dec(TextBox.Bottom, reqHeight-MaxHeight);
|
||||||
|
reqHeight := MaxHeight;
|
||||||
|
end;
|
||||||
|
|
||||||
// calculate the text position
|
// calculate the text position
|
||||||
OffsetRect(TextBox,
|
OffsetRect(TextBox,
|
||||||
@ -713,9 +727,11 @@ begin
|
|||||||
FBitmapY := (reqHeight - CurBtnSize.Y - FBitmap.Height - cLabelSpacing) div 2;
|
FBitmapY := (reqHeight - CurBtnSize.Y - FBitmap.Height - cLabelSpacing) div 2;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// set size of form
|
// set size&position of form
|
||||||
SetBounds((Screen.Width - reqWidth-10) div 2, (Screen.Height - reqHeight-50) div 2,
|
SetBounds(
|
||||||
reqWidth, reqHeight);
|
(Monitor.WorkareaRect.Left + Monitor.WorkareaRect.Right - reqWidth) div 2,
|
||||||
|
Monitor.WorkareaRect.Top + (MaxHeight - reqHeight) div 2,
|
||||||
|
reqWidth, reqHeight);
|
||||||
|
|
||||||
// position memo
|
// position memo
|
||||||
if (FMsgMemo<>nil) and FMsgMemo.Visible then
|
if (FMsgMemo<>nil) and FMsgMemo.Visible then
|
||||||
@ -769,7 +785,7 @@ begin
|
|||||||
inherited CreateNew(nil, 1);
|
inherited CreateNew(nil, 1);
|
||||||
PopupMode := pmAuto;
|
PopupMode := pmAuto;
|
||||||
BorderStyle := bsDialog;
|
BorderStyle := bsDialog;
|
||||||
Position := poScreenCenter;
|
Position := poDesigned;
|
||||||
MessageTxt := ConvertLineEndings(aMsg);
|
MessageTxt := ConvertLineEndings(aMsg);
|
||||||
HelpContext := HelpCtx;
|
HelpContext := HelpCtx;
|
||||||
KeyPreview := True;
|
KeyPreview := True;
|
||||||
|
Loading…
Reference in New Issue
Block a user