mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 14:01:49 +02:00
LCL-CustomDrawn: Fixes a crash due to uninitialized CDBaseControl.Children and starts implementing bitbtn glyph support
git-svn-id: trunk@36036 -
This commit is contained in:
parent
6ff8e898ac
commit
ae72fa682f
@ -231,6 +231,7 @@ var
|
||||
lTarget: TWinControl;
|
||||
begin
|
||||
lTarget := AWindowHandle.GetFocusedControl();
|
||||
if lTarget = nil then Exit;
|
||||
{$ifdef VerboseCDEvents}
|
||||
DebugLn(Format('CallbackKeyUp FocusedControl=%s:%s', [lTarget.Name, lTarget.ClassName]));
|
||||
{$endif}
|
||||
|
@ -238,7 +238,6 @@ begin
|
||||
{$ENDIF}
|
||||
lFormInfo := TCDNonNativeForm.Create;
|
||||
lFormInfo.LCLForm := AForm;
|
||||
lFormInfo.Children := TFPList.Create;
|
||||
AddFormWithCDHandle(lFormInfo);
|
||||
Result := lFormInfo;
|
||||
end;
|
||||
@ -986,11 +985,14 @@ begin
|
||||
//FProps.CaseSensitive:=false; commented as in the qt widgetset
|
||||
FProps.Sorted:=true;
|
||||
IncInvalidateCount(); // Always starts needing an invalidate
|
||||
|
||||
Children := TFPList.Create;
|
||||
end;
|
||||
|
||||
destructor TCDBaseControl.Destroy;
|
||||
begin
|
||||
FProps.Free;
|
||||
Children.Free;
|
||||
|
||||
// Free the Canvas and Image if required
|
||||
// Dont free for the Form because elsewhere this is taken care of
|
||||
|
@ -113,51 +113,17 @@ end;
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TCDWSBitBtn.SetGlyph(const ABitBtn: TCustomBitBtn; const AValue: TButtonGlyph);
|
||||
(*const
|
||||
IconModeToButtonState: array[QIconMode] of TButtonState =
|
||||
(
|
||||
{ QIconNormal } bsUp,
|
||||
{ QIconDisabled } bsDisabled,
|
||||
{ QIconActive } bsHot,
|
||||
{ QIconSelected } bsDown
|
||||
);
|
||||
|
||||
var
|
||||
AIcon: QIconH;
|
||||
APixmap: QPixmapH;
|
||||
AGlyph: TBitmap;
|
||||
AIndex: Integer;
|
||||
AEffect: TGraphicsDrawEffect;
|
||||
Mode: QIconMode;
|
||||
ASize: TSize;*)
|
||||
lCDWinControl: TCDWinControl;
|
||||
lCDControl: TCDIntfButton;
|
||||
begin
|
||||
{ if not WSCheckHandleAllocated(ABitBtn, 'SetGlyph') then
|
||||
Exit;
|
||||
// if not WSCheckHandleAllocated(ABitBtn, 'SetGlyph') then
|
||||
// Exit;
|
||||
|
||||
TQtBitBtn(ABitBtn.Handle).GlyphLayout := Ord(ABitBtn.Layout);
|
||||
AIcon := QIcon_create();
|
||||
if ABitBtn.CanShowGlyph then
|
||||
begin
|
||||
AGlyph := TBitmap.Create;
|
||||
APixmap := QPixmap_create();
|
||||
lCDWinControl := TCDWinControl(ABitBtn.Handle);
|
||||
lCDControl := TCDIntfButton(lCDWinControl.CDControl);
|
||||
|
||||
for Mode := QIconNormal to QIconSelected do
|
||||
begin
|
||||
AValue.GetImageIndexAndEffect(IconModeToButtonState[Mode], AIndex, AEffect);
|
||||
AValue.Images.GetBitmap(AIndex, AGlyph, AEffect);
|
||||
QPixmap_fromImage(APixmap, TQtImage(AGlyph.Handle).Handle);
|
||||
QIcon_addPixmap(AIcon, APixmap, Mode, QIconOn);
|
||||
end;
|
||||
QPixmap_destroy(APixmap);
|
||||
AGlyph.Free;
|
||||
|
||||
ASize.cx := AValue.Images.Width;
|
||||
ASize.cy := AValue.Images.Height;
|
||||
TQtBitBtn(ABitBtn.Handle).setIconSize(@ASize);
|
||||
end;
|
||||
|
||||
TQtBitBtn(ABitBtn.Handle).setIcon(AIcon);
|
||||
QIcon_destroy(AIcon);}
|
||||
lCDControl.Glyph.Assign(AValue.Glyph);
|
||||
end;
|
||||
|
||||
class procedure TCDWSBitBtn.SetLayout(const ABitBtn: TCustomBitBtn;
|
||||
|
Loading…
Reference in New Issue
Block a user