From 07b9c83841e91f80140ba33a8d93e11620776f06 Mon Sep 17 00:00:00 2001 From: eugene1 Date: Sun, 5 Oct 2008 17:29:37 +0000 Subject: [PATCH] fixed TabPosition-change issue git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@582 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../gradcontrols/examples/Forms/unit1.lfm | 6 +- .../gradcontrols/examples/Forms/unit1.lrs | 94 ++++++------ .../gradcontrols/examples/Forms/unit1.pas | 2 +- .../gradcontrols/examples/gradcontroltest.lpi | 2 +- .../gradcontrols/src/ugradtabcontrol.pas | 135 +++++++++++++++--- 5 files changed, 168 insertions(+), 71 deletions(-) diff --git a/components/gradcontrols/examples/Forms/unit1.lfm b/components/gradcontrols/examples/Forms/unit1.lfm index 05b668b05..f090dbcfe 100644 --- a/components/gradcontrols/examples/Forms/unit1.lfm +++ b/components/gradcontrols/examples/Forms/unit1.lfm @@ -1,7 +1,7 @@ object Form1: TForm1 - Left = 165 + Left = 270 Height = 506 - Top = 182 + Top = 98 Width = 898 Caption = 'Form1' ClientHeight = 506 @@ -29,6 +29,8 @@ object Form1: TForm1 ControlStyle = [csAcceptsControls] PageIndex = -1 TabHeight = 30 + TabPosition = tpLeft + MoveIncrement = 1 end end object Panel2: TPanel diff --git a/components/gradcontrols/examples/Forms/unit1.lrs b/components/gradcontrols/examples/Forms/unit1.lrs index f7ea0422c..f9c1bcac7 100644 --- a/components/gradcontrols/examples/Forms/unit1.lrs +++ b/components/gradcontrols/examples/Forms/unit1.lrs @@ -1,51 +1,51 @@ { Das ist eine automatisch erzeugte Lazarus-Ressourcendatei } LazarusResources.Add('TForm1','FORMDATA',[ - 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#165#0#6'Height'#3#250#1#3'Top'#3#182#0#5 - +'Width'#3#130#3#7'Caption'#6#5'Form1'#12'ClientHeight'#3#250#1#11'ClientWidt' - +'h'#3#130#3#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#10'P' - +'arentFont'#8#10'LCLVersion'#6#6'0.9.27'#0#6'TPanel'#6'Panel1'#6'Height'#3 - +#250#1#5'Width'#3#239#2#5'Align'#7#6'alLeft'#7'Anchors'#11#5'akTop'#6'akLeft' - +#7'akRight'#8'akBottom'#0#7'Caption'#6#6'Panel1'#12'ClientHeight'#3#250#1#11 - +'ClientWidth'#3#239#2#8'TabOrder'#2#0#7'OnClick'#7#9'BewegeBtn'#0#15'TGradTa' - +'bControl'#15'GradTabControl1'#4'Left'#2#1#6'Height'#3#248#1#3'Top'#2#1#5'Wi' - +'dth'#3#237#2#5'Align'#7#8'alClient'#12'ControlStyle'#11#17'csAcceptsControl' - +'s'#0#9'PageIndex'#2#255#9'TabHeight'#2#30#0#0#0#6'TPanel'#6'Panel2'#4'Left' - +#3#244#2#6'Height'#3#250#1#5'Width'#3#142#0#5'Align'#7#8'alClient'#7'Caption' - +#6#6'Panel2'#12'ClientHeight'#3#250#1#11'ClientWidth'#3#142#0#8'TabOrder'#2#2 - +#7'OnClick'#7#11'Panel2Click'#0#6'TLabel'#6'Label1'#4'Left'#2#15#6'Height'#2 - +#14#3'Top'#3'0'#1#5'Width'#2'O'#7'Caption'#6#14'Move Increment'#11'ParentCol' - +'or'#8#0#0#9'TComboBox'#9'ComboBox1'#4'Left'#2#16#6'Height'#2#21#3'Top'#2#16 - +#5'Width'#2'd'#10'ItemHeight'#2#13#9'MaxLength'#2#255#8'OnChange'#7#15'Combo' - +'Box1Change'#5'Style'#7#14'csDropDownList'#8'TabOrder'#2#0#0#0#11'TRadioGrou' - +'p'#11'RadioGroup1'#4'Left'#2#17#6'Height'#2'q'#3'Top'#2'P'#5'Width'#2'd'#8 - +'AutoFill'#9#7'Caption'#6#12'Tab Position'#28'ChildSizing.LeftRightSpacing'#2 - +#6#28'ChildSizing.TopBottomSpacing'#2#6#29'ChildSizing.EnlargeHorizontal'#7 - +#24'crsHomogenousChildResize'#27'ChildSizing.EnlargeVertical'#7#24'crsHomoge' - +'nousChildResize'#28'ChildSizing.ShrinkHorizontal'#7#14'crsScaleChilds'#26'C' - +'hildSizing.ShrinkVertical'#7#14'crsScaleChilds'#18'ChildSizing.Layout'#7#29 - +'cclLeftToRightThenTopToBottom'#27'ChildSizing.ControlsPerLine'#2#1#12'Clien' - +'tHeight'#2'_'#11'ClientWidth'#2'`'#9'ItemIndex'#2#0#13'Items.Strings'#1#6#5 - +'tpTop'#6#8'tpBottom'#6#6'tpLeft'#6#7'tpRight'#0#7'OnClick'#7#16'RadioGroup1' - +'Click'#8'TabOrder'#2#2#0#0#9'TCheckBox'#9'CheckBox1'#4'Left'#2#15#6'Height' - +#2#19#3'Top'#3#20#1#5'Width'#2'K'#7'Caption'#6#9'Long Tabs'#7'Enabled'#8#7'O' - +'nClick'#7#14'CheckBox1Click'#8'TabOrder'#2#3#0#0#9'TSpinEdit'#9'SpinEdit1'#4 - +'Left'#2'_'#6'Height'#2#19#3'Top'#3#20#1#5'Width'#2'"'#7'Enabled'#8#8'MaxVal' - +'ue'#2'2'#13'OnEditingDone'#7#20'SpinEdit1EditingDone'#8'TabOrder'#2#1#5'Val' - +'ue'#2'2'#0#0#11'TGradButton'#11'GradButton1'#4'Left'#2#16#6'Height'#2#25#3 - +'Top'#2'0'#5'Width'#2'h'#7'Caption'#6#8'New Page'#7'OnClick'#7#9'BewegeBtn'#8 - +'TabOrder'#2#4#7'TabStop'#9#11'NormalBlend'#5#0#0#0#0#0#0#0#128#254'?'#9'Ove' - +'rBlend'#5'5^'#186'I'#12#2'+'#167#254'?'#9'BaseColor'#7#6'clBlue'#5'Color'#7 - +#6'clBlue'#16'NormalBlendColor'#7#7'clWhite'#14'OverBlendColor'#7#8'clSilver' - +#15'BackgroundColor'#7#9'clBtnFace'#11'BorderSides'#11#9'bsTopLine'#12'bsBot' - +'tomLine'#10'bsLeftLine'#11'bsRightLine'#0#15'ShowFocusBorder'#9#20'GlyphBac' - +'kgroundColor'#7#7'clWhite'#10'ClickColor'#7#6'clBlue'#22'AutoWidthBorderSpa' - +'cing'#2#15#0#0#9'TSpinEdit'#9'SpinEdit2'#4'Left'#2#15#6'Height'#2#23#3'Top' - +#3'@'#1#5'Width'#2'O'#8'MinValue'#2#156#8'OnChange'#7#15'SpinEdit2Change'#8 - +'TabOrder'#2#5#0#0#0#9'TSplitter'#9'Splitter1'#4'Left'#3#239#2#6'Height'#3 - +#250#1#5'Width'#2#5#0#0#10'TPopupMenu'#10'PopupMenu1'#4'left'#3#222#2#3'top' - +#3#141#1#0#9'TMenuItem'#9'MenuItem1'#7'Caption'#6#9'New Item1'#0#0#0#10'TSyn' - +'PHPSyn'#10'SynPHPSyn1'#13'DefaultFilter'#6'CPHP-Dateien (*.php,*.php3,*.pht' - +'ml,*.inc)|*.php;*.php3;*.phtml;*.inc'#7'Enabled'#8#4'left'#2's'#3'top'#3#255 - +#0#0#0#0 + 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#14#1#6'Height'#3#250#1#3'Top'#2'b'#5'Widt' + +'h'#3#130#3#7'Caption'#6#5'Form1'#12'ClientHeight'#3#250#1#11'ClientWidth'#3 + +#130#3#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#10'Parent' + +'Font'#8#10'LCLVersion'#6#6'0.9.27'#0#6'TPanel'#6'Panel1'#6'Height'#3#250#1#5 + +'Width'#3#239#2#5'Align'#7#6'alLeft'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRi' + +'ght'#8'akBottom'#0#7'Caption'#6#6'Panel1'#12'ClientHeight'#3#250#1#11'Clien' + +'tWidth'#3#239#2#8'TabOrder'#2#0#7'OnClick'#7#9'BewegeBtn'#0#15'TGradTabCont' + +'rol'#15'GradTabControl1'#4'Left'#2#1#6'Height'#3#248#1#3'Top'#2#1#5'Width'#3 + +#237#2#5'Align'#7#8'alClient'#12'ControlStyle'#11#17'csAcceptsControls'#0#9 + +'PageIndex'#2#255#9'TabHeight'#2#30#11'TabPosition'#7#6'tpLeft'#13'MoveIncre' + +'ment'#2#1#0#0#0#6'TPanel'#6'Panel2'#4'Left'#3#244#2#6'Height'#3#250#1#5'Wid' + +'th'#3#142#0#5'Align'#7#8'alClient'#7'Caption'#6#6'Panel2'#12'ClientHeight'#3 + +#250#1#11'ClientWidth'#3#142#0#8'TabOrder'#2#2#7'OnClick'#7#11'Panel2Click'#0 + +#6'TLabel'#6'Label1'#4'Left'#2#15#6'Height'#2#14#3'Top'#3'0'#1#5'Width'#2'O' + +#7'Caption'#6#14'Move Increment'#11'ParentColor'#8#0#0#9'TComboBox'#9'ComboB' + +'ox1'#4'Left'#2#16#6'Height'#2#21#3'Top'#2#16#5'Width'#2'd'#10'ItemHeight'#2 + +#13#9'MaxLength'#2#255#8'OnChange'#7#15'ComboBox1Change'#5'Style'#7#14'csDro' + +'pDownList'#8'TabOrder'#2#0#0#0#11'TRadioGroup'#11'RadioGroup1'#4'Left'#2#17 + +#6'Height'#2'q'#3'Top'#2'P'#5'Width'#2'd'#8'AutoFill'#9#7'Caption'#6#12'Tab ' + +'Position'#28'ChildSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpac' + +'ing'#2#6#29'ChildSizing.EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27 + +'ChildSizing.EnlargeVertical'#7#24'crsHomogenousChildResize'#28'ChildSizing.' + +'ShrinkHorizontal'#7#14'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14 + +'crsScaleChilds'#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom' + +#27'ChildSizing.ControlsPerLine'#2#1#12'ClientHeight'#2'_'#11'ClientWidth'#2 + +'`'#9'ItemIndex'#2#0#13'Items.Strings'#1#6#5'tpTop'#6#8'tpBottom'#6#6'tpLeft' + +#6#7'tpRight'#0#7'OnClick'#7#16'RadioGroup1Click'#8'TabOrder'#2#2#0#0#9'TChe' + +'ckBox'#9'CheckBox1'#4'Left'#2#15#6'Height'#2#19#3'Top'#3#20#1#5'Width'#2'K' + +#7'Caption'#6#9'Long Tabs'#7'Enabled'#8#7'OnClick'#7#14'CheckBox1Click'#8'Ta' + +'bOrder'#2#3#0#0#9'TSpinEdit'#9'SpinEdit1'#4'Left'#2'_'#6'Height'#2#19#3'Top' + +#3#20#1#5'Width'#2'"'#7'Enabled'#8#8'MaxValue'#2'2'#13'OnEditingDone'#7#20'S' + +'pinEdit1EditingDone'#8'TabOrder'#2#1#5'Value'#2'2'#0#0#11'TGradButton'#11'G' + +'radButton1'#4'Left'#2#16#6'Height'#2#25#3'Top'#2'0'#5'Width'#2'h'#7'Caption' + +#6#8'New Page'#7'OnClick'#7#9'BewegeBtn'#8'TabOrder'#2#4#7'TabStop'#9#11'Nor' + +'malBlend'#5#0#0#0#0#0#0#0#128#254'?'#9'OverBlend'#5'5^'#186'I'#12#2'+'#167 + +#254'?'#9'BaseColor'#7#6'clBlue'#5'Color'#7#6'clBlue'#16'NormalBlendColor'#7 + +#7'clWhite'#14'OverBlendColor'#7#8'clSilver'#15'BackgroundColor'#7#9'clBtnFa' + +'ce'#11'BorderSides'#11#9'bsTopLine'#12'bsBottomLine'#10'bsLeftLine'#11'bsRi' + +'ghtLine'#0#15'ShowFocusBorder'#9#20'GlyphBackgroundColor'#7#7'clWhite'#10'C' + +'lickColor'#7#6'clBlue'#22'AutoWidthBorderSpacing'#2#15#0#0#9'TSpinEdit'#9'S' + +'pinEdit2'#4'Left'#2#15#6'Height'#2#23#3'Top'#3'@'#1#5'Width'#2'O'#8'MinValu' + +'e'#2#156#8'OnChange'#7#15'SpinEdit2Change'#8'TabOrder'#2#5#0#0#0#9'TSplitte' + +'r'#9'Splitter1'#4'Left'#3#239#2#6'Height'#3#250#1#5'Width'#2#5#0#0#10'TPopu' + +'pMenu'#10'PopupMenu1'#4'left'#3#222#2#3'top'#3#141#1#0#9'TMenuItem'#9'MenuI' + +'tem1'#7'Caption'#6#9'New Item1'#0#0#0#10'TSynPHPSyn'#10'SynPHPSyn1'#13'Defa' + +'ultFilter'#6'CPHP-Dateien (*.php,*.php3,*.phtml,*.inc)|*.php;*.php3;*.phtml' + +';*.inc'#7'Enabled'#8#4'left'#2's'#3'top'#3#255#0#0#0#0 ]); diff --git a/components/gradcontrols/examples/Forms/unit1.pas b/components/gradcontrols/examples/Forms/unit1.pas index 141d3d37d..5cabef75f 100644 --- a/components/gradcontrols/examples/Forms/unit1.pas +++ b/components/gradcontrols/examples/Forms/unit1.pas @@ -302,7 +302,7 @@ begin //WriteLn(R, ' ', G, ' ', B, ColorToString(RGBToColor(R,G,B))); GradTabControl1.CurrentPage.Caption:='tab_'+IntToStr(C); - GradTabControl1.CurrentPage.Color:=RGBToColor(R, G, B); + //GradTabControl1.CurrentPage.Color:=RGBToColor(R, G, B); GradTabControl1.CurrentPage.TabPopupMenu := PopupMenu1; GradTabControl1.CurrentPage.PopupMenu:= PopupMenu1; diff --git a/components/gradcontrols/examples/gradcontroltest.lpi b/components/gradcontrols/examples/gradcontroltest.lpi index 94964c2e0..2c6347e70 100644 --- a/components/gradcontrols/examples/gradcontroltest.lpi +++ b/components/gradcontrols/examples/gradcontroltest.lpi @@ -15,7 +15,7 @@ - + diff --git a/components/gradcontrols/src/ugradtabcontrol.pas b/components/gradcontrols/src/ugradtabcontrol.pas index 5d19f1feb..9910f6a33 100644 --- a/components/gradcontrols/src/ugradtabcontrol.pas +++ b/components/gradcontrols/src/ugradtabcontrol.pas @@ -704,14 +704,14 @@ procedure TGradTabPagesBar.InsertButton(AButton: TGradTabPageButton; Index: Inte var LastLeft : Integer; begin - Left := 0; + LastLeft := 0; if (Index >= 1) AND (FPageList.Count>=1) then LastLeft := TGradTabPage(FPageList.Items[Index-1]).TabButton.Left; with AButton do begin - Left := -123; + Left := LastLeft; Parent := Self; ShowFocusBorder:=false; AutoWidth:=true; @@ -805,16 +805,25 @@ end; ------------------------------------------------------------------------------} procedure TGradTabPagesBar.OrderButtons; var - LastLeft, LastTop, i: Integer; + LastLeft, LastTop, i, BarWidth, BarHeight: Integer; NewDirection: TRotateDirection; NewBorderSides: TBorderSides; NewGradientType: TGradientType; + B : TGradButton; begin DebugLn('OrderButton Start'); LastLeft:= FMovedTo; LastTop := FMovedTo; + { if FTabPosition in [tpTop, tpBottom] then begin + BarWidth:= Width; + BarHeight:= 0; + end else begin } + BarWidth := Width; + BarHeight:= Height; + //end; + case FTabPosition of tpTop: begin @@ -843,33 +852,105 @@ begin end; for i := 0 to FPageList.Count - 1 do - with TGradTabPage(FPageList.Items[i]).TabButton do begin - if Visible then - begin - DebugLn('I: %d W: %d H: %d L: %d T: %d',[i,Width,Height,Left,Top]); + B := TGradTabPage(FPageList.Items[i]).TabButton; + + if B.Visible then + begin + B.RotateDirection := NewDirection; + B.BorderSides := NewBorderSides; + B.GradientType := NewGradientType; + + DebugLn('Begin I: %d W: %d H: %d L: %d T: %d, BW: %d, BH: %d',[i,B.Width,B.Height,B.Left,B.Top,BarWidth,BarHeight]); + + case FTabPosition of + tpTop: + begin + B.Left := LastLeft; + LastLeft := LastLeft + B.Width + 1; + + if FActiveIndex = i then begin + B.Top := 0; + B.Height:= BarHeight; + end else begin + B.Top := 3; + B.Height:= BarHeight-3; + end; + end; + tpBottom: + begin + B.Left := LastLeft; + LastLeft := LastLeft + B.Width + 1; + + B.Top := 0; + + if FActiveIndex = i then + B.Height := BarHeight + else + B.Height := BarHeight-3; + end; + tpLeft: + begin + B.Top := LastTop; + LastTop := LastTop + B.Height + 1; + + if FActiveIndex = i then begin + B.Left := 0; + B.Width:= BarWidth; + end else begin + B.Left := 3; + B.Width:= BarWidth-3; + end; + end; + tpRight: + begin + B.Top := LastTop; + LastTop := LastTop + B.Height + 1; + + B.Left := 0; + + if FActiveIndex = i then + B.Width := BarWidth + else + B.Width := BarWidth-3; + end; + end; + + + - RotateDirection := NewDirection; {if FActiveIndex = i then FocusButton(i) else UnFocusButton(i); } - BorderSides := NewBorderSides; - GradientType := NewGradientType; - if FTabPosition in [tpTop, tpBottom] then + + {if FTabPosition in [tpTop, tpBottom] then begin - Left := LastLeft; - LastLeft := LastLeft + Width + 1; + B.Left := LastLeft; + LastLeft := LastLeft + B.Width + 1; + if FTabPosition = tpBottom then begin + + + + + end else begin + + end; end else begin - Top := LastTop; - LastTop := LastTop + Height + 1; - end; + + if FTabPosition = tpRight then begin + + + end else + end; } + + DebugLn('End I: %d W: %d H: %d L: %d T: %d, BW: %d, BH: %d',[i,B.Width,B.Height,B.Left,B.Top,BarWidth,BarHeight]) end; end; DebugLn('OrderButton End'); @@ -946,7 +1027,20 @@ end; TGradTabPagesBar SetTabPosition(Value: TTabPosition) ------------------------------------------------------------------------------} procedure TGradTabPagesBar.SetTabPosition(Value: TTabPosition); + + function DbgsTabPosition(V : TTabPosition) : String; + begin + case V of + tpTop : Result := 'tpTop'; + tpBottom: Result := 'tpBottom'; + tpRight: Result := 'tpRight'; + tpLeft: Result := 'tpLeft'; + end; + end; + begin + if FTabPosition = Value then Exit; + DebugLn('Change TabPosition from %s to %s',[DbgsTabPosition(FTabPosition),DbgsTabPosition(Value)]); FTabPosition:=Value; OrderButtons; @@ -1509,10 +1603,10 @@ begin if (Value<0) or (Value>=fPageList.Count) then Exit; if FPageIndex=Value then Exit; - if FPageIndex <> -1 then - UnShowPage(FPageIndex); + if FPageIndex <> -1 then UnShowPage(FPageIndex); ShowPage(Value); + FPagesBar.FocusButton(Value); FPageIndex := Value; @@ -1800,8 +1894,7 @@ begin end; end; - FPagesBar.Align:=alClient; - FPagesBar.TabPosition:=Value; + //FPagesBar.Align:=alClient; case Value of tpTop: begin @@ -1834,6 +1927,8 @@ begin end; end; + FPagesBar.TabPosition:=Value; + {$IFDEF DEBUGTAB} DebugLn('After'); DebugLn('FBar Left %d Top %d Height %d Width %d',[ FBar.Left, Fbar.Top, FBar.Height, FBar.Width]);