Improvements to update the tabsheet caption and adds events compatible with TPageControl

git-svn-id: trunk@33012 -
This commit is contained in:
sekelsenmat 2011-10-21 20:56:42 +00:00
parent e786f8a45e
commit d4d4ef453f

View File

@ -444,6 +444,8 @@ type
private private
CDTabControl: TCDCustomTabControl; CDTabControl: TCDCustomTabControl;
FTabVisible: Boolean; FTabVisible: Boolean;
protected
procedure RealSetText(const Value: TCaption); override; // to update on caption changes
public public
destructor Destroy; override; destructor Destroy; override;
property TabVisible: Boolean read FTabVisible write FTabVisible; property TabVisible: Boolean read FTabVisible write FTabVisible;
@ -454,6 +456,8 @@ type
FTabIndex: Integer; FTabIndex: Integer;
FTabs: TStringList; FTabs: TStringList;
FDrawerWinCE: TCDCustomTabControlDrawerWinCE; FDrawerWinCE: TCDCustomTabControlDrawerWinCE;
FOnChanging: TNotifyEvent;
FOnChange: TNotifyEvent;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: integer); override; X, Y: integer); override;
//procedure MouseMove(Shift: TShiftState; X, Y: integer); override; //procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
@ -472,6 +476,9 @@ type
public public
CustomDrawer: TCDCustomTabControlDrawer; // Fill the field to use the dsCustom draw mode CustomDrawer: TCDCustomTabControlDrawer; // Fill the field to use the dsCustom draw mode
property Tabs: TStringList read FTabs write SetTabs; property Tabs: TStringList read FTabs write SetTabs;
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property TabIndex: integer read FTabIndex write SetTabIndex;
end; end;
{ TCDCustomTabControlDrawer } { TCDCustomTabControlDrawer }
@ -517,9 +524,10 @@ type
published published
property Color; property Color;
property Font; property Font;
property TabIndex: integer read FTabIndex write SetTabIndex;
property Tabs; property Tabs;
// property OnTabSelected: TTabSelectedEvent read fOnTabSelected write fOnTabSelected; property TabIndex;
property OnChanging;
property OnChange;
end; end;
{ TCDTabSheet } { TCDTabSheet }
@ -587,6 +595,9 @@ type
property ParentColor; property ParentColor;
property ParentFont; property ParentFont;
property TabStop default True; property TabStop default True;
property TabIndex;
property OnChanging;
property OnChange;
end; end;
procedure Register; procedure Register;
@ -617,6 +628,17 @@ end;
{ TCDCustomTabSheet } { TCDCustomTabSheet }
procedure TCDCustomTabSheet.RealSetText(const Value: TCaption);
var
lIndex: Integer;
begin
inherited RealSetText(Value);
lIndex := CDTabControl.Tabs.IndexOfObject(Self);
if lIndex >= 0 then
CDTabControl.Tabs.Strings[lIndex] := Value;
CDTabControl.Invalidate;
end;
destructor TCDCustomTabSheet.Destroy; destructor TCDCustomTabSheet.Destroy;
var var
lIndex: Integer; lIndex: Integer;
@ -979,7 +1001,9 @@ end;
procedure TCDCustomTabControl.SetTabIndex(AValue: Integer); procedure TCDCustomTabControl.SetTabIndex(AValue: Integer);
begin begin
if FTabIndex = AValue then Exit; if FTabIndex = AValue then Exit;
if Assigned(OnChanging) then OnChanging(Self);
FTabIndex := AValue; FTabIndex := AValue;
if Assigned(OnChange) then OnChange(Self);
Invalidate; Invalidate;
end; end;
@ -1054,7 +1078,7 @@ end;
procedure TCDCustomTabControl.CorrectTabIndex; procedure TCDCustomTabControl.CorrectTabIndex;
begin begin
if FTabIndex >= FTabs.Count then FTabIndex := FTabs.Count - 1; if FTabIndex >= FTabs.Count then SetTabIndex(FTabs.Count - 1);
end; end;
{ TCustomBitmappedButton } { TCustomBitmappedButton }
@ -2456,7 +2480,7 @@ begin
Application.ReleaseComponent(TComponent(FTabs.Objects[AIndex])); Application.ReleaseComponent(TComponent(FTabs.Objects[AIndex]));
FTabs.Delete(aIndex); FTabs.Delete(aIndex);
if FTabIndex >= FTabs.Count then Dec(FTabIndex); if FTabIndex >= FTabs.Count then SetTabIndex(FTabIndex-1);
Invalidate; Invalidate;
end; end;
@ -2534,7 +2558,7 @@ begin
CurPage.Visible := True; CurPage.Visible := True;
// Check first, Tab is Visible? // Check first, Tab is Visible?
FTabIndex := i; SetTabIndex(i);
end end
else if CurPage <> nil then else if CurPage <> nil then
begin begin
@ -2551,7 +2575,7 @@ procedure TCDPageControl.SetPageIndex(Value: integer);
begin begin
if (Value > -1) and (Value < FTabs.Count) then if (Value > -1) and (Value < FTabs.Count) then
begin begin
FTabIndex := Value; SetTabIndex(Value);
ActivePage := GetPage(Value); ActivePage := GetPage(Value);
end; end;
end; end;