Menu-question

Menu-question

Postby byte-one » Wed Dec 11, 2019 2:33 pm

Can we change the colors of a menu at runtime with oMenu:setcolors()?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menu-question

Postby cnavarro » Wed Dec 11, 2019 3:21 pm

Is a menu of dialog or windows?, or a POPUP menu?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Postby byte-one » Wed Dec 11, 2019 3:25 pm

From Window the main-menu!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menu-question

Postby cnavarro » Wed Dec 11, 2019 7:32 pm

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  Expand view  RUN

         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
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Postby byte-one » Thu Dec 12, 2019 10:34 am

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

Re: Menu-question

Postby byte-one » Fri Dec 13, 2019 9:37 am

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
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menu-question

Postby cnavarro » Fri Dec 13, 2019 10:04 am

Without modifying the FONT?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Menu-question

Postby byte-one » Fri Dec 13, 2019 11:31 am

Yes, with same font.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Menu-question

Postby cnavarro » Fri Dec 13, 2019 3:56 pm

Ok, try and tell me
Look value negative of clause HEIGHT for MENUBAR

Code: Select all  Expand view  RUN


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

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

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests