started TTabControlNotebookStrings

git-svn-id: trunk@5952 -
This commit is contained in:
mattias 2004-09-09 22:00:37 +00:00
parent 81a54223f5
commit 4643737fa0
4 changed files with 183 additions and 38 deletions

View File

@ -272,17 +272,61 @@ type
{$IFDEF EnableTabControl}
{ TCustomTabControl }
TCustomTabControl = class;
{ TTabControlStrings }
TTabControlStrings = class(TStrings)
private
FTabControl: TCustomTabControl;
protected
function GetTabIndex: integer; virtual; abstract;
procedure SetTabIndex(const AValue: integer); virtual; abstract;
public
constructor Create(TheTabControl: TCustomTabControl); virtual;
function GetSize: integer; virtual; abstract;
procedure TabControlBoundsChange; virtual;
public
property TabControl: TCustomTabControl read FTabControl;
property TabIndex: integer read GetTabIndex write SetTabIndex;
end;
{ TTabControlNoteBookStrings }
TTabControlNoteBookStrings = class(TTabControlStrings)
private
FNoteBook: TNoteBook;
protected
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
function GetObject(Index: Integer): TObject; override;
procedure Put(Index: Integer; const S: string); override;
procedure PutObject(Index: Integer; AObject: TObject); override;
procedure SetUpdateState(Updating: Boolean); override;
function GetTabIndex: integer; override;
procedure SetTabIndex(const AValue: integer); override;
public
constructor Create(TheTabControl: TCustomTabControl); override;
destructor Destroy; override;
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
function GetSize: integer; override;
procedure TabControlBoundsChange; override;
public
property NoteBook: TNoteBook read FNoteBook;
end;
{ TCustomTabControl }
TDrawTabEvent = procedure(Control: TCustomTabControl; TabIndex: Integer;
const Rect: TRect; Active: Boolean) of object;
TCustomTabControl = class(TWinControl)
TCustomTabControl = class(TCustomControl)
private
FCanvas: TCanvas;
FHotTrack: Boolean;
FImageChangeLink: TChangeLink;
FImages: TCustomImageList;
@ -326,6 +370,7 @@ type
procedure SetTabIndex(Value: Integer); virtual;
procedure UpdateTabImages;
procedure ImageListChange(Sender: TObject); virtual;
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
protected
property DisplayRect: TRect read GetDisplayRect;
property HotTrack: Boolean read FHotTrack write SetHotTrack default False;
@ -335,7 +380,8 @@ type
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChanging: TTabChangingEvent read FOnChanging write FOnChanging;
property OnDrawTab: TDrawTabEvent read FOnDrawTab write FOnDrawTab;
property OnGetImageIndex: TTabGetImageEvent read FOnGetImageIndex write FOnGetImageIndex;
property OnGetImageIndex: TTabGetImageEvent read FOnGetImageIndex
write FOnGetImageIndex;
property OwnerDraw: Boolean read FOwnerDraw write SetOwnerDraw default False;
property RaggedRight: Boolean read FRaggedRight write SetRaggedRight default False;
property ScrollOpposite: Boolean read FScrollOpposite
@ -355,7 +401,7 @@ type
function TabRect(Index: Integer): TRect;
function RowCount: Integer;
procedure ScrollTabs(Delta: Integer);
property Canvas: TCanvas read FCanvas;
public
property TabStop default True;
end;
@ -2456,6 +2502,9 @@ end.
{ =============================================================================
$Log$
Revision 1.148 2004/09/09 22:00:37 mattias
started TTabControlNotebookStrings
Revision 1.147 2004/09/09 09:35:44 mattias
renamed customradiogroup.inc to radiogroup.inc

View File

@ -1861,16 +1861,6 @@ begin
MoveWindowOrgEx(DC,X,Y);
end;
function CompareRect(R1, R2: PRect): Boolean;
begin
Result:=(R1^.Left=R2^.Left) and (R1^.Top=R2^.Top) and
(R1^.Bottom=R2^.Bottom) and (R1^.Right=R2^.Right);
{if not Result then begin
DebugLn(' DIFFER: ',R1^.Left,',',R1^.Top,',',R1^.Right,',',R1^.Bottom
,' <> ',R2^.Left,',',R2^.Top,',',R2^.Right,',',R2^.Bottom);
end;}
end;
function GetKeyShiftState: TShiftState;
begin
Result:=[];
@ -2410,6 +2400,9 @@ end.
{ =============================================================================
$Log$
Revision 1.246 2004/09/09 22:00:37 mattias
started TTabControlNotebookStrings
Revision 1.245 2004/09/08 22:59:54 mattias
started TTabControl

View File

@ -23,34 +23,118 @@
{$IFDEF EnableTabControl}
type
TTabControlStrings = class(TStrings)
protected
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
function GetObject(Index: Integer): TObject; override;
procedure Put(Index: Integer; const S: string); override;
procedure PutObject(Index: Integer; AObject: TObject); override;
procedure SetUpdateState(Updating: Boolean); override;
public
TabControl: TCustomTabControl;
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
end;
{ TTabControlStrings }
constructor TTabControlStrings.Create(TheTabControl: TCustomTabControl);
begin
inherited Create;
FTabControl:=TheTabControl;
end;
procedure TTabControlStrings.TabControlBoundsChange;
begin
end;
{ TTabControlNoteBookStrings }
function TTabControlNoteBookStrings.Get(Index: Integer): string;
begin
Result:=FNoteBook.Pages[Index];
end;
function TTabControlNoteBookStrings.GetCount: Integer;
begin
Result:=FNoteBook.PageCount;
end;
function TTabControlNoteBookStrings.GetObject(Index: Integer): TObject;
begin
Result:=FNoteBook.Pages.GetObject(Index);
end;
procedure TTabControlNoteBookStrings.Put(Index: Integer; const S: string);
begin
FNoteBook.Pages.Put(Index, S);
end;
procedure TTabControlNoteBookStrings.PutObject(Index: Integer; AObject: TObject
);
begin
FNoteBook.Pages.PutObject(Index, AObject);
end;
procedure TTabControlNoteBookStrings.SetUpdateState(Updating: Boolean);
begin
FNoteBook.Pages.SetUpdateState(Updating);
end;
function TTabControlNoteBookStrings.GetTabIndex: integer;
begin
Result:=FNoteBook.PageIndex;
end;
procedure TTabControlNoteBookStrings.SetTabIndex(const AValue: integer);
begin
FNoteBook.PageIndex:=AValue;
end;
constructor TTabControlNoteBookStrings.Create(TheTabControl: TCustomTabControl);
begin
inherited Create(TheTabControl);
FNoteBook:=TNoteBook.Create(nil);
FNoteBook.Parent:=TabControl;
TabControlBoundsChange;
end;
destructor TTabControlNoteBookStrings.Destroy;
begin
FreeThenNil(FNoteBook);
inherited Destroy;
end;
procedure TTabControlNoteBookStrings.Clear;
begin
FNoteBook.Pages.Clear;
end;
procedure TTabControlNoteBookStrings.Delete(Index: Integer);
begin
FNoteBook.Pages.Delete(Index);
end;
procedure TTabControlNoteBookStrings.Insert(Index: Integer; const S: string);
begin
FNoteBook.Pages.Insert(Index, S);
end;
function TTabControlNoteBookStrings.GetSize: integer;
begin
// ToDo
Result:=FNoteBook.Height;
end;
procedure TTabControlNoteBookStrings.TabControlBoundsChange;
begin
inherited TabControlBoundsChange;
FNoteBook.SetBounds(0,0,TabControl.Width,30);
end;
{ TCustomTabControl }
function TCustomTabControl.GetDisplayRect: TRect;
var
TabAreaSize: LongInt;
begin
// ToDo
Result:=ClientRect;
TabAreaSize:=TTabControlStrings(FTabs).GetSize;
Result.Top:=Min(TabAreaSize,Result.Bottom);
end;
function TCustomTabControl.GetTabIndex: Integer;
begin
Result:=FTabIndex;
// ToDo
Result:=TTabControlStrings(FTabs).TabIndex;
end;
procedure TCustomTabControl.SetHotTrack(const AValue: Boolean);
@ -125,9 +209,7 @@ end;
procedure TCustomTabControl.SetTabs(const AValue: TStrings);
begin
if FTabs=AValue then exit;
FTabs:=AValue;
// ToDo
FTabs.Assign(AValue);
end;
procedure TCustomTabControl.SetTabWidth(const AValue: Smallint);
@ -181,8 +263,7 @@ end;
procedure TCustomTabControl.SetTabIndex(Value: Integer);
begin
if TabIndex=Value then exit;
FTabIndex:=Value;
TTabControlStrings(FTabs).TabIndex:=Value;
end;
procedure TCustomTabControl.UpdateTabImages;
@ -195,6 +276,12 @@ begin
// ToDo
end;
procedure TCustomTabControl.DoSetBounds(ALeft, ATop, AWidth, AHeight: integer);
begin
inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
TTabControlStrings(FTabs).TabControlBoundsChange;
end;
constructor TCustomTabControl.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
@ -211,11 +298,13 @@ begin
FTabWidth:=0;
FImageChangeLink := TChangeLink.Create;
FImageChangeLink.OnChange := @ImageListChange;
FTabs:=TTabControlNoteBookStrings.Create(Self);
SetInitialBounds(0,0,200,150);
end;
destructor TCustomTabControl.Destroy;
begin
FreeThenNil(FTabs);
FreeThenNil(FImageChangeLink);
inherited Destroy;
end;
@ -257,6 +346,9 @@ end;
{ =============================================================================
$Log$
Revision 1.3 2004/09/09 22:00:37 mattias
started TTabControlNotebookStrings
Revision 1.2 2004/09/09 09:35:44 mattias
renamed customradiogroup.inc to radiogroup.inc

View File

@ -96,6 +96,7 @@ function BreakString(const s: string; MaxLineLength, Indent: integer): string;
function ComparePointers(p1, p2: Pointer): integer;
function CompareHandles(h1, h2: THandle): integer;
function CompareRect(R1, R2: PRect): Boolean;
function RoundToInt(const e: Extended): integer;
@ -678,6 +679,16 @@ begin
Result:=0;
end;
function CompareRect(R1, R2: PRect): Boolean;
begin
Result:=(R1^.Left=R2^.Left) and (R1^.Top=R2^.Top) and
(R1^.Bottom=R2^.Bottom) and (R1^.Right=R2^.Right);
{if not Result then begin
DebugLn(' DIFFER: ',R1^.Left,',',R1^.Top,',',R1^.Right,',',R1^.Bottom
,' <> ',R2^.Left,',',R2^.Top,',',R2^.Right,',',R2^.Bottom);
end;}
end;
function RoundToInt(const e: Extended): integer;
begin
Result:=integer(Round(e));