Browse Source

Added OnChange event for RadioButton. Using custom radio button in combobox test.

Damian Diaz 6 years ago
parent
commit
0e069c02a4

+ 3 - 0
bgrathemeradiobutton.pas

@@ -15,6 +15,7 @@ type
   TBGRAThemeRadioButton = class(TCustomControl)
   private
     FChecked: boolean;
+    FOnChange: TNotifyEvent;
     FTheme: TBGRATheme;
     FState: TBGRAThemeButtonState;
     procedure SetFChecked(AValue: boolean);
@@ -39,6 +40,7 @@ type
     property Font;
     property Enabled;
     property Theme: TBGRATheme read FTheme write SetFTheme;
+    property OnChange: TNotifyEvent read FOnChange write FOnChange;
   end;
 
 procedure Register;
@@ -67,6 +69,7 @@ begin
   if FChecked = AValue then
     Exit;
   FChecked := AValue;
+  if Assigned(FOnChange) then FOnChange(Self);
   if FChecked then
     UncheckOthers;
   Invalidate;

+ 4 - 2
test/test_bccombobox/test_bccombobox.lpi

@@ -1,11 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
   <ProjectOptions>
-    <Version Value="11"/>
+    <Version Value="12"/>
     <PathDelim Value="\"/>
     <General>
+      <Flags>
+        <CompatibilityMode Value="True"/>
+      </Flags>
       <SessionStorage Value="InProjectDir"/>
-      <MainUnit Value="0"/>
       <Title Value="test_bccombobox"/>
       <Scaled Value="True"/>
       <ResourceType Value="res"/>

+ 43 - 44
test/test_bccombobox/umain.lfm

@@ -1,66 +1,65 @@
 object Form1: TForm1
   Left = 433
-  Height = 196
+  Height = 157
   Top = 119
-  Width = 400
+  Width = 320
   Caption = 'Form1'
-  ClientHeight = 196
-  ClientWidth = 400
-  DesignTimePPI = 120
+  ClientHeight = 157
+  ClientWidth = 320
   OnCreate = FormCreate
-  LCLVersion = '2.0.2.0'
+  LCLVersion = '2.1.0.0'
   object BCComboBox1: TBCComboBox
-    Left = 10
-    Height = 49
-    Top = 10
-    Width = 184
+    Left = 8
+    Height = 39
+    Top = 8
+    Width = 147
     ItemIndex = -1
     DropDownBorderColor = clBlack
     OnChange = BCComboBox1Change
   end
   object Label1: TLabel
-    Left = 208
-    Height = 22
-    Top = 24
-    Width = 53
+    Left = 166
+    Height = 16
+    Top = 19
+    Width = 45
     Caption = 'Waiting'
     ParentColor = False
+    ParentFont = False
   end
-  object RadioWin7: TRadioButton
-    Left = 8
-    Height = 26
-    Top = 104
-    Width = 62
-    Caption = 'Win7'
-    Checked = True
-    OnChange = RadioButtonChange
-    TabOrder = 3
-    TabStop = True
+  object Label2: TLabel
+    Left = 10
+    Height = 16
+    Top = 68
+    Width = 38
+    Caption = 'Style :'
+    ParentColor = False
+    ParentFont = False
   end
-  object RadioFlash: TRadioButton
-    Left = 8
-    Height = 26
-    Top = 128
-    Width = 62
+  object RadioFlash: TBGRAThemeRadioButton
+    Left = 6
+    Height = 18
+    Top = 102
+    Width = 55
     Caption = 'Flash'
+    Checked = False
     OnChange = RadioButtonChange
-    TabOrder = 1
   end
-  object RadioCustom: TRadioButton
-    Left = 8
-    Height = 26
-    Top = 152
-    Width = 79
-    Caption = 'Custom'
+  object RadioWin7: TBGRAThemeRadioButton
+    Left = 6
+    Height = 18
+    Top = 83
+    Width = 53
+    Caption = 'Win7'
+    Checked = True
     OnChange = RadioButtonChange
-    TabOrder = 2
   end
-  object Label2: TLabel
-    Left = 13
-    Height = 22
-    Top = 85
-    Width = 41
-    Caption = 'Style :'
-    ParentColor = False
+  object RadioCustom: TBGRAThemeRadioButton
+    Left = 6
+    Height = 18
+    Top = 122
+    Width = 69
+    Caption = 'Custom'
+    Checked = False
+    OnChange = RadioButtonChange
   end
 end

+ 4 - 4
test/test_bccombobox/umain.pas

@@ -6,7 +6,7 @@ interface
 
 uses
   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, BCComboBox,
-  BCListBox, LCLType, BCSamples, Types;
+  BCListBox, LCLType, BCSamples, BGRAThemeRadioButton, Types;
 
 type
 
@@ -16,9 +16,9 @@ type
     BCComboBox1: TBCComboBox;
     Label1: TLabel;
     Label2: TLabel;
-    RadioWin7: TRadioButton;
-    RadioFlash: TRadioButton;
-    RadioCustom: TRadioButton;
+    RadioCustom: TBGRAThemeRadioButton;
+    RadioFlash: TBGRAThemeRadioButton;
+    RadioWin7: TBGRAThemeRadioButton;
     procedure BCComboBox1Change(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure RadioButtonChange(Sender: TObject);