Border problems

Post your Gambas programming questions here.
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Border problems

Post by Doctor Watson »

Hi.
There has been written a lot on this forum on setting or customizing control borders, but it’s all about the GridView control.
I just have taken up programming again – new computer Gambas 3.14.3 installed, and something feels wrong.
Whichever control I want to set a border for, it only results in something thin faint greyish. Whether I choose Plain, Sunken, Raised or Etched, it all looks the same.
Is this a bug?
But what’s more important for my project : is it at all possible to assign some ‘style’ to Gambas controls other than GridView? Such as width or thickness or colour…
Old african saying:
You eat an elephant one small bite at a time.
User avatar
cogier
Site Admin
Posts: 1125
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Border problems

Post by cogier »

Most of the settings you are looking for a set by your desktop. If you can explain which items you want borders on or colour changes and perhaps a picture or program to show the problem we may be able to be more helpful.
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Border problems

Post by BruceSteers »

Doctor Watson wrote: Thursday 25th February 2021 10:13am Hi.
There has been written a lot on this forum on setting or customizing control borders, but it’s all about the GridView control.
I just have taken up programming again – new computer Gambas 3.14.3 installed, and something feels wrong.
Whichever control I want to set a border for, it only results in something thin faint greyish. Whether I choose Plain, Sunken, Raised or Etched, it all looks the same.
Is this a bug?
But what’s more important for my project : is it at all possible to assign some ‘style’ to Gambas controls other than GridView? Such as width or thickness or colour…
you could apply some tricks to add more borders like placing your object inside a panel , maybe even 2 panels for thickness and give the panels borders.

gambas mostly uses the gui interfaces to make it's controls, so borders and styles will be set by that.

To be honest i've not seen much difference in border styles either.
but the above trick of using bordered panels can help.

As for colours most controls have a background and foreground colour setting.
Keep your eyes peeled on the object properties panel and the auto-complete popup menu , , lots of details there
BruceS
If at first you don't succeed , try doing something differently.
BruceS
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Border problems

Post by Doctor Watson »

Hi Cogier and Bruce
Bruce : I’ve tried that ‘trick’ already, but it makes building a GUI rather complicated. It would just be nice if there are ways to define control borders using more options than the 4 provided. Also provided those work in the first place – unless I’m doing something wrong.
Cogier : I will build post one or more screenshots ASAP.

Greetings
Old african saying:
You eat an elephant one small bite at a time.
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Border problems

Post by BruceSteers »

Doctor Watson wrote: Friday 26th February 2021 7:07am Hi Cogier and Bruce
Bruce : I’ve tried that ‘trick’ already, but it makes building a GUI rather complicated. It would just be nice if there are ways to define control borders using more options than the 4 provided. Also provided those work in the first place – unless I’m doing something wrong.
Cogier : I will build post one or more screenshots ASAP.

Greetings
Yes but like we both said Doc....
the controls are mostly gtk or qt controls ,
gtk and qt do not offer that level of border customisation so neither can gambas.

if you really want it , you gotta try to implement it yourself either with a panel trick or building a custom control :)

And watch out for the fact for some Controls .Border can be Border.Raised, Border.Etched, etc while for some other controls.Border is just True or False.

Bruce
If at first you don't succeed , try doing something differently.
BruceS
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Border problems

Post by Doctor Watson »

Hi Cogier
I hope this will shed a light on what’s going wrong.
Steps :
- created a Form ‘TestBorders’
- placed 4 Label controls on it
- Using the Properties Panel, chose a Border for each of them
That’s all. There is no code whatsoever in TestBorders.class
The screenshots speak for themselves.
Please look at what happens on the TestBorders form when Border has been set to Etched.
Perhaps this hasn’t anything to do with the problem : screen resolution is 1920x1080 (16:9)
TestBorders Form.png
TestBorders Form.png (15.55 KiB) Viewed 5266 times
TestBorders running.png
Attachments
TestBorders running.png
TestBorders running.png (14.11 KiB) Viewed 5266 times
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Border problems

Post by stevedee »

Doctor Watson wrote: Friday 26th February 2021 8:28am ...I hope this will shed a light on what’s going wrong....
We hear what you are saying Doc, but you need to follow through your test to the next stage.

The one thing that is rubbish about my Distro (Peppermint 10) is bloody "Themes", and I suspect the Themes on your OS are not much better.

What Charlie & Bruce are saying is that the look of your borders is completely controlled by the Theme in use.

Here are my results from changing themes with the same Gambas Form and Labels;
ThinIce.png
ThinIce.png (20.69 KiB) Viewed 5261 times
Rayleigh.png
Rayleigh.png (21.16 KiB) Viewed 5261 times
Redmond.png
Redmond.png (21.29 KiB) Viewed 5261 times
I started compiling a spreadsheet some time ago (until I got bored with it) in the hope that I could find a Theme on Peppermint that works well. With some themes you cant even read all text because it displays black-on-black!
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Border problems

Post by stevedee »

Doctor Watson wrote: Friday 26th February 2021 7:07am ...Bruce : I’ve tried that ‘trick’ already, but it makes building a GUI rather complicated....
Adding your own borders will add some complexity, but you can still write tidy & compact code if you avoid just adding code in-line.

