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
function insertTab(index: Integer; page: QWidgetH; p2: PWideString): Integer;
procedure SetTabPosition(ATabPosition: QTabWidgetTabPosition);
procedure SignalCurrentChanged(Index: Integer); cdecl;
end;
{ TQtComboBox }
@ -2698,7 +2699,6 @@ end;
function TQtTabWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin
Result := False;
inherited EventFilter(Sender, Event);
end;
@ -2712,11 +2712,49 @@ begin
Result := QTabWidget_insertTab(QTabWidgetH(Widget), index, page, p2);
end;
{------------------------------------------------------------------------------
Function: TQtTabWidget.setTabPosition
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
procedure TQtTabWidget.SetTabPosition(ATabPosition: QTabWidgetTabPosition);
begin
QTabWidget_setTabPosition(QTabWidgetH(Widget), ATabPosition);
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 }
function TQtComboBox.CreateWidget(const AParams: TCreateParams): QWidgetH;

View File

@ -2728,10 +2728,10 @@ var
R: TRect;
FRepaint: Boolean;
function PrepareScrollInfo: Boolean;
function PrepareScrollInfo: Integer;
begin
Result := False;
Result := 0;
if not Assigned(ScrollBar) then exit;
@ -2741,6 +2741,8 @@ begin
if GetScrollInfo(Handle, SBStyle, FScrollInfo) then
begin
{impossible cases}
if (ScrollInfo.nPage > ScrollInfo.nMax) then exit;
if (ScrollInfo.FMask or SIF_RANGE) = ScrollInfo.FMask then
begin
@ -2789,9 +2791,10 @@ begin
if (ScrollInfo.FMask or SIF_DISABLENOSCROLL) = ScrollInfo.FMask then
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,
disable the scroll bar instead of removing it.}
ScrollBar.Enabled := False;
end else
begin
@ -2803,7 +2806,7 @@ begin
end;
ScrollInfo := FScrollInfo;
Result := True;
Result := FScrollInfo.nPos;
end;
end;
@ -2850,10 +2853,6 @@ begin
or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
exit;
if TQtWidget(Handle).LCLObject.InheritsFrom(TScrollingWinControl) then
if not TScrollingWinControl(TQtWidget(Handle).LCLObject).HorzScrollBar.Visible then exit;;
{do not localize !}
ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject.FindChildControl(TQtWidget(Handle).LCLObject.Name+'_HSCROLLBAR'));
@ -2881,10 +2880,6 @@ begin
or (csDestroying in TQtWidget(Handle).LCLObject.ComponentState) then
exit;
if TQtWidget(Handle).LCLObject.InheritsFrom(TScrollingWinControl) then
if not TScrollingWinControl(TQtWidget(Handle).LCLObject).VertScrollBar.Visible then exit;
{do not localize !}
ScrollBar := TScrollBar(TQtWidget(Handle).LCLObject.FindChildControl(TQtWidget(Handle).LCLObject.Name+'_VSCROLLBAR'));
@ -2905,15 +2900,16 @@ begin
Scrollbar.Height := R.Bottom;
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;
if FRepaint then ScrollBar.Invalidate;
PrepareScrollInfo;
Result := ScrollInfo.nPos;
if bRedraw then
Result := PrepareScrollInfo;
end;

View File

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

View File

@ -447,7 +447,7 @@ begin
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);
end;
@ -793,7 +793,7 @@ begin
Color:=ColorToRGB(AWinControl.Color);
// 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
TQtLineEdit(AWinControl.Handle).SetColor(@QColor);