StatusBar - New features ItemWidth + Color + Alignment

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

StatusBar - New features ItemWidth + Color + Alignment

Post by Pablo César »

Now ItemWidth could be assignable ! :D

I do not know if someone has experienced the same difficulty when there are more than one Item in StatusBar and we wish a new width resizing. And according hmgdoc, Width of items are not assignable.

Image

Normally it will take the first item at most left of StatusBar. But now, this could be changed, with following criteria:
  1. When just one of cell is Nil Width size.
    It will take this cell for trimming.
  2. When all Width sizes are defined.
    It will take the bigger width size cell for trimming.
  3. When all Width sizes are equally.
    It will take the first cell for trimming, as ever done.
Recently I tested this code and works perfectly attending this propose. Here goes an example:

Code: Select all

#include <hmg.ch>

Function Main()
DEFINE WINDOW Form_1 MAIN ;
    TITLE "StatusBar ItemWidth resizing demo"
    
    _DefineHotKey ( "Form_1" , 0 , VK_ESCAPE , {|| ThisWindow.Release()} )
	
	DEFINE STATUSBAR FONT "Courier New" SIZE 9
        STATUSITEM HMG_PadC("New Project",14) WIDTH 110
        STATUSITEM HMG_PadC("Esc for Exit",160) // (Not Width defined)          
        STATUSITEM HMG_PadC("Version 1.1",14) WIDTH 110
    END STATUSBAR
	
END WINDOW
My_SetStatusBarSize("Form_1",{110,,110})
Form_1.Center
Form_1.Activate
Return Nil

Function My_SetStatusBarSize(cParentForm,anWidths)
Local nParentHandle, nStatusHandle
Local i, nTotWidth := 0
Local nMaxWidth := 0
Local aNil := {}
Local nP := 1

nParentHandle := GetFormHandle ( cParentForm )
i := GetControlIndex ("STATUSBAR",cParentForm)
nStatusHandle := _HMG_SYSDATA [3] [i]

For i := 1 To HMG_LEN (anWidths)
	If ValType ( anWidths [i] ) <> 'N'
		anWidths [i] := 120
		Aadd(aNil,i)
	EndIf
	If anWidths[i] > nMaxWidth
	   nMaxWidth := anWidths[i]
	   nP := i
	Endif
	nTotWidth := nTotWidth + anWidths [i]
Next i
If HMG_Len(aNil)=1
   nP := aNil[1]
ElseIf HMG_Len(aNil)>1
   nP := 1
Endif
nTotWidth := nTotWidth - anWidths [nP]
anWidths[nP] := GetWindowWidth ( nParentHandle ) - nTotWidth
InitStatusBarSize ( nStatusHandle, anWidths )
Return Nil
As you can see, one of three options wil be considered for trimming.

Disable this line in above demo:
// My_SetStatusBarSize("Form_1",{110,,110})
Or you also see when Windows is sizing how StatusBar acts with width size of each StatuBar's item :o

The main point is, the width size sum of each item in StatusBar should be equal to GetWindowWidth size and when any item is bigger than it can: trimming/re-sizing is required in order to keep same GetWindowWidth size. And for making this, needs to choose one Item. Actually it takes the first item and this some times it is not the ideal result we wish.

This function, will be useful when Window is being resized (maximize or sizing).

Hope you enjoy ! :D
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

StatusBar - New features ItemWidth + Color + Alignment

Post by Pablo César »

I got more two useful functions:
  1. StatusBar BackColor changeable. My_SetStatusBarBackColor receive as second argument an array defining BackColor.
     
  2. StatuBar Item Trimming. My_SetStatusBarTrim receive as second argument an array containing character values ("L","C","R") for alignment issue. This works very well with monospaced fonts like as: Courier, Courier New, Lucida Console, Monaco, and Consolas (according in your OS be installed).

    Note: I've added "." just to display dots and with it to let evidenced the fit. But this third argument, it could be removed. 8-)
It would it be so wonderful to set at any kind of fonts, but I did not found the way yet... :(

All this code it would be improved. Please be free to indicate your improvements.

<Source files and executable was removed due there is an updated version at subsequent messages>
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: StatusBar - New features ItemWidth + Color + Alignment

Post by danielmaximiliano »

Gracias por compartir Pablo
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

StatusBar - New features ItemWidth + Color + Alignment

Post by Pablo César »

Sorry guys, My_SetStatusBarTrim is still not working as I wish.

I need to get widthsize and calculate how long is in characters.

So I will review this funtion... :oops:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

StatusBar - New features ItemWidth + Color + Alignment

Post by Pablo César »

Hi all,

I got it ! :D

Now it will be posible with any font. I used existing functions to calculate thru GetTextWidth and It was forced anWidths for _HMG_SYSDATA [20] [nIdx] which is still working with trimming at most left item and there is a different concept for new trimming.

I received few comments around. Many have downloaded (more than 21) the previous demo files but no comments... :?

But as somebody said to me:
Do not expect anything in return ...
Do it for your own satisfaction and fulfillment.
I hope you enjoy it ! :D
TrimingColor.rar
Source files
(1.59 KiB) Downloaded 308 times
Demo1.rar
Executable file
(1.12 MiB) Downloaded 325 times
Please test this demo sizing the main window. It will resize, new trim and new colors be changed. :P

danielmaximiliano wrote:Gracias por compartir Pablo
Es un placer, amigo ! :D

B.Rgds to HMG community (I'm happy) :D
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: StatusBar - New features ItemWidth + Color + Alignment

Post by serge_girard »

Pablo,

Thanks !

When resizing DEMO.EXE colors of statusbar changes?
Built in feature?

Anyway: very good improvement!

Serge
There's nothing you can do that can't be done...
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

StatusBar - New features ItemWidth + Color + Alignment

Post by Pablo César »

Hi Serge thanks for your interest,
serge_girard wrote:When resizing DEMO.EXE colors of statusbar changes?
This is just an example, do not need to be like this. This demo was with missing buttons (user option) for changing colors and I thought it will be funny to demostrate like this. :)

I think changing StatusBar color only one time or whenever be required for colors settings, I think.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: StatusBar - New features ItemWidth + Color + Alignment

Post by Javier Tovar »

Hola Pablo César,

No cambia el color del StatusBar, Es correcto?

Win7, 32Bits.

Saludos
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

StatusBar - New features ItemWidth + Color + Alignment

Post by Pablo César »

Hola Javier,

Si a mi me cambia. Yo utilizo Win7 32bits pero no en AERO.

De facto en AERO no funciona el cambio de color del StatusBar... :oops:

Cosas de la Microsoft. Porque este cambio se utiliza la API, asi que mismo en AERO tendria que funcionar tambien.

Image
Hello Javier,

If my PC it's changing for me. I'm using Win7 32bit but not in AERO.

In the fact, AERO does not change color for StatusBar ...: oops:

These inexplicable things of Microsoft. Because this change uses API, so it would be OK even in AERO too.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: StatusBar - New features ItemWidth + Color + Alignment

Post by Javier Tovar »

OK Pablo César,

Ya quedo, se ve bien !!!

Gracias por compartir.

Saludos
Post Reply