Menu-question

Post Reply
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Menu-question

Post by byte-one »

Can we change the colors of a menu at runtime with oMenu:setcolors()?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Post by cnavarro »

Is a menu of dialog or windows?, or a POPUP menu?
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: Menu-question

Post by byte-one »

From Window the main-menu!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Post 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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: Menu-question

Post by byte-one »

Cristobal, i followed your way and now is ok! Thanks
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: Menu-question

Post 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.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Post by cnavarro »

Without modifying the FONT?
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: Menu-question

Post by byte-one »

Yes, with same font.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Post 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

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

 
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
Post Reply