IDE: implemented except click for notebook close buttons

git-svn-id: trunk@9479 -
This commit is contained in:
mattias 2006-06-22 19:51:58 +00:00
parent 8eb418b76e
commit 01555cf0fa
6 changed files with 132 additions and 51 deletions

View File

@ -2295,8 +2295,30 @@ begin
end;
Procedure TMainIDE.OnSrcNotebookFileClose(Sender: TObject);
var
PageIndex: LongInt;
i: Integer;
begin
mnuCloseClicked(Sender);
if GetKeyState(VK_CONTROL)<0 then begin
// close all source editors except the clicked
if SourceNoteBook.Notebook=nil then exit;
if Sender is TPage then begin
PageIndex:=SourceNoteBook.Notebook.Pages.IndexOfObject(Sender);
if PageIndex<0 then
PageIndex:=SourceNoteBook.Notebook.PageIndex;
end else begin
PageIndex:=SourceNoteBook.Notebook.PageIndex;
end;
repeat
i:=SourceNoteBook.Notebook.PageCount-1;
if i=PageIndex then dec(i);
if i<0 then break;
if DoCloseEditorFile(i,[cfSaveFirst])<>mrOk then exit;
if i<PageIndex then PageIndex:=i;
until false;
end else
// close only the clicked source editor
mnuCloseClicked(Sender);
end;
Procedure TMainIDE.OnSrcNotebookFileOpen(Sender: TObject);

View File

@ -221,7 +221,6 @@ type
TPageControl = class(TCustomNotebook)
private
//FOnChange: TNotifyEvent; //changed to use inherited OnPageChanged
FOnChanging: TTabChangingEvent;
function GetActivePageIndex: Integer;
function GetActiveTabSheet: TTabSheet;

View File

