Recent

Author Topic: [SOLVED]I can't change the splash window size on GTK2  (Read 1279 times)

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
[SOLVED]I can't change the splash window size on GTK2
« on: February 09, 2018, 08:29:44 pm »
Hi friends

I try to change the splash size which has to depend on the size of a line of the message
Code: Pascal  [Select][+][-]
  1. procedure TFrmMain.LMMyMsg(var Msg: TLMessage);
  2. var
  3.   AText: String;
  4.   ARect: TRect;
  5.   h: Integer; //height of the drawn text
  6.   AFlag: UINT;
  7.   SplashCenterPnt: TPoint;
  8.   DiffHeight: Integer;//difference between a splash height and textcontainer height
  9. begin
  10.   ARect:= Rect(-500,0, FrmSplash.sttTextCont.Width - 500,0);
  11.   AText:= String(NativeInt(Msg.lParam));
  12.  
  13.   with Self.Canvas do
  14.   begin
  15.     //uses LCLType
  16.     AFlag:=
  17.       DT_NOCLIP
  18.       or DT_WORDBREAK
  19.       or DT_LEFT
  20.       ;
  21.     //uses LCLIntf
  22.     h:= DrawText(Handle,PChar(AText),-1, ARect, AFlag);
  23.  
  24.     { TODO : it's not work for linux GTK2. Why? }
  25.     with FrmSplash do
  26.     begin
  27.       sttTextCont.Caption:= '';
  28.       SplashCenterPnt.y:= Top + Height div 2;//a middle splash height
  29.       DiffHeight:= Height - sttTextCont.Height;
  30.       Height:= h + 15 + DiffHeight;
  31.       Top:= SplashCenterPnt.y - Height div 2;
  32.       Repaint;
  33.       InMsgStr:= AText;
  34.     end;
  35.   end;
  36. end;  
       

It perfectly works for windows
https://imgur.com/a/8C3km

and for Ubuntu
https://imgur.com/a/dtDJ6

But it incorrectly works for Debian GTK2
https://imgur.com/a/N9vPr

Why? I will be grateful for any council                             
« Last Edit: February 12, 2018, 08:57:45 am by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

zoltanleo

  • Hero Member
  • *****
  • Posts: 504
Re: I can't change the splash GTK2 size
« Reply #1 on: February 12, 2018, 07:35:15 am »
Solved. 

Code: Pascal  [Select][+][-]
  1.  with Self.Canvas do
  2.   begin
  3.     //uses LCLType
  4.     AFlag:= DT_CALCRECT or DT_WORDBREAK or DT_LEFT;
  5.  
  6.     //uses LCLIntf
  7.     h:= DrawText(Handle,PUTF8Char(AText),UTF8Length(AText), ARect, AFlag);
  8.   end;
  9.  
  10.   with FrmSplash do
  11.   begin
  12.     sttTextCont.Caption:= '';
  13.     SplashCenterPnt.y:= Top + Height div 2;//a middle splash height
  14.     DiffHeight:= Height - sttTextCont.Height;
  15.     Height:= h + 15 + DiffHeight;
  16.  
  17.     {$IFDEF LCLGTK2}
  18.     DoSetBounds(Left,SplashCenterPnt.y - Height div 2,Width,Height);
  19.     {$ELSE}
  20.     Top:= SplashCenterPnt.y - Height div 2;
  21.     {$ENDIF}
  22.  
  23.     InMsgStr:= AText;
  24.   end;
« Last Edit: February 12, 2018, 08:54:53 pm by zoltanleo »
Win10 LTSC x64/Deb 12 amd64(gtk2)/Kubuntu(qt5)/Darwin Cocoa (Sequoia):
Lazarus x32_64 (trunk); FPC(trunk), FireBird 3.0.11; IBX by TonyW

Sorry for my bad English, I'm using translator ;)

 

TinyPortal © 2005-2018