mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 15:30:52 +02:00
GTK2: tabcontrol, check for tab vs page
git-svn-id: trunk@42634 -
This commit is contained in:
parent
f21f82c614
commit
f38edbcf27
@ -275,7 +275,9 @@ begin
|
|||||||
TGtkPrivateWidgetClass(TheWinControl.WidgetSetClass.WSPrivate).UpdateCursor(WinWidgetInfo);
|
TGtkPrivateWidgetClass(TheWinControl.WidgetSetClass.WSPrivate).UpdateCursor(WinWidgetInfo);
|
||||||
ConnectInternalWidgetsSignals(MainWidget,TheWinControl);
|
ConnectInternalWidgetsSignals(MainWidget,TheWinControl);
|
||||||
|
|
||||||
if TheWinControl is TCustomPage then
|
if (TheWinControl is TCustomPage)
|
||||||
|
and not ((TheWinControl.Parent <> nil) and (TheWinControl.Parent is TTabControl))
|
||||||
|
then
|
||||||
UpdateNotebookPageTab(nil,TheWinControl);
|
UpdateNotebookPageTab(nil,TheWinControl);
|
||||||
|
|
||||||
if TheWinControl is TCustomForm then
|
if TheWinControl is TCustomForm then
|
||||||
|
@ -362,6 +362,13 @@ begin
|
|||||||
// set LCL size
|
// set LCL size
|
||||||
AChild.SetBounds(AChild.Left, AChild.Top, ATabControl.ClientWidth, ATabControl.ClientHeight);
|
AChild.SetBounds(AChild.Left, AChild.Top, ATabControl.ClientWidth, ATabControl.ClientHeight);
|
||||||
|
|
||||||
|
if (ATabControl is TTabControl) then begin
|
||||||
|
if AChild.HandleObjectShouldBeVisible then
|
||||||
|
gtk_widget_show(PageWidget);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
// For a PageControl the widget must be visible
|
// For a PageControl the widget must be visible
|
||||||
// If not the page control will not use it. It may not even show the tab
|
// If not the page control will not use it. It may not even show the tab
|
||||||
gtk_widget_show(PageWidget);
|
gtk_widget_show(PageWidget);
|
||||||
@ -425,6 +432,9 @@ class procedure TGtk2WSCustomTabControl.MovePage(const ATabControl: TCustomTabCo
|
|||||||
var
|
var
|
||||||
NoteBookWidget: PGtkNotebook;
|
NoteBookWidget: PGtkNotebook;
|
||||||
begin
|
begin
|
||||||
|
if (ATabControl is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
NoteBookWidget:={%H-}PGtkNotebook(ATabControl.Handle);
|
NoteBookWidget:={%H-}PGtkNotebook(ATabControl.Handle);
|
||||||
gtk_notebook_reorder_child(NoteBookWidget, {%H-}PGtkWidget(AChild.Handle), NewIndex);
|
gtk_notebook_reorder_child(NoteBookWidget, {%H-}PGtkWidget(AChild.Handle), NewIndex);
|
||||||
UpdateNoteBookClientWidget(ATabControl);
|
UpdateNoteBookClientWidget(ATabControl);
|
||||||
@ -466,6 +476,9 @@ var
|
|||||||
Count: guint;
|
Count: guint;
|
||||||
begin
|
begin
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
|
if (ATabControl is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
NoteBookWidget:={%H-}PGtkNotebook(ATabControl.Handle);
|
NoteBookWidget:={%H-}PGtkNotebook(ATabControl.Handle);
|
||||||
if (NotebookWidget=nil) then exit;
|
if (NotebookWidget=nil) then exit;
|
||||||
//DebugLn(['TGtkWSCustomTabControl.GetTabIndexAtPos ',GetWidgetDebugReport(PGtkWidget(NotebookWidget))]);
|
//DebugLn(['TGtkWSCustomTabControl.GetTabIndexAtPos ',GetWidgetDebugReport(PGtkWidget(NotebookWidget))]);
|
||||||
@ -507,6 +520,9 @@ var
|
|||||||
Count: guint;
|
Count: guint;
|
||||||
begin
|
begin
|
||||||
Result := inherited;
|
Result := inherited;
|
||||||
|
if (ATabControl is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
NoteBookWidget:={%H-}PGtkNotebook(ATabControl.Handle);
|
NoteBookWidget:={%H-}PGtkNotebook(ATabControl.Handle);
|
||||||
if (NotebookWidget=nil) then exit;
|
if (NotebookWidget=nil) then exit;
|
||||||
|
|
||||||
@ -527,6 +543,9 @@ var
|
|||||||
ANewIndex: Integer;
|
ANewIndex: Integer;
|
||||||
Page: PGtkWidget;
|
Page: PGtkWidget;
|
||||||
begin
|
begin
|
||||||
|
if (ATabControl is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
if not WSCheckHandleAllocated(ATabControl, 'SetPageIndex') then
|
if not WSCheckHandleAllocated(ATabControl, 'SetPageIndex') then
|
||||||
Exit;
|
Exit;
|
||||||
if (AIndex < 0) or (AIndex > ATabControl.PageCount - 1) then
|
if (AIndex < 0) or (AIndex > ATabControl.PageCount - 1) then
|
||||||
@ -550,6 +569,9 @@ end;
|
|||||||
class procedure TGtk2WSCustomTabControl.SetTabPosition(
|
class procedure TGtk2WSCustomTabControl.SetTabPosition(
|
||||||
const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
|
const ATabControl: TCustomTabControl; const ATabPosition: TTabPosition);
|
||||||
begin
|
begin
|
||||||
|
if (ATabControl is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
gtk_notebook_set_tab_pos({%H-}PGtkNotebook(ATabControl.Handle),
|
gtk_notebook_set_tab_pos({%H-}PGtkNotebook(ATabControl.Handle),
|
||||||
GtkPositionTypeMap[ATabPosition]);
|
GtkPositionTypeMap[ATabPosition]);
|
||||||
end;
|
end;
|
||||||
@ -567,6 +589,9 @@ end;
|
|||||||
|
|
||||||
class procedure TGtk2WSCustomTabControl.UpdateProperties(const ATabControl: TCustomTabControl);
|
class procedure TGtk2WSCustomTabControl.UpdateProperties(const ATabControl: TCustomTabControl);
|
||||||
begin
|
begin
|
||||||
|
if (ATabControl is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
if (nboHidePageListPopup in ATabControl.Options) then
|
if (nboHidePageListPopup in ATabControl.Options) then
|
||||||
gtk_notebook_popup_disable({%H-}PGtkNotebook(ATabControl.Handle))
|
gtk_notebook_popup_disable({%H-}PGtkNotebook(ATabControl.Handle))
|
||||||
else
|
else
|
||||||
@ -612,6 +637,9 @@ var
|
|||||||
TabWidget: PGtkWidget;
|
TabWidget: PGtkWidget;
|
||||||
TabImageWidget: PGtkWidget;
|
TabImageWidget: PGtkWidget;
|
||||||
begin
|
begin
|
||||||
|
if (ACustomPage.Parent <> nil) and (ACustomPage.Parent is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
UpdateNotebookPageTab(nil, ACustomPage);
|
UpdateNotebookPageTab(nil, ACustomPage);
|
||||||
{we must update our icon (if exists) otherwise it will be updated only
|
{we must update our icon (if exists) otherwise it will be updated only
|
||||||
when our tab reach focus}
|
when our tab reach focus}
|
||||||
@ -639,20 +667,32 @@ end;
|
|||||||
class procedure TGtk2WSCustomPage.SetBounds(const AWinControl: TWinControl;
|
class procedure TGtk2WSCustomPage.SetBounds(const AWinControl: TWinControl;
|
||||||
const ALeft, ATop, AWidth, AHeight: Integer);
|
const ALeft, ATop, AWidth, AHeight: Integer);
|
||||||
begin
|
begin
|
||||||
|
if (AWinControl.Parent <> nil) and (AWinControl.Parent is TTabControl) then begin
|
||||||
|
// call inherited; need to do it this way,
|
||||||
|
// because the compile time ancestor class is TWSCustomListView
|
||||||
|
TWSWinControlClass(ClassParent).SetBounds(AWinControl, ALeft, ATop, AWidth, AHeight);
|
||||||
|
inherited;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
// ignore resizes from the LCL
|
// ignore resizes from the LCL
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomPage.SetFont(const AWinControl: TWinControl;
|
class procedure TGtk2WSCustomPage.SetFont(const AWinControl: TWinControl;
|
||||||
const AFont: TFont);
|
const AFont: TFont);
|
||||||
begin
|
begin
|
||||||
|
if (AWinControl.Parent <> nil) and (AWinControl.Parent is TTabControl) then begin
|
||||||
|
// runtime inherited
|
||||||
|
TWSWinControlClass(ClassParent).SetFont(AWinControl, AFont);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'SetFont') then
|
if not WSCheckHandleAllocated(AWinControl, 'SetFont') then
|
||||||
exit;
|
exit;
|
||||||
UpdateNotebookTabFont(AWinControl, AFont);
|
UpdateNotebookTabFont(AWinControl, AFont);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TGtk2WSCustomPage.ShowHide(const AWinControl: TWinControl);
|
class procedure TGtk2WSCustomPage.ShowHide(const AWinControl: TWinControl);
|
||||||
var
|
|
||||||
AShow: Boolean;
|
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'ShowHide') then
|
if not WSCheckHandleAllocated(AWinControl, 'ShowHide') then
|
||||||
exit;
|
exit;
|
||||||
@ -660,7 +700,7 @@ begin
|
|||||||
// In a PageControl, the child widget must always be visible
|
// In a PageControl, the child widget must always be visible
|
||||||
// it will be controlled by gtk_notebook_set_page
|
// it will be controlled by gtk_notebook_set_page
|
||||||
// Making a page invisible, also hides the tab.
|
// Making a page invisible, also hides the tab.
|
||||||
if not (AWinControl is TTabControl) then
|
if (AWinControl.Parent = nil) or (AWinControl.Parent is TPageControl) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
TGtk2WidgetSet(WidgetSet).SetVisible(AWinControl, AWinControl.HandleObjectShouldBeVisible);
|
TGtk2WidgetSet(WidgetSet).SetVisible(AWinControl, AWinControl.HandleObjectShouldBeVisible);
|
||||||
@ -670,6 +710,13 @@ class function TGtk2WSCustomPage.GetDefaultClientRect(
|
|||||||
const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
|
const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
|
||||||
var aClientRect: TRect): boolean;
|
var aClientRect: TRect): boolean;
|
||||||
begin
|
begin
|
||||||
|
if (AWinControl.Parent <> nil) and (AWinControl.Parent is TTabControl) then begin
|
||||||
|
// runtime inherited
|
||||||
|
Result := TWSWinControlClass(ClassParent).GetDefaultClientRect(
|
||||||
|
AWinControl, aLeft, aTop, aWidth, aHeight, aClientRect);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if AWinControl.Parent=nil then exit;
|
if AWinControl.Parent=nil then exit;
|
||||||
if AWinControl.HandleAllocated and AWinControl.Parent.HandleAllocated
|
if AWinControl.HandleAllocated and AWinControl.Parent.HandleAllocated
|
||||||
|
@ -4607,7 +4607,7 @@ begin
|
|||||||
// -> if this is the last page, then add a dummy page
|
// -> if this is the last page, then add a dummy page
|
||||||
APage:=TCustomPage(Sender);
|
APage:=TCustomPage(Sender);
|
||||||
if (APage.Parent<>nil) and APage.Parent.HandleAllocated
|
if (APage.Parent<>nil) and APage.Parent.HandleAllocated
|
||||||
and (APage.Parent is TCustomTabControl) then
|
and (APage.Parent is TPageControl) then
|
||||||
begin
|
begin
|
||||||
NoteBookWidget:={%H-}PGtkNotebook(TCustomTabControl(APage.Parent).Handle);
|
NoteBookWidget:={%H-}PGtkNotebook(TCustomTabControl(APage.Parent).Handle);
|
||||||
if GetGtkNoteBookPageCount(NoteBookWidget)=1 then
|
if GetGtkNoteBookPageCount(NoteBookWidget)=1 then
|
||||||
|
@ -27,7 +27,7 @@ uses
|
|||||||
// To get as little as posible circles,
|
// To get as little as posible circles,
|
||||||
// uncomment only when needed for registration
|
// uncomment only when needed for registration
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
Controls,
|
Controls, ComCtrls,
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
Graphics,
|
Graphics,
|
||||||
@ -798,6 +798,9 @@ class procedure TGtk2WSWinControl.SetText(const AWinControl: TWinControl;
|
|||||||
MenuLabelWidget: PGtkWidget; // the label in the popup menu item
|
MenuLabelWidget: PGtkWidget; // the label in the popup menu item
|
||||||
NewText: PChar;
|
NewText: PChar;
|
||||||
begin
|
begin
|
||||||
|
if (AWinControl.Parent <> nil) and (AWinControl.Parent is TTabControl) then
|
||||||
|
exit;
|
||||||
|
|
||||||
// dig through the hierachy to get the labels
|
// dig through the hierachy to get the labels
|
||||||
NoteBookWidget:={%H-}PGtkWidget((AWinControl.Parent).Handle);
|
NoteBookWidget:={%H-}PGtkWidget((AWinControl.Parent).Handle);
|
||||||
PageWidget:={%H-}PGtkWidget(AWinControl.Handle);
|
PageWidget:={%H-}PGtkWidget(AWinControl.Handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user