Change Size Menuitem im hmg.4

Moderator: Rathinagiri

Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Change Size Menuitem im hmg.4

Post by Rossine »

Hello,

Is possible change the size of "menuitem" ? See this image ?
menu_size.png
menu_size.png (9.79 KiB) Viewed 6022 times
Best Regards,

Rossine.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Change Size Menuitem im hmg.4

Post by l3whmg »

Hi Rossine.
With my compiled library, MainMenu, MenuPop and MenuItem have the same size.... this is the code

Code: Select all

      WITH OBJECT MainMenu():New( "MainMenu" )
         :FontSize   := 16
         WITH OBJECT MenuPopup():New( 'File',, 'File' )
            WITH OBJECT MenuItem():New( 'ItemOpen' ,, 'Open'  , { || MsgInfo( 'Open'  ) } ); END WITH
            WITH OBJECT MenuItem():New( 'ItemClose',, 'Close' , { || MsgInfo( 'Close' ) } ); END WITH
            WITH OBJECT MenuPopup():New( 'PopUp',, 'PopUp' )
               WITH OBJECT MenuItem():New( 'Item1' ,, 'Open'  , { || MsgInfo( 'Open'  ) } ); END WITH
               WITH OBJECT MenuItem():New( 'Item2',, 'Close' , { || MsgInfo( 'Close' ) } ); END WITH
            END WITH
         END WITH
      END WITH
And these are two picture, one without "FontSize" (default system size)
default
default
Default.jpg (15.83 KiB) Viewed 6009 times
16 px
16 px
16px.jpg (22.81 KiB) Viewed 6009 times
If I understand your request or problem.

It's not possible (I have tried some times ago...) to have different size between MainMenu, MenuPopUp or MenuItem... In other words

Code: Select all

      WITH OBJECT MainMenu():New( "MainMenu" )
         :FontSize   := 16
         WITH OBJECT MenuPopup():New( 'File',, 'File' )
          :FontSize   := 10
           WITH OBJECT MenuItem():New( 'ItemOpen' ,, 'Open'  , { || MsgInfo( 'Open'  ) } )
              :FontSize   := 8
           END WITH
         END WITH
      END WITH
Cheers
Last edited by l3whmg on Thu Dec 22, 2011 10:30 am, edited 1 time in total.
Luigi from Italy
www.L3W.it
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Change Size Menuitem im hmg.4

Post by Rathinagiri »

Wow! Thanks Luigi.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Change Size Menuitem im hmg.4

Post by Pablo César »

Wow ! It´s wonderful !

Taking this chance to ask:

In HMG 3 is this possible to do ?
Last edited by Pablo César on Thu Dec 22, 2011 1:17 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Change Size Menuitem im hmg.4

Post by danielmaximiliano »

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

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Change Size Menuitem im hmg.4

Post by l3whmg »

Hi DanielMaximiliano

"De nada", but I stop here my knowledge about hispanic language ;)

Cheers
Luigi from Italy
www.L3W.it
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: Change Size Menuitem im hmg.4

Post by Rossine »

Hello Luigi,
l3whmg wrote:Hi Rossine.
With my compiled library, MainMenu, MenuPop and MenuItem have the same size.... this is the code

Code: Select all

      WITH OBJECT MainMenu():New( "MainMenu" )
         :FontSize   := 16
         WITH OBJECT MenuPopup():New( 'File',, 'File' )
            WITH OBJECT MenuItem():New( 'ItemOpen' ,, 'Open'  , { || MsgInfo( 'Open'  ) } ); END WITH
            WITH OBJECT MenuItem():New( 'ItemClose',, 'Close' , { || MsgInfo( 'Close' ) } ); END WITH
            WITH OBJECT MenuPopup():New( 'PopUp',, 'PopUp' )
               WITH OBJECT MenuItem():New( 'Item1' ,, 'Open'  , { || MsgInfo( 'Open'  ) } ); END WITH
               WITH OBJECT MenuItem():New( 'Item2',, 'Close' , { || MsgInfo( 'Close' ) } ); END WITH
            END WITH
         END WITH
      END WITH
And these are two picture, one without "FontSize" (default system size)
Default.jpg
16px.jpg
If I understand your request or problem.

It's not possible (I have tried some times ago...) to have different size between MainMenu, MenuPopUp or MenuItem... In other words

Code: Select all

      WITH OBJECT MainMenu():New( "MainMenu" )
         :FontSize   := 16
         WITH OBJECT MenuPopup():New( 'File',, 'File' )
          :FontSize   := 10
           WITH OBJECT MenuItem():New( 'ItemOpen' ,, 'Open'  , { || MsgInfo( 'Open'  ) } )
              :FontSize   := 8
           END WITH
         END WITH
      END WITH
