convert LM_NB_UPDATETAB message to interface method

git-svn-id: trunk@6070 -
This commit is contained in:
micha 2004-09-24 18:00:52 +00:00
parent 8b5ece2b97
commit 46c5e54090
10 changed files with 319 additions and 298 deletions

View File

@ -650,7 +650,7 @@ var i: integer;
begin
if not HandleAllocated or (csLoading in ComponentState) then exit;
for i := 0 to PageCount - 1 do
CNSendMessage(LM_NB_UpdateTab, Page[i], nil);
TWSCustomPageClass(Page[i].WidgetSetClass).UpdateProperties(Page[i]);
end;
function TCustomNotebook.ChildClassAllowed(ChildClass: TClass): boolean;
@ -788,6 +788,9 @@ end;}
{ =============================================================================
$Log$
Revision 1.62 2004/09/24 18:00:51 micha
convert LM_NB_UPDATETAB message to interface method
Revision 1.61 2004/09/23 16:37:13 vincents
fix compilation

View File

@ -48,7 +48,7 @@ begin
if FImageIndex=AValue then exit;
FImageIndex:=AValue;
if not HandleAllocated or (csLoading in ComponentState) then exit;
CNSendMessage(LM_NB_UpdateTab, Self, nil);
TWSCustomPageClass(WidgetSetClass).UpdateProperties(Self);
end;
function TCustomPage.GetTabVisible: Boolean;

View File

@ -94,12 +94,6 @@ type
FRCFileAge: integer;
FWidgetsWithResizeRequest: TDynHashArray; // hasharray of PGtkWidget
FGTKToolTips: PGtkToolTips;
{$IFDef GTK1}
FNoteBookCloseBtnPixmapImg: PGdkPixmap;
FNoteBookCloseBtnPixmapMask: PGdkPixmap;
{$Else}
FNoteBookCloseBtnPixbuf : PGdkPixbuf;
{$EndIf}
FLogHandlerID: guint; // ID returend by set_handler
@ -184,8 +178,6 @@ type
function CreateEmptyRegion: hRGN; override;
// images
procedure LoadXPMFromLazResource(const ResourceName: string;
Window: PGdkWindow; var PixmapImg, PixmapMask: PGdkPixmap);virtual;
{$IfNDef NoGdkPixbufLib}
procedure LoadPixbufFromLazResource(const ResourceName: string;
var Pixbuf: PGdkPixbuf);
@ -213,12 +205,6 @@ type
procedure ParseRCFile;virtual;
// notebook
{$IFDef GTK1}
procedure GetNoteBookCloseBtnImage(Window: PGdkWindow;
var Img, Mask: PGdkPixmap);virtual;
{$Else}
procedure GetNoteBookCloseBtnImage(var Img: PGdkPixbuf);virtual;
{$EndIF}
procedure AddDummyNoteBookPage(NoteBookWidget: PGtkNoteBook);virtual;
procedure MoveNBPage(ANoteBook, APage: TObject; NewIndex: Integer);virtual;
@ -289,8 +275,6 @@ type
procedure SetResizeRequest(Widget: PGtkWidget);virtual;
// |-forms
procedure UpdateTransientWindows; virtual;
// |-notebook
procedure UpdateNotebookPageTab(ANoteBook, APage: TObject);virtual;
// |-listbox
procedure SetSelectionMode(Sender: TObject; Widget: PGtkWidget;
MultiSelect, ExtendedSelect: boolean); virtual;
@ -449,6 +433,9 @@ end.
{ =============================================================================
$Log$
Revision 1.214 2004/09/24 18:00:51 micha
convert LM_NB_UPDATETAB message to interface method
Revision 1.213 2004/09/24 15:31:01 micha
convert LM_LB_GETTOPINDEX and LM_LB_SETTOPINDEX message to interface methods

View File

@ -3029,8 +3029,6 @@ begin
case LM_Message of
LM_Create : CreateComponent(Sender);
LM_NB_UpdateTab: UpdateNotebookPageTab(nil,TCustomPage(Sender));
else
begin
Case LM_Message of
@ -5679,34 +5677,6 @@ begin
// DebugLn('[TGtkWidgetSet.ShowHide] END ',Sender.ClassName,' Window=',FormWidget^.Window<>nil);
end;
{-------------------------------------------------------------------------------
method TGtkWidgetSet LoadXPMFromLazResource
Params: const ResourceName: string;
Window: PGdkWindow;
var PixmapImg, PixmapMask: PGdkPixmap
Result: none
Loads a pixmap from a lazarus resource. The resource must be a XPM file.
-------------------------------------------------------------------------------}
procedure TGtkWidgetSet.LoadXPMFromLazResource(const ResourceName: string;
Window: PGdkWindow; var PixmapImg, PixmapMask: PGdkPixmap);
var
ImgData: PPGChar;
begin
PixmapImg:=nil;
PixmapMask:=nil;
try
ImgData:=PPGChar(LazResourceXPMToPPChar(ResourceName));
except
on e: Exception do
DebugLn('WARNING: TGtkWidgetSet.LoadXPMFromLazResource: '+e.Message);
end;
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
PixmapImg:=gdk_pixmap_create_from_xpm_d(Window,PixmapMask,nil,ImgData);
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
FreeMem(ImgData);
end;
{-------------------------------------------------------------------------------
method TGtkWidgetSet LoadPixbufFromLazResource
Params: const ResourceName: string;
@ -5735,34 +5705,6 @@ begin
end;
{$EndIF}
{-------------------------------------------------------------------------------
method TGtkWidgetSet GetNoteBookCloseBtnImage
Params:
Result: none
Loads the image for the close button in the tabs of the TCustomNoteBook(s).
-------------------------------------------------------------------------------}
{$IfDef GTK1}
procedure TGtkWidgetSet.GetNoteBookCloseBtnImage(Window: PGdkWindow;
var Img, Mask: PGdkPixmap);
begin
if (FNoteBookCloseBtnPixmapImg=nil)
and (Window<>nil) then begin
LoadXPMFromLazResource('tnotebook_close_tab',Window,
FNoteBookCloseBtnPixmapImg,FNoteBookCloseBtnPixmapMask);
end;
Img:=FNoteBookCloseBtnPixmapImg;
Mask:=FNoteBookCloseBtnPixmapMask;
end;
{$Else}
procedure TGtkWidgetSet.GetNoteBookCloseBtnImage(var Img: PGdkPixbuf);
begin
if (FNoteBookCloseBtnPixbuf=nil) then
LoadPixbufFromLazResource('tnotebook_close_tab', FNoteBookCloseBtnPixbuf);
Img:=FNoteBookCloseBtnPixbuf;
end;
{$EndIF}
{-------------------------------------------------------------------------------
procedure AddDummyNoteBookPage(NoteBookWidget: PGtkNoteBook);
@ -5795,212 +5737,6 @@ begin
end;
end;
{-------------------------------------------------------------------------------
method TGtkWidgetSet UpdateNotebookPageTab
Params: ANoteBook: TCustomNotebook; APage: TCustomPage
Result: none
Updates the tab of a page of a notebook. This contains the image to the left
side, the label, the close button, the menu image and the menu label.
-------------------------------------------------------------------------------}
procedure TGtkWidgetSet.UpdateNotebookPageTab(ANoteBook, APage: TObject);
var
TheNoteBook: TCustomNotebook;
ThePage: TCustomPage;
NoteBookWidget: PGtkWidget; // the notebook
PageWidget: PGtkWidget; // the page (content widget)
TabWidget: PGtkWidget; // the tab (hbox containing a pixmap, a label
// and a close button)
TabImageWidget: PGtkWidget; // the icon widget in the tab (a fixed widget)
TabLabelWidget: PGtkWidget; // the label in the tab
TabCloseBtnWidget: PGtkWidget;// the close button in the tab
TabCloseBtnImageWidget: PGtkWidget; // the pixmap in the close button
MenuWidget: PGtkWidget; // the popup menu (hbox containing a pixmap and
// a label)
MenuImageWidget: PGtkWidget; // the icon widget in the popup menu item (a fixed widget)
MenuLabelWidget: PGtkWidget; // the label in the popup menu item
procedure UpdateTabImage;
var
HasIcon: Boolean;
IconSize: TPoint;
begin
HasIcon:=false;
IconSize:=Point(0,0);
if (TheNoteBook.Images<>nil)
and (ThePage.ImageIndex>=0)
and (ThePage.ImageIndex<TheNoteBook.Images.Count) then begin
// page has valid image
IconSize:=Point(TheNoteBook.Images.Width,TheNoteBook.Images.Height);
HasIcon:=(IconSize.X>0) and (IconSize.Y>0);
end;
if HasIcon then begin
// page has an image
if TabImageWidget<>nil then begin
// there is already an icon widget for the image in the tab
// -> resize the icon widget
gtk_widget_set_usize(TabImageWidget,IconSize.X,IconSize.Y);
end else begin
// there is no pixmap for the image in the tab
// -> insert one ot the left side of the label
TabImageWidget:= gtk_label_new(#0);
g_signal_connect(PgtkObject(TabImageWidget), 'expose_event',
TGTKSignalFunc(@PageIconWidgetExposeAfter), ThePage);
{$IFNDEF GTK2}
g_signal_connect(PgtkObject(TabImageWidget), 'draw',
TGTKSignalFunc(@PageIconWidgetDrawAfter), ThePage);
{$ENDIF}
gtk_object_set_data(PGtkObject(TabWidget),'TabImage',TabImageWidget);
gtk_widget_set_usize(TabImageWidget,IconSize.X,IconSize.Y);
gtk_widget_show(TabImageWidget);
gtk_box_pack_start_defaults(PGtkBox(TabWidget),TabImageWidget);
gtk_box_reorder_child(PGtkBox(TabWidget),TabImageWidget,0);
end;
if MenuImageWidget<>nil then begin
// there is already an icon widget for the image in the menu
// -> resize the icon widget
gtk_widget_set_usize(MenuImageWidget,IconSize.X,IconSize.Y);
end else begin
// there is no icon widget for the image in the menu
// -> insert one at the left side of the label
MenuImageWidget:=gtk_label_new(#0);
g_signal_connect_after(PgtkObject(MenuImageWidget), 'expose_event',
TGTKSignalFunc(@PageIconWidgetExposeAfter), ThePage);
{$IFNDEF GTK2}
g_signal_connect_after(PgtkObject(MenuImageWidget), 'draw',
TGTKSignalFunc(@PageIconWidgetDrawAfter), ThePage);
{$ENDIF}
gtk_widget_set_usize(MenuImageWidget,IconSize.X,IconSize.Y);
gtk_object_set_data(PGtkObject(MenuWidget),'TabImage',MenuImageWidget);
gtk_widget_show(MenuImageWidget);
gtk_box_pack_start_defaults(PGtkBox(MenuWidget),MenuImageWidget);
gtk_box_reorder_child(PGtkBox(MenuWidget),MenuImageWidget,0);
end;
end else begin
// page does not have an image
if TabImageWidget<>nil then begin
// there is a pixmap for an old image in the tab
// -> remove the icon widget
DestroyWidget(TabImageWidget);
gtk_object_set_data(PGtkObject(TabWidget), 'TabImage', nil);
TabImageWidget:=nil;
end;
if MenuImageWidget<>nil then begin
// there is a pixmap for an old image in the menu
// -> remove the icon widget
DestroyWidget(MenuImageWidget);
gtk_object_set_data(PGtkObject(MenuWidget), 'TabImage', nil);
MenuImageWidget:=nil;
end;
end;
end;
procedure UpdateTabLabel;
var TheCaption: PChar;
begin
TheCaption:=PChar(ThePage.Caption);
if TheCaption=nil then
TheCaption:=#0;
gtk_label_set_text(PGtkLabel(TabLabelWidget),TheCaption);
if MenuLabelWidget<>nil then
gtk_label_set_text(PGtkLabel(MenuLabelWidget),TheCaption);
end;
procedure UpdateTabCloseBtn;
var
{$IfDef GTK1}
Img: PGdkPixmap;
Mask: PGdkBitmap;
{$Else}
Img: PGdkPixbuf;
{$EndIf}
begin
{$IfDef GTK1}
GetNoteBookCloseBtnImage(GetControlWindow(NoteBookWidget),Img,Mask);
{$Else}
GetNoteBookCloseBtnImage(Img);
{$EndIf}
if (nboShowCloseButtons in TheNotebook.Options) and (Img<>nil) then begin
// close buttons enabled
if TabCloseBtnWidget=nil then begin
// there is no close button yet
// -> add one to the right side of the label in the tab
TabCloseBtnWidget:=gtk_button_new;
gtk_object_set_data(PGtkObject(TabWidget), 'TabCloseBtn',
TabCloseBtnWidget);
begin
// put a pixmap into the button
{$IfDef GTK1}
TabCloseBtnImageWidget:=gtk_pixmap_new(Img,Mask);
{$Else}
TabCloseBtnImageWidget:=gtk_image_new_from_pixbuf(Img);
{$EndIf}
gtk_object_set_data(PGtkObject(TabCloseBtnWidget),'TabCloseBtnImage',
TabCloseBtnImageWidget);
gtk_widget_show(TabCloseBtnImageWidget);
gtk_container_add(PGtkContainer(TabCloseBtnWidget),
TabCloseBtnImageWidget);
end;
gtk_widget_show(TabCloseBtnWidget);
g_signal_connect(PGtkObject(TabCloseBtnWidget), 'clicked',
TGTKSignalFunc(@gtkNoteBookCloseBtnClicked), APage);
gtk_box_pack_start_defaults(PGtkBox(TabWidget),TabCloseBtnWidget);
end;
end else begin
// close buttons disabled
if TabCloseBtnWidget<>nil then begin
// there is a close button
// -> remove it
gtk_object_set_data(PGtkObject(TabWidget), 'TabCloseBtn',
nil);
DestroyWidget(TabCloseBtnWidget);
TabCloseBtnWidget:=nil;
end;
end;
end;
begin
ThePage:=TCustomPage(APage);
TheNoteBook:=TCustomNotebook(ANoteBook);
if (APage=nil) or (not ThePage.HandleAllocated) then exit;
if TheNoteBook=nil then begin
TheNoteBook:=TCustomNotebook(ThePage.Parent);
if TheNoteBook=nil then exit;
end;
NoteBookWidget:=PGtkWidget(TWinControl(TheNoteBook).Handle);
PageWidget:=PGtkWidget(TWinControl(ThePage).Handle);
// get the tab container and the tab components: pixmap, label and closebtn
TabWidget:=gtk_notebook_get_tab_label(PGtkNoteBook(NotebookWidget),
PageWidget);
if TabWidget<>nil then begin
TabImageWidget:=gtk_object_get_data(PGtkObject(TabWidget), 'TabImage');
TabLabelWidget:=gtk_object_get_data(PGtkObject(TabWidget), 'TabLabel');
TabCloseBtnWidget:=gtk_object_get_data(PGtkObject(TabWidget),'TabCloseBtn');
end else begin
TabImageWidget:=nil;
TabLabelWidget:=nil;
TabCloseBtnWidget:=nil;
end;
// get the menu container and its components: pixmap and label
MenuWidget:=gtk_notebook_get_menu_label(PGtkNoteBook(NotebookWidget),
PageWidget);
if MenuWidget<>nil then begin
MenuImageWidget:=gtk_object_get_data(PGtkObject(MenuWidget), 'TabImage');
MenuLabelWidget:=gtk_object_get_data(PGtkObject(MenuWidget), 'TabLabel');
end else begin
MenuImageWidget:=nil;
MenuLabelWidget:=nil;
end;
UpdateTabImage;
UpdateTabLabel;
UpdateTabCloseBtn;
end;
{------------------------------------------------------------------------------
procedure TGtkWidgetSet.MoveNBPage(ANoteBook, APage: TObject; NewIndex: Integer);
@ -7267,6 +7003,9 @@ end;
{ =============================================================================
$Log$
Revision 1.601 2004/09/24 18:00:52 micha
convert LM_NB_UPDATETAB message to interface method
Revision 1.600 2004/09/24 17:20:43 micha
convert LM_SETGEOMETRY message to interface method

View File

@ -4642,6 +4642,33 @@ begin
Accelerate(Component,Widget,GDKKey,GDKModifier,Signal);
end;
{-------------------------------------------------------------------------------
method LoadXPMFromLazResource
Params: const ResourceName: string;
Window: PGdkWindow;
var PixmapImg, PixmapMask: PGdkPixmap
Result: none
Loads a pixmap from a lazarus resource. The resource must be a XPM file.
-------------------------------------------------------------------------------}
procedure LoadXPMFromLazResource(const ResourceName: string;
Window: PGdkWindow; var PixmapImg, PixmapMask: PGdkPixmap);
var
ImgData: PPGChar;
begin
PixmapImg:=nil;
PixmapMask:=nil;
try
ImgData:=PPGChar(LazResourceXPMToPPChar(ResourceName));
except
on e: Exception do
DebugLn('WARNING: TGtkWidgetSet.LoadXPMFromLazResource: '+e.Message);
end;
{$IFDEF DebugGDK}BeginGDKErrorTrap;{$ENDIF}
PixmapImg:=gdk_pixmap_create_from_xpm_d(Window,PixmapMask,nil,ImgData);
{$IFDEF DebugGDK}EndGDKErrorTrap;{$ENDIF}
FreeMem(ImgData);
end;
{------------------------------------------------------------------------------
procedure GetGdkPixmapFromGraphic(LCLGraphic: TGraphic;
@ -7282,6 +7309,9 @@ end;
{ =============================================================================
$Log$
Revision 1.310 2004/09/24 18:00:52 micha
convert LM_NB_UPDATETAB message to interface method
Revision 1.309 2004/09/17 20:30:13 vincents
replaced write by DbgOut

View File

@ -575,6 +575,9 @@ procedure Accelerate(Component: TComponent; const Widget: PGtkWidget;
procedure ShareWindowAccelGroups(AWindow: PGtkWidget);
procedure UnshareWindowAccelGroups(AWindow: PGtkWidget);
procedure LoadXPMFromLazResource(const ResourceName: string;
Window: PGdkWindow; var PixmapImg, PixmapMask: PGdkPixmap);
// pixmaps
procedure GetGdkPixmapFromGraphic(LCLGraphic: TGraphic;
var IconImg, IconMask: PGdkPixmap; var Width, Height: integer);

View File

@ -29,11 +29,11 @@ interface
uses
LCLProc, Controls,
{$IFDEF GTK2}
gtk2,
gtk2, gdk2,
{$ELSE GTK2}
gtk,
gtk, gdk,
{$ENDIF GTK2}
GtkGlobals, GtkProc, ExtCtrls,
GtkGlobals, GtkProc, ExtCtrls, Classes,
WSExtCtrls, WSLCLClasses, gtkint, interfacebase;
type
@ -44,6 +44,7 @@ type
private
protected
public
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
end;
{ TGtkWSCustomNotebook }
@ -209,6 +210,14 @@ type
implementation
var
{$IFDef GTK1}
NoteBookCloseBtnPixmapImg: PGdkPixmap = nil;
NoteBookCloseBtnPixmapMask: PGdkPixmap = nil;
{$Else}
NoteBookCloseBtnPixbuf: PGdkPixbuf = nil;
{$EndIf}
{-------------------------------------------------------------------------------
procedure RemoveDummyNoteBookPage(NoteBookWidget: PGtkNotebook);
@ -227,6 +236,247 @@ begin
SetGtkNoteBookDummyPage(NoteBookWidget,DummyWidget);
end;
{-------------------------------------------------------------------------------
method GetNoteBookCloseBtnImage
Params:
Result: none
Loads the image for the close button in the tabs of the TCustomNoteBook(s).
-------------------------------------------------------------------------------}
{$IfDef GTK1}
procedure GetNoteBookCloseBtnImage(Window: PGdkWindow;
var Img, Mask: PGdkPixmap);
begin
if (NoteBookCloseBtnPixmapImg=nil)
and (Window<>nil) then begin
LoadXPMFromLazResource('tnotebook_close_tab',Window,
NoteBookCloseBtnPixmapImg,NoteBookCloseBtnPixmapMask);
end;
Img:=NoteBookCloseBtnPixmapImg;
Mask:=NoteBookCloseBtnPixmapMask;
end;
{$Else}
procedure GetNoteBookCloseBtnImage(var Img: PGdkPixbuf);
begin
if (NoteBookCloseBtnPixbuf=nil) then
LoadPixbufFromLazResource('tnotebook_close_tab', NoteBookCloseBtnPixbuf);
Img:=NoteBookCloseBtnPixbuf;
end;
{$EndIF}
{-------------------------------------------------------------------------------
method UpdateNotebookPageTab
Params: ANoteBook: TCustomNotebook; APage: TCustomPage
Result: none
Updates the tab of a page of a notebook. This contains the image to the left
side, the label, the close button, the menu image and the menu label.
-------------------------------------------------------------------------------}
procedure UpdateNotebookPageTab(ANoteBook, APage: TObject);
var
TheNoteBook: TCustomNotebook;
ThePage: TCustomPage;
NoteBookWidget: PGtkWidget; // the notebook
PageWidget: PGtkWidget; // the page (content widget)
TabWidget: PGtkWidget; // the tab (hbox containing a pixmap, a label
// and a close button)
TabImageWidget: PGtkWidget; // the icon widget in the tab (a fixed widget)
TabLabelWidget: PGtkWidget; // the label in the tab
TabCloseBtnWidget: PGtkWidget;// the close button in the tab
TabCloseBtnImageWidget: PGtkWidget; // the pixmap in the close button
MenuWidget: PGtkWidget; // the popup menu (hbox containing a pixmap and
// a label)
MenuImageWidget: PGtkWidget; // the icon widget in the popup menu item (a fixed widget)
MenuLabelWidget: PGtkWidget; // the label in the popup menu item
procedure UpdateTabImage;
var
HasIcon: Boolean;
IconSize: TPoint;
begin
HasIcon:=false;
IconSize:=Point(0,0);
if (TheNoteBook.Images<>nil)
and (ThePage.ImageIndex>=0)
and (ThePage.ImageIndex<TheNoteBook.Images.Count) then begin
// page has valid image
IconSize:=Point(TheNoteBook.Images.Width,TheNoteBook.Images.Height);
HasIcon:=(IconSize.X>0) and (IconSize.Y>0);
end;
if HasIcon then begin
// page has an image
if TabImageWidget<>nil then begin
// there is already an icon widget for the image in the tab
// -> resize the icon widget
gtk_widget_set_usize(TabImageWidget,IconSize.X,IconSize.Y);
end else begin
// there is no pixmap for the image in the tab
// -> insert one ot the left side of the label
TabImageWidget:= gtk_label_new(#0);
g_signal_connect(PgtkObject(TabImageWidget), 'expose_event',
TGTKSignalFunc(@PageIconWidgetExposeAfter), ThePage);
{$IFNDEF GTK2}
g_signal_connect(PgtkObject(TabImageWidget), 'draw',
TGTKSignalFunc(@PageIconWidgetDrawAfter), ThePage);
{$ENDIF}
gtk_object_set_data(PGtkObject(TabWidget),'TabImage',TabImageWidget);
gtk_widget_set_usize(TabImageWidget,IconSize.X,IconSize.Y);
gtk_widget_show(TabImageWidget);
gtk_box_pack_start_defaults(PGtkBox(TabWidget),TabImageWidget);
gtk_box_reorder_child(PGtkBox(TabWidget),TabImageWidget,0);
end;
if MenuImageWidget<>nil then begin
// there is already an icon widget for the image in the menu
// -> resize the icon widget
gtk_widget_set_usize(MenuImageWidget,IconSize.X,IconSize.Y);
end else begin
// there is no icon widget for the image in the menu
// -> insert one at the left side of the label
MenuImageWidget:=gtk_label_new(#0);
g_signal_connect_after(PgtkObject(MenuImageWidget), 'expose_event',
TGTKSignalFunc(@PageIconWidgetExposeAfter), ThePage);
{$IFNDEF GTK2}
g_signal_connect_after(PgtkObject(MenuImageWidget), 'draw',
TGTKSignalFunc(@PageIconWidgetDrawAfter), ThePage);
{$ENDIF}
gtk_widget_set_usize(MenuImageWidget,IconSize.X,IconSize.Y);
gtk_object_set_data(PGtkObject(MenuWidget),'TabImage',MenuImageWidget);
gtk_widget_show(MenuImageWidget);
gtk_box_pack_start_defaults(PGtkBox(MenuWidget),MenuImageWidget);
gtk_box_reorder_child(PGtkBox(MenuWidget),MenuImageWidget,0);
end;
end else begin
// page does not have an image
if TabImageWidget<>nil then begin
// there is a pixmap for an old image in the tab
// -> remove the icon widget
DestroyWidget(TabImageWidget);
gtk_object_set_data(PGtkObject(TabWidget), 'TabImage', nil);
TabImageWidget:=nil;
end;
if MenuImageWidget<>nil then begin
// there is a pixmap for an old image in the menu
// -> remove the icon widget
DestroyWidget(MenuImageWidget);
gtk_object_set_data(PGtkObject(MenuWidget), 'TabImage', nil);
MenuImageWidget:=nil;
end;
end;
end;
procedure UpdateTabLabel;
var TheCaption: PChar;
begin
TheCaption:=PChar(ThePage.Caption);
if TheCaption=nil then
TheCaption:=#0;
gtk_label_set_text(PGtkLabel(TabLabelWidget),TheCaption);
if MenuLabelWidget<>nil then
gtk_label_set_text(PGtkLabel(MenuLabelWidget),TheCaption);
end;
procedure UpdateTabCloseBtn;
var
{$IfDef GTK1}
Img: PGdkPixmap;
Mask: PGdkBitmap;
{$Else}
Img: PGdkPixbuf;
{$EndIf}
begin
{$IfDef GTK1}
GetNoteBookCloseBtnImage(GetControlWindow(NoteBookWidget),Img,Mask);
{$Else}
GetNoteBookCloseBtnImage(Img);
{$EndIf}
if (nboShowCloseButtons in TheNotebook.Options) and (Img<>nil) then begin
// close buttons enabled
if TabCloseBtnWidget=nil then begin
// there is no close button yet
// -> add one to the right side of the label in the tab
TabCloseBtnWidget:=gtk_button_new;
gtk_object_set_data(PGtkObject(TabWidget), 'TabCloseBtn',
TabCloseBtnWidget);
begin
// put a pixmap into the button
{$IfDef GTK1}
TabCloseBtnImageWidget:=gtk_pixmap_new(Img,Mask);
{$Else}
TabCloseBtnImageWidget:=gtk_image_new_from_pixbuf(Img);
{$EndIf}
gtk_object_set_data(PGtkObject(TabCloseBtnWidget),'TabCloseBtnImage',
TabCloseBtnImageWidget);
gtk_widget_show(TabCloseBtnImageWidget);
gtk_container_add(PGtkContainer(TabCloseBtnWidget),
TabCloseBtnImageWidget);
end;
gtk_widget_show(TabCloseBtnWidget);
g_signal_connect(PGtkObject(TabCloseBtnWidget), 'clicked',
TGTKSignalFunc(@gtkNoteBookCloseBtnClicked), APage);
gtk_box_pack_start_defaults(PGtkBox(TabWidget),TabCloseBtnWidget);
end;
end else begin
// close buttons disabled
if TabCloseBtnWidget<>nil then begin
// there is a close button
// -> remove it
gtk_object_set_data(PGtkObject(TabWidget), 'TabCloseBtn',
nil);
DestroyWidget(TabCloseBtnWidget);
TabCloseBtnWidget:=nil;
end;
end;
end;
begin
ThePage:=TCustomPage(APage);
TheNoteBook:=TCustomNotebook(ANoteBook);
if (APage=nil) or (not ThePage.HandleAllocated) then exit;
if TheNoteBook=nil then begin
TheNoteBook:=TCustomNotebook(ThePage.Parent);
if TheNoteBook=nil then exit;
end;
NoteBookWidget:=PGtkWidget(TWinControl(TheNoteBook).Handle);
PageWidget:=PGtkWidget(TWinControl(ThePage).Handle);
// get the tab container and the tab components: pixmap, label and closebtn
TabWidget:=gtk_notebook_get_tab_label(PGtkNoteBook(NotebookWidget),
PageWidget);
if TabWidget<>nil then begin
TabImageWidget:=gtk_object_get_data(PGtkObject(TabWidget), 'TabImage');
TabLabelWidget:=gtk_object_get_data(PGtkObject(TabWidget), 'TabLabel');
TabCloseBtnWidget:=gtk_object_get_data(PGtkObject(TabWidget),'TabCloseBtn');
end else begin
TabImageWidget:=nil;
TabLabelWidget:=nil;
TabCloseBtnWidget:=nil;
end;
// get the menu container and its components: pixmap and label
MenuWidget:=gtk_notebook_get_menu_label(PGtkNoteBook(NotebookWidget),
PageWidget);
if MenuWidget<>nil then begin
MenuImageWidget:=gtk_object_get_data(PGtkObject(MenuWidget), 'TabImage');
MenuLabelWidget:=gtk_object_get_data(PGtkObject(MenuWidget), 'TabLabel');
end else begin
MenuImageWidget:=nil;
MenuLabelWidget:=nil;
end;
UpdateTabImage;
UpdateTabLabel;
UpdateTabCloseBtn;
end;
{ TGtkWSCustomPage }
procedure TGtkWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
begin
UpdateNotebookPageTab(nil, ACustomPage);
end;
{ TGtkWSCustomNotebook }
procedure TGtkWSCustomNotebook.AddPage(const ANotebook: TCustomNotebook;
@ -284,7 +534,7 @@ begin
gtk_notebook_insert_page_menu(GTK_NOTEBOOK(NotebookWidget), PageWidget,
TabWidget, MenuWidget, AIndex);
TGtkWidgetSet(InterfaceObject).UpdateNotebookPageTab(ANoteBook, AChild);
UpdateNotebookPageTab(ANoteBook, AChild);
UpdateNoteBookClientWidget(ANoteBook);
end;
@ -393,7 +643,7 @@ initialization
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TCustomPage, TGtkWSCustomPage);
RegisterWSComponent(TCustomPage, TGtkWSCustomPage);
RegisterWSComponent(TCustomNotebook, TGtkWSCustomNotebook);
// RegisterWSComponent(TPage, TGtkWSPage);
// RegisterWSComponent(TNotebook, TGtkWSNotebook);

View File

@ -45,6 +45,7 @@ type
private
protected
public
class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
end;
{ TWin32WSCustomNotebook }
@ -258,6 +259,13 @@ begin
TWin32WidgetSet(InterfaceObject).ResizeChild(Notebook.Page[I], R.Left, R.Top, R.Right, R.Bottom);
end;
{ TWin32WSCustomPage }
procedure TWin32WSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
begin
// TODO: implement me!
end;
{ TWin32WSCustomNotebook }
procedure TWin32WSCustomNotebook.AddPage(const ANotebook: TCustomNotebook;
@ -356,7 +364,7 @@ initialization
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TCustomPage, TWin32WSCustomPage);
RegisterWSComponent(TCustomPage, TWin32WSCustomPage);
RegisterWSComponent(TCustomNotebook, TWin32WSCustomNotebook);
// RegisterWSComponent(TPage, TWin32WSPage);
// RegisterWSComponent(TNotebook, TWin32WSNotebook);

View File

@ -47,11 +47,6 @@ const
LM_ComUser = $1000;
LM_Create = LM_ComUser+1;
// TNoteBook
LM_NB_First = LM_COMUSER+100;
LM_NB_UpdateTab = LM_NB_First+0;
LM_NB_Last = LM_NB_UpdateTab;
//-------------
// lcl messages
@ -733,11 +728,6 @@ begin
LM_ComUser :Result:='LM_ComUser';
LM_Create :Result:='LM_Create';
// TNoteBook
//LM_NB_First :Result:='LM_NB_First';
LM_NB_UpdateTab :Result:='LM_NB_UpdateTab';
//LM_NB_Last :Result:='LM_NB_Last';
//-------------
// lcl messages
//
@ -827,6 +817,9 @@ end.
{
$Log$
Revision 1.122 2004/09/24 18:00:51 micha
convert LM_NB_UPDATETAB message to interface method
Revision 1.121 2004/09/24 17:20:43 micha
convert LM_SETGEOMETRY message to interface method

View File

@ -51,7 +51,9 @@ uses
type
{ TWSCustomPage }
TWSCustomPageClass = class of TWSCustomPage;
TWSCustomPage = class(TWSWinControl)
class procedure UpdateProperties(const ACustomPage: TCustomPage); virtual;
end;
{ TWSCustomNotebook }
@ -162,6 +164,12 @@ type
implementation
{ TWSCustomPage }
procedure TWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
begin
end;
{ TWSCustomNotebook }
{ -----------------------------------------------------------------------------