Page 1 of 3

Change Size Menuitem im hmg.4

Posted: Wed Dec 21, 2011 8:18 pm
by Rossine
Hello,

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

Rossine.

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 8:16 am
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 6851 times
16 px
16 px
16px.jpg (22.81 KiB) Viewed 6851 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

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 9:41 am
by Rathinagiri
Wow! Thanks Luigi.

Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 10:23 am
by Pablo César
Wow ! It´s wonderful !

Taking this chance to ask:

In HMG 3 is this possible to do ?

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 11:43 am
by danielmaximiliano
Luigi :
Gracias por compartir tus conocimientos.

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 11:56 am
by l3whmg
Hi DanielMaximiliano

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

Cheers

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 12:59 pm
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.

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 5:02 pm
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

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 8:00 pm
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.

Re: Change Size Menuitem im hmg.4

Posted: Thu Dec 22, 2011 10:15 pm
by l3whmg
Hi Rossine.
WoW :shock: very 8-)

Many thanks

Cheers