This simple routine could be used for any number of labels & panels...or any other controls;
Public Sub Form_Open()

    BorderMe(Label1, panel1, Color.DarkGray)
    BorderMe(Label4, panel2, Color.Red)

End


Public Function BorderMe(thisControl As Control, thisPanel As Control, shadowColour As Integer)

  With thisControl
    .Background = Color.LightBackground
    thisPanel.top = .Top - 1
    thisPanel.Left = .Left - 1
    thisPanel.Width = .Width + 4
    thisPanel.Height = .Height + 4
    thisPanel.Background = shadowColour
    thisPanel.Lower()
  End With

End
Doctor Watson
Posts: 84
Joined: Wednesday 22nd August 2018 7:55am

Re: Border problems

Post by Doctor Watson »

Indeed Steve. This code should simplify something I tried with a lot more coding.
But it doesn’t solve the problem regarding the border styles. Meanwhile I found that 3 more styles should be possible: Dashed, Dotted and Double.
And that brings me to the Themes. I have never used any, just satisfied with the ‘default’ one gets when installing Ubuntu, whatever it’s called.
I’m rather surprised to see that one would have to install a particular Ubuntu theme for Gambas controls to work / show properly.
That must have consequences for program developers.
Suppose I did install a theme such as Raleigh – where the borders show as they should – and I write this project I’m working on. When I run it, all looks like it should. Then I compile it into an executable and distribute it. But only users who have installed a compatible Theme would see it as it should …..
This looks like a clear bug to me. If my reasoning is right, it could even be that the Gambas developers were using such a Theme at the time they wrote the code.
I’m still hoping for a solution. It’s the Raised Border style I’m looking for in particular.
I wrote my program some years ago in RealBasic and it’s GUI just looked fine. If I have to settle for a meagre trick to produce something that looks like a border … it’s just feels not right, doesn't it?
Old african saying:
You eat an elephant one small bite at a time.
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Border problems

Post by stevedee »

Doctor Watson wrote: Saturday 27th February 2021 8:59am ...I have never used any [themes], just satisfied with the ‘default’ one gets when installing Ubuntu, whatever it’s called.
I’m rather surprised to see that one would have to install a particular Ubuntu theme for Gambas controls to work / show properly.

...But only users who have installed a compatible Theme would see it as it should …..

...This looks like a clear bug to me...

… it’s just feels not right, doesn't it?
What we call "Linux" is really just the core of the operating system. This core has been used in "distributions" like Debian, Red Hat & so on to create a usable graphical computer system. Each distribution is built with a number of sub-systems, one of which is the Window Manager which presents/displays windows and usually allows a lot of flexibility in terms of font sizes, colours, icons, mouse pointers & so on.

The selection of icons used are generally grouped in a icon theme set. There are also system themes which interpret and display controls like labels and text boxes. On my Peppermint system there are 43 listed themes and I suspect there are a similar number on Ubuntu, as there must be hundreds in circulation.

The Gambas devs don't write controls based upon a particular system theme and its not a Gambas bug. Its the theme writers that determine how they want to display components. Take a look at my post with the Rayleigh theme and you will notice that although the label borders look correct, the textbox doesn't have a border or even a white background. There isn't a Gambas theme (unfortunately) and none of the 43 themes on my system 'work properly' because each one appears to mis-interpret some aspect of one or more controls (...if I can put it that way).

To make matters worse, users can also change system colours, which may affect how your carefully designed Gambas Form looks when it is displayed.


I have just expanded my example:-
Const PLAIN_BORDER As Integer = 0
Const RAISED_BORDER As Integer = 1
Const SUNKEN_BORDER As Integer = 2

Public Sub Form_Open()

    BorderMe(Label5, panel1, Color.DarkGray, SUNKEN_BORDER)
    BorderMe(Label6, panel2, Color.Black, RAISED_BORDER)
    BorderMe(textbox6, panel3, Color.DarkBlue, SUNKEN_BORDER)
    BorderMe(Button4, panel4, Color.Red, RAISED_BORDER)

End


Public Function BorderMe(thisControl As Control, thisPanel As Control, shadowColour As Integer, iStyle As Integer)
Dim iOffsetTL As Integer
Dim iOffsetWH As Integer

  Select Case iStyle
    Case RAISED_BORDER
      iOffsetTL = 1
      iOffsetWH = 4
      
    Case SUNKEN_BORDER
      iOffsetTL = 4
      iOffsetWH = 5
      
    Default
      iOffsetTL = 0
      iOffsetWH = 0
      
  End Select
  
  With thisControl
    .Background = Color.Background
    thisPanel.top = .Top - iOffsetTL
    thisPanel.Left = .Left - iOffsetTL
    thisPanel.Width = .Width + iOffsetWH
    thisPanel.Height = .Height + iOffsetWH
    thisPanel.Background = shadowColour
    thisPanel.Lower()
  End With

End
Which give controls that look like this (on my system);
bordersCoded.png
bordersCoded.png (17.94 KiB) Viewed 5220 times
But its probably pointless using code like this if you want to distribute your code to other users, because you still cant be sure how it will look on other peoples systems.

Yes, its a bit of a mess.
Post Reply