win32, qt: fix retrieving correct imageindex for page (bug #0012029)

git-svn-id: trunk@18230 -
This commit is contained in:
paul 2009-01-09 20:02:30 +00:00
parent 5df806377b
commit 5612e34a33
3 changed files with 22 additions and 18 deletions

View File

@ -309,13 +309,13 @@ function TCustomNotebook.GetImageIndex(ThePageIndex: Integer): Integer;
var
APage: TCustomPage;
begin
APage:=Page[ThePageIndex];
if APage<>nil then
Result:=APage.ImageIndex
APage := Page[ThePageIndex];
if APage <> nil then
Result := APage.ImageIndex
else
Result:=-1;
Result := -1;
if Assigned(OnGetImageIndex) then
OnGetImageIndex(Self,ThePageIndex,Result);
OnGetImageIndex(Self, ThePageIndex, Result);
end;
function TCustomNotebook.IndexOf(APage: TCustomPage): integer;

View File

@ -256,19 +256,23 @@ end;
class procedure TQtWSCustomPage.UpdateProperties(const ACustomPage: TCustomPage);
var
ImageList: TCustomImageList;
ImageIndex: Integer;
Bmp: TBitmap;
begin
ImageList := TCustomNoteBook(ACustomPage.Parent).Images;
if Assigned(ImageList) and (ACustomPage.ImageIndex >= 0) and
(ACustomPage.ImageIndex < ImageList.Count) then
if Assigned(ImageList) then
begin
Bmp := TBitmap.Create;
try
ImageList.GetBitmap(ACustomPage.ImageIndex, Bmp);
TQtPage(ACustomPage.Handle).setIcon(TQtImage(Bmp.Handle).AsIcon);
finally
Bmp.Free;
ImageIndex := TCustomNoteBook(ACustomPage.Parent).GetImageIndex(ACustomPage.PageIndex);
if (ImageIndex >= 0) and (ImageIndex < ImageList.Count) then
begin
Bmp := TBitmap.Create;
try
ImageList.GetBitmap(ACustomPage.ImageIndex, Bmp);
TQtPage(ACustomPage.Handle).setIcon(TQtImage(Bmp.Handle).AsIcon);
finally
Bmp.Free;
end;
end;
end;
end;

View File

@ -58,7 +58,7 @@ type
TWin32WSCustomNotebook = class(TWSCustomNotebook)
published
class function CreateHandle(const AWinControl: TWinControl;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure AddAllNBPages(const ANotebook: TCustomNotebook);
class procedure AdjustSizeNotebookPages(const ANotebook: TCustomNotebook);
@ -197,7 +197,7 @@ type
end;
procedure NotebookFocusNewControl(const ANotebook: TCustomNotebook; NewIndex: integer);
function NotebookPageRealToLCLIndex(const ANotebook: TCustomNotebook; AIndex: integer): integer;
function NotebookPageRealToLCLIndex(const ANotebook: TCustomNotebook; AIndex: integer): integer;
implementation
@ -439,7 +439,7 @@ begin
TCI.Mask := TCIF_TEXT or TCIF_PARAM or TCIF_IMAGE;
// store object as extra, so we can verify we got the right page later
TCI.lParam := PtrUInt(AChild);
TCI.iImage := ANotebook.GetImageIndex(AIndex);
TCI.iImage := ANotebook.GetImageIndex(NotebookPageRealToLCLIndex(ANotebook, AIndex));
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
begin
@ -459,7 +459,7 @@ begin
// windows should send a WM_SIZE message because of this, but it doesn't
// send it ourselves
end;
LCLControlSizeNeedsUpdate(ANotebook, true);
LCLControlSizeNeedsUpdate(ANotebook, True);
end;
end;
@ -571,7 +571,7 @@ var
begin
Result := AIndex;
if csDesigning in ANotebook.ComponentState then exit;
for X := 0 to AIndex-1 do
for X := 0 to AIndex - 1 do
if ANotebook.Page[X].TabVisible = False then Dec(Result);
end;