Patch from zeljko for the qt interface. TPageControl now sets properly ActivePage while changing tabs, a bug with TScrollWinControls fixed.

git-svn-id: trunk@11226 -
This commit is contained in:
sekelsenmat 2007-05-30 09:21:48 +00:00
parent ee57c2741e
commit 09025d10df
4 changed files with 59 additions and 23 deletions

View File

@ -301,6 +301,7 @@ type
public public
function insertTab(index: Integer; page: QWidgetH; p2: PWideString): Integer; function insertTab(index: Integer; page: QWidgetH; p2: PWideString): Integer;
procedure SetTabPosition(ATabPosition: QTabWidgetTabPosition); procedure SetTabPosition(ATabPosition: QTabWidgetTabPosition);
procedure SignalCurrentChanged(Index: Integer); cdecl;
end; end;
{ TQtComboBox } { TQtComboBox }
@ -2698,7 +2699,6 @@ end;
function TQtTabWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; function TQtTabWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin begin
Result := False; Result := False;
inherited EventFilter(Sender, Event); inherited EventFilter(Sender, Event);
end; end;
@ -2712,11 +2712,49 @@ begin
Result := QTabWidget_insertTab(QTabWidgetH(Widget), index, page, p2); Result := QTabWidget_insertTab(QTabWidgetH(Widget), index, page, p2);
end; end;
{------------------------------------------------------------------------------
Function: TQtTabWidget.setTabPosition
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TQtTabWidget.SetTabPosition(ATabPosition: QTabWidgetTabPosition); procedure TQtTabWidget.SetTabPosition(ATabPosition: QTabWidgetTabPosition);
begin begin
QTabWidget_setTabPosition(QTabWidgetH(Widget), ATabPosition); QTabWidget_setTabPosition(QTabWidgetH(Widget), ATabPosition);
end; end;
{------------------------------------------------------------------------------
Function: TQtTabWidget.SignalCurrentChanged
Params: None
Returns: Nothing
Changes ActivePage of TPageControl
------------------------------------------------------------------------------}
procedure TQtTabWidget.SignalCurrentChanged(Index: Integer); cdecl;
var
TS: TTabSheet;
begin
TS := TPageControl(LCLObject).ActivePage;
if Assigned(TS) then
begin
if TS.PageIndex <> Index then TS := TPageControl(LCLObject).Pages[Index]
else
TS := NiL;
end;
try
if Assigned(TS) then
begin
if TPageControl(LCLObject).CanChangePageIndex then
TPageControl(LCLObject).ActivePage := TS;
end;
except
Application.HandleException(nil);
end;
end;
{ TQtComboBox } { TQtComboBox }
function TQtComboBox.CreateWidget(const AParams: TCreateParams): QWidgetH; function TQtComboBox.CreateWidget(const AParams: TCreateParams): QWidgetH;

View File

@ -2728,10 +2728,10 @@ var
R: TRect; R: TRect;
FRepaint: Boolean; FRepaint: Boolean;
function PrepareScrollInfo: Boolean; function PrepareScrollInfo: Integer;
begin begin
Result := False; Result := 0;
if not Assigned(ScrollBar) then exit; if not Assigned(ScrollBar) then exit;
@ -2741,6 +2741,8 @@ begin
if GetScrollInfo(Handle, SBStyle, FScrollInfo) then if GetScrollInfo(Handle, SBStyle, FScrollInfo) then
begin begin
{impossible cases}
if (ScrollInfo.nPage > ScrollInfo.nMax) then exit;
if (ScrollInfo.FMask or SIF_RANGE) = ScrollInfo.FMask then if (ScrollInfo.FMask or SIF_RANGE) = ScrollInfo.FMask then
begin begin
@ -2789,9 +2791,10 @@ begin
if (ScrollInfo.FMask or SIF_DISABLENOSCROLL) = ScrollInfo.FMask then if (ScrollInfo.FMask or SIF_DISABLENOSCROLL) = ScrollInfo.FMask then
begin begin
{This value is used only when setting a scroll bar's parameters. {This value is used only when setting a scroll bar''s parameters.
If the scroll bar's new parameters make the scroll bar unnecessary, If the scroll bar's new parameters make the scroll bar unnecessary,
disable the scroll bar instead of removing it.} disable the scroll bar instead of removing it.}
ScrollBar.Enabled := False; ScrollBar.Enabled := False;
end else end else
begin begin
@ -2803,7 +2806,7 @@ begin
end; end;
ScrollInfo := FScrollInfo; ScrollInfo := FScrollInfo;
Result := True; Result := FScrollInfo.nPos;
end; end;
end; end;
@ -2850,10 +2853,6 @@ begin
or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
exit; exit;
if TQtWidget(Handle).LCLObject.InheritsFrom(TScrollingWinControl) then
if not TScrollingWinControl(TQtWidget(Handle).LCLObject).HorzScrollBar.Visible then exit;;
{do not localize !} {do not localize !}
ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject.FindChildControl(TQtWidget(Handle).LCLObject.Name+'_HSCROLLBAR')); ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject.FindChildControl(TQtWidget(Handle).LCLObject.Name+'_HSCROLLBAR'));
@ -2881,10 +2880,6 @@ begin
or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
exit; exit;
if TQtWidget(Handle).LCLObject.InheritsFrom(TScrollingWinControl) then
if not TScrollingWinControl(TQtWidget(Handle).LCLObject).VertScrollBar.Visible then exit;
{do not localize !} {do not localize !}
ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject.FindChildControl(TQtWidget(Handle).LCLObject.Name+'_VSCROLLBAR')); ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject.FindChildControl(TQtWidget(Handle).LCLObject.Name+'_VSCROLLBAR'));
@ -2905,15 +2900,16 @@ begin
Scrollbar.Height := R.Bottom; Scrollbar.Height := R.Bottom;
ScrollBar.Top := 0; ScrollBar.Top := 0;
ScrollBar.Left := R.Right - ScrollBar.Width; {TODO: Check why BorderWidth is 0 when BorderStyle is eg. bsSingle ?!? }
ScrollBar.Left := R.Right - ScrollBar.Width - (TQtWidget(Handle).LCLObject.BorderWidth * 2);
end; {SB_VERT} end; {SB_VERT}
end; end;
if FRepaint then ScrollBar.Invalidate; if FRepaint then ScrollBar.Invalidate;
PrepareScrollInfo; if bRedraw then
Result := ScrollInfo.nPos; Result := PrepareScrollInfo;
end; end;

