Forum > Linux

[solved] lbOwnerDrawFixed - minor niggles

(1/1)

andyH:
I found this:
https://forum.lazarus.freepascal.org/index.php?topic=42397.0 
Which led me to define this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TBasePanel.BoldOS(Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);begin  with (Control as TCheckListBox).Canvas do       begin         if MyDrives.isOS((Control as TCheckListBox).Items[Index]) then Font.Style:= [fsBold];         TextOut(ARect.Left, ARect.Top,(Control as TCheckListBox).Items[Index]);       end;end;With the relevant TCheckListBox:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Box2.Style:= lbOwnerDrawFixed;Box2.OnDrawItem:= @BoldOS;
MyDrives.isOS checks to see if a partition has an operating system on it and if true, sets the font bold for the relevant TCheckListBox item.

The niggles are that relative to an unmodified TCheckListBox (boxd screenshot), the text in the modified TCheckListBox (boxp screenshot) is placed closer to the checkbox and the text is aligned top instead of centre.

Posted in the linux subforum just in case it is GTK dependent.

Is there any way to get the alignment and spacing with lbOwnerDrawFixed the same as an unmodified TCheckListBox?

andyH:
Should have googled textout before I posted  :(

Fixed:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TBasePanel.BoldOS(Control: TWinControl; Index: Integer; ARect: TRect; State: TOwnerDrawState);begin  with (Control as TCheckListBox).Canvas do       begin         if MyDrives.isOS((Control as TCheckListBox).Items[Index]) then Font.Style:= [fsBold];         TextOut(ARect.Left+5, ARect.Top+3,(Control as TCheckListBox).Items[Index]);       end;end;

Navigation

[0] Message Index

Go to full version