Yet another question about the background color of a TSpeedButton \ TBitButton lazarus / 39-Graphics ---------------------------------------------------------------------- devEric69 · 2021-11-07 12:16 Hello, I'm looking just for a TSpeedButton \ TGlyphButton that can display: - a glyph; - and can change its clientarea background-color at run-time. I did a test with the " candy controls " using the TECSpeedBtn (it exposes, publishes its Canvas property) like below, but I can't repaint it in red: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmMain.ECSpeedBtn1_OnRepeating(Sender: TObject);var  aRect: TRect;begin  TECSpeedBtn(Sender).Color:= clRed; // test 1: doesn't work   aRect:= TECSpeedBtn(Sender).ClientRect;  // test 2: doesn't work neither  TECSpeedBtn(Sender).Canvas.Brush.Color:= clRed;  TECSpeedBtn(Sender).Canvas.Rectangle(aRect);  TECSpeedBtn(Sender).Canvas.FillRect(aRect);end;    I may be coding wrong because this control exposes very well its painting TCanvas, which is made for what I am looking to do, AFAIK. Any suggestions for using just such a TSpeedButton \ TGlyphButton that could be repainted over the OS theme (I'm on Linux)? ---------------------------------------------------------------------- Fred vS · 2021-11-07 12:32 Quote from: devEric69 on November 07, 2021, 01:16:09 pmAny suggestions for using just such a TSpeedButton \ TGlyphButton that could be repainted over the OS theme (I'm on Linux)? MSEgui. Fre;D ---------------------------------------------------------------------- winni · 2021-11-07 13:50 Hi! Hardrock solution to get around the traps of the SpeedButton and the OS: Create a BGRAbitmap from the glyph, which is a TBitmap Paint on the BGRAbitmp as you need Draw the BGRAbitmap on the Glyph.Canvas Untested but should work Winni ---------------------------------------------------------------------- devEric69 · 2021-11-07 14:55 Hi Fred, Very nice buttons. I know you are working hard to refactor and maintain mseIDE. I allow myself to express a wish: it would be nice if we could create windows, either entirely build using MSEgui, or either entirely build using fpGUI, in the same X11 application. This is just an idea, may be crazy (I've no knowledge of mseIDE), but by making its message distribution loop "polymorphic" \ adaptable to MSEgui that I don't know , and fpGUI that I know - to make the two types of windows working together in an application - whether there is a real possibility, mseIDE would become THE MUST HAVE IDE-tool for X11 programming. Hi Winni, In fact, I've just tried to install libxst-dev + libl-dev Debian packages + bgrabitmappack.lpk + bgracontrols.lpk this morning ==> but unfortunately, I encountered some annoying messages after compiling and installing these packages: - cannot load libGLU.so ; - canot find opengl/src/glu.pp ; - Lazarus stopped launching itself, then it hung up ; That said, sooner or later, I will have to use BGRAbitmap with TeeChart (so, I will have to reinstall and really understand the above unwelcome messages). But for now, I have to finish quickly something else: I'll postpone to understand these messages. I've used SVN to clean everything up and put Lazarus back the way it was - renamming lazarusOld.elf towards lazarus.elf - before my trial to install the BGRA framework. Hence, my test with another controls framework (" candy controls ", which has funny shape controls, rather electronically oriented): I think it should be possible to override an OS theme with them (but I only started reading their source code since yesterday ). ---------------------------------------------------------------------- winni · 2021-11-07 15:08 Hi! Again Debian trouble ..... AFAIR libGLU is part of the package libglu1-mesa Install this Debian Package. And look for the next Debian trouble ... Winni ---------------------------------------------------------------------- Fred vS · 2021-11-07 15:17 Quote from: devEric69 on November 07, 2021, 03:55:14 pmHi Fred, ... I allow myself to express a wish: it would be nice if we could create windows, either entirely build using MSEgui, or either entirely build using fpGUI, in the same X11 application. This is just an idea, may be crazy (I've no knowledge of mseIDE), but by making its message distribution loop "polymorphic" \ adaptable to MSEgui that I don't know , and fpGUI that I know - to make the two types of windows working together in an application - whether there is a real possibility, mseIDE would become THE MUST HAVE IDE-tool for X11 programming. Hum, that would be difficult because fpGUI and MSEgui have totally different architectures. They share both libX11.so.6 library but dont have the same interface. So for all the graphic widgets at the moment I dont see solution to share for example a TMSEButton on a fpGUIForm and vice versa ). But you may, of course, load-edit-debug-run fpGUI projects with MSEide ( the IDE for MSEgui ). ideU ( a fork of MSEide ) has integration with fpGUI designer for example. PS: A other advantage with fpGUI/MSEgui is: no more problems with all that dependencies  Fre;D ---------------------------------------------------------------------- devEric69 · 2021-11-07 15:39 Quote from: winni on November 07, 2021, 04:08:47 pmAgain Debian trouble ..... AFAIK libGLU is part of the package libglu1-mesa Install this Debian Package. And look for the next Debian trouble ... Thanks for the information, that's good to know.  I'll give it a try . Quote from: Fred vS on November 07, 2021, 04:17:13 pmThey share both libX11.so.6 library but dont have the same interface. So for all the graphic widgets at the moment I dont see solution to share for example a TMSEButton on a fpGUIForm and vice versa. Of course, I knew - in fact - that my request was very complicated . But I thought very less complicated than what you're talking: just to create only pure MSEgui windows or only pure fpGUI windows. And at first, only MSEgui windows will understand \ talk each other, and only fpGUI windows will understand \ talk each other. In other words, initially the mseIDE loop messages would not send an fpGUI message towards an MSEGUI window, and vice versa (a MSEGUI message towards an fpGUI window). Anyway: it's just an idea. ---------------------------------------------------------------------- Fred vS · 2021-11-07 15:56 Quote from: devEric69 on November 07, 2021, 04:39:21 pmBut I thought very less complicated than what you're talking: just to create only pure MSEgui windows or only pure fpGUI windows. And at first, only MSEgui windows will understand \ talk each other, and only fpGUI windows will understand \ talk each other. In other words, initially the mseIDE loop messages would not send an fpGUI message towards an MSEGUI window, and vice versa (a MSEGUI message towards an fpGUI window). Anyway: it's just an idea. Hum, it is what ideU does. For example if you edit a unit-form, when you press F12 the form- designer of fpGUI will be loaded for a fpGUI unit and the MSEgui designer for a MSEgui unit. For both MSEgui and fpGUI designers, if you change something in design, it is changed in the code too. Also if you change the code, for both MSEgui and fpGUI designers the change is done in design too. In the release of ideU is included fpGUI Desinger_ext who is a fork of the original fpGUI UIDesinger but adapted for interaction with ideU. ---------------------------------------------------------------------- winni · 2021-11-07 16:31 Hi! It is hard to draw  on the Speedbutton.glyph: It remembers the transparent parts of the bitmap. If you want to get around that  you have to make changes in the Class TButtonGlyph. But you can get around the glyph this way: Do not put a bitmap inside the glyph. Use another place for your icon (ImageList, Resource, HardDisk) Load and/or draw on a Bitmap/BGRAbitmap Draw it on the canvas oft the SpeedButton (NOT the glyph) done Example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.SpeedButton5Paint(Sender: TObject);var tmp : TBGRAbitmap;begin  tmp := TBGRAbitmap.create (SpeedButton5.width,SpeedButton5.height, cssBlue);  tmp.DrawLineAntialias(0,0,tmp.width,tmp.height,cssRed,5);  tmp.Draw(SpeedButton5.canvas,0,0,true);  tmp.free;end;  Winni ---------------------------------------------------------------------- devEric69 · 2021-11-07 20:10 Well, I think I'm going to write a pseudo-TBitButton composition (@Winni: thanks for the code examples. As already said, I will sooner or later use the BGRAbitmap framework to draw on TaChart; but I need a rapid embedded solution), i.e. a component following @wp's idea (found here...) i.e. encapsulating a TPanel with its small 16x16 [px] TBitmap image + its TLabel + the TPanel.onOver, etc..., events, all encapsulated in the said component-visual-control that will only publish, delegate the OnClik of the encapsulated TPanel. This is really the easiest way to do it quickly. By the way, I was tired this morning: I've confused the TECSpeedBtn OnRepeating event with the OnRepainting one, which in fact doesn't exist   . Sorry. That said, it's a damage that most Lazarus controls don't add the possibility to override through the call of an external event at the end of their virtual Paint method. But hey, that's the way it is. @Fred: my real respect for your ideU IT automatisation. I hope you'll find some magical inspiration to make the 2 types of application messages loops (those of MSEgui and those of fpGUI) cohabit in one more holistic and magically unifying messages loop  . ---------------------------------------------------------------------- marcov · 2021-11-08 16:18 (Sometimes when native controls don't want to change color is because parentcolor/parentbackground is on. I use something like this procedure to test if that is the case: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure zapcolor(t:twincontrol;col:tcolorref); var i : integer;     x : TControl; begin  if t is  tpanel then    begin      tpanel(t).parentcolor:=false;  //    {$ifndef fpc}      tpanel(t).parentbackground:=false;//      {$endif}      tpanel(t).color:=col;     end;  if t is  tform then    begin      {$ifndef fpc}//      tform(t).parentcolor:=false;//      tform(t).parentbackground:=false;      {$endif}      tform(t).color:=col;     end;  if t is tframe then    begin      tframe(t).parentcolor:=false;      tframe(t).parentbackground:=false;      tframe(t).Color:=col;    end;  for i:=0 to t.ControlCount-1  do  begin      x:=t.controls[i];      if x is tpanel then        begin        tpanel(x).parentcolor:=false;          tpanel(x).parentbackground:=false;          tpanel(x).color:=col;       end;       if x is tgroupbox then         begin           tgroupbox(x).parentcolor:=false;           tgroupbox(x).parentbackground:=false;           tgroupbox(x).color:=col;         end;     if x is twincontrol then     zapcolor(twincontrol(x),col);    end;end;  ) ---------------------------------------------------------------------- devEric69 · 2021-11-11 10:52 @marcov: thanks for the piece of code. I'm posting a TMimicRollOverBitBtn (this kind of the 3 button's colours management is called a " web rollover button ", on the internet) graphic control (based on an idea from @wp). Not perfect, but it does what I want. By the way, if someone can explain me how to assign the container TPanel caption to '' (empty string): I do this assignment (Self.Caption:= '';) in the constructor and in the Loaded, but a side- effect always rewrites the panel's name in its caption . ---------------------------------------------------------------------- howardpc · 2021-11-11 12:02 Quote from: devEric69 on November 11, 2021, 11:52:55 amBy the way, if someone can explain me how to assign the container TPanel caption to '' (empty string): I do this assignment (Self.Caption:= '';) in the constructor and in the Loaded, but a side-effect always rewrites the panel's name in its caption . In the container's constructor include this line: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ControlStyle := ControlStyle - [csSetCaption]; ---------------------------------------------------------------------- devEric69 · 2021-11-12 10:53 Okay, thanks: I've learned something (component uploaded with this tiny correction).