View File

@ -22,7 +22,7 @@
} }
unit QtWSExtCtrls; unit QtWSExtCtrls;
{$mode objfpc}{$H+} {$mode delphi}{$H+}
interface interface
@ -30,7 +30,7 @@ uses
// Bindings // Bindings
qt4, qtwidgets, qt4, qtwidgets,
// LCL // LCL
SysUtils, Controls, LCLType, Forms, ExtCtrls, SysUtils, Controls, Forms, ExtCtrls, LCLType,
// Widgetset // Widgetset
WSExtCtrls, WSLCLClasses; WSExtCtrls, WSLCLClasses;
@ -249,7 +249,7 @@ begin
Hook := QObject_hook_create(QtFrame.Widget); Hook := QObject_hook_create(QtFrame.Widget);
TEventFilterMethod(Method) := @QtFrame.EventFilter; TEventFilterMethod(Method) := QtFrame.EventFilter;
QObject_hook_hook_events(Hook, Method); QObject_hook_hook_events(Hook, Method);
@ -304,7 +304,7 @@ begin
Hook := QTabBar_hook_create(QtWidget.Widget); Hook := QTabBar_hook_create(QtWidget.Widget);
TEventFilterMethod(Method) := @QtWidget.EventFilter; TEventFilterMethod(Method) := QtWidget.EventFilter;
QObject_hook_hook_events(Hook, Method); QObject_hook_hook_events(Hook, Method);
@ -364,9 +364,11 @@ begin
Hook := QTabWidget_hook_create(QtTabWidget.Widget); Hook := QTabWidget_hook_create(QtTabWidget.Widget);
TEventFilterMethod(Method) := @QtTabWidget.EventFilter; TEventFilterMethod(Method) := QtTabWidget.EventFilter;
QObject_hook_hook_events(Hook, Method); QObject_hook_hook_events(Hook, Method);
QTabWidget_currentChanged_Event(Method) := QtTabWidget.SignalCurrentChanged;
QTabWidget_hook_hook_currentChanged(QTabWidget_hook_create(QtTabWidget.Widget), Method);
// Returns the Handle // Returns the Handle

View File

@ -447,7 +447,7 @@ begin
QListWidget_currentItemChanged_Event(Method) := QtListWidget.SlotSelectionChange; QListWidget_currentItemChanged_Event(Method) := QtListWidget.SlotSelectionChange;
QListWidget_hook_hook_currentItemChanged(Hook, Method); QListWidget_hook_hook_currentItemChanged(QListWidget_hook_create(QtListWidget.Widget), Method);
Result := THandle(QtListWidget); Result := THandle(QtListWidget);
end; end;
@ -793,7 +793,7 @@ begin
Color:=ColorToRGB(AWinControl.Color); Color:=ColorToRGB(AWinControl.Color);
// Fill QColor // Fill QColor
QColor_setRgb(@QColor,Red(Color),Green(Color),Blue(Color)); QColor_setRgb(QColorH(@QColor),Red(Color),Green(Color),Blue(Color));
// Set color of the widget to QColor // Set color of the widget to QColor
TQtLineEdit(AWinControl.Handle).SetColor(@QColor); TQtLineEdit(AWinControl.Handle).SetColor(@QColor);