@ -103,7 +103,7 @@ begin
// Make sure Index is in the range of valid pages to delete
{$IFDEF NOTEBOOK_DEBUG}
//DebugLn('TNBPages.Delete A Index=',Index);
DebugLn('TNBPages.Delete B ',fNoteBook.Name,' Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
DebugLn(['TNBPages.Delete B ',fNoteBook.Name,' Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex]);
{$ENDIF}
if (Index >= 0) and
(Index < fPageList.Count) then
@ -115,7 +115,7 @@ begin
APage.Free;
end;
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TNBPages.Delete END ',fNoteBook.Name,' Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
DebugLn(['TNBPages.Delete END ',fNoteBook.Name,' Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex]);
{$ENDIF}
end;
@ -128,7 +128,7 @@ var
NewOwner: TComponent;
begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TNBPages.Insert A ',FNoteBook.Name,' Index=',Index,' S="',S,'"');
DebugLn(['TNBPages.Insert A ',FNoteBook.Name,' Index=',Index,' S="',S,'"']);
{$ENDIF}
NewOwner:=FNotebook.Owner;
if NewOwner=nil then
@ -138,11 +138,11 @@ begin
Caption := S;
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TNBPages.Insert B ',FNotebook;.Name,' Index=',Index,' S="',S,'"');
DebugLn(['TNBPages.Insert B ',FNotebook.Name,' Index=',Index,' S="',S,'"']);
{$ENDIF}
FNoteBook.InsertPage(NewPage,Index);
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TNBPages.Insert END ',FNotebook;.Name,' Index=',Index,' S="',S,'"');
DebugLn(['TNBPages.Insert END ',FNotebook.Name,' Index=',Index,' S="',S,'"']);
{$ENDIF}
end;
@ -227,7 +227,7 @@ end;
procedure TCustomNotebook.CreateWnd;
begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.CreateWnd ',Name,':',ClassName,' HandleAllocated=',HandleAllocated);
DebugLn(['TCustomNotebook.CreateWnd ',dbgsName(Self),' HandleAllocated=',HandleAllocated]);
{$ENDIF}
inherited CreateWnd;
DoCreateWnd;
@ -244,12 +244,12 @@ var
lPage: TCustomPage;
begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.DoCreateWnd ',Name,':',ClassName,' HandleAllocated=',HandleAllocated);
DebugLn(['TCustomNotebook.DoCreateWnd ',dbgsName(Self),' HandleAllocated=',HandleAllocated]);
{$ENDIF}
fAddingPages:=true;
for i := 0 to FPageList.Count -1 do begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.DoCreateWnd ',Name,':',ClassName,' ',Page[i].Caption,' ',not (pfAdded in Page[i].Flags));
DebugLn(['TCustomNotebook.DoCreateWnd ',dbgsName(Self),' Page.Caption=',Page[i].Caption,' pfAdded=',pfAdded in Page[i].Flags]);
{$ENDIF}
lPage := Page[i];
if not (pfAdded in lPage.Flags) then begin
@ -447,8 +447,8 @@ var
NewZPosition: integer;
begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.InsertPage A ',Name,' Index=',Index,' Name=',
APage.Name,' Caption=',APage.Caption);
DebugLn(['TCustomNotebook.InsertPage A ',dbgsName(Self),' Index=',Index,' Name=',
APage.Name,' Caption=',APage.Caption]);
{$ENDIF}
APage.DisableAutoSizing;
try
@ -463,16 +463,9 @@ begin
if PageIndex = -1 then
FPageIndex := Index;
{$ifndef WINDOWS}
// TODO: remove when gtk widgetset fixed to show tabpage tab upon
// AddPage, instead of needing TabPage.Visible := true
APage.Visible := true;
{$endif}
UpdateDesignerFlags(Index);
if HandleAllocated and (not (csLoading in ComponentState)) then begin
//TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, Index);
ChildPageSetTabVisible(APage, APage.TabVisible, Index);
Include(APage.FFlags, pfAdded);
if PageIndex = Index then
@ -482,8 +475,8 @@ begin
APage.EnableAutoSizing;
end;
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.InsertPage END ',Name,' Index=',
Index,' Name=',APage.Name,' Caption=',APage.Caption);
DebugLn(['TCustomNotebook.InsertPage END ',dbgsName(Self),' Index=',
Index,' Name=',APage.Name,' Caption=',APage.Caption]);
{$ENDIF}
end;
@ -533,8 +526,8 @@ var
begin
// Make sure Index is in the range of valid pages to delete
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.RemovePage A ',Name,' Index=',Index,
' FPageList.Count=',FPageList.Count,' PageIndex=',PageIndex);
DebugLn(['TCustomNotebook.RemovePage A ',dbgsName(Self),' Index=',Index,
' FPageList.Count=',FPageList.Count,' PageIndex=',PageIndex]);
{$ENDIF}
if (Index >= 0) and
(Index < FPageList.Count) then
@ -559,7 +552,6 @@ begin
end;
end;
if HandleAllocated and APage.TabVisible then begin
//TWSCustomNotebookClass(WidgetSetClass).RemovePage(Self, Index);
ChildPageSetTabVisible(APage, False, Index);
end;
FPageList.Delete(Index);
@ -568,7 +560,7 @@ begin
Dec(fPageIndex);
end;
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('TCustomNotebook.RemovePage END ',fNoteBook.Name,' Index=',Index,' fPageList.Count=',fPageList.Count,' fNoteBook.PageIndex=',fNoteBook.PageIndex);
DebugLn(['TCustomNotebook.RemovePage END ',dbgsName(Self),' Index=',Index,' fPageList.Count=',fPageList.Count,' PageIndex=',PageIndex]);
{$ENDIF}
end;
@ -756,7 +748,7 @@ Begin
else
begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('[TCustomNotebook.CNNotify] unhandled NMHdr code:', NMHdr^.code);
DebugLn(['[TCustomNotebook.CNNotify] unhandled NMHdr code:', NMHdr^.code]);
{$ENDIF}
end;
end;
@ -778,10 +770,10 @@ end;
------------------------------------------------------------------------------}
procedure TCustomNotebook.DoSendPageIndex;
begin
//DebugLn('[TCustomNotebook.DoSendPageIndex] A ',Name,' PageIndex=',dbgs(fPageIndex),' ',dbgs(csLoading in ComponentState),' ',dbgs(HandleAllocated));
//DebugLn('[TCustomNotebook.DoSendPageIndex] A ',dbgsName(Self),' PageIndex=',dbgs(fPageIndex),' ',dbgs(csLoading in ComponentState),' ',dbgs(HandleAllocated));
if not HandleAllocated or (csLoading in ComponentState) then exit;
{$IFDEF NOTEBOOK_DEBUG}
//DebugLn('[TCustomNotebook.DoSendPageIndex] B ',Name,' PageIndex=',dbgs(fPageIndex));
//DebugLn('[TCustomNotebook.DoSendPageIndex] B ',dbgsName(Self),' PageIndex=',dbgs(fPageIndex));
{$ENDIF}
ShowCurrentPage;
TWSCustomNotebookClass(WidgetSetClass).SetPageIndex(Self, FPageIndex);
@ -797,11 +789,11 @@ procedure TCustomNotebook.DoSendShowTabs;
begin
if not HandleAllocated or (csLoading in ComponentState) then exit;
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('[TCustomNotebook.DoSendShowTabs] A ',Name);
DebugLn('[TCustomNotebook.DoSendShowTabs] A ',dbgsName(Self));
{$ENDIF}
TWSCustomNotebookClass(WidgetSetClass).ShowTabs(Self, FShowTabs);
{$IFDEF NOTEBOOK_DEBUG}
DebugLn('[TCustomNotebook.DoSendShowTabs] B ',Name);
DebugLn('[TCustomNotebook.DoSendShowTabs] B ',dbgsName(Self));
{$ENDIF}
end;

View File

@ -238,12 +238,20 @@ var
// a label)
MenuLabelWidget: PGtkWidget; // the label in the popup menu item
begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn(['TGtkWSCustomNotebook.AddPage ',dbgsName(ANoteBook),' ',ANotebook.HandleAllocated,' AChild=',dbgsName(AChild),' ',AChild.HandleAllocated,' Child.TabVisible=',AChild.TabVisible]);
{$ENDIF}
NoteBookWidget:=PGtkWidget(ANoteBook.Handle);
PageWidget:=PGtkWidget(AChild.Handle);
// Check if already created. if so just show it because it is invisible
if gtk_notebook_get_tab_label(PGtkNoteBook(NoteBookWidget), PageWidget) <> nil then begin
if AChild.TabVisible then
gtk_widget_show(PageWidget);
// Check if already created. if so just show it because it is invisible
if gtk_notebook_get_tab_label(PGtkNoteBook(NoteBookWidget), PageWidget) <> nil
then begin
{$IFDEF NOTEBOOK_DEBUG}
DebugLn(['TGtkWSCustomNotebook.AddPage already added']);
{$ENDIF}
exit;
end;
@ -258,9 +266,10 @@ begin
gtk_widget_show(TabLabelWidget);
gtk_box_pack_start_defaults(PGtkBox(TabWidget),TabLabelWidget);
end;
gtk_widget_show(TabWidget);
if AChild.TabVisible then
gtk_widget_show(TabWidget);
// create popup menu
// create popup menu item
MenuWidget:=gtk_hbox_new(false,2);
begin
// set icon widget to nil
@ -271,10 +280,12 @@ begin
gtk_widget_show(MenuLabelWidget);
gtk_box_pack_start_defaults(PGtkBox(MenuWidget),MenuLabelWidget);
end;
if AChild.TabVisible then
gtk_widget_show(MenuWidget);
gtk_widget_show(MenuWidget);
// remove the dummy page (a gtk_notebook needs at least one page)
RemoveDummyNoteBookPage(PGtkNotebook(NoteBookWidget));
// insert the page
gtk_notebook_insert_page_menu(GTK_NOTEBOOK(NotebookWidget), PageWidget,
TabWidget, MenuWidget, AIndex);
@ -550,4 +561,4 @@ initialization
// RegisterWSComponent(TPanel, TGtkWSPanel);
////////////////////////////////////////////////////
end.
end.

View File

@ -44,9 +44,11 @@ type
procedure InsertPageRightButtonClick(Sender: TObject);
procedure MovePageLeftButtonClick(Sender: TObject);
procedure MovePageRightButtonClick(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
public
constructor Create(TheOwner: TComponent); override;
procedure AddNewPage(Index: integer);
procedure FillPagesListBox;
end;
{ TForm1 }
@ -62,6 +64,7 @@ begin
Align:=alTop;
Height:=200;
Parent:=Self;
OnChange:=@PageControl1Change;
end;
PagesListBox:=TListBox.Create(Self);
@ -136,43 +139,74 @@ begin
end;
procedure TForm1.DeletePageButtonClick(Sender: TObject);
var
i: LongInt;
begin
if PageControl1.PageCount=0 then exit;
PageControl1.PageList.Delete(PageControl1.PageIndex);
i:=PagesListBox.ItemIndex;
if (i<0) or (i>=PageControl1.PageCount) then exit;
PageControl1.PageList.Delete(i);
FillPagesListBox;
end;
procedure TForm1.InsertPageLeftButtonClick(Sender: TObject);
var
i: LongInt;
begin
AddNewPage(PageControl1.PageIndex);
i:=PagesListBox.ItemIndex;
if (i<0) or (i>=PageControl1.PageCount) then i:=PageControl1.PageIndex;
AddNewPage(i);
end;
procedure TForm1.InsertPageRightButtonClick(Sender: TObject);
var
i: LongInt;
begin
if PageControl1.PageCount=0 then
AddNewPage(0)
else
AddNewPage(PageControl1.PageIndex+1);
else begin
i:=PagesListBox.ItemIndex;
if (i<0) or (i>=PageControl1.PageCount) then i:=PageControl1.PageIndex;
AddNewPage(i+1);
end;
end;
procedure TForm1.MovePageLeftButtonClick(Sender: TObject);
var
i: LongInt;
begin
if PageControl1.PageIndex=0 then exit;
PageControl1.PageList.Move(PageControl1.PageIndex,PageControl1.PageIndex-1);
i:=PagesListBox.ItemIndex;
if (i<0) or (i>=PageControl1.PageCount) then i:=PageControl1.PageIndex;
if i=0 then exit;
PageControl1.PageList.Move(i,i-1);
FillPagesListBox;
end;
procedure TForm1.MovePageRightButtonClick(Sender: TObject);
var
i: LongInt;
begin
if PageControl1.PageIndex<PageControl1.PageCount-1 then exit;
PageControl1.PageList.Move(PageControl1.PageIndex,PageControl1.PageIndex+1);
i:=PagesListBox.ItemIndex;
if (i<0) or (i>=PageControl1.PageCount) then i:=PageControl1.PageIndex;
if i<PageControl1.PageCount-1 then exit;
PageControl1.PageList.Move(i,i+1);
FillPagesListBox;
end;
procedure TForm1.PageControl1Change(Sender: TObject);
begin
FillPagesListBox;
PagesListBox.ItemIndex:=PageControl1.PageIndex;
end;
constructor TForm1.Create(TheOwner: TComponent);
var
i: Integer;
begin
OnCreate:=@Form1Create;
inherited Create(TheOwner);
AddNewPage(0);
AddNewPage(1);
AddNewPage(2);
// start with 3 pages
for i:=0 to 2 do AddNewPage(i);
FillPagesListBox;
end;
procedure TForm1.AddNewPage(Index: integer);
@ -186,6 +220,28 @@ begin
NewPage.Name:=NewName;
NewPage.Caption:=NewName;
PageControl1.PageList.Insert(Index,NewPage);
FillPagesListBox;
PagesListBox.ItemIndex:=Index;
end;
procedure TForm1.FillPagesListBox;
var
i: Integer;
OldItemIndex: LongInt;
begin
PagesListBox.Items.BeginUpdate;
OldItemIndex:=PagesListBox.ItemIndex;
for i:=0 to PageControl1.PageCount-1 do begin
if PagesListBox.Items.Count>i then begin
PagesListBox.Items[i]:=PageControl1.Pages[i].Name;
end else begin
PagesListBox.Items.Add(PageControl1.Pages[i].Name);
end;
end;
while (PagesListBox.Items.Count>PageControl1.PageCount) do
PagesListBox.Items.Delete(PagesListBox.Items.Count-1);
PagesListBox.ItemIndex:=OldItemIndex;
PagesListBox.Items.EndUpdate;
end;
var

View File

@ -10,7 +10,8 @@ Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}-%{
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
#BuildRequires:
Requires: fpc-src = FPCVERSION, fpc = FPCVERSION, gdk-pixbuf, gtk+, gdb, glibc
Requires: fpc-src = FPCVERSION, fpc = FPCVERSION, gdk-pixbuf, gtk+, glibc, gdb
# NOTE: without the symlink trick for gtk1, it requires the devel packages.
Requires(post): desktop-file-utils
Requires(postun): desktop-file-utils