mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 06:01:51 +02:00
carbon: fixed notebook close page, insert page, setpageindex, bug #11719,#11680, #10171
git-svn-id: trunk@15852 -
This commit is contained in:
parent
a87d5a8d4b
commit
4969fb1643
14
ide/main.pp
14
ide/main.pp
@ -6736,9 +6736,8 @@ begin
|
|||||||
// update marks and cursor positions in Project1, so that merging the old
|
// update marks and cursor positions in Project1, so that merging the old
|
||||||
// settings during restoration will work
|
// settings during restoration will work
|
||||||
SaveSourceEditorProjectSpecificSettings;
|
SaveSourceEditorProjectSpecificSettings;
|
||||||
SourceNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.UnitName,
|
NewSrcEdit:=SourceNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.UnitName,
|
||||||
AFilename,-1),AnUnitInfo.Source,false);
|
AFilename,-1),AnUnitInfo.Source,false);
|
||||||
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
|
||||||
NewSrcEdit.EditorComponent.BeginUpdate;
|
NewSrcEdit.EditorComponent.BeginUpdate;
|
||||||
NewSrcEditorCreated:=true;
|
NewSrcEditorCreated:=true;
|
||||||
MainIDEBar.itmFileClose.Enabled:=True;
|
MainIDEBar.itmFileClose.Enabled:=True;
|
||||||
@ -6769,7 +6768,8 @@ begin
|
|||||||
if (not (ofProjectLoading in Flags)) and NewSrcEditorCreated then
|
if (not (ofProjectLoading in Flags)) and NewSrcEditorCreated then
|
||||||
Project1.InsertEditorIndex(SourceNotebook.Notebook.PageIndex);
|
Project1.InsertEditorIndex(SourceNotebook.Notebook.PageIndex);
|
||||||
AnUnitInfo.EditorIndex:=SourceNotebook.FindPageWithEditor(NewSrcEdit);
|
AnUnitInfo.EditorIndex:=SourceNotebook.FindPageWithEditor(NewSrcEdit);
|
||||||
|
//debugln(['TMainIDE.DoOpenFileInSourceEditor ',AnUnitInfo.Filename,' ',AnUnitInfo.EditorIndex]);
|
||||||
|
|
||||||
// restore source editor settings
|
// restore source editor settings
|
||||||
DoRestoreBookMarks(AnUnitInfo,NewSrcEdit);
|
DoRestoreBookMarks(AnUnitInfo,NewSrcEdit);
|
||||||
DebugBoss.DoRestoreDebuggerMarks(AnUnitInfo);
|
DebugBoss.DoRestoreDebuggerMarks(AnUnitInfo);
|
||||||
@ -7234,7 +7234,6 @@ var
|
|||||||
ReOpen, Handled:boolean;
|
ReOpen, Handled:boolean;
|
||||||
NewUnitInfo:TUnitInfo;
|
NewUnitInfo:TUnitInfo;
|
||||||
NewBuf: TCodeBuffer;
|
NewBuf: TCodeBuffer;
|
||||||
OtherUnitIndex: Integer;
|
|
||||||
FilenameNoPath: String;
|
FilenameNoPath: String;
|
||||||
LoadBufferFlags: TLoadBufferFlags;
|
LoadBufferFlags: TLoadBufferFlags;
|
||||||
DiskFilename: String;
|
DiskFilename: String;
|
||||||
@ -7364,13 +7363,6 @@ begin
|
|||||||
if (not (ofRevert in Flags)) then begin
|
if (not (ofRevert in Flags)) then begin
|
||||||
UnitIndex:=Project1.IndexOfFilename(AFilename);
|
UnitIndex:=Project1.IndexOfFilename(AFilename);
|
||||||
ReOpen:=(UnitIndex>=0);
|
ReOpen:=(UnitIndex>=0);
|
||||||
// check if there is already a symlinked file open in the editor
|
|
||||||
OtherUnitIndex:=Project1.IndexOfFilename(AFilename,
|
|
||||||
[pfsfOnlyEditorFiles]);
|
|
||||||
if (OtherUnitIndex>=0) and (OtherUnitIndex<>UnitIndex) then begin
|
|
||||||
// There is another file open in the editor symlinked to the same file
|
|
||||||
// ToDo
|
|
||||||
end;
|
|
||||||
if ReOpen then begin
|
if ReOpen then begin
|
||||||
NewUnitInfo:=Project1.Units[UnitIndex];
|
NewUnitInfo:=Project1.Units[UnitIndex];
|
||||||
if (ofAddToProject in Flags) and (not NewUnitInfo.IsPartOfProject) then
|
if (ofAddToProject in Flags) and (not NewUnitInfo.IsPartOfProject) then
|
||||||
|
@ -715,8 +715,8 @@ type
|
|||||||
procedure StartShowCodeHelp;
|
procedure StartShowCodeHelp;
|
||||||
|
|
||||||
// new, close, focus
|
// new, close, focus
|
||||||
procedure NewFile(const NewShortName: String; ASource: TCodeBuffer;
|
function NewFile(const NewShortName: String; ASource: TCodeBuffer;
|
||||||
FocusIt: boolean);
|
FocusIt: boolean): TSourceEditor;
|
||||||
procedure CloseFile(PageIndex:integer);
|
procedure CloseFile(PageIndex:integer);
|
||||||
procedure FocusEditor;
|
procedure FocusEditor;
|
||||||
|
|
||||||
@ -4377,10 +4377,12 @@ Begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result := TSourceEditor.Create(Self,Notebook.Page[PageNum]);
|
Result := TSourceEditor.Create(Self,Notebook.Page[PageNum]);
|
||||||
Result.EditorComponent.BeginUpdate;
|
Result.EditorComponent.BeginUpdate;
|
||||||
|
//debugln(['TSourceNotebook.NewSE PageNum=',PageNum,' Notebook.PageIndex=',Notebook.PageIndex,' FindPageWithEditor=',FindPageWithEditor(Result)]);
|
||||||
|
|
||||||
FSourceEditorList.Add(Result);
|
FSourceEditorList.Add(Result);
|
||||||
Result.CodeTemplates:=CodeTemplateModul;
|
Result.CodeTemplates:=CodeTemplateModul;
|
||||||
Notebook.PageIndex := Pagenum;
|
Notebook.PageIndex := Pagenum;
|
||||||
|
//debugln(['TSourceNotebook.NewSE C GetActiveSE=Result=',GetActiveSE=Result]);
|
||||||
Result.FPageName:=NoteBook.Pages[Pagenum];
|
Result.FPageName:=NoteBook.Pages[Pagenum];
|
||||||
Result.EditorComponent.BookMarkOptions.BookmarkImages :=
|
Result.EditorComponent.BookMarkOptions.BookmarkImages :=
|
||||||
SourceEditorMarks.ImgList;
|
SourceEditorMarks.ImgList;
|
||||||
@ -5639,25 +5641,23 @@ begin
|
|||||||
BookMarkGoTo(Value);
|
BookMarkGoTo(Value);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Procedure TSourceNotebook.NewFile(const NewShortName: String;
|
function TSourceNotebook.NewFile(const NewShortName: String;
|
||||||
ASource: TCodeBuffer; FocusIt: boolean);
|
ASource: TCodeBuffer; FocusIt: boolean): TSourceEditor;
|
||||||
Var
|
|
||||||
TempEditor: TSourceEditor;
|
|
||||||
Begin
|
Begin
|
||||||
//create a new page
|
//create a new page
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('[TSourceNotebook.NewFile] A ');
|
writeln('[TSourceNotebook.NewFile] A ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Visible:=true;
|
Visible:=true;
|
||||||
TempEditor := NewSE(-1);
|
Result := NewSE(-1);
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('[TSourceNotebook.NewFile] B ');
|
writeln('[TSourceNotebook.NewFile] B ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TempEditor.CodeBuffer:=ASource;
|
Result.CodeBuffer:=ASource;
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('[TSourceNotebook.NewFile] D ');
|
writeln('[TSourceNotebook.NewFile] D ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TempEditor.PageName:=FindUniquePageName(NewShortName,Notebook.PageIndex);
|
Result.PageName:=FindUniquePageName(NewShortName,Notebook.PageIndex);
|
||||||
if FocusIt then FocusEditor;
|
if FocusIt then FocusEditor;
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('[TSourceNotebook.NewFile] end');
|
writeln('[TSourceNotebook.NewFile] end');
|
||||||
@ -5674,20 +5674,22 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TempEditor:=FindSourceEditorWithPageIndex(PageIndex);
|
TempEditor:=FindSourceEditorWithPageIndex(PageIndex);
|
||||||
if TempEditor=nil then exit;
|
if TempEditor=nil then exit;
|
||||||
|
//debugln(['TSourceNotebook.CloseFile ',TempEditor.FileName,' ',TempEditor.PageIndex]);
|
||||||
Visible:=true;
|
Visible:=true;
|
||||||
EndIncrementalFind;
|
EndIncrementalFind;
|
||||||
TempEditor.Close;
|
TempEditor.Close;
|
||||||
TempEditor.Free;
|
TempEditor.Free;
|
||||||
if Notebook.PageCount>1 then
|
if Notebook.PageCount>1 then
|
||||||
begin
|
begin
|
||||||
//writeln('TSourceNotebook.CloseFile B PageIndex=',PageIndex);
|
//writeln('TSourceNotebook.CloseFile B PageIndex=',PageIndex,' Notebook.PageIndex=',Notebook.PageIndex);
|
||||||
// if this is the current page, switch to right PageIndex (if possible)
|
// if this is the current page, switch to right PageIndex (if possible)
|
||||||
if (Notebook.PageIndex = PageIndex) then
|
if (Notebook.PageIndex = PageIndex) then
|
||||||
Notebook.PageIndex := PageIndex +
|
Notebook.PageIndex := PageIndex +
|
||||||
IfThen(PageIndex + 1 < Notebook.PageCount, 1, -1);
|
IfThen(PageIndex + 1 < Notebook.PageCount, 1, -1);
|
||||||
// delete the page
|
// delete the page
|
||||||
|
//writeln('TSourceNotebook.CloseFile C PageIndex=',PageIndex,' Notebook.PageCount=',Notebook.PageCount,' NoteBook.PageIndex=',Notebook.PageIndex);
|
||||||
Notebook.Pages.Delete(PageIndex);
|
Notebook.Pages.Delete(PageIndex);
|
||||||
//writeln('TSourceNotebook.CloseFile C PageIndex=',PageIndex,' Notebook.PageCount=',Notebook.PageCount);
|
//writeln('TSourceNotebook.CloseFile D PageIndex=',PageIndex,' Notebook.PageCount=',Notebook.PageCount,' NoteBook.PageIndex=',Notebook.PageIndex);
|
||||||
UpdateStatusBar;
|
UpdateStatusBar;
|
||||||
// set focus to new editor
|
// set focus to new editor
|
||||||
TempEditor:=FindSourceEditorWithPageIndex(Notebook.PageIndex);
|
TempEditor:=FindSourceEditorWithPageIndex(Notebook.PageIndex);
|
||||||
@ -5695,9 +5697,9 @@ begin
|
|||||||
TempEditor.EditorComponent.SetFocus;
|
TempEditor.EditorComponent.SetFocus;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
//writeln('TSourceNotebook.CloseFile D PageIndex=',PageIndex);
|
|
||||||
Notebook.Free;
|
|
||||||
//writeln('TSourceNotebook.CloseFile E PageIndex=',PageIndex);
|
//writeln('TSourceNotebook.CloseFile E PageIndex=',PageIndex);
|
||||||
|
Notebook.Free;
|
||||||
|
//writeln('TSourceNotebook.CloseFile F PageIndex=',PageIndex);
|
||||||
Notebook:=nil;
|
Notebook:=nil;
|
||||||
Hide;
|
Hide;
|
||||||
end;
|
end;
|
||||||
|
@ -42,9 +42,10 @@ type
|
|||||||
{ TCustomPage }
|
{ TCustomPage }
|
||||||
|
|
||||||
TPageFlag = (
|
TPageFlag = (
|
||||||
pfAdded, // page handle added to notebook handle
|
pfHandleAdded, // page handle added to notebook handle
|
||||||
pfAdding, // currently page handle adding to notebook handle
|
pfHandleAdding, // currently page handle adding to notebook handle
|
||||||
pfRemoving
|
pfHandleRemoving,
|
||||||
|
pfAdding
|
||||||
);
|
);
|
||||||
TPageFlags = set of TPageFlag;
|
TPageFlags = set of TPageFlag;
|
||||||
|
|
||||||
|
@ -36,9 +36,13 @@ end;
|
|||||||
procedure TNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
procedure TNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
procedure TNBPages.PageListChange(Ptr: Pointer; AnAction: TListNotification);
|
||||||
|
var
|
||||||
|
APage: TCustomPage;
|
||||||
begin
|
begin
|
||||||
if (AnAction=lnAdded) then begin
|
if (AnAction=lnAdded) then begin
|
||||||
(TObject(Ptr) as TCustomPage).Parent:=fNotebook;
|
APage:=TObject(Ptr) as TCustomPage;
|
||||||
|
if not (pfAdding in APage.FFlags) then
|
||||||
|
APage.Parent:=fNotebook;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -248,7 +252,7 @@ begin
|
|||||||
fAddingPages:=true;
|
fAddingPages:=true;
|
||||||
for i := 0 to FPageList.Count -1 do begin
|
for i := 0 to FPageList.Count -1 do begin
|
||||||
{$IFDEF NOTEBOOK_DEBUG}
|
{$IFDEF NOTEBOOK_DEBUG}
|
||||||
DebugLn(['TCustomNotebook.DoCreateWnd ',dbgsName(Self),' Page.Caption=',Page[i].Caption,' pfAdded=',pfAdded in Page[i].Flags]);
|
DebugLn(['TCustomNotebook.DoCreateWnd ',dbgsName(Self),' Page.Caption=',Page[i].Caption,' pfHandleAdded=',pfHandleAdded in Page[i].Flags]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
lPage := Page[i];
|
lPage := Page[i];
|
||||||
AddRemovePageHandle(lPage);
|
AddRemovePageHandle(lPage);
|
||||||
@ -444,6 +448,7 @@ procedure TCustomNotebook.InsertPage(APage: TCustomPage; Index: Integer);
|
|||||||
var
|
var
|
||||||
NewZPosition: integer;
|
NewZPosition: integer;
|
||||||
begin
|
begin
|
||||||
|
if FPageList.IndexOf(APage)>=0 then exit;
|
||||||
{$IFDEF NOTEBOOK_DEBUG}
|
{$IFDEF NOTEBOOK_DEBUG}
|
||||||
DebugLn(['TCustomNotebook.InsertPage A ',dbgsName(Self),' Index=',Index,' Name=',
|
DebugLn(['TCustomNotebook.InsertPage A ',dbgsName(Self),' Index=',Index,' Name=',
|
||||||
APage.Name,' Caption=',APage.Caption]);
|
APage.Name,' Caption=',APage.Caption]);
|
||||||
@ -454,7 +459,9 @@ begin
|
|||||||
NewZPosition:=GetControlIndex(TCustomPage(fPageList[Index]))
|
NewZPosition:=GetControlIndex(TCustomPage(fPageList[Index]))
|
||||||
else
|
else
|
||||||
NewZPosition:=-1;
|
NewZPosition:=-1;
|
||||||
|
Include(APage.FFlags,pfAdding);
|
||||||
FPageList.Insert(Index,APage);
|
FPageList.Insert(Index,APage);
|
||||||
|
Exclude(APage.FFlags,pfAdding);
|
||||||
APage.Parent := Self;
|
APage.Parent := Self;
|
||||||
if NewZPosition>=0 then
|
if NewZPosition>=0 then
|
||||||
SetControlIndex(APage,NewZPosition);
|
SetControlIndex(APage,NewZPosition);
|
||||||
@ -532,13 +539,13 @@ var
|
|||||||
RealIndex: Integer;
|
RealIndex: Integer;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
//DebugLn(['TCustomNotebook.WSMovePage APage=',DbgSName(APage),' NewIndex=',NewIndex,' pfAdded=',pfAdded in APage.FFlags]);
|
//DebugLn(['TCustomNotebook.WSMovePage APage=',DbgSName(APage),' NewIndex=',NewIndex,' pfHandleAdded=',pfHandleAdded in APage.FFlags]);
|
||||||
if HandleAllocated and (pfAdded in APage.FFlags) then begin
|
if HandleAllocated and (pfHandleAdded in APage.FFlags) then begin
|
||||||
RealIndex:=0;
|
RealIndex:=0;
|
||||||
i:=0;
|
i:=0;
|
||||||
repeat
|
repeat
|
||||||
if (i=NewIndex) or (i=PageCount) then break;
|
if (i=NewIndex) or (i=PageCount) then break;
|
||||||
if pfAdded in Page[i].FFlags then inc(RealIndex);
|
if pfHandleAdded in Page[i].FFlags then inc(RealIndex);
|
||||||
inc(i);
|
inc(i);
|
||||||
until false;
|
until false;
|
||||||
//DebugLn(['TCustomNotebook.WSMovePage APage=',DbgSName(APage),' NewIndex=',NewIndex,' RealIndex=',RealIndex]);
|
//DebugLn(['TCustomNotebook.WSMovePage APage=',DbgSName(APage),' NewIndex=',NewIndex,' RealIndex=',RealIndex]);
|
||||||
@ -551,24 +558,24 @@ begin
|
|||||||
if (not (csDestroying in APage.ComponentState))
|
if (not (csDestroying in APage.ComponentState))
|
||||||
and (APage.TabVisible or (csDesigning in ComponentState)) then begin
|
and (APage.TabVisible or (csDesigning in ComponentState)) then begin
|
||||||
{$IFDEF NOTEBOOK_DEBUG}
|
{$IFDEF NOTEBOOK_DEBUG}
|
||||||
DebugLn(['TCustomNoteBook.AddRemovePageHandle ADD ',DbgSName(APage),' pfAdded=',pfAdded in APage.FFlags]);
|
DebugLn(['TCustomNoteBook.AddRemovePageHandle ADD ',DbgSName(APage),' pfHandleAdded=',pfHandleAdded in APage.FFlags]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if (pfAdded in APage.FFlags) then exit;
|
if (pfHandleAdded in APage.FFlags) then exit;
|
||||||
Include(APage.FFlags,pfAdding);
|
Include(APage.FFlags,pfHandleAdding);
|
||||||
TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, APage.VisibleIndex);
|
TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, APage.VisibleIndex);
|
||||||
APage.FFlags:=APage.FFlags+[pfAdded]-[pfAdding];
|
APage.FFlags:=APage.FFlags+[pfHandleAdded]-[pfHandleAdding];
|
||||||
APage.ResizeDelayedAutoSizeChildren
|
APage.ResizeDelayedAutoSizeChildren
|
||||||
end else begin
|
end else begin
|
||||||
{$IFDEF NOTEBOOK_DEBUG}
|
{$IFDEF NOTEBOOK_DEBUG}
|
||||||
DebugLn(['TCustomNoteBook.AddRemovePageHandle REMOVE ',DbgSName(APage),' pfAdded=',pfAdded in APage.FFlags]);
|
DebugLn(['TCustomNoteBook.AddRemovePageHandle REMOVE ',DbgSName(APage),' pfHandleAdded=',pfHandleAdded in APage.FFlags]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if not (pfAdded in APage.FFlags) or (pfRemoving in APage.FFlags) then
|
if not (pfHandleAdded in APage.FFlags) or (pfHandleRemoving in APage.FFlags) then
|
||||||
exit;
|
exit;
|
||||||
APage.FFlags := APage.FFlags - [pfAdded] + [pfRemoving];
|
APage.FFlags := APage.FFlags - [pfHandleAdded] + [pfHandleRemoving];
|
||||||
TWSCustomNotebookClass(WidgetSetClass).RemovePage(Self, APage.VisibleIndex);
|
TWSCustomNotebookClass(WidgetSetClass).RemovePage(Self, APage.VisibleIndex);
|
||||||
if APage.HandleAllocated then
|
if APage.HandleAllocated then
|
||||||
APage.DestroyHandle;
|
APage.DestroyHandle;
|
||||||
Exclude(APage.FFlags, pfRemoving);
|
Exclude(APage.FFlags, pfHandleRemoving);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -102,12 +102,12 @@ var
|
|||||||
ParentNotebook: TCustomNotebook;
|
ParentNotebook: TCustomNotebook;
|
||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
if AParent=Parent then exit;
|
if (AParent=Parent) or (pfAdding in FFlags) then exit;
|
||||||
CheckNewParent(AParent);
|
CheckNewParent(AParent);
|
||||||
OldParent:=Parent;
|
OldParent:=Parent;
|
||||||
if (OldParent<>AParent) and (OldParent<>nil)
|
if (OldParent<>AParent) and (OldParent<>nil)
|
||||||
and (OldParent is TCustomNotebook)
|
and (OldParent is TCustomNotebook)
|
||||||
and (not (pfRemoving in FFlags)) then begin
|
and (not (pfHandleRemoving in FFlags)) then begin
|
||||||
// remove from old pagelist
|
// remove from old pagelist
|
||||||
ParentNotebook := TCustomNotebook(OldParent);
|
ParentNotebook := TCustomNotebook(OldParent);
|
||||||
i := PageIndex;
|
i := PageIndex;
|
||||||
@ -122,11 +122,8 @@ begin
|
|||||||
// add to new pagelist
|
// add to new pagelist
|
||||||
ParentNotebook:=TCustomNotebook(Parent);
|
ParentNotebook:=TCustomNotebook(Parent);
|
||||||
i:=ParentNotebook.PageList.IndexOf(Self);
|
i:=ParentNotebook.PageList.IndexOf(Self);
|
||||||
if i>=0 then
|
if i<0 then
|
||||||
ParentNotebook.PageList.Delete(i)
|
ParentNotebook.InsertPage(Self,ParentNotebook.PageCount);
|
||||||
else
|
|
||||||
i:=ParentNotebook.PageCount;
|
|
||||||
ParentNotebook.InsertPage(Self,i);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -203,7 +200,7 @@ end;
|
|||||||
procedure TCustomPage.DestroyHandle;
|
procedure TCustomPage.DestroyHandle;
|
||||||
begin
|
begin
|
||||||
inherited DestroyHandle;
|
inherited DestroyHandle;
|
||||||
Exclude(FFlags,pfAdded);
|
Exclude(FFlags,pfHandleAdded);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomPage.IsControlVisible: Boolean;
|
function TCustomPage.IsControlVisible: Boolean;
|
||||||
@ -248,7 +245,7 @@ end;
|
|||||||
|
|
||||||
function TCustomPage.AutoSizeDelayed: boolean;
|
function TCustomPage.AutoSizeDelayed: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(not (pfAdded in FFlags)) or (inherited AutoSizeDelayed);
|
Result:=(not (pfHandleAdded in FFlags)) or (inherited AutoSizeDelayed);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// included by extctrls.pp
|
// included by extctrls.pp
|
||||||
|
@ -75,6 +75,7 @@ type
|
|||||||
FNextArrow: ControlRef;
|
FNextArrow: ControlRef;
|
||||||
FScrollingLeftTimer: TTimer;
|
FScrollingLeftTimer: TTimer;
|
||||||
FScrollingRightTimer: TTimer;
|
FScrollingRightTimer: TTimer;
|
||||||
|
FLockChangeEvent: integer;
|
||||||
function GetPrevArrowBounds(const R: TRect): TRect;
|
function GetPrevArrowBounds(const R: TRect): TRect;
|
||||||
function GetNextArrowBounds(const R: TRect): TRect;
|
function GetNextArrowBounds(const R: TRect): TRect;
|
||||||
procedure ScrollingLeftTimer(Sender: TObject);
|
procedure ScrollingLeftTimer(Sender: TObject);
|
||||||
@ -88,12 +89,14 @@ type
|
|||||||
procedure UpdateTabs(EnsureLastVisible: Boolean = False; UpdateIndex: Boolean = True);
|
procedure UpdateTabs(EnsureLastVisible: Boolean = False; UpdateIndex: Boolean = True);
|
||||||
procedure UpdateTabIndex;
|
procedure UpdateTabIndex;
|
||||||
procedure Remove(ATab: TCarbonTab);
|
procedure Remove(ATab: TCarbonTab);
|
||||||
function GetControlTabIndex: Integer;
|
function GetControlTabIndex: Integer; // visible index, without hidden or scrolled tabs
|
||||||
function GetTabIndex(APageIndex: Integer): Integer;
|
function GetTabIndex(APageIndex: Integer): Integer;
|
||||||
function TabIndexToPageIndex(AIndex: Integer): Integer;
|
function TabIndexToPageIndex(AIndex: Integer): Integer;
|
||||||
public
|
public
|
||||||
class function GetValidEvents: TCarbonControlEvents; override;
|
class function GetValidEvents: TCarbonControlEvents; override;
|
||||||
procedure ValueChanged; override;
|
procedure ValueChanged; override;
|
||||||
|
procedure DisableChangeEvent;
|
||||||
|
procedure EnableChangeEvent;
|
||||||
public
|
public
|
||||||
function GetClientRect(var ARect: TRect): Boolean; override;
|
function GetClientRect(var ARect: TRect): Boolean; override;
|
||||||
function SetBounds(const ARect: TRect): Boolean; override;
|
function SetBounds(const ARect: TRect): Boolean; override;
|
||||||
@ -587,7 +590,13 @@ end;
|
|||||||
procedure TCarbonTabsControl.UpdateTabIndex;
|
procedure TCarbonTabsControl.UpdateTabIndex;
|
||||||
begin
|
begin
|
||||||
// set tab index
|
// set tab index
|
||||||
SetControl32BitValue(ControlRef(Widget), GetControlTabIndex);
|
//debugln(['TCarbonTabsControl.UpdateTabIndex FFirstIndex=',FFirstIndex,' FLastIndex=',FLastIndex,' TabIndex=',FTabIndex]);
|
||||||
|
DisableChangeEvent;
|
||||||
|
try
|
||||||
|
SetControl32BitValue(ControlRef(Widget), GetControlTabIndex);
|
||||||
|
finally
|
||||||
|
EnableChangeEvent;
|
||||||
|
end;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
ShowTab;
|
ShowTab;
|
||||||
end;
|
end;
|
||||||
@ -599,8 +608,12 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TCarbonTabsControl.Remove(ATab: TCarbonTab);
|
procedure TCarbonTabsControl.Remove(ATab: TCarbonTab);
|
||||||
begin
|
begin
|
||||||
|
// FTabs is a TObjectLisy and Remove frees the ATab, which will
|
||||||
|
// automatically call this proc again. Check if ATab is already removed.
|
||||||
|
if FTabs.IndexOf(ATab)<0 then exit;
|
||||||
FTabs.Remove(ATab);
|
FTabs.Remove(ATab);
|
||||||
UpdateTabs(False, False);
|
UpdateTabs(False, False);
|
||||||
|
//debugln(['TCarbonTabsControl.Remove ',GetControlTabIndex,' FFirstIndex=',FFirstIndex,' FTabIndex=',FTabIndex,' Count=',ftabs.Count]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonTabsControl.GetControlTabIndex: Integer;
|
function TCarbonTabsControl.GetControlTabIndex: Integer;
|
||||||
@ -609,6 +622,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonTabsControl.GetTabIndex(APageIndex: Integer): Integer;
|
function TCarbonTabsControl.GetTabIndex(APageIndex: Integer): Integer;
|
||||||
|
// find the index in FTabs with TCustomPage.PageIndex=APageIndex
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
@ -659,6 +673,7 @@ var
|
|||||||
NMHdr: TNMHDR;
|
NMHdr: TNMHDR;
|
||||||
Index, PIndex: Integer;
|
Index, PIndex: Integer;
|
||||||
begin
|
begin
|
||||||
|
if FLockChangeEvent>0 then exit;
|
||||||
Index := GetValue - 1;
|
Index := GetValue - 1;
|
||||||
if Index >= 0 then Inc(Index, FFirstIndex);
|
if Index >= 0 then Inc(Index, FFirstIndex);
|
||||||
|
|
||||||
@ -707,6 +722,16 @@ begin
|
|||||||
DeliverMessage(LCLObject, Msg);
|
DeliverMessage(LCLObject, Msg);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCarbonTabsControl.DisableChangeEvent;
|
||||||
|
begin
|
||||||
|
inc(FLockChangeEvent);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCarbonTabsControl.EnableChangeEvent;
|
||||||
|
begin
|
||||||
|
dec(FLockChangeEvent);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonTabsControl.GetClientRect
|
Method: TCarbonTabsControl.GetClientRect
|
||||||
Params: ARect - Record for client area coordinates
|
Params: ARect - Record for client area coordinates
|
||||||
@ -832,11 +857,13 @@ end;
|
|||||||
procedure TCarbonTabsControl.Add(ATab: TCarbonTab; AIndex: Integer);
|
procedure TCarbonTabsControl.Add(ATab: TCarbonTab; AIndex: Integer);
|
||||||
begin
|
begin
|
||||||
//DebugLn('TCarbonTabsControl.Add ' + DbgS(AIndex));
|
//DebugLn('TCarbonTabsControl.Add ' + DbgS(AIndex));
|
||||||
if FTabs.IndexOf(ATab) < 0 then
|
if FTabs.IndexOf(ATab) >= 0 then exit;
|
||||||
FTabs.Insert(AIndex, ATab);
|
FTabs.Insert(AIndex, ATab);
|
||||||
ATab.Attach(Self);
|
ATab.Attach(Self);
|
||||||
|
|
||||||
UpdateTabs;
|
UpdateTabs;
|
||||||
|
// sync PageIndex with LCL
|
||||||
|
SetPageIndex(TCustomNotebook(LCLObject).PageIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -848,6 +875,8 @@ end;
|
|||||||
procedure TCarbonTabsControl.Remove(AIndex: Integer);
|
procedure TCarbonTabsControl.Remove(AIndex: Integer);
|
||||||
begin
|
begin
|
||||||
Remove(FTabs[AIndex] as TCarbonTab);
|
Remove(FTabs[AIndex] as TCarbonTab);
|
||||||
|
// sync PageIndex with LCL
|
||||||
|
SetPageIndex(TCustomNotebook(LCLObject).PageIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -860,26 +889,34 @@ procedure TCarbonTabsControl.SetPageIndex(AIndex: Integer);
|
|||||||
var
|
var
|
||||||
ATabIndex: Integer;
|
ATabIndex: Integer;
|
||||||
begin
|
begin
|
||||||
ATabIndex := GetTabIndex(AIndex);
|
DisableChangeEvent;
|
||||||
|
try
|
||||||
|
ATabIndex := GetTabIndex(AIndex);
|
||||||
|
|
||||||
//DebugLn('TCarbonTabsControl.SetPageIndex Page: ' + DbgS(AIndex) + ' Tab: ' + DbgS(ATabIndex));
|
//DebugLn('TCarbonTabsControl.SetPageIndex Page: ' + DbgS(AIndex) + ' Tab: ' + DbgS(ATabIndex));
|
||||||
|
|
||||||
if (ATabIndex < 0) or (ATabIndex >= FTabs.Count) then
|
if (ATabIndex < 0) or (ATabIndex >= FTabs.Count) then
|
||||||
begin
|
begin
|
||||||
ATabIndex := -1;
|
// this PageIndex does not exist. This should only happen if AIndex<0
|
||||||
SetControl32BitValue(ControlRef(Widget), 0);
|
if AIndex>=0 then
|
||||||
ShowTab;
|
debugln(['TCarbonTabsControl.SetPageIndex unknown pageindex: ',AIndex]);
|
||||||
Exit;
|
ATabIndex := -1;
|
||||||
|
SetControl32BitValue(ControlRef(Widget), 0);
|
||||||
|
ShowTab;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FTabIndex := ATabIndex;
|
||||||
|
if (ATabIndex < FFirstIndex) or (ATabIndex > FLastIndex) then
|
||||||
|
begin
|
||||||
|
FFirstIndex := ATabIndex;
|
||||||
|
UpdateTabs;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
UpdateTabIndex;
|
||||||
|
finally
|
||||||
|
EnableChangeEvent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
FTabIndex := ATabIndex;
|
|
||||||
if (ATabIndex < FFirstIndex) or (ATabIndex > FLastIndex) then
|
|
||||||
begin
|
|
||||||
FFirstIndex := ATabIndex;
|
|
||||||
UpdateTabs;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
UpdateTabIndex;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user