diff --git a/components/rx/trunk/demos/RxSwitch/project1.ico b/components/rx/trunk/demos/RxSwitch/project1.ico
new file mode 100644
index 000000000..0341321b5
Binary files /dev/null and b/components/rx/trunk/demos/RxSwitch/project1.ico differ
diff --git a/components/rx/trunk/demos/RxSwitch/project1.lpi b/components/rx/trunk/demos/RxSwitch/project1.lpi
new file mode 100644
index 000000000..db0f610f4
--- /dev/null
+++ b/components/rx/trunk/demos/RxSwitch/project1.lpi
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/rx/trunk/demos/RxSwitch/project1.lpr b/components/rx/trunk/demos/RxSwitch/project1.lpr
new file mode 100644
index 000000000..b2bce819a
--- /dev/null
+++ b/components/rx/trunk/demos/RxSwitch/project1.lpr
@@ -0,0 +1,22 @@
+program project1;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, Unit1, rxnew
+ { you can add units after this };
+
+{$R *.res}
+
+begin
+ RequireDerivedFormResource:=True;
+ Application.Scaled:=True;
+ Application.Initialize;
+ Application.CreateForm(TForm1, Form1);
+ Application.Run;
+end.
+
diff --git a/components/rx/trunk/demos/RxSwitch/project1.lps b/components/rx/trunk/demos/RxSwitch/project1.lps
new file mode 100644
index 000000000..fdda65ff0
--- /dev/null
+++ b/components/rx/trunk/demos/RxSwitch/project1.lps
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/rx/trunk/demos/RxSwitch/project1.res b/components/rx/trunk/demos/RxSwitch/project1.res
new file mode 100644
index 000000000..1adb0406c
Binary files /dev/null and b/components/rx/trunk/demos/RxSwitch/project1.res differ
diff --git a/components/rx/trunk/demos/RxSwitch/unit1.lfm b/components/rx/trunk/demos/RxSwitch/unit1.lfm
new file mode 100644
index 000000000..b99fd1516
--- /dev/null
+++ b/components/rx/trunk/demos/RxSwitch/unit1.lfm
@@ -0,0 +1,71 @@
+object Form1: TForm1
+ Left = 600
+ Height = 344
+ Top = 231
+ Width = 474
+ Caption = 'Form1'
+ ClientHeight = 344
+ ClientWidth = 474
+ OnCreate = RxSwitch1Off
+ LCLVersion = '1.9.0.0'
+ object RxSwitch1: TRxSwitch
+ Left = 40
+ Height = 84
+ Top = 16
+ Width = 98
+ Caption = 'RxSwitch1'
+ TabOrder = 0
+ TextPosition = tpAbove
+ Style = swsClassic
+ OnOn = RxSwitch1Off
+ OnOff = RxSwitch1Off
+ end
+ object Label1: TLabel
+ AnchorSideLeft.Control = RxSwitch1
+ AnchorSideLeft.Side = asrCenter
+ AnchorSideTop.Control = RxSwitch1
+ AnchorSideTop.Side = asrBottom
+ Left = 68
+ Height = 20
+ Top = 100
+ Width = 42
+ Caption = 'Label1'
+ ParentColor = False
+ end
+ object RadioGroup1: TRadioGroup
+ Left = 216
+ Height = 117
+ Top = 16
+ Width = 161
+ AutoFill = True
+ AutoSize = True
+ Caption = 'Style'
+ ChildSizing.LeftRightSpacing = 6
+ ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
+ ChildSizing.EnlargeVertical = crsHomogenousChildResize
+ ChildSizing.ShrinkHorizontal = crsScaleChilds
+ ChildSizing.ShrinkVertical = crsScaleChilds
+ ChildSizing.Layout = cclLeftToRightThenTopToBottom
+ ChildSizing.ControlsPerLine = 1
+ ClientHeight = 96
+ ClientWidth = 159
+ ItemIndex = 0
+ Items.Strings = (
+ 'swsClassic'
+ 'swsNewHorizontal'
+ 'swsVerticalUD'
+ 'swsVerticalDU'
+ )
+ OnClick = RadioGroup1Click
+ TabOrder = 1
+ end
+ object RxSwitch2: TRxSwitch
+ Left = 40
+ Height = 60
+ Top = 200
+ Width = 50
+ Caption = 'RxSwitch2'
+ TabOrder = 2
+ Style = swsClassic
+ end
+end
diff --git a/components/rx/trunk/demos/RxSwitch/unit1.pas b/components/rx/trunk/demos/RxSwitch/unit1.pas
new file mode 100644
index 000000000..a2653b5da
--- /dev/null
+++ b/components/rx/trunk/demos/RxSwitch/unit1.pas
@@ -0,0 +1,50 @@
+unit Unit1;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
+ rxswitch;
+
+type
+
+ { TForm1 }
+
+ TForm1 = class(TForm)
+ Label1: TLabel;
+ RadioGroup1: TRadioGroup;
+ RxSwitch1: TRxSwitch;
+ RxSwitch2: TRxSwitch;
+ procedure RadioGroup1Click(Sender: TObject);
+ procedure RxSwitch1Off(Sender: TObject);
+ private
+
+ public
+
+ end;
+
+var
+ Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+const
+ SwithcStateStr:array [TSwithState] of string = ('OFF', 'ON');
+
+procedure TForm1.RxSwitch1Off(Sender: TObject);
+begin
+ Label1.Caption:=SwithcStateStr[RxSwitch1.StateOn];
+end;
+
+procedure TForm1.RadioGroup1Click(Sender: TObject);
+begin
+ RxSwitch1.Style:=TSwithStyle(RadioGroup1.ItemIndex);
+end;
+
+end.
+
diff --git a/components/rx/trunk/images/componet_img/all_component_res.sh b/components/rx/trunk/images/componet_img/all_component_res.sh
index 30530acda..c82e9e459 100644
--- a/components/rx/trunk/images/componet_img/all_component_res.sh
+++ b/components/rx/trunk/images/componet_img/all_component_res.sh
@@ -16,3 +16,5 @@ rm rxswitch.res
/usr/local/share/lazarus/tools/lazres pickdate.res rx_next1.png rx_next2.png rx_prev1.png rx_prev2.png
/usr/local/share/lazarus/tools/lazres rxswitch.res rxswitch_off.png rxswitch_on.png rx_ButtonOffHor.png rx_ButtonOffVertDown.png rx_ButtonOffVertUp.png rx_ButtonOnHor.png rx_ButtonOnVertDown.png rx_ButtonOnVertUp.png
+
+cp rxswitch.res ../../rxcontrols
diff --git a/components/rx/trunk/rxcontrols/rxswitch.pas b/components/rx/trunk/rxcontrols/rxswitch.pas
index b9b2bcb99..d1ab4e60f 100644
--- a/components/rx/trunk/rxcontrols/rxswitch.pas
+++ b/components/rx/trunk/rxcontrols/rxswitch.pas
@@ -44,7 +44,7 @@ type
TTextPos = (tpNone, tpLeft, tpRight, tpAbove, tpBelow);
TSwithState = (sw_off, sw_on);
- TSwithStyle = (swsClassic, swsNewHorizontal, swsNewVertical, swsCustom);
+ TSwithStyle = (swsClassic, swsHorizontal, swsVerticalUD, swsVerticalDU);
TSwitchBitmaps = set of TSwithState;
TRxSwitch = class(TCustomControl)
@@ -125,7 +125,7 @@ type
property Constraints;
property DragKind;
property Visible;
- property Style:TSwithStyle read FStyle write SetStyle;
+ property Style:TSwithStyle read FStyle write SetStyle default swsClassic;
property OnClick;
property OnDblClick;
property OnEnter;
@@ -166,8 +166,9 @@ var
I : TSwithState;
begin
inherited Create(AOwner);
- ControlStyle := [csClickEvents, csSetCaption, csCaptureMouse,
- csOpaque, csDoubleClicks];
+ ControlStyle := [csClickEvents, csSetCaption, csCaptureMouse, csOpaque, csDoubleClicks];
+ FStyle:=swsClassic;
+
Width := 50;
Height := 60;
for I := sw_off to sw_on do
@@ -293,6 +294,11 @@ begin
Result:=GetSwitchGlyph(sw_on);
end;
+const
+ s_sw_on : array [TSwithStyle] of string = ('rxswitch_on', 'rx_ButtonOnHor', 'rx_ButtonOnVertDown', 'rx_ButtonOnVertUp');
+ s_sw_off : array [TSwithStyle] of string = ('rxswitch_off', 'rx_ButtonOffHor', 'rx_ButtonOffVertUp', 'rx_ButtonOffVertDown');
+
+
procedure TRxSwitch.SetSwitchGlyph(Index: TSwithState; Value: TBitmap);
var
S: String;
@@ -310,14 +316,19 @@ begin
{ sw_off: FBitmaps[Index].Handle:=CreatePixmapIndirect(@RXSWITCH_OFF[0], GetSysColor(COLOR_BTNFACE));
sw_on: FBitmaps[Index].Handle:=CreatePixmapIndirect(@RXSWITCH_ON[0],
GetSysColor(COLOR_BTNFACE));}
- sw_off:S:='rxswitch_off';
- sw_on:S:='rxswitch_on';
+ //sw_off:S:='rxswitch_off';
+ //sw_on:S:='rxswitch_on';
+ sw_off:S:=s_sw_off[FStyle];
+ sw_on:S:=s_sw_on[FStyle];
else
Exit;
end;
- B:=CreateResBitmap(S);
- FBitmaps[Index].Assign(B);
- B.Free;
+ if S<>'' then
+ begin
+ B:=CreateResBitmap(S);
+ FBitmaps[Index].Assign(B);
+ B.Free;
+ end;
Exclude(FUserBitmaps, Index);
end;
end;
@@ -504,6 +515,8 @@ procedure TRxSwitch.SetStyle(AValue: TSwithStyle);
begin
if FStyle=AValue then Exit;
FStyle:=AValue;
+ SetSwitchGlyph(sw_off, nil);
+ SetSwitchGlyph(sw_on, nil);
end;
procedure TRxSwitch.SetSwitchGlyphOff(const AValue: TBitmap);
diff --git a/components/rx/trunk/rxcontrols/rxswitch.res b/components/rx/trunk/rxcontrols/rxswitch.res
index 343f8f2b2..b68304c5c 100644
Binary files a/components/rx/trunk/rxcontrols/rxswitch.res and b/components/rx/trunk/rxcontrols/rxswitch.res differ