Page 1 of 1

Menu-question

Posted: Wed Dec 11, 2019 2:33 pm
by byte-one
Can we change the colors of a menu at runtime with oMenu:setcolors()?

Re: Menu-question

Posted: Wed Dec 11, 2019 3:21 pm
by cnavarro
Is a menu of dialog or windows?, or a POPUP menu?

Re: Menu-question

Posted: Wed Dec 11, 2019 3:25 pm
by byte-one
From Window the main-menu!

Re: Menu-question

Posted: Wed Dec 11, 2019 7:32 pm
by cnavarro
Once you have defined the menu, you can change its general characteristics, both colors and font, but you have to take into account that if you have defined a style: 2007/2010/2015, do not expect that modification to take effect. The only style that allows modifications by the user is the 2013 style that I defined precisely for this purpose, or do not define any style and initially use the COLORS clause.
Can you change the styles? Yes, of course, but only the 2013 style will allow you to change the standard colors of that style.
Also, keep in mind that some of the values accepted by the SetColors method are the background color and the items of the main bar, so to have an effect I recommend you do the following:

Code: Select all

         oWnd:oMenu:End()
         oWnd:SetMenu( BuildMenu( aColors ) )

//  And in your function BuildMenu( aColors )
Function BuildMenu( aColors )

   local oMenu

   MENU oMenu   // COLORS or 2013

   oMenu:SetColors( aColors )



   ENDMENU
.../...

Return oMenu
 
if you use the SetColors Method without parameter you are telling the class to take the default colors for that style
POPUP menus do not need to be destroyed and repainted, because they are precisely painted every time they are invoked

Try and tell me

Re: Menu-question

Posted: Thu Dec 12, 2019 10:34 am
by byte-one
Cristobal, i followed your way and now is ok! Thanks

Re: Menu-question

Posted: Fri Dec 13, 2019 9:37 am
by byte-one
Another question: Can i increase the height of the main menu from window? The HIGHT-clausula are only respected from he menuitems.

Re: Menu-question

Posted: Fri Dec 13, 2019 10:04 am
by cnavarro
Without modifying the FONT?

Re: Menu-question

Posted: Fri Dec 13, 2019 11:31 am
by byte-one
Yes, with same font.

Re: Menu-question

Posted: Fri Dec 13, 2019 3:56 pm
by cnavarro
Ok, try and tell me
Look value negative of clause HEIGHT for MENUBAR

Code: Select all


Static oFont
Static oFontMenu
Static oWnd

Function Main()

   Local oMnu
   Local cFont   := "Tahoma"
   Local cFontH  := -14

   DEFINE FONT oFont NAME "TIMES NEW ROMAN" SIZE 0,-12
   DEFINE FONT oFontMenu NAME cFont SIZE 0, cFontH WEIGHT 300
 
   DEFINE WINDOW oWnd MENU ( oMnu := MakeMenu() ) TITLE FWVERSION
   oWnd:nWidth   := 600
   oWnd:nHeight  := 600

   oWnd:bRClicked := { | r, c | MyPopup( r, c ) }

   ACTIVATE WINDOW oWnd CENTERED

   RELEASE FONT oFont
   RELEASE FONT oFontMenu

Return nil

//----------------------------------------------------------------------------//
 
function MakeMenu()
 
   local oMenu, oMnu1, oMnu2
 
   MENU oMenu 2015 HEIGHT -2.8 FONT oFontMenu
      MENUITEM "One" //FILE "..\bitmaps\full.bmp"    // Also try with this
      MENU
         MENUITEM "Sunday"  CHECKED
         MENUITEM SEPARATOR Upper( "Select" )
         MENUITEM "Monday" + CRLF + "Other"  BOLD  RADIOCHECK 3, 2
         MENUITEM "Tuesday"  ACTION MsgInfo( "Hola" ) ITALIC
         MENUITEM "Wednesday"
         MENU
            MENUITEM "Other"
            MENUITEM "More"
         ENDMENU
         SEPARATOR
         MENUITEM "Thursday" FILE "..\bitmaps\full.bmp"
         SEPARATOR
         MENUITEM "Exit" ACTION oWnd:End() HSYSBITMAP 5
      ENDMENU
      MENUITEM "Two"
      MENU
         MENUITEM "Sunday" HSYSBITMAP 9
         SEPARATOR
         MENUITEM "Monday" HSYSBITMAP 11
      ENDMENU
   ENDMENU
 
return oMenu

//----------------------------------------------------------------------------//

Function MyPopup( nRow, nCol )

   local oMenuNew
   local nOldH     := GetnHeightItem()     // Save Height Item

   MENU oMenuNew POPUP 2015 HEIGHT 4 FONT oFontMenu
            
      MENUITEM "New &Dialog" 
      SEPARATOR
      MENUITEM "New &Bitmap" CHARICON 57696
      SEPARATOR
      MENUITEM "New &Bitmap" CHARICON 57698
      SEPARATOR
      MENUITEM "New &Icon" CHARICON 57697

   ENDMENU

   ACTIVATE POPUP oMenuNew OF oWnd AT nRow, nCol

   GetnHeightItem( nOldH )   // Restore old height 

Return nil

//----------------------------------------------------------------------------//