mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 22:36:17 +02:00
statusbar:
- better fix for statusbar jumping (from top to bottom) - add SizeGrip property and implement it for win32 (0001705) git-svn-id: trunk@14591 -
This commit is contained in:
parent
63d551e608
commit
9642488f11
@ -121,6 +121,7 @@ type
|
|||||||
FHandleObjectNeedsUpdate: boolean;
|
FHandleObjectNeedsUpdate: boolean;
|
||||||
FHandleUpdatePanelIndex: integer; // which panel in the handle object needs update
|
FHandleUpdatePanelIndex: integer; // which panel in the handle object needs update
|
||||||
FOnCreatePanelClass: TSBCreatePanelClassEvent;
|
FOnCreatePanelClass: TSBCreatePanelClassEvent;
|
||||||
|
FSizeGrip: Boolean;
|
||||||
FUpdateLock: integer; // set by BeginUpdate/EndUpdate
|
FUpdateLock: integer; // set by BeginUpdate/EndUpdate
|
||||||
FPanels: TStatusPanels;
|
FPanels: TStatusPanels;
|
||||||
FSimpleText: String;
|
FSimpleText: String;
|
||||||
@ -129,6 +130,7 @@ type
|
|||||||
procedure SetPanels(Value: TStatusPanels);
|
procedure SetPanels(Value: TStatusPanels);
|
||||||
procedure SetSimpleText(const Value : String);
|
procedure SetSimpleText(const Value : String);
|
||||||
procedure SetSimplePanel(Value : Boolean);
|
procedure SetSimplePanel(Value : Boolean);
|
||||||
|
procedure SetSizeGrip(const AValue: Boolean);
|
||||||
protected
|
protected
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
procedure DestroyWnd; override;
|
procedure DestroyWnd; override;
|
||||||
@ -149,6 +151,7 @@ type
|
|||||||
procedure InvalidatePanel(PanelIndex: integer; PanelParts: TPanelParts); virtual;
|
procedure InvalidatePanel(PanelIndex: integer; PanelParts: TPanelParts); virtual;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
|
function SizeGripEnabled: Boolean;
|
||||||
function UpdatingStatusBar: boolean;
|
function UpdatingStatusBar: boolean;
|
||||||
property Canvas: TCanvas read FCanvas;
|
property Canvas: TCanvas read FCanvas;
|
||||||
published
|
published
|
||||||
@ -159,6 +162,7 @@ type
|
|||||||
property Panels: TStatusPanels read FPanels write SetPanels;
|
property Panels: TStatusPanels read FPanels write SetPanels;
|
||||||
property SimpleText: String read FSimpleText write SetSimpleText;
|
property SimpleText: String read FSimpleText write SetSimpleText;
|
||||||
property SimplePanel: Boolean read FSimplePanel write SetSimplePanel default True;
|
property SimplePanel: Boolean read FSimplePanel write SetSimplePanel default True;
|
||||||
|
property SizeGrip: Boolean read FSizeGrip write SetSizeGrip default True;
|
||||||
property Visible default true;
|
property Visible default true;
|
||||||
property Color default clBtnFace;
|
property Color default clBtnFace;
|
||||||
property OnClick;
|
property OnClick;
|
||||||
|
@ -25,6 +25,7 @@ begin
|
|||||||
TControlCanvas(FCanvas).Control := Self;
|
TControlCanvas(FCanvas).Control := Self;
|
||||||
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks, csOpaque];
|
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks, csOpaque];
|
||||||
FSimplePanel := True;
|
FSimplePanel := True;
|
||||||
|
FSizeGrip := True;
|
||||||
FPanels := CreatePanels;
|
FPanels := CreatePanels;
|
||||||
Color := clBtnFace;
|
Color := clBtnFace;
|
||||||
Align := alBottom;
|
Align := alBottom;
|
||||||
@ -41,7 +42,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
FSimpleText := Value;
|
FSimpleText := Value;
|
||||||
if HandleAllocated and FSimplePanel then
|
if HandleAllocated and FSimplePanel then
|
||||||
TWSStatusBarClass(WidgetSetClass).SetPanelText(Self,0);
|
TWSStatusBarClass(WidgetSetClass).SetPanelText(Self, 0);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -55,6 +56,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TStatusBar.SetSizeGrip(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FSizeGrip = AValue then
|
||||||
|
Exit;
|
||||||
|
FSizeGrip := AValue;
|
||||||
|
if HandleAllocated then
|
||||||
|
TWSStatusBarClass(WidgetSetClass).SetSizeGrip(Self, AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TStatusBar.SetPanels(Value: TStatusPanels);
|
procedure TStatusBar.SetPanels(Value: TStatusPanels);
|
||||||
begin
|
begin
|
||||||
FPanels.Assign(Value);
|
FPanels.Assign(Value);
|
||||||
@ -167,6 +177,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TStatusBar.SizeGripEnabled: Boolean;
|
||||||
|
begin
|
||||||
|
Result := (Parent <> nil) and
|
||||||
|
(Parent is TCustomForm) and
|
||||||
|
(TCustomForm(Parent).BorderStyle in [bsSizeable, bsSizeToolWin]) and
|
||||||
|
(Align = alBottom);
|
||||||
|
end;
|
||||||
|
|
||||||
function TStatusBar.UpdatingStatusBar: boolean;
|
function TStatusBar.UpdatingStatusBar: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=FUpdateLock>0;
|
Result:=FUpdateLock>0;
|
||||||
|
@ -2152,9 +2152,6 @@ begin
|
|||||||
ThemeServices.UpdateThemes;
|
ThemeServices.UpdateThemes;
|
||||||
ThemeServices.IntfDoOnThemeChange;
|
ThemeServices.IntfDoOnThemeChange;
|
||||||
end;
|
end;
|
||||||
WM_SIZE:
|
|
||||||
if lWinControl is TStatusBar then
|
|
||||||
WinProcess := False;
|
|
||||||
|
|
||||||
{ >= WM_USER }
|
{ >= WM_USER }
|
||||||
|
|
||||||
|
@ -46,11 +46,12 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
class function CreateHandle(const AWinControl: TWinControl;
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): HWND; override;
|
const AParams: TCreateParams): HWND; override;
|
||||||
class procedure Update(const AStatusBar: TStatusBar); override;
|
class procedure Update(const AStatusBar: TStatusBar); override;
|
||||||
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); override;
|
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); override;
|
||||||
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
|
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); override;
|
||||||
|
class procedure SetSizeGrip(const AStatusBar: TStatusBar; SizeGrip: Boolean); override;
|
||||||
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||||
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
class procedure GetPreferredSize(const AWinControl: TWinControl;
|
||||||
var PreferredWidth, PreferredHeight: integer;
|
var PreferredWidth, PreferredHeight: integer;
|
||||||
@ -314,7 +315,7 @@ begin
|
|||||||
Windows.SendMessage(StatusBar.Handle, SB_SETTEXT, 255, WPARAM(PChar('')));
|
Windows.SendMessage(StatusBar.Handle, SB_SETTEXT, 255, WPARAM(PChar('')));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Getmem(Rights, StatusBar.Panels.Count * sizeof(integer));
|
Getmem(Rights, StatusBar.Panels.Count * SizeOf(integer));
|
||||||
try
|
try
|
||||||
CurrentRight := 0;
|
CurrentRight := 0;
|
||||||
for PanelIndex := 0 to StatusBar.Panels.Count-2 do begin
|
for PanelIndex := 0 to StatusBar.Panels.Count-2 do begin
|
||||||
@ -371,6 +372,12 @@ end;
|
|||||||
|
|
||||||
class function TWin32WSStatusBar.CreateHandle(const AWinControl: TWinControl;
|
class function TWin32WSStatusBar.CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): HWND;
|
const AParams: TCreateParams): HWND;
|
||||||
|
const
|
||||||
|
GripFlags: array[Boolean] of DWord =
|
||||||
|
(
|
||||||
|
{ - grip } 0,
|
||||||
|
{ + grip } SBARS_SIZEGRIP
|
||||||
|
);
|
||||||
var
|
var
|
||||||
Params: TCreateWindowExParams;
|
Params: TCreateWindowExParams;
|
||||||
begin
|
begin
|
||||||
@ -379,6 +386,7 @@ begin
|
|||||||
// customization of Params
|
// customization of Params
|
||||||
with Params do
|
with Params do
|
||||||
begin
|
begin
|
||||||
|
Flags := Flags or CCS_NOPARENTALIGN or GripFlags[TStatusBar(AWinControl).SizeGrip and TStatusBar(AWinControl).SizeGripEnabled];
|
||||||
pClassName := STATUSCLASSNAME;
|
pClassName := STATUSCLASSNAME;
|
||||||
WindowTitle := StrCaption;
|
WindowTitle := StrCaption;
|
||||||
if ThemeServices.ThemesEnabled then
|
if ThemeServices.ThemesEnabled then
|
||||||
@ -423,6 +431,18 @@ begin
|
|||||||
UpdateStatusBarPanel(AStatusBar.Panels[PanelIndex]);
|
UpdateStatusBarPanel(AStatusBar.Panels[PanelIndex]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWin32WSStatusBar.SetSizeGrip(const AStatusBar: TStatusBar;
|
||||||
|
SizeGrip: Boolean);
|
||||||
|
var
|
||||||
|
AStyle: Long;
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AStatusBar, 'SetSizeGrip') then
|
||||||
|
Exit;
|
||||||
|
AStyle := GetWindowLong(AStatusBar.Handle, GWL_STYLE);
|
||||||
|
if ((AStyle and SBARS_SIZEGRIP) <> 0) <> (SizeGrip and AStatusBar.SizeGripEnabled) then
|
||||||
|
RecreateWnd(AStatusBar);
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWin32WSStatusBar.SetText(const AWinControl: TWinControl;
|
class procedure TWin32WSStatusBar.SetText(const AWinControl: TWinControl;
|
||||||
const AText: string);
|
const AText: string);
|
||||||
begin
|
begin
|
||||||
|
@ -57,6 +57,7 @@ type
|
|||||||
TWSStatusBar = class(TWSWinControl)
|
TWSStatusBar = class(TWSWinControl)
|
||||||
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); virtual;
|
class procedure PanelUpdate(const AStatusBar: TStatusBar; PanelIndex: integer); virtual;
|
||||||
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); virtual;
|
class procedure SetPanelText(const AStatusBar: TStatusBar; PanelIndex: integer); virtual;
|
||||||
|
class procedure SetSizeGrip(const AStatusBar: TStatusBar; SizeGrip: Boolean); virtual;
|
||||||
class procedure Update(const AStatusBar: TStatusBar); virtual;
|
class procedure Update(const AStatusBar: TStatusBar); virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -205,6 +206,11 @@ class procedure TWSStatusBar.SetPanelText(const AStatusBar: TStatusBar; PanelInd
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TWSStatusBar.SetSizeGrip(const AStatusBar: TStatusBar;
|
||||||
|
SizeGrip: Boolean);
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWSStatusBar.Update(const AStatusBar: TStatusBar);
|
class procedure TWSStatusBar.Update(const AStatusBar: TStatusBar);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user