From 344d9b00e18ea0325e3cffe2109af270c2c79746 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 26 Apr 2024 17:16:47 +0000 Subject: [PATCH] ExCtrls: Fix some inconsistencies in ProgressBarEx demo. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9345 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../exctrls/examples/ProgressBarEx/demo.lpi | 1 - .../exctrls/examples/ProgressBarEx/main.lfm | 34 +++++++-------- .../exctrls/examples/ProgressBarEx/main.pas | 43 ++++++++++++------- components/exctrls/source/exprogressbar.pas | 1 + 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/components/exctrls/examples/ProgressBarEx/demo.lpi b/components/exctrls/examples/ProgressBarEx/demo.lpi index 5962e05e1..d4da56022 100644 --- a/components/exctrls/examples/ProgressBarEx/demo.lpi +++ b/components/exctrls/examples/ProgressBarEx/demo.lpi @@ -12,7 +12,6 @@ - diff --git a/components/exctrls/examples/ProgressBarEx/main.lfm b/components/exctrls/examples/ProgressBarEx/main.lfm index c5281d5ba..51fde2fd6 100644 --- a/components/exctrls/examples/ProgressBarEx/main.lfm +++ b/components/exctrls/examples/ProgressBarEx/main.lfm @@ -6,8 +6,8 @@ object Form1: TForm1 Caption = 'TProgressBarEx Demo' ClientHeight = 511 ClientWidth = 528 + LCLVersion = '3.99.0.0' OnCreate = FormCreate - LCLVersion = '2.3.0.0' object GroupBox1: TGroupBox Left = 106 Height = 136 @@ -26,9 +26,9 @@ object Form1: TForm1 Width = 86 Caption = 'Normal Style' Checked = True - OnChange = rbNormalStyleChange TabOrder = 1 TabStop = True + OnChange = rbNormalStyleChange end object rbMarqueeStyle: TRadioButton AnchorSideTop.Control = Edit1 @@ -38,8 +38,8 @@ object Form1: TForm1 Top = 31 Width = 93 Caption = 'Marquee Style' - OnChange = rbMarqueeStyleChange TabOrder = 0 + OnChange = rbMarqueeStyleChange end object ScrollBar1: TScrollBar AnchorSideTop.Control = GroupBox1 @@ -53,16 +53,14 @@ object Form1: TForm1 OnChange = ScrollBar1Change end object Edit1: TEdit - AnchorSideTop.Control = ScrollBar1 - AnchorSideTop.Side = asrBottom Left = 136 Height = 23 Top = 29 Width = 257 BorderSpacing.Top = 8 - OnChange = Edit1Change TabOrder = 3 Text = 'Some text...' + OnChange = Edit1Change end object lblMarqueeLength: TLabel AnchorSideTop.Control = seMarqueeLength @@ -82,9 +80,9 @@ object Form1: TForm1 Width = 50 Alignment = taRightJustify BorderSpacing.Top = 8 - OnChange = seMarqueeLengthChange TabOrder = 4 Value = 120 + OnChange = seMarqueeLengthChange end object lblMarqueeSpeed: TLabel AnchorSideTop.Control = seMarqueeSpeed @@ -104,9 +102,9 @@ object Form1: TForm1 Width = 50 Alignment = taRightJustify BorderSpacing.Top = 4 - OnChange = seMarqueeSpeedChange TabOrder = 5 Value = 8 + OnChange = seMarqueeSpeedChange end end object btnFont: TButton @@ -115,8 +113,8 @@ object Form1: TForm1 Top = 344 Width = 75 Caption = 'Font' - OnClick = btnFontClick TabOrder = 1 + OnClick = btnFontClick end object ProgressBar1: TProgressBar Left = 13 @@ -184,8 +182,8 @@ object Form1: TForm1 Top = 64 Width = 164 Caption = 'Compare with TProgressBar' - OnChange = CheckBox1Change TabOrder = 3 + OnChange = CheckBox1Change end object rgOrientation: TRadioGroup Left = 105 @@ -211,8 +209,8 @@ object Form1: TForm1 'right to left' 'top down' ) - OnClick = rgOrientationClick TabOrder = 4 + OnClick = rgOrientationClick end object rgDrawingStyle: TRadioGroup Left = 105 @@ -239,11 +237,11 @@ object Form1: TForm1 'shiny' 'bevel' ) - OnClick = rgDrawingStyleClick TabOrder = 5 + OnClick = rgDrawingStyleClick end - object RadioGroup1: TRadioGroup - Left = 104 + object rgCaption: TRadioGroup + Left = 105 Height = 88 Top = 408 Width = 235 @@ -267,10 +265,10 @@ object Form1: TForm1 'Position+Percentage' 'Custom text' ) - OnClick = RadioGroup1Click TabOrder = 6 + OnClick = rgCaptionClick end - object RadioGroup2: TRadioGroup + object rgBorder: TRadioGroup Left = 374 Height = 88 Top = 408 @@ -295,8 +293,8 @@ object Form1: TForm1 'Raised' 'Etched' ) - OnClick = RadioGroup2Click TabOrder = 7 + OnClick = rgBorderClick end object Button1: TButton Left = 355 @@ -304,8 +302,8 @@ object Form1: TForm1 Top = 61 Width = 75 Caption = 'AutoSize' - OnClick = Button1Click TabOrder = 8 + OnClick = Button1Click end object FontDialog1: TFontDialog MinFontSize = 0 diff --git a/components/exctrls/examples/ProgressBarEx/main.pas b/components/exctrls/examples/ProgressBarEx/main.pas index 703420570..8099fb128 100644 --- a/components/exctrls/examples/ProgressBarEx/main.pas +++ b/components/exctrls/examples/ProgressBarEx/main.pas @@ -26,8 +26,8 @@ type lblMarqueeLength: TLabel; lblMarqueeSpeed: TLabel; ProgressBar1: TProgressBar; - RadioGroup1: TRadioGroup; - RadioGroup2: TRadioGroup; + rgCaption: TRadioGroup; + rgBorder: TRadioGroup; rbNormalStyle: TRadioButton; rbMarqueeStyle: TRadioButton; rgOrientation: TRadioGroup; @@ -44,8 +44,8 @@ type procedure clbBorderColorColorChanged(Sender: TObject); procedure Edit1Change(Sender: TObject); procedure FormCreate(Sender: TObject); - procedure RadioGroup1Click(Sender: TObject); - procedure RadioGroup2Click(Sender: TObject); + procedure rgCaptionClick(Sender: TObject); + procedure rgBorderClick(Sender: TObject); procedure rbNormalStyleChange(Sender: TObject); procedure rbMarqueeStyleChange(Sender: TObject); procedure rgDrawingStyleClick(Sender: TObject); @@ -95,28 +95,41 @@ begin Height := Width; end; -procedure TForm1.RadioGroup1Click(Sender: TObject); +procedure TForm1.rgCaptionClick(Sender: TObject); begin - ProgressBarEx.TextMode := TProgressbarTextMode(RadioGroup1.ItemIndex); + ProgressBarEx.TextMode := TProgressbarTextMode(rgCaption.ItemIndex); case ProgressBarEx.TextMode of - tmValue: ProgressBarEx.Caption := 'Voltage: %d mV'; - tmPercent: ProgressBarEx.Caption := '%.0f%% complete'; - tmValueAndPercent: ProgressBarEx.Caption := '%1:.0f%% complete at position %0:d'; - tmCustom: ProgressBarEx.Caption := Edit1.Text; + tmValue: + if ProgressBarEx.Style = pbstNormal then + ProgressBarEx.Caption := 'Voltage: %d mV' + else + ProgressBarEx.Caption := ''; + tmPercent: + if ProgressBarEx.Style = pbstNormal then + ProgressBarEx.Caption := '%.0f%% complete' + else + ProgressBarEx.Caption := ''; + tmValueAndPercent: + if ProgressBarEx.Style = pbstNormal then + ProgressBarEx.Caption := '%1:.0f%% complete at position %0:d' + else + ProgressBarEx.Caption := ''; + tmCustom: + ProgressBarEx.Caption := Edit1.Text; end; end; -procedure TForm1.RadioGroup2Click(Sender: TObject); +procedure TForm1.rgBorderClick(Sender: TObject); begin - ProgressBarEx.BorderStyle := TProgressBarBorderStyle(RadioGroup2.ItemIndex); + ProgressBarEx.BorderStyle := TProgressBarBorderStyle(rgBorder.ItemIndex); end; procedure TForm1.rbNormalStyleChange(Sender: TObject); begin - Progressbar1.style := pbstNormal; + Progressbar1.Style := pbstNormal; ProgressbarEx.Style := pbstNormal; - ProgressbarEx.Caption := IntToStr(ProgressbarEx.Position); - Scrollbar1.Position := ProgressbarEx.Position; + rgCaptionClick(nil); + ProgressbarEx.Position := Scrollbar1.Position; Scrollbar1.Show; end; diff --git a/components/exctrls/source/exprogressbar.pas b/components/exctrls/source/exprogressbar.pas index 79311ef87..d0d71e2e5 100644 --- a/components/exctrls/source/exprogressbar.pas +++ b/components/exctrls/source/exprogressbar.pas @@ -515,6 +515,7 @@ begin FTimer.Enabled := true; end; end; + Invalidate; end; procedure TProgressBarEx.SetTextMode(AValue: TProgressBarTextMode);