SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Linux specific forum
BlindMan
User
User
Posts: 32
Joined: Thu Aug 30, 2018 11:34 am

SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Post by BlindMan »

Hi

SetWindowColor() doesn't appear to be working.
Window background colour is always white regardless of RGB() value.

Code: Select all

 OpenWindow(0, 0, 0, 800, 600, "")
 OpenWindowedScreen(WindowID(0), 100, 100, 600, 400, 0, 0, 0)
 SetWindowColor(0, RGB(255,0,0))



Are the errors displayed by ./launch.sh (see below) going to cause problems?

Code: Select all

jah@ubuntu:~/purebasic$ ls -l *.sh
-rwxr-xr-x 1 jah jah 2202 Mar 30 20:08 checkinstall.sh
-rwxr-xr-x 1 jah jah   21 Mar 30 20:08 launch.sh
-rwxr-xr-x 1 jah jah 1807 Mar 30 20:08 register.sh


jah@ubuntu:~/purebasic$ ./register.sh
File extensions .pb, .pbi, .pbf are now registered for PureBasic.


jah@ubuntu:~/purebasic$ ./checkinstall.sh
This script try to detect if all developments packages are correctly installed. 
<snip>
Everything seems correctly setup for PureBasic !


jah@ubuntu:~/purebasic$ ./launch.sh
Gtk-Message: 10:16:49.617: Failed to load module "canberra-gtk-module"

** (purebasic:4481): CRITICAL **: 10:16:49.830: murrine_style_draw_box_gap: assertion 'height >= -1' failed

** (purebasic:4481): CRITICAL **: 10:16:49.904: murrine_style_draw_box_gap: assertion 'height >= -1' failed
User avatar
Shardik
Addict
Addict
Posts: 1988
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Post by Shardik »

You should always post code which you have tested. Your posted example doesn't work because you don't use InitSprite() at the beginning (an error message is displayed which gives you that hint) and your code doesn't have any event loop so the program ends at once. In order to answer your question I first had to do this for you:

Code: Select all

InitSprite()
OpenWindow(0, 0, 0, 800, 600, "")
OpenWindowedScreen(WindowID(0), 100, 100, 600, 400, 0, 0, 0)
SetWindowColor(0, RGB(255,0,0))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
To set the window background color you have two options:
1. Set the subsystem to Gtk2 (Menu > Compiler > Compiler Options... > Library Subsystem: gtk2)
2. When using the default Gtk3, trying to use SetWindowColor() will most likely fail in most Linux distributions. This is not PureBasic's fault but that of Gtk3. During the development of Gtk3 at least 3 times the required methods to change the background color have been modified so being a moving target for PureBasic. But you may try this workaround which was tested successfully on 16 different Linux versions with different Gtk3 versions.
BlindMan
User
User
Posts: 32
Joined: Thu Aug 30, 2018 11:34 am

Re: SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Post by BlindMan »

Thank you Shardik. Sorry code was incomplete but I presumed this would be a known issue.

Both of the SetWindowBackColor() examples work as does (Menu > Compiler > Compiler Options... > Library Subsystem: gtk2)
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: SetWindowColor() Using PB 572 x64 on Ubuntu 18.04 x64

Post by mk-soft »

Workaround for GTK3

Link: viewtopic.php?f=15&t=71992
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply