View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0020447 | Lazarus | LCL | public | 2011-10-09 20:53 | 2014-07-11 10:22 |
Reporter | cobines | Assigned To | Juha Manninen | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | Win32 | OS | Windows XP | ||
Product Version | 0.9.31 (SVN) | ||||
Target Version | 1.4 | ||||
Summary | 0020447: Autosized GroupBox does not take caption into account | ||||
Description | Only child controls are taken into account when calculating size of an autosized GroupBox, the caption is not. So if the caption of the GroupBox is longer then it is cut. The GroupBox should be wide enough so that the caption fits in whole. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | r45786, r45795, r45823 | ||||
LazTarget | 1.4 | ||||
Widgetset | |||||
Attached Files |
|
related to | 0019637 | resolved | Bart Broersma | MessageDlg caption cut off. |
related to | 0020620 | feedback | wrong subcomponent positioning in a tGroupbox dependent on tGroupbox.Caption | |
related to | 0022957 | closed | Zeljan Rikalo | flawed view of editor options with qt widgetset |
2011-10-09 20:53
|
|
2011-10-09 20:58
|
|
|
Not blocker, postponed. |
|
gtk2-groupbox-autosize.patch (1,606 bytes)
Index: lcl/interfaces/gtk2/gtk2wsstdctrls.pp =================================================================== --- lcl/interfaces/gtk2/gtk2wsstdctrls.pp (revision 45769) +++ lcl/interfaces/gtk2/gtk2wsstdctrls.pp (working copy) @@ -2365,32 +2365,9 @@ class procedure TGtk2WSCustomGroupBox.GetPreferredSize( const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); -var - Widget: PGtkWidget; - border_width: Integer; begin - Widget := PGtkWidget(GetFrameWidget({%H-}PGTKEventBox(AWinControl.Handle))); - - if Assigned(PGtkFrame(Widget)^.label_widget) then - begin - PreferredWidth := gtk_widget_get_xthickness(Widget) * 2 + - gtk_widget_get_xthickness(PGtkFrame(Widget)^.label_widget); - PreferredHeight := Max(gtk_widget_get_ythickness(Widget), - gtk_widget_get_ythickness(PGtkFrame(Widget)^.label_widget)) + - gtk_widget_get_ythickness(Widget); - end else - begin - PreferredWidth := gtk_widget_get_xthickness(Widget) * 2; - PreferredHeight := gtk_widget_get_ythickness(Widget) * 2; - end; - - if WithThemeSpace then - begin - border_width := (PGtkContainer(Widget)^.flag0 and bm_TGtkContainer_border_width) shr - bp_TGtkContainer_border_width; - inc(PreferredWidth, border_width); - inc(PreferredHeight, 2 * border_width); - end; + GetGTKDefaultWidgetSize(AWinControl, PreferredWidth, PreferredHeight, + WithThemeSpace); end; class procedure TGtk2WSCustomGroupBox.SetFont(const AWinControl: TWinControl; |
|
I've uploaded a patch with a fix for the gtk2 interface. Can anyone give me a tip for how to fix it in the win32 interface? |
|
Thanks, I applied your patch in r45786. Looks good. I will keep this open at least until LCL-Win is fixed. Lazarus mailng list may be the best place to ask about win32 interface code. Vincent used to work on it but he has not been active recently. I guess you must dive into the code and figure it out. It is doable, even I have changed some things there when I had to. |
|
win32wsstdctrls.pp.patch (1,210 bytes)
Index: lcl/interfaces/win32/win32wsstdctrls.pp =================================================================== --- lcl/interfaces/win32/win32wsstdctrls.pp (revision 45786) +++ lcl/interfaces/win32/win32wsstdctrls.pp (working copy) @@ -54,6 +54,9 @@ const AParams: TCreateParams): HWND; override; class procedure SetBiDiMode(const AWinControl: TWinControl; UseRightToLeftAlign, UseRightToLeftReading, UseRightToLeftScrollBar : Boolean); override; + class procedure GetPreferredSize(const AWinControl: TWinControl; + var PreferredWidth, PreferredHeight: integer; + WithThemeSpace: Boolean); override; end; { TWin32WSGroupBox } @@ -560,6 +563,17 @@ RecreateWnd(AWinControl); end; +class procedure TWin32WSCustomGroupBox.GetPreferredSize( + const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; + WithThemeSpace: Boolean); +begin + if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, + PreferredHeight) then begin + PreferredWidth += 19; + PreferredHeight += 4; + end; +end; + { TWin32WSCustomListBox } function ListBoxWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; |
|
I've uploaded a patch for Windows. I see a lot of border sizes are hardcoded in the Windows interface, look for example at the other GetPreferredSize implementations in that unit. I don't know if there's a better way to do it, but it seems to work OK on Vista with and without the aero theme. I don't know if extra space should be allowed in the case of WithThemeSpace. |
|
Cool, thanks. I applied it in r45795. Finally the other widgetsets should follow this logic as well. Are you planning to provide more patches or should I resolve this issue? |
|
qt-groupbox-prefsize.patch (1,603 bytes)
Index: lcl/interfaces/qt/qtwidgets.pas =================================================================== --- lcl/interfaces/qt/qtwidgets.pas (revision 45807) +++ lcl/interfaces/qt/qtwidgets.pas (working copy) @@ -7730,7 +7730,7 @@ ASize: TSize; begin QWidget_getContentsMargins(Widget,@L, @T, @R, @B); - QWidget_sizeHint(Widget, @ASize); + QGroupBox_minimumSizeHint(QGroupBoxH(Widget), @ASize); PreferredWidth := ASize.cx + L + R; PreferredHeight := ASize.cy + B + T; {$IFDEF VerboseQtResize} Index: lcl/interfaces/qt/qtwsstdctrls.pp =================================================================== --- lcl/interfaces/qt/qtwsstdctrls.pp (revision 45807) +++ lcl/interfaces/qt/qtwsstdctrls.pp (working copy) @@ -55,6 +55,8 @@ class function GetDefaultClientRect(const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect ): boolean; override; + class procedure GetPreferredSize(const AWinControl: TWinControl; + var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; end; { TQtWSGroupBox } @@ -1317,6 +1319,15 @@ end; end; +class procedure TQtWSCustomGroupBox.GetPreferredSize( + const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; + WithThemeSpace: Boolean); +begin + if AWinControl.HandleAllocated then + TQtGroupBox(AWinControl.Handle).PreferredSize(PreferredWidth, + PreferredHeight, WithThemeSpace); +end; + { TQtWSCustomComboBox } {------------------------------------------------------------------------------ |
|
Patch for Qt uploaded. Since these patches are quite small, could I ask for them to be merged into fixes_1_2, please? |
|
@Juha, pls commit win32 and qt patches and close issue. Also add all (gtk2,win32 and qt) revisions about this issue to the merge list: http://wiki.lazarus.freepascal.org/Lazarus_1.2_fixes_branch |
|
Done. Thanks for the patches. Please test. |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-10-09 20:53 | cobines | New Issue | |
2011-10-09 20:53 | cobines | File Added: autosize_groupbox_caption.tar.bz2 | |
2011-10-09 20:58 | cobines | File Added: autosize_groupbox_caption.png | |
2011-10-09 22:19 | Maxim Ganetsky | LazTarget | => - |
2011-10-09 22:19 | Maxim Ganetsky | Status | new => confirmed |
2011-10-09 22:20 | Maxim Ganetsky | LazTarget | - => 1.2 |
2011-10-09 22:20 | Maxim Ganetsky | Target Version | => 1.2.0 |
2011-10-09 22:22 | Maxim Ganetsky | LazTarget | 1.2 => 1.0 |
2011-10-09 22:22 | Maxim Ganetsky | Target Version | 1.2.0 => 1.0.0 |
2011-11-04 12:11 | Juha Manninen | Relationship added | related to 0019637 |
2011-11-11 12:51 | Juha Manninen | Relationship added | related to 0020620 |
2012-02-04 14:14 | Zeljan Rikalo | LazTarget | 1.0 => 1.2 |
2012-02-04 14:14 | Zeljan Rikalo | Note Added: 0056442 | |
2012-03-13 07:50 | Vincent Snijders | Target Version | 1.0.0 => 1.2.0 |
2012-09-23 22:17 | Juha Manninen | Relationship added | related to 0022957 |
2014-01-14 15:10 | Martin Friebe | LazTarget | 1.2 => 1.4 |
2014-01-14 15:12 | Martin Friebe | Target Version | 1.2.0 => 1.4 |
2014-07-04 15:01 | Henry Vermaak | File Added: gtk2-groupbox-autosize.patch | |
2014-07-04 15:02 | Henry Vermaak | Note Added: 0076063 | |
2014-07-05 12:49 | Juha Manninen | Assigned To | => Juha Manninen |
2014-07-05 12:49 | Juha Manninen | Status | confirmed => assigned |
2014-07-05 12:53 | Juha Manninen | Note Added: 0076079 | |
2014-07-05 21:51 | Henry Vermaak | File Added: win32wsstdctrls.pp.patch | |
2014-07-05 21:55 | Henry Vermaak | Note Added: 0076091 | |
2014-07-06 19:23 | Juha Manninen | Note Added: 0076103 | |
2014-07-07 15:48 | Henry Vermaak | File Added: qt-groupbox-prefsize.patch | |
2014-07-07 15:50 | Henry Vermaak | Note Added: 0076111 | |
2014-07-08 10:14 | Zeljan Rikalo | Note Added: 0076133 | |
2014-07-11 00:20 | Juha Manninen | Fixed in Revision | => r45786, r45795, r45823 |
2014-07-11 05:29 | Juha Manninen | Note Added: 0076173 | |
2014-07-11 10:22 | Juha Manninen | Status | assigned => resolved |
2014-07-11 10:22 | Juha Manninen | Resolution | open => fixed |