mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 00:35:56 +02:00
gtk:
- move GtkSwitchPage from GtkCallbacks unit to GtkWsExtCtrls unit - fix double call of OnChanging on manual page change (part of 8338) git-svn-id: trunk@13745 -
This commit is contained in:
parent
8e8ae63a6d
commit
e0b764dc96
@ -1983,51 +1983,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GtkSwitchPage(widget: PGtkWidget; page: Pgtkwidget; pagenum: integer;
|
|
||||||
data: gPointer): GBoolean; cdecl;
|
|
||||||
var
|
|
||||||
Mess: TLMNotify;
|
|
||||||
NMHdr: tagNMHDR;
|
|
||||||
begin
|
|
||||||
Result := CallBackDefaultReturn;
|
|
||||||
|
|
||||||
EventTrace('switch-page', data);
|
|
||||||
UpdateNoteBookClientWidget(TObject(Data));
|
|
||||||
|
|
||||||
if PGtkNotebook(Widget)^.cur_page = nil then // for windows compatibility
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
// gtkswitchpage is called before the switch
|
|
||||||
|
|
||||||
// send first the TCN_SELCHANGING to ask if switch is allowed
|
|
||||||
FillChar(Mess, SizeOf(Mess), 0);
|
|
||||||
Mess.Msg := LM_NOTIFY;
|
|
||||||
FillChar(NMHdr, SizeOf(NMHdr), 0);
|
|
||||||
NMHdr.code := TCN_SELCHANGING;
|
|
||||||
NMHdr.hwndFrom := PtrUInt(widget);
|
|
||||||
NMHdr.idFrom := pagenum; //use this to set pageindex to the correct page.
|
|
||||||
Mess.NMHdr := @NMHdr;
|
|
||||||
Mess.Result := 0;
|
|
||||||
DeliverMessage(Data, Mess);
|
|
||||||
if Mess.Result <> 0 then
|
|
||||||
begin
|
|
||||||
g_signal_stop_emission_by_name(PGtkObject(Widget), 'switch-page');
|
|
||||||
Result := not CallBackDefaultReturn;
|
|
||||||
Exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// then send the new page
|
|
||||||
FillChar(Mess, SizeOf(Mess), 0);
|
|
||||||
Mess.Msg := LM_NOTIFY;
|
|
||||||
FillChar(NMHdr, SizeOf(NMHdr), 0);
|
|
||||||
NMHdr.code := TCN_SELCHANGE;
|
|
||||||
NMHdr.hwndFrom := PtrUInt(widget);
|
|
||||||
NMHdr.idFrom := pagenum; //use this to set pageindex to the correct page.
|
|
||||||
Mess.NMHdr := @NMHdr;
|
|
||||||
DeliverMessage(Data, Mess);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function gtkconfigureevent( widget: PGtkWidget; event : PgdkEventConfigure;
|
function gtkconfigureevent( widget: PGtkWidget; event : PgdkEventConfigure;
|
||||||
data: gPointer) : GBoolean; cdecl;
|
data: gPointer) : GBoolean; cdecl;
|
||||||
var
|
var
|
||||||
|
@ -184,8 +184,6 @@ function gtksize_allocateCB(widget: PGtkWidget; size :pGtkAllocation;
|
|||||||
data: gPointer): GBoolean; cdecl;
|
data: gPointer): GBoolean; cdecl;
|
||||||
function gtksize_allocate_client(widget: PGtkWidget; size :pGtkAllocation;
|
function gtksize_allocate_client(widget: PGtkWidget; size :pGtkAllocation;
|
||||||
data: gPointer): GBoolean; cdecl;
|
data: gPointer): GBoolean; cdecl;
|
||||||
function gtkswitchpage(widget: PGtkWidget; page: Pgtkwidget; pagenum: integer;
|
|
||||||
data: gPointer): GBoolean; cdecl;
|
|
||||||
function gtkconfigureevent( widget: PGtkWidget; event: PgdkEventConfigure;
|
function gtkconfigureevent( widget: PGtkWidget; event: PgdkEventConfigure;
|
||||||
data: gPointer): GBoolean; cdecl;
|
data: gPointer): GBoolean; cdecl;
|
||||||
function gtkreleasedCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
|
function gtkreleasedCB(widget: PGtkWidget; data: gPointer): GBoolean; cdecl;
|
||||||
|
@ -3253,9 +3253,6 @@ begin
|
|||||||
'value_changed', @gtkvaluechanged);
|
'value_changed', @gtkvaluechanged);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if ALCLObject is TCustomNotebook then
|
|
||||||
ConnectSenderSignal(gObject, 'switch_page', @gtkswitchpage)
|
|
||||||
else
|
|
||||||
if ALCLObject is TCustomCombobox then
|
if ALCLObject is TCustomCombobox then
|
||||||
ConnectSenderSignal (PGtkObject(
|
ConnectSenderSignal (PGtkObject(
|
||||||
PGtkCombo(gObject)^.entry), 'changed', @gtkchangedCB)
|
PGtkCombo(gObject)^.entry), 'changed', @gtkchangedCB)
|
||||||
|
@ -246,6 +246,8 @@ const
|
|||||||
{ tpRight } GTK_POS_RIGHT
|
{ tpRight } GTK_POS_RIGHT
|
||||||
);
|
);
|
||||||
|
|
||||||
|
LCL_NotebookManualPageSwitchKey = 'lcl_manual_page_switch';
|
||||||
|
|
||||||
{ TGtkWSCustomPage }
|
{ TGtkWSCustomPage }
|
||||||
|
|
||||||
class procedure TGtkWSCustomPage.SetCallbacks(const AGtkWidget: PGtkWidget;
|
class procedure TGtkWSCustomPage.SetCallbacks(const AGtkWidget: PGtkWidget;
|
||||||
@ -289,11 +291,62 @@ end;
|
|||||||
|
|
||||||
{ TGtkWSCustomNotebook }
|
{ TGtkWSCustomNotebook }
|
||||||
|
|
||||||
|
function GtkWSNotebook_SwitchPage(widget: PGtkWidget; page: Pgtkwidget; pagenum: integer; data: gPointer): GBoolean; cdecl;
|
||||||
|
var
|
||||||
|
Mess: TLMNotify;
|
||||||
|
NMHdr: tagNMHDR;
|
||||||
|
begin
|
||||||
|
Result := CallBackDefaultReturn;
|
||||||
|
|
||||||
|
EventTrace('switch-page', data);
|
||||||
|
UpdateNoteBookClientWidget(TObject(Data));
|
||||||
|
|
||||||
|
if PGtkNotebook(Widget)^.cur_page = nil then // for windows compatibility
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
// gtkswitchpage is called before the switch
|
||||||
|
|
||||||
|
if g_object_get_data(PGObject(Widget), LCL_NotebookManualPageSwitchKey) = nil then
|
||||||
|
begin
|
||||||
|
// send first the TCN_SELCHANGING to ask if switch is allowed
|
||||||
|
FillChar(Mess, SizeOf(Mess), 0);
|
||||||
|
Mess.Msg := LM_NOTIFY;
|
||||||
|
FillChar(NMHdr, SizeOf(NMHdr), 0);
|
||||||
|
NMHdr.code := TCN_SELCHANGING;
|
||||||
|
NMHdr.hwndFrom := PtrUInt(widget);
|
||||||
|
NMHdr.idFrom := pagenum; //use this to set pageindex to the correct page.
|
||||||
|
Mess.NMHdr := @NMHdr;
|
||||||
|
Mess.Result := 0;
|
||||||
|
DeliverMessage(Data, Mess);
|
||||||
|
if Mess.Result <> 0 then
|
||||||
|
begin
|
||||||
|
g_signal_stop_emission_by_name(PGtkObject(Widget), 'switch-page');
|
||||||
|
Result := not CallBackDefaultReturn;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
// remove flag
|
||||||
|
g_object_set_data(PGObject(Widget), LCL_NotebookManualPageSwitchKey, nil);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// then send the new page
|
||||||
|
FillChar(Mess, SizeOf(Mess), 0);
|
||||||
|
Mess.Msg := LM_NOTIFY;
|
||||||
|
FillChar(NMHdr, SizeOf(NMHdr), 0);
|
||||||
|
NMHdr.code := TCN_SELCHANGE;
|
||||||
|
NMHdr.hwndFrom := PtrUInt(widget);
|
||||||
|
NMHdr.idFrom := pagenum; //use this to set pageindex to the correct page.
|
||||||
|
Mess.NMHdr := @NMHdr;
|
||||||
|
DeliverMessage(Data, Mess);
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TGtkWSCustomNotebook.SetCallbacks(const AGtkWidget: PGtkWidget;
|
class procedure TGtkWSCustomNotebook.SetCallbacks(const AGtkWidget: PGtkWidget;
|
||||||
const AWidgetInfo: PWidgetInfo);
|
const AWidgetInfo: PWidgetInfo);
|
||||||
begin
|
begin
|
||||||
TGtkWSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
TGtkWSWinControl.SetCallbacks(PGtkObject(AGtkWidget), TComponent(AWidgetInfo^.LCLObject));
|
||||||
TGTKWidgetSet(WidgetSet).SetCallback(LM_CHANGED, PGtkObject(AGtkWidget), AWidgetInfo^.LCLObject);
|
ConnectSignal(PGtkObject(AGtkWidget), 'switch_page', @GtkWSNotebook_SwitchPage, AWidgetInfo^.LCLObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TGtkWSCustomNotebook.CreateHandle(const AWinControl: TWinControl;
|
class function TGtkWSCustomNotebook.CreateHandle(const AWinControl: TWinControl;
|
||||||
@ -535,6 +588,7 @@ end;
|
|||||||
class procedure TGtkWSCustomNotebook.SetPageIndex(
|
class procedure TGtkWSCustomNotebook.SetPageIndex(
|
||||||
const ANotebook: TCustomNotebook; const AIndex: integer);
|
const ANotebook: TCustomNotebook; const AIndex: integer);
|
||||||
begin
|
begin
|
||||||
|
g_object_set_data(PGObject(ANotebook.Handle), LCL_NotebookManualPageSwitchKey, ANoteBook);
|
||||||
gtk_notebook_set_page(PGtkNotebook(ANotebook.Handle), AIndex);
|
gtk_notebook_set_page(PGtkNotebook(ANotebook.Handle), AIndex);
|
||||||
UpdateNoteBookClientWidget(ANotebook);
|
UpdateNoteBookClientWidget(ANotebook);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user