Skip to content

Commit dfb86d5

Browse files
committed
fix: status bar text gets written into the panel right besides the current one, on Linux/macOS
TextRect does not automatically clip on all widgetsets unless you tell it to. On Linux/macOS you must set Canvas.TextStyle so clipping is enabled.
1 parent 93e1b39 commit dfb86d5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

source/main.pas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@ procedure TMainForm.StatusBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPane
15081508
PanelRect: TRect;
15091509
ImageIndex: Integer;
15101510
Conn: TDBConnection;
1511+
TS: TTextStyle;
15111512
begin
15121513
// Refresh one status bar panel, probably with icon
15131514
ImageIndex := -1;
@@ -1532,6 +1533,11 @@ procedure TMainForm.StatusBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPane
15321533
ImageListMain.DrawForControl(StatusBar.Canvas, PanelRect.Left, PanelRect.Top+2, ImageIndex, ImageListMain.Width, StatusBar);
15331534
OffsetRect(PanelRect, Scale96ToForm(ImageListMain.Width)+4, 0);
15341535
end;
1536+
// Enable clipping, so a longer text does not get written into the panel right besides this one
1537+
// If we'd write StatusBar.Canvas.TextStyle.Clipping := True;, we only modify the temporary copy and the change is lost immediately
1538+
TS := StatusBar.Canvas.TextStyle; // get record copy
1539+
TS.Clipping := True; // modify
1540+
StatusBar.Canvas.TextStyle := TS; // write back
15351541
StatusBar.Canvas.TextRect(PanelRect, PanelRect.Left, PanelRect.Top+2, Panel.Text);
15361542
end;
15371543

0 commit comments

Comments
 (0)