- dont send notification message to lcl when page of notebook is switching from no-page state
- AllowChange = False now has effect
qt:
- send notification message to lcl when notebook page want to switch
and look at AllowChange result
(fix part of 0008338)

git-svn-id: trunk@13744 -
This commit is contained in:
paul 2008-01-14 07:48:25 +00:00
parent 0db10a247b
commit 8e8ae63a6d
3 changed files with 64 additions and 25 deletions

View File

@ -321,19 +321,19 @@ end;
function TCustomNotebook.CanChangePageIndex: boolean;
begin
Result := True;
if ([csDestroying] * ComponentState = []) and Assigned(OnChanging) then
OnChanging(Self,Result);
if ([csDesigning, csDestroying] * ComponentState = []) and Assigned(OnChanging) then
OnChanging(Self, Result);
end;
function TCustomNotebook.GetMinimumTabWidth: integer;
begin
Result:=TWSCustomNotebookClass(WidgetSetClass).GetNotebookMinTabWidth(Self);
Result := TWSCustomNotebookClass(WidgetSetClass).GetNotebookMinTabWidth(Self);
//debugln('TCustomNotebook.GetMinimumTabWidth A ',dbgs(Result));
end;
function TCustomNotebook.GetMinimumTabHeight: integer;
begin
Result:=TWSCustomNotebookClass(WidgetSetClass).GetNotebookMinTabHeight(Self);
Result := TWSCustomNotebookClass(WidgetSetClass).GetNotebookMinTabHeight(Self);
//debugln('TCustomNotebook.GetMinimumTabHeight A ',dbgs(Result));
end;
@ -770,9 +770,9 @@ end;
procedure TCustomNotebook.CNNotify(var Message: TLMNotify);
var
OldPageIndex: LongInt;
Begin
begin
with Message do
Case NMHdr^.code of
case NMHdr^.code of
TCN_SELCHANGE:
begin
// set the page from the NMHDR^.idfrom

View File

@ -1988,39 +1988,41 @@ function GtkSwitchPage(widget: PGtkWidget; page: Pgtkwidget; pagenum: integer;
var
Mess: TLMNotify;
NMHdr: tagNMHDR;
SwitchAllowed: Boolean;
begin
Result := CallBackDefaultReturn;
if (Widget=nil) or (Page=nil) then ;
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);
FillChar(Mess, SizeOf(Mess), 0);
Mess.Msg := LM_NOTIFY;
FillChar(NMHdr,SizeOf(NMHdr),0);
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.
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);
SwitchAllowed:=Mess.Result=0;
if not SwitchAllowed then begin
debugln('gtkswitchpage A SwitchAllowed=false not yet implemented');
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);
FillChar(Mess, SizeOf(Mess), 0);
Mess.Msg := LM_NOTIFY;
FillChar(NMHdr,SizeOf(NMHdr),0);
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.
NMHdr.hwndFrom := PtrUInt(widget);
NMHdr.idFrom := pagenum; //use this to set pageindex to the correct page.
Mess.NMHdr := @NMHdr;
DeliverMessage(Data, Mess);
end;

View File

@ -584,6 +584,7 @@ type
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
procedure SignalCurrentChanged(Index: Integer); cdecl;
function SlotTabBarMouse(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
public
function indexOf(const AWidget: QWidgetH): integer;
function insertTab(index: Integer; page: QWidgetH; p2: WideString): Integer; overload;
@ -4800,6 +4801,7 @@ var
Method: TMethod;
begin
inherited AttachEvents;
FCurrentChangedHook := QTabWidget_hook_create(Widget);
FTabBarEventHook := QWidget_hook_create(TabBar);
@ -4831,7 +4833,7 @@ begin
QEventKeyRelease: SlotKey(Sender, Event);
QEventMouseButtonPress,
QEventMouseButtonRelease,
QEventMouseButtonDblClick: SlotMouse(Sender, Event);
QEventMouseButtonDblClick: Result := SlotTabBarMouse(Sender, Event);
else
QEvent_ignore(Event);
end;
@ -4935,18 +4937,53 @@ var
begin
if LCLObject = nil then
Exit;
FillChar(Msg, SizeOf(Msg), #0);
FillChar(Msg, SizeOf(Msg), 0);
Msg.Msg := LM_NOTIFY;
FillChar(Hdr, SizeOf(Hdr), 0);
Msg.Msg := CN_NOTIFY;
Hdr.hwndFrom := LCLObject.Handle;
Hdr.Code := TCN_SELCHANGE;
Hdr.idFrom := Index;
Msg.NMHdr := @Hdr;
Msg.Result := 0;
DeliverMessage(Msg);
end;
function TQtTabWidget.SlotTabBarMouse(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
var
MousePos: TQtPoint;
NewIndex, CurIndex: Integer;
Msg: TLMNotify;
Hdr: TNmHdr;
begin
Result := False;
MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
NewIndex := QTabBar_tabAt(QTabBarH(Sender), @MousePos);
CurIndex := QTabBar_currentIndex(QTabBarH(Sender));
if (NewIndex <> CurIndex) and (NewIndex <> -1) and (CurIndex <> -1) then
begin
FillChar(Msg, SizeOf(Msg), 0);
Msg.Msg := LM_NOTIFY;
FillChar(Hdr, SizeOf(Hdr), 0);
Hdr.hwndFrom := LCLObject.Handle;
Hdr.Code := TCN_SELCHANGING;
Hdr.idFrom := CurIndex;
Msg.NMHdr := @Hdr;
Msg.Result := 0;
DeliverMessage(Msg);
if Msg.Result <> 0 then
begin
QEvent_accept(Event);
Result := True;
Exit;
end;
end;
SlotMouse(Sender, Event);
end;
function TQtTabWidget.indexOf(const AWidget: QWidgetH): integer;
begin
Result := QTabWidget_indexOf(QTabWidgetH(Widget), AWidget);