Page 1 of 1

gtk2 /gtk3 -x86 /x64 - size mismatch

Posted: Sat Oct 24, 2015 1:45 pm
by walbus
Linux / gtk2 - gtk3 - x86 - x64 - size differences and other

Please compare x64 vs x86 also gtk2 vs gtk3 - the results are other

Code: Select all

;- Color Button -------------------------------------------------------------------------
Procedure color_button(button, x, y, width, height, text$, color.l)
  Protected image=CreateImage(#PB_Any, width, height)
  StartDrawing(ImageOutput(image))
  DrawingFont(FontID(1))
  Box(0, 0, width, height, color)
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(width/2-TextWidth(text$)/2,height/2-TextHeight(text$)/2,text$,0)
  StopDrawing()
  ButtonImageGadget(button, x, y, width, height, ImageID(image))
EndProcedure

LoadFont(1, "Arial", 9)

OpenWindow(0, 0, 0, 370, 150, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

ButtonGadget(1, 10, 10, 70, 40,"Test")
ButtonGadget(2, 10, 70, 70, 40,"Test")
color_button(3, 95, 10, 70, 40, "Test", $00FF)
color_button(4, 95, 70, 70, 40, "Test", $00FF)
StartDrawing(WindowOutput(0))
DrawingMode(#PB_2DDrawing_Outlined)
Box(10, 10, 168, 110, color)
Box(10, 10, 155, 100, color)
StopDrawing()

ButtonGadget(5, 190, 10, 70, 40,"Test")
ButtonGadget(6, 190, 70, 70, 40,"Test")
color_button(7, 275, 10, 70, 40, "Test", $00FF)
color_button(8, 275, 70, 70, 40, "Test", $00FF)
StartDrawing(WindowOutput(0))
DrawingMode(#PB_2DDrawing_Outlined)
Box(190, 10, 169, 110, color)
Box(190, 10, 155, 100, color)
StopDrawing()

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Image

Re: gtk2 /gtk3 -x86 /x64 - size mismatch

Posted: Fri Nov 20, 2015 12:56 pm
by Fred
Unfortunately, with GTK3 the button grows automatically depending of the image size and I didn't found a way to avoid this. So you will have to reduce a bit your image size to have "correct" sized button:

Code: Select all

;- Color Button -------------------------------------------------------------------------
Procedure color_button(button, x, y, width, height, text$, color.l)
  
  imageWidth = width-10
  imageHeight = height-10
  Protected image=CreateImage(#PB_Any, imageWidth, imageHeight)
  StartDrawing(ImageOutput(image))
  DrawingFont(FontID(1))
  Box(0, 0, imageWidth, imageHeight, color)
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(imageWidth/2-TextWidth(text$)/2,imageHeight/2-TextHeight(text$)/2,text$,0)
  StopDrawing()
  ButtonImageGadget(button, x, y, width, height, ImageID(image))
EndProcedure

LoadFont(1, "Arial", 9)

OpenWindow(0, 0, 0, 370, 150, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

ButtonGadget(1, 10, 10, 70, 40,"Test")
ButtonGadget(2, 10, 70, 70, 40,"Test")
color_button(3, 95, 10, 70, 40, "Test", $00FF)
color_button(4, 95, 70, 70, 40, "Test", $00FF)
StartDrawing(WindowOutput(0))
DrawingMode(#PB_2DDrawing_Outlined)
Box(10, 10, 168, 110, color)
Box(10, 10, 155, 100, color)
StopDrawing()

ButtonGadget(5, 190, 10, 70, 40,"Test")
ButtonGadget(6, 190, 70, 70, 40,"Test")
color_button(7, 275, 10, 70, 40, "Test", $00FF)
color_button(8, 275, 70, 70, 40, "Test", $00FF)
StartDrawing(WindowOutput(0))
DrawingMode(#PB_2DDrawing_Outlined)
Box(190, 10, 169, 110, color)
Box(190, 10, 155, 100, color)
StopDrawing()

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Moved to linux forum