Cheers
>> If I understand your request or problem.

This would be a request :o

Wonderful to see it all working. Thank you for sharing your knowledge with us all and also all over your precious time dedicated to this great project.

Thanks Master Luigi ;)

Rossine.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Change Size Menuitem im hmg.4

Post by l3whmg »

Hi friends.
Many thanks for your words :oops:

A little brief about Menu and related font problem/request.

Code: Select all

      WITH OBJECT MainMenu():New( "MainMenu" )
         WITH OBJECT MenuPopup():New( 'File',, 'File' )
            WITH OBJECT MenuItem():New( 'ItemOpen' ,, 'Open'  , { || MsgInfo( 'Open'  ) } ); END WITH
         END WITH
      END WITH
In the previous code, the MainMenu object inherit font (size, name, etc.) from QT default.

Code: Select all

      WITH OBJECT MainMenu():New( "MainMenu" )
         :FontSize := 16
         WITH OBJECT MenuPopup():New( 'File',, 'File' )
            WITH OBJECT MenuItem():New( 'ItemOpen' ,, 'Open'  , { || MsgInfo( 'Open'  ) } ); END WITH
         END WITH
      END WITH
In the previous code, we have changed the fontsize property for the MainMenu object.

MenuItem inherit font (size, name, etc.) from its parent. Who is its parent? MainMenu :o
So, with first example MenuItem inherit Qt default font, in the second one inherit a "changed" font.

There are 3 lines within MenuPopUp.prg (97-100): if I remove these lines, menuitem doesn't inherit font property from its parent, but what happens? If I set a font for the MainMenu, this font it is not propagate to the MenuItem (in other words, it has default font) and we must use :FontSize to align its fontsize.
Remember that all font* methods are used by many objects.

From one side we can use only one time :FontSize and all menu objects have the same size; on the other side, we can have different size, but we must use everywhere :FontSize to have the same size.

I think this can be an evolution and everyone can think a solution.

Cheers
Luigi from Italy
www.L3W.it
Rossine
Posts: 87
Joined: Thu Jun 30, 2011 10:04 pm

Re: Change Size Menuitem im hmg.4

Post by Rossine »

Hello Luigi,

Many thank´s for this explanation ;)

Below an example to let the possibility of using each submenu with a different size.

Code: Select all


#include "hmg.ch"
#include "hbqtgui.ch"

static Form_1

Function Main

   HbQt_ErrorSys()

   WITH OBJECT Form_1 := MAINWINDOW():New( "Form_1" )
      :Row           := 10
      :Col           := 10
      :Width         := 1024
      :Height        := 630
      :Title         := "HMG4 demo change font menu"
      :Icon          := ":HMG_ICO"

     DEFINE TOOLBAR oToolBar1 BUTTONSIZE 120, 80 FONT "ms sans serif" SIZE 12 MOVEABLE .F.

         TOOLBUTTON oButton1 ;
            Caption 'Font Menu Main' ;
            picture 'open.png' ;
            ACTION  { || Form_1:MainMenu:FontSize ++ }
            tooltip 'Change font of <Menu Main>'

         TOOLBUTTON oButton2 ;
            Caption 'Font Menu File' ;
            picture 'open.png' ;
            ACTION  { || Form_1:MainMenu:ItemFile:FontSize ++ }
            tooltip 'Change font of Option <File>'

         TOOLBUTTON oButton3 ;
            Caption 'Font Menu Help' ;
            picture 'open.png' ;
            ACTION  { || Form_1:MainMenu:ItemHelp:FontSize ++ }
            tooltip 'Change font of Option <Help>'

      END TOOLBAR

      WITH OBJECT MainMenu():New( "MainMenu" )
         :FontSize  := 16
         WITH OBJECT MenuPopup():New( 'ItemFile',, 'File' )
           WITH OBJECT MenuItem():New( ,, 'Open'  , { || MsgInfo( 'Open'  ) } )
           END WITH
           WITH OBJECT MenuItem():New( ,, 'Save'  , { || MsgInfo( 'Save'  ) } )
           END WITH
         END WITH

         WITH OBJECT MenuPopup():New( 'ItemHelp',, 'Help' )
           WITH OBJECT MenuItem():New( ,, 'About'  , { || MsgInfo( 'About'  ) } )
           END WITH
         END WITH

      END WITH

END WITH

ACTIVATE WINDOW Form_1

return NIL

Thanks for your help,

Rossine.
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: Change Size Menuitem im hmg.4

Post by l3whmg »

Hi Rossine.
WoW :shock: very 8-)

Many thanks

Cheers
Luigi from Italy
www.L3W.it
Post Reply