fixed notebook popupmenu from Andrew Haines

git-svn-id: trunk@8262 -
This commit is contained in:
mattias 2005-12-06 18:49:41 +00:00
parent 22c1e9cb16
commit f9ef53b540
2 changed files with 55 additions and 17 deletions

View File

@ -156,7 +156,7 @@ uses
// Gtk2WSDialogs, // Gtk2WSDialogs,
// Gtk2WSDirSel, // Gtk2WSDirSel,
// Gtk2WSEditBtn, // Gtk2WSEditBtn,
// Gtk2WSExtCtrls, Gtk2WSExtCtrls,
// Gtk2WSExtDlgs, // Gtk2WSExtDlgs,
// Gtk2WSFileCtrl, // Gtk2WSFileCtrl,
// Gtk2WSForms, // Gtk2WSForms,

View File

@ -27,32 +27,31 @@ unit Gtk2WSExtCtrls;
interface interface
uses uses
//////////////////////////////////////////////////// // libs
// I M P O R T A N T GLib2, Gtk2, Gdk2, Gdk2pixbuf,
//////////////////////////////////////////////////// // LCL
// To get as little as posible circles, ExtCtrls, Classes, Controls, LCLType,
// uncomment only when needed for registration // widgetset
//////////////////////////////////////////////////// WSExtCtrls, WSLCLClasses, WSProc,
// ExtCtrls, GtkWSExtCtrls;
////////////////////////////////////////////////////
WSExtCtrls, WSLCLClasses;
type type
{ TGtk2WSCustomPage } { TGtk2WSCustomPage }
TGtk2WSCustomPage = class(TWSCustomPage) {TGtk2WSCustomPage = class(TWSCustomPage)
private private
protected protected
public public
end; end;}
{ TGtk2WSCustomNotebook } { TGtk2WSCustomNotebook }
TGtk2WSCustomNotebook = class(TWSCustomNotebook) TGtk2WSCustomNotebook = class(TGtkWSCustomNotebook)
private private
protected protected
public public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
end; end;
{ TGtk2WSPage } { TGtk2WSPage }
@ -161,11 +160,11 @@ type
{ TGtk2WSBoundLabel } { TGtk2WSBoundLabel }
TGtk2WSBoundLabel = class(TWSBoundLabel) {TGtk2WSBoundLabel = class(TWSBoundLabel)
private private
protected protected
public public
end; end;}
{ TGtk2WSCustomLabeledEdit } { TGtk2WSCustomLabeledEdit }
@ -202,6 +201,45 @@ type
implementation implementation
uses interfacebase;
type
GtkNotebookPressEventProc = function (widget:PGtkWidget; event:PGdkEventButton):gboolean; cdecl;
var
OldNoteBookButtonPress: GtkNotebookPressEventProc = nil;
// this was created as a workaround of a tnotebook eating rightclick of custom controls
function Notebook_Button_Press(widget:PGtkWidget; event:PGdkEventButton):gboolean; cdecl;
begin
Result := True;
if gtk_get_event_widget(PGdkEvent(event)) <> widget then exit;
if OldNoteBookButtonPress = nil then exit;
Result := OldNoteBookButtonPress(widget, event);
end;
procedure HookNoteBookClass;
var
WidgetClass: PGtkWidgetClass;
begin
WidgetClass := GTK_WIDGET_CLASS(gtk_type_class(gtk_notebook_get_type));
OldNoteBookButtonPress := GtkNotebookPressEventProc(WidgetClass^.button_press_event);
WidgetClass^.button_press_event := @Notebook_Button_Press;
end;
{ TGtk2WSCustomNotebook }
function TGtk2WSCustomNotebook.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
P: PGtkNoteBook;
begin
if OldNoteBookButtonPress = nil then HookNoteBookClass;
P := PGtknotebook(WidgetSet.CreateComponent(AWinControl));
Result := HWND(P);
end;
initialization initialization
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
@ -211,7 +249,7 @@ initialization
// which actually implement something // which actually implement something
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// RegisterWSComponent(TCustomPage, TGtk2WSCustomPage); // RegisterWSComponent(TCustomPage, TGtk2WSCustomPage);
// RegisterWSComponent(TCustomNotebook, TGtk2WSCustomNotebook); RegisterWSComponent(TCustomNotebook, TGtk2WSCustomNotebook);
// RegisterWSComponent(TPage, TGtk2WSPage); // RegisterWSComponent(TPage, TGtk2WSPage);
// RegisterWSComponent(TNotebook, TGtk2WSNotebook); // RegisterWSComponent(TNotebook, TGtk2WSNotebook);
// RegisterWSComponent(TShape, TGtk2WSShape); // RegisterWSComponent(TShape, TGtk2WSShape);