View Issue Details

IDProjectCategoryView StatusLast Update
0003942JEDI VCL00 JVCL Componentspublic2006-12-03 05:47
ReporterRoman GanzAssigned Torobert_marquardt 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version 
Summary0003942: checkable JvGroupbox
DescriptionI often need a Groupbox with a included Checkbox instead of the Caption.
I need this for example for optional Filters of Tables or other optional Configurations.

When the Checkbox is checked, all Child-Components of the Groupbox
should be enabled and when the Checkbox is unchecked then all Child-Components of the Groupbox should be disabled (but not the Checkbox itself).

I don't know if someone else could use that, but for me, it would make a lot easier.
Additional InformationI made a first try, it should be backward compatible... Please check it.
TagsNo tags attached.

Activities

2006-10-06 15:28

 

JvGroupBox.patch (4,176 bytes)
Index: JvGroupBox.pas
===================================================================
--- JvGroupBox.pas	(Revision 10965)
+++ JvGroupBox.pas	(Arbeitskopie)
@@ -14,7 +14,8 @@
 Portions created by Peter Below are Copyright (C) 2000 Peter Below.
 All Rights Reserved.
 
-Contributor(s): ______________________________________.
+Contributor(s):
+Roman Ganz
 
 You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
 located at http://jvcl.sourceforge.net
@@ -34,14 +35,24 @@
   JclUnitVersioning,
   {$ENDIF UNITVERSIONING}
   SysUtils, Classes, Windows, Messages, Graphics, Controls, Forms, StdCtrls,
-  JvThemes, JvExControls, JvExStdCtrls, JvJCLUtils, JvComponent;
+  JvThemes, JvExControls, JvExStdCtrls, JvJCLUtils, JvComponent, JvCheckBox;
 
 type
   TJvGroupBox = class(TJvExGroupBox, IJvDenySubClassing)
   private
+    FCheckBox: TJvCheckBox;
+    FOnCheck: TNotifyEvent;
     FOnHotKey: TNotifyEvent;
     FPropagateEnable: Boolean;
+    FCheckable: Boolean;
     procedure SetPropagateEnable(const Value: Boolean);
+    procedure SetCheckable(const Value: Boolean);
+    function GetCaption: TCaption;
+    procedure SetCaption(const Value: TCaption);
+    function GetChecked: Boolean;
+    procedure SetChecked(const Value: Boolean);
+    function StoredCheckable: Boolean;
+    procedure SetOnCheck(const Value: TNotifyEvent);
   protected
     function WantKey(Key: Integer; Shift: TShiftState;
       const KeyText: WideString): Boolean; override;
@@ -52,11 +63,15 @@
     constructor Create(AOwner: TComponent); override;
     property Canvas;
   published
+    property Caption: TCaption read GetCaption write SetCaption;
+    property Checkable: Boolean read FCheckable write SetCheckable default False;
+    property Checked: Boolean read GetChecked write SetChecked stored StoredCheckable;
     property HintColor;
     {$IFDEF JVCLThemesEnabledD56}
     property ParentBackground default True;
     {$ENDIF JVCLThemesEnabledD56}
     property PropagateEnable: Boolean read FPropagateEnable write SetPropagateEnable default False;
+    property OnCheck: TNotifyEvent read FOnCheck write SetOnCheck;
     property OnMouseEnter;
     property OnMouseLeave;
     property OnParentColorChange;
@@ -86,6 +101,7 @@
   {$IFDEF JVCLThemesEnabledD56}
   IncludeThemeStyle(Self, [csParentBackground]);
   {$ENDIF JVCLThemesEnabledD56}
+  FCheckable := False;
 end;
 
 procedure TJvGroupBox.Paint;
@@ -198,12 +214,70 @@
   Invalidate;
 end;
 
+function TJvGroupBox.GetCaption: TCaption;
+begin
+  if FCheckable then
+    Result := FCheckBox.Caption
+  else
+    Result := inherited Caption;
+end;
+
+function TJvGroupBox.GetChecked: Boolean;
+begin
+  if FCheckable then
+    Result := FCheckBox.Checked
+  else
+    Result := False;
+end;
+
 procedure TJvGroupBox.DoHotKey;
 begin
   if Assigned(FOnHotKey) then
     FOnHotKey(Self);
 end;
 
+procedure TJvGroupBox.SetCaption(const Value: TCaption);
+begin
+  if FCheckable then
+    FCheckBox.Caption := Value
+  else
+    inherited Caption := Value;
+end;
+
+procedure TJvGroupBox.SetCheckable(const Value: Boolean);
+begin
+  if FCheckable <> Value then
+  begin
+    if Value then begin
+      FCheckBox := TJvCheckBox.Create(Self);
+      FCheckBox.Parent := Self;
+      FCheckBox.Top := 0;
+      FCheckBox.Left := 8;
+      FCheckBox.Caption := Caption;
+      inherited Caption := '';
+    end
+    else
+    begin
+      inherited Caption := FCheckBox.Caption;
+      FCheckBox.Free;
+    end;
+    FCheckable := Value;
+  end;
+end;
+
+procedure TJvGroupBox.SetChecked(const Value: Boolean);
+begin
+  if FCheckable then
+    FCheckBox.Checked := Value;
+end;
+
+procedure TJvGroupBox.SetOnCheck(const Value: TNotifyEvent);
+begin
+  FOnCheck := Value;
+  if FCheckable then
+    FCheckBox.OnClick := FOnCheck;
+end;
+
 procedure TJvGroupBox.SetPropagateEnable(const Value: Boolean);
 var
   I: Integer;
@@ -213,6 +287,11 @@
     Controls[I].Enabled := Enabled;
 end;
 
+function TJvGroupBox.StoredCheckable: Boolean;
+begin
+  Result := FCheckable and Checked;
+end;
+
 {$IFDEF UNITVERSIONING}
 initialization
   RegisterUnitVersion(HInstance, UnitVersioning);
JvGroupBox.patch (4,176 bytes)

Roman Ganz

2006-10-06 15:31

reporter   ~0010326

Oh, I forgot to say: the feature that all Child-Components were disabled on uncheck, is not implemented in the Patch. I dont know if we should...

robert_marquardt

2006-12-03 05:46

developer   ~0010449

Implemented. It needed some tweaks especially to implement nested TJvGroupBoxes.

Issue History

Date Modified Username Field Change
2006-10-06 15:28 Roman Ganz New Issue
2006-10-06 15:28 Roman Ganz File Added: JvGroupBox.patch
2006-10-06 15:31 Roman Ganz Note Added: 0010326
2006-12-03 05:46 robert_marquardt Note Added: 0010449
2006-12-03 05:47 robert_marquardt Status new => resolved
2006-12-03 05:47 robert_marquardt Resolution open => fixed
2006-12-03 05:47 robert_marquardt Assigned To => robert_marquardt