Author Topic: File Menu  (Read 6158 times)

0 Members and 1 Guest are viewing this topic.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: File Menu
« Reply #15 on: June 30, 2020, 10:49:37 pm »
Hi Ken.  Here's the 1st right click menu thing I posted on [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there].  It's far from the best out there, but it's easy to add to a program.  I need to update it to handle the mouse better, and other stuff.

- Dav

Code: QB64: [Select]
  1. '====================
  2. 'RIGHT-CLICK-MENU.BAS
  3. '====================
  4. 'User defined Right click Popup Menu.
  5. 'Menu created on mouse x/y position.
  6. 'Easy to add to your programs.
  7. 'Coded by Dav JULY/2013
  8.  
  9.  
  10. '=== =============DEFINES FOR RIGHT CLICK MENU - CHANGE TO SUIT ==========================
  11. DECLARE FUNCTION RightClickMenu% ()
  12.  
  13. DIM SHARED RightClickItems: RightClickItems = 9 '    <----- Number of items in your menu
  14. DIM SHARED RightClickList$(1 TO RightClickItems)
  15.  
  16. RightClickList$(1) = "New" '     <------------ List all your menu items here
  17. RightClickList$(2) = "Open..."
  18. RightClickList$(3) = "-Save" '   <------------ Make it a Disabled Item (-)
  19. RightClickList$(4) = "Save As..."
  20. RightClickList$(5) = "---" '     <------------ This means it's a separator (---)
  21. RightClickList$(6) = "Settings..."
  22. RightClickList$(7) = "About"
  23. RightClickList$(8) = "---" '     <------------ (another separator)
  24. RightClickList$(9) = "Exit"
  25.  
  26. '========================================================================================
  27.  
  28.  
  29. '=== Demo follows....
  30.  
  31. SCREEN _NEWIMAGE(640, 480, 32)
  32.  
  33. PAINT (0, 0), _RGB(33, 66, 99)
  34.  
  35. '=== draw stuff
  36. FOR x = 25 TO 610 STEP 3
  37.     FOR y = 25 TO 300 STEP 3
  38.         PSET (x, y), _RGB(RND * 255, RND * 255, RND * 255)
  39.     NEXT
  40.  
  41. LOCATE 24, 24: COLOR _RGB(255, 255, 255), _RGB(33, 66, 99)
  42. PRINT "Right Click Anywhere for Popup menu."
  43. LOCATE 25, 30: PRINT "Select EXIT to quit."
  44.  
  45.  
  46.     a% = RightClickMenu% ' <----- Check for rightclick menu
  47.  
  48.     '=== what did you select?
  49.     IF a% > 0 THEN
  50.         COLOR _RGB(255, 155, 55), _RGB(33, 66, 99)
  51.         LOCATE 21, 25: PRINT "You last selected: "; RightClickList$(a%); SPACE$(25);
  52.     END IF
  53.  
  54. LOOP UNTIL a% = 9 'Item 9 (EXIT) exits demo...
  55.  
  56.  
  57.  
  58.  
  59. '================================================================================
  60. '================================================================================
  61. '================================================================================
  62. FUNCTION RightClickMenu% ()
  63.  
  64. 'Returns 0 if nothing selected, else return number of item selected.
  65. 'Requires RightClickList$ array defined.
  66.  
  67. Cheese = _MOUSEINPUT
  68.  
  69.  
  70.     Row = FIX(_MOUSEY / 16): Col = FIX(_MOUSEX / 8)
  71.  
  72.     x = Col * 8 - 8: y = Row * 16 - 16
  73.  
  74.     '=== Compute BoxWidth based on longest menu item string length
  75.     BoxWidth = 0
  76.     FOR t = 1 TO RightClickItems
  77.         temp = LEN(RightClickList$(t))
  78.         IF LEFT$(RightClickList$(t), 1) = "-" THEN temp = temp - 1
  79.         IF temp > BoxWidth THEN BoxWidth = temp
  80.     NEXT: BoxWidth = BoxWidth * 8
  81.  
  82.     '=== Compute BoxHeight based on num of menu items
  83.     BoxHeight = RightClickItems * 16
  84.  
  85.     '===== Make sure Mouse not too close to edge of screen
  86.     '===== If it is, Adjust x & y position here, move in closer...
  87.     IF _MOUSEX < 20 THEN
  88.         Col = 3: x = Col * 8 - 8:
  89.     END IF
  90.     IF _MOUSEX + BoxWidth + 20 > _WIDTH THEN
  91.         xm = _WIDTH - (BoxWidth + 10)
  92.         Col = FIX(xm / 8): x = Col * 8 - 8:
  93.     END IF
  94.     IF _MOUSEY < 20 THEN
  95.         Row = 2: y = Row * 16 - 16
  96.     END IF
  97.     IF _MOUSEY + BoxHeight + 20 > _HEIGHT THEN
  98.         xy = _HEIGHT - (BoxHeight + 10)
  99.         Row = FIX(xy / 16): y = Row * 16 - 16
  100.     END IF
  101.  
  102.     FirstRow = Row - 1
  103.  
  104.     '=== copy screen using _mem (thanks Steve!)
  105.     DIM m AS _MEM, n AS _MEM
  106.     m = _MEMIMAGE(0)
  107.     n = _MEMNEW(m.SIZE)
  108.     _MEMCOPY m, m.OFFSET, m.SIZE TO n, n.OFFSET
  109.  
  110.     '=== trap until buttons up
  111.     DO
  112.         nibble = _MOUSEINPUT
  113.  
  114.     '=== Draw Box (10 pix padding)
  115.     LINE (x - 10, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(214, 211, 206), BF
  116.     LINE (x + 10 + BoxWidth, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  117.     LINE (x - 10, y + 10 + BoxHeight)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  118.     LINE (x - 9, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  119.     LINE (x - 9, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  120.     LINE (x + 9 + BoxWidth, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  121.     LINE (x - 9, y + 9 + BoxHeight)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  122.  
  123.     DO
  124.         Cheese = _MOUSEINPUT
  125.  
  126.         '=== if in bounds of menu space
  127.         IF _MOUSEX > x AND _MOUSEX < x + BoxWidth AND _MOUSEY > y AND _MOUSEY < y + BoxHeight THEN
  128.  
  129.             '=== Draw items
  130.             IF CurRow <> FIX(_MOUSEY / 16) THEN
  131.                 COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  132.                 FOR t = 0 TO RightClickItems - 1
  133.                     IF Row + t - FirstRow = FIX(_MOUSEY / 16) - FirstRow + 1 THEN
  134.                         'Draw highlight box...
  135.                         COLOR _RGB(255, 255, 255), _RGB(8, 36, 107)
  136.                     ELSE
  137.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  138.                             COLOR _RGB(130, 130, 130), _RGB(214, 211, 206)
  139.                         ELSE
  140.                             COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  141.                         END IF
  142.                     END IF
  143.                     padme = BoxWidth / 8 - LEN(RightClickList$(t + 1))
  144.                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN padme = padme - 1
  145.                     IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  146.                     LOCATE Row + t, Col - 1
  147.                     IF RightClickList$(t + 1) = "---" THEN
  148.                         COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  149.                         PRINT STRING$((BoxWidth / 8) + 2, 196);
  150.                     ELSE
  151.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  152.                             PRINT " "; RIGHT$(RightClickList$(t + 1), LEN(RightClickList$(t + 1)) - 1); pad$; " ";
  153.                         ELSE
  154.                             PRINT " "; RightClickList$(t + 1); pad$; " ";
  155.                         END IF
  156.                     END IF
  157.                 NEXT
  158.             END IF
  159.  
  160.             IF _MOUSEBUTTON(1) THEN
  161.                 sel = FIX(_MOUSEY / 16) - FirstRow + 1
  162.                 'only select if not a seperator and not disabled
  163.                 IF RightClickList$(sel) <> "---" THEN
  164.                     IF LEFT$(RightClickList$(sel), 1) <> "-" THEN
  165.                         RightClickMenu% = sel: EXIT DO
  166.                     END IF
  167.                 END IF
  168.             END IF
  169.  
  170.             IF _MOUSEBUTTON(2) THEN EXIT DO
  171.  
  172.         ELSE
  173.  
  174.             '=== Draw items
  175.             IF FIX(_MOUSEY / 16) <> CurRow THEN
  176.                 FOR t = 0 TO RightClickItems - 1
  177.                     padme = BoxWidth / 8 - LEN(RightClickList$(t + 1))
  178.                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN padme = padme - 1
  179.                     IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  180.                     LOCATE Row + t, Col - 1
  181.                     IF RightClickList$(t + 1) = "---" THEN
  182.                         COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  183.                         PRINT STRING$((BoxWidth / 8) + 2, 196);
  184.                     ELSE
  185.  
  186.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  187.                             COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  188.                             PRINT " "; RIGHT$(RightClickList$(t + 1), LEN(RightClickList$(t + 1)) - 1); pad$; " ";
  189.                         ELSE
  190.                             COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  191.                             PRINT " "; RightClickList$(t + 1); pad$; " ";
  192.                         END IF
  193.  
  194.                     END IF
  195.                 NEXT
  196.             END IF
  197.  
  198.             IF _MOUSEBUTTON(1) OR _MOUSEBUTTON(2) THEN EXIT DO
  199.  
  200.         END IF
  201.  
  202.         '=== Mark current row mouse is in
  203.         CurRow = FIX(_MOUSEY / 16)
  204.  
  205.     LOOP
  206.  
  207.     '=== restore screen
  208.     _MEMCOPY n, n.OFFSET, n.SIZE TO m, m.OFFSET
  209.     _MEMFREE m: _MEMFREE n
  210.  
  211.  
  212. '================================================================================
  213. '================================================================================
  214. '================================================================================
  215.  
« Last Edit: June 30, 2020, 10:50:43 pm by Dav »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: File Menu
« Reply #16 on: June 30, 2020, 11:21:23 pm »
Oh that's nice @Dav

I'm akeep'n that one!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: File Menu
« Reply #17 on: July 01, 2020, 12:31:25 am »
This is totally awesome Dav!!! Thank you!!! I got it working in Paint Pixels 8. It's not completely done but I know how to finish the menu. :))) Thanks tons! I'll put your name in the Comments.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: File Menu
« Reply #18 on: July 01, 2020, 01:16:04 am »
Here's my little pop-up circle menu, which I thought I'd toss out just for fun.  I just wanted something a little different when I came up with this idea, since Dav and I had already created square popup menus.  I don't think this is the one Dav was asking about, but it's more or less the one which I'd had in my old IDE for playing around with as a "quick access menu".  I'll have to dig around to see if I can find my other one somewhere, but maybe Ken will get inspired by this oddity to think outside the box and see if he can come up with a menu/selection system which suits his own unique style of coding.  ;)

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 720, 32)
  2. _DELAY .25
  3.  
  4.  
  5.     DO
  6.         MScroll = MScroll + _MOUSEWHEEL
  7.     IF RMB = 0 AND _MOUSEBUTTON(2) = 0 THEN RMB = 1
  8.     IF RMB AND _MOUSEBUTTON(2) THEN
  9.         Menu = 1 'if the rmb is ready and we click the right mouse, then open the main menu
  10.         MX = _MOUSEX: MY = _MOUSEY
  11.     END IF
  12.  
  13.     _LIMIT 30
  14.     IF Menu > 0 THEN
  15.         Result = DrawMenu(Menu, MX, MY)
  16.         IF Result > -1 THEN '-1 says we moved/clicked off the menu area
  17.             PRINT Menu * 100 + Result 'Show how to get an unique menu result with simple math
  18.             SELECT CASE Menu
  19.                 CASE 1 'main menu
  20.                     SELECT CASE Result 'what do we do if someone clicks on the main menu?
  21.                         CASE 0: Menu = 0: 'we close the main menu; do nothing
  22.                         CASE 1: Menu = 2 'we open the files menu
  23.                         CASE 2: Menu = 3 'we open the edit menu
  24.                         CASE 3: Menu = 4 'we open the run menu
  25.                         CASE 4: Menu = 5 'we open the Do More menu
  26.                         CASE 5: Menu = 0 'we open the Help options (which we don't actually do here)
  27.                     END SELECT
  28.                 CASE ELSE 'I'm actually not doing anything but closing the menus, as this is just a quick demo
  29.                     Menu = 0 'menu 0 closes the menus
  30.             END SELECT
  31.         ELSE
  32.             Menu = 0 'menu 0 closes the menus
  33.         END IF
  34.         _DISPLAY
  35.     END IF
  36.  
  37. FUNCTION DrawMenu% (Menu AS _BYTE, x AS INTEGER, y AS INTEGER)
  38.     SELECT CASE Menu
  39.         CASE 1:
  40.             REDIM menu(5) AS STRING
  41.             menu(0) = "Exit"
  42.             menu(1) = "File"
  43.             menu(2) = "Edit"
  44.             menu(3) = "Run"
  45.             menu(4) = "Do More"
  46.             menu(5) = "Help"
  47.         CASE 2
  48.             REDIM menu(5) AS STRING
  49.             menu(0) = "Main"
  50.             menu(1) = "New"
  51.             menu(2) = "Open"
  52.             menu(3) = "Save"
  53.             menu(4) = "Save As"
  54.             menu(5) = "Exit"
  55.         CASE 3
  56.             REDIM menu(4) AS STRING
  57.             menu(0) = "Main"
  58.             menu(1) = "Undo"
  59.             menu(2) = "Redo"
  60.             menu(3) = "Syntax"
  61.             menu(4) = "GoTo"
  62.         CASE 4
  63.             REDIM menu(3) AS STRING
  64.             menu(0) = "Main"
  65.             menu(1) = "Test"
  66.             menu(2) = "P-Comp"
  67.             menu(3) = "S & Run"
  68.         CASE 5
  69.             REDIM menu(5) AS STRING
  70.             menu(0) = "Main"
  71.             menu(1) = "Wiki"
  72.             menu(2) = "Forums"
  73.             menu(3) = "QB64"
  74.             menu(4) = "Chat"
  75.             menu(5) = "ASCII"
  76.     END SELECT
  77.  
  78.     IF x < 100 THEN x = 100
  79.     IF x > _WIDTH - 100 THEN x = _WIDTH - 100
  80.     IF y < 100 THEN y = 100
  81.     IF y > _HEIGHT - 100 THEN y = _HEIGHT - 100
  82.  
  83.  
  84.     DrawMenu% = -1
  85.  
  86.     CONST CirclePI = 6.2831853071795
  87.     TYPE Point_Type
  88.         x AS INTEGER
  89.         y AS INTEGER
  90.     END TYPE
  91.     DIM Arc AS DOUBLE
  92.  
  93.     Limit = UBOUND(Menu)
  94.     DIM Centers(Limit) AS Point_Type
  95.  
  96.     PCOPY 0, 1
  97.  
  98.  
  99.     'Draw the whole pop-up first in a black shadow
  100.     CircleFill x + 2, y + 2, 100, _RGB32(0, 0, 0)
  101.     'Then draw the main work area
  102.     CircleFill x, y, 100, _RGBA32(0, 0, 255, 128)
  103.     'Next, Divide the circle into quadrants based on how many menu choices we have
  104.  
  105.     Arc = CirclePI / Limit
  106.     FOR i = 1 TO Limit
  107.         Centers(i).x = x + 70 * COS(Arc * i)
  108.         Centers(i).y = y + 70 * SIN(Arc * i)
  109.         'Menu Shadow
  110.         CircleFill Centers(i).x + 2, Centers(i).y + 2, 29, _RGB32(0, 0, 0)
  111.         'Menu Circle
  112.         CircleFill Centers(i).x, Centers(i).y, 29, _RGB32(255, 0, 0)
  113.         COLOR _RGB32(255, 255, 255), 0
  114.         _PRINTSTRING (Centers(i).x - (_FONTWIDTH * LEN(menu(i)) / 2), Centers(i).y - _FONTHEIGHT / 2), menu(i)
  115.     NEXT
  116.  
  117.     'Center Circle Shadow
  118.     CircleFill x + 2, y + 2, 40, _RGB32(0, 0, 0)
  119.     'Center Circle
  120.     CircleFill x, y, 40, _RGB32(0, 255, 0)
  121.     _PRINTSTRING (x - (_FONTWIDTH * LEN(menu(0)) / 2), y - _FONTHEIGHT / 2), menu(0)
  122.  
  123.  
  124.     RMB = 0: LMB = 0
  125.     DO
  126.         _LIMIT 30
  127.         DO: LOOP WHILE _MOUSEINPUT
  128.         _DISPLAY
  129.  
  130.         IF _MOUSEBUTTON(1) = 0 THEN LMB = 1 'make certain left mouse is up before we accept a click
  131.         IF _MOUSEBUTTON(2) = 0 THEN RMB = 1 'make certain right mouse is up before we accept a click
  132.         FOR i = 1 TO Limit
  133.             CX = Centers(i).x: CY = Centers(i).y
  134.             IF SQR((_MOUSEX - CX) ^ 2 + (_MOUSEY - CY) ^ 2) < 30 AND LMB AND _MOUSEBUTTON(1) THEN
  135.                 'The button is down in a menu area
  136.                 DrawMenu% = i: GOTO exitfunction
  137.             END IF
  138.         NEXT
  139.         'Check our special center.  It's bigger than the others.
  140.         IF SQR((_MOUSEX - x) ^ 2 + (_MOUSEY - y) ^ 2) <= 40 AND LMB AND _MOUSEBUTTON(1) THEN
  141.             DrawMenu% = 0: GOTO exitfunction
  142.         END IF
  143.         'Check to see if we moved off the pop-up
  144.         IF SQR((_MOUSEX - x) ^ 2 + (_MOUSEY - y) ^ 2) > 100 AND LMB OR (RMB AND _MOUSEBUTTON(2)) THEN DrawMenu% = -1: GOTO exitfunction
  145.     LOOP
  146.  
  147.     exitfunction:
  148.  
  149.     PCOPY 1, 0
  150.     COLOR DC, BG
  151.  
  152.  
  153. SUB CircleFill (CX AS LONG, CY AS LONG, R AS LONG, C AS LONG)
  154.     DIM Radius AS LONG, RadiusError AS LONG
  155.     DIM X AS LONG, Y AS LONG
  156.  
  157.     Radius = ABS(R)
  158.     RadiusError = -Radius
  159.     X = Radius
  160.     Y = 0
  161.  
  162.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  163.  
  164.     ' Draw the middle span here so we don't draw it twice in the main loop,
  165.     ' which would be a problem with blending turned on.
  166.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  167.  
  168.     WHILE X > Y
  169.         RadiusError = RadiusError + Y * 2 + 1
  170.         IF RadiusError >= 0 THEN
  171.             IF X <> Y + 1 THEN
  172.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  173.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  174.             END IF
  175.             X = X - 1
  176.             RadiusError = RadiusError - X * 2
  177.         END IF
  178.         Y = Y + 1
  179.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  180.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  181.     WEND
  182.  
  183.  

« Last Edit: July 01, 2020, 01:18:42 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: File Menu
« Reply #19 on: July 01, 2020, 07:45:19 am »
Thanks @bplus and @SierraKen. I'm glad it can be useful.  If I remember right, @SMcNeill  improved it and added larger font (and I like your circle one too, Steve).  I can't find the 2nd version which had different menu styles and color schemes - it may be lost.   I'll just have to redo it, maybe add some small in-code images to make fancier menu.  A menu with some transparency and a shadow would be nice.  QB64 has some cool tools to utilize now days.

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: File Menu
« Reply #20 on: July 01, 2020, 11:26:45 am »
@SMcNeill

I had a fun little mod for your code but I load and run it and nothing, but big black screen. I am using QB64 v1.4 stable, maybe your code was designed for something else?

I am sure I can find the glitch but if you could save me some trouble, I'd appreciate it.

Update: dah... never mind RMB means right mouse button ;-))

That's nice too AND it pops up where the mouse is so you aren't blocking something you might want to see while using menu and that is nice demo how one menu item can become a whole other menu. This is perfect for a Paint app the pop-up almost looks like a palette. (Hint to Ken maybe)
« Last Edit: July 01, 2020, 11:54:57 am by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: File Menu
« Reply #21 on: July 03, 2020, 01:01:13 pm »
@Dav: Richard posted code from the old [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] forums which might be what you were thinking of, where I modded your example a little:

Code: QB64: [Select]
  1. DECLARE FUNCTION RightClickMenu% ()
  2.  
  3. DIM SHARED RightClickItems: RightClickItems = 9 '    <----- Number of items in your menu
  4. DIM SHARED RightClickList$(1 TO RightClickItems)
  5.  
  6. RightClickList$(1) = "New" '     <------------ List all your menu items here
  7. RightClickList$(2) = "Open..."
  8. RightClickList$(3) = "Save"
  9. RightClickList$(4) = "Save As..."
  10. RightClickList$(5) = "---" '     <------------ This means it's a separator (---)
  11. RightClickList$(6) = "Settings..."
  12. RightClickList$(7) = "About"
  13. RightClickList$(8) = "---" '     <------------ (another separator)
  14. RightClickList$(9) = "Exit"
  15.  
  16. '========================================================================================
  17.  
  18.  
  19. '=== Demo follows....
  20.  
  21. SCREEN _NEWIMAGE(640, 480, 32)
  22. font& = _LOADFONT("c:\windows\fonts\cour.ttf", 24, "MONOSPACE")
  23. _FONT font&
  24. PAINT (0, 0), _RGB(33, 66, 99)
  25.  
  26. '=== draw stuff
  27. FOR x = 25 TO 610 STEP 3
  28.     FOR y = 25 TO 300 STEP 3
  29.         PSET (x, y), _RGB(RND * 255, RND * 255, RND * 255)
  30.     NEXT
  31.  
  32. LOCATE (_HEIGHT - _FONTHEIGHT * 4) / _FONTHEIGHT, 1: COLOR _RGB(255, 255, 255), _RGB(33, 66, 99)
  33. PRINT "Right Click Anywhere for Popup menu.";
  34. LOCATE (_HEIGHT - _FONTHEIGHT * 2) / _FONTHEIGHT, 1: PRINT "Select EXIT to quit.";
  35.  
  36.  
  37.     a% = RightClickMenu% ' <----- Check for rightclick menu
  38.  
  39.     '=== what did you select?
  40.     IF a% > 0 THEN
  41.         COLOR _RGB(255, 155, 55), _RGB(33, 66, 99)
  42.         LOCATE (_HEIGHT - _FONTHEIGHT * 6) / _FONTHEIGHT, 1: PRINT "You last selected: "; RightClickList$(a%); SPACE$(25);
  43.     END IF
  44.  
  45. LOOP UNTIL a% = 9 'Item 9 (EXIT) exits demo...
  46.  
  47.  
  48.  
  49.  
  50. '================================================================================
  51. '================================================================================
  52. '================================================================================
  53. FUNCTION RightClickMenu% ()
  54.  
  55.     'Returns 0 if nothing selected, else return number of item selected.
  56.     'Requires RightClickList$ array defined.
  57.  
  58.     Cheese = _MOUSEINPUT
  59.  
  60.  
  61.         Row = FIX(_MOUSEY / _FONTHEIGHT): Col = FIX(_MOUSEX / _FONTWIDTH)
  62.  
  63.         x = Col * _FONTWIDTH - _FONTWIDTH: y = Row * _FONTHEIGHT - _FONTHEIGHT
  64.  
  65.         '=== Compute BoxWidth based on longest menu item string length
  66.         BoxWidth = 0
  67.         FOR t = 1 TO RightClickItems
  68.             temp = LEN(RightClickList$(t)): IF temp > BoxWidth THEN BoxWidth = temp
  69.         NEXT: BoxWidth = BoxWidth * _FONTWIDTH
  70.  
  71.         '=== Compute BoxHeight based on num of menu items
  72.         BoxHeight = RightClickItems * _FONTHEIGHT
  73.  
  74.         '===== Make sure Mouse not too close to edge of screen
  75.         '===== If it is, Adjust x & y position here, move in closer...
  76.         IF _MOUSEX < 20 THEN
  77.             Col = 3: x = Col * _FONTWIDTH - _FONTWIDTH:
  78.         END IF
  79.         IF _MOUSEX + BoxWidth + 20 > _WIDTH THEN
  80.             xm = _WIDTH - (BoxWidth + 10)
  81.             Col = FIX(xm / _FONTWIDTH): x = Col * _FONTWIDTH - _FONTWIDTH:
  82.         END IF
  83.         IF _MOUSEY < 20 THEN
  84.             Row = 2: y = Row * _FONTHEIGHT - _FONTHEIGHT
  85.         END IF
  86.         IF _MOUSEY + BoxHeight + 20 > _HEIGHT THEN
  87.             xy = _HEIGHT - (BoxHeight + 10)
  88.             Row = FIX(xy / _FONTHEIGHT): y = Row * _FONTHEIGHT - _FONTHEIGHT
  89.         END IF
  90.  
  91.         FirstRow = Row - 1
  92.  
  93.         '=== copy screen using _mem (thanks Steve!)
  94.         DIM m AS _MEM, n AS _MEM
  95.         m = _MEMIMAGE(0)
  96.         n = _MEMNEW(m.SIZE)
  97.         _MEMCOPY m, m.OFFSET, m.SIZE TO n, n.OFFSET
  98.  
  99.         '=== trap until buttons up
  100.         DO
  101.             nibble = _MOUSEINPUT
  102.         LOOP UNTIL NOT _MOUSEBUTTON(2)
  103.  
  104.         '=== Draw Box (10 pix padding)
  105.         LINE (x - _FONTWIDTH, y - 10)-(x + _FONTWIDTH + BoxWidth, y + 10 + BoxHeight), _RGB(214, 211, 206), BF
  106.         LINE (x + _FONTWIDTH + BoxWidth, y - 10)-(x + _FONTWIDTH + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  107.         LINE (x - _FONTWIDTH, y + 10 + BoxHeight)-(x + _FONTWIDTH + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  108.         LINE (x - _FONTWIDTH + 1, y - 9)-(x + _FONTWIDTH - 1 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  109.         LINE (x - _FONTWIDTH + 1, y - 9)-(x + _FONTWIDTH - 1 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  110.         LINE (x + _FONTWIDTH - 1 + BoxWidth, y - 9)-(x + _FONTWIDTH - 1 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  111.         LINE (x - _FONTWIDTH + 1, y + 9 + BoxHeight)-(x + _FONTWIDTH - 1 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  112.  
  113.         DO
  114.             Cheese = _MOUSEINPUT
  115.  
  116.             '=== if in bounds of menu space
  117.             IF _MOUSEX > x AND _MOUSEX < x + BoxWidth AND _MOUSEY > y AND _MOUSEY < y + BoxHeight THEN
  118.  
  119.                 '=== Draw items
  120.                 COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  121.                 IF FIX(_MOUSEY / _FONTHEIGHT) <> CurRow THEN
  122.                     FOR t = 0 TO RightClickItems - 1
  123.                         IF Row + t - FirstRow = FIX(_MOUSEY / _FONTHEIGHT) - FirstRow + 1 THEN
  124.                             'Draw highlight box...
  125.                             COLOR _RGB(255, 255, 255), _RGB(_FONTWIDTH, 36, 107)
  126.                         ELSE
  127.                             COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  128.                         END IF
  129.                         padme = BoxWidth / _FONTWIDTH - LEN(RightClickList$(t + 1))
  130.                         IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  131.                         LOCATE Row + t, Col - 1
  132.                         IF RightClickList$(t + 1) = "---" THEN
  133.                             COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  134.                             PRINT STRING$((BoxWidth / _FONTWIDTH) + 2, 196);
  135.                         ELSE
  136.                             PRINT " "; RightClickList$(t + 1); pad$; " ";
  137.                         END IF
  138.                     NEXT
  139.                 END IF
  140.  
  141.                 IF _MOUSEBUTTON(1) THEN
  142.                     sel = FIX(_MOUSEY / _FONTHEIGHT) - FirstRow + 1
  143.                     'only select if not a seperator
  144.                     IF RightClickList$(sel) <> "---" THEN
  145.                         RightClickMenu% = sel: EXIT DO
  146.                     END IF
  147.                 END IF
  148.  
  149.                 IF _MOUSEBUTTON(2) THEN EXIT DO
  150.  
  151.             ELSE
  152.                 'We went well off the click area.  Close the menu.
  153.                 IF _MOUSEX < x - _FONTWIDTH OR _MOUSEX > x + BoxWidth + _FONTWIDTH THEN EXIT DO
  154.                 IF _MOUSEY < y OR _MOUSEY > y + BoxHeight THEN EXIT DO
  155.  
  156.                 '=== Draw items
  157.                 IF FIX(_MOUSEY / _FONTHEIGHT) <> CurRow THEN
  158.                     FOR t = 0 TO RightClickItems - 1
  159.                         IF RightClickList$(t + 1) = "---" THEN
  160.                             COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  161.                             _PRINTSTRING (x, y + t * _FONTHEIGHT), STRING$((BoxWidth / _FONTWIDTH + 1), 196)
  162.                         ELSE
  163.                             COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  164.                             _PRINTSTRING (x, y + t * _FONTHEIGHT), RightClickList$(t + 1)
  165.                         END IF
  166.                     NEXT
  167.                 END IF
  168.  
  169.                 IF _MOUSEBUTTON(1) OR _MOUSEBUTTON(2) THEN EXIT DO
  170.  
  171.             END IF
  172.  
  173.             '=== Mark the current row the mouse is in
  174.  
  175.             CurRow = FIX(_MOUSEY / _FONTHEIGHT)
  176.  
  177.         LOOP
  178.  
  179.         '=== restore screen
  180.         _MEMCOPY n, n.OFFSET, n.SIZE TO m, m.OFFSET
  181.         _MEMFREE m: _MEMFREE n
  182.  
  183.     END IF
  184.  
  185. '================================================================================
  186. '================================================================================
  187. '================================================================================
  188.  

There's several versions in the whole topic, but I just copied what seemed like the final one and shared it here, for ease of reference.  If you want to try the others out, or follow our old conversation where we altered and fixed things along the way to get to this point, the whole topic is now copied into my Popup Menu post in the Programs area.  (I'll come back and edit and link to it in a moment to save some searching, if anyone is curious...)

Edit: https://www.qb64.org/forum/index.php?topic=2773.msg120243#msg120243
« Last Edit: July 03, 2020, 01:02:20 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: File Menu
« Reply #22 on: July 03, 2020, 05:41:01 pm »
Thanks, @SMcNeill  & @Richard.

Actually I've lost version 2 of mine which had multiple menu styles and user color schemes.  I dunno...maybe I'm confused and posted it at another QB64 forum...or planet...this is Earth isn't it? :)

Anyway, I appreciate your helpfulness.

- Dav


Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: File Menu
« Reply #23 on: July 30, 2020, 09:27:35 pm »
I just rediscovered the 2nd right click menu on an old HD that has different style menus.  Here it is finally...might as well keep it in this same thread with the other one above...

- Dav

Code: QB64: [Select]
  1. '====================
  2. 'RIGHT-CLICK-MENU.BAS
  3. '====================
  4. 'Easy to use right click popup menu.
  5. 'Coded by Dav JULY/2013
  6.  
  7. 'Here's a single FUNCTION easy to add to your programs to have a right click popup menu.
  8. 'Several menu styles to choose from - or set your own custom menu colors (See FUNCTION).
  9. 'Menu lets you enable/disble items on the fly and you can also have menu separators.
  10. 'Supports many screen sizes, never off screen, and restores original background on exit.
  11. 'To use simply add the RightClickMenu% FUNCTION and its defines below to your program.
  12. 'Study the demo code below to see how to call and use the function.
  13.  
  14. '========================================================================================
  15. '================== DEFINES FOR RIGHT CLICK MENU - CHANGE TO SUIT =======================
  16. '========================================================================================
  17.  
  18. DECLARE FUNCTION RightClickMenu% (menustyle%) ' (not really needed, but it feels good)
  19.  
  20. DIM SHARED RightClickItems: RightClickItems = 9 '    <----- Number of items in your menu
  21. DIM SHARED RightClickList$(1 TO RightClickItems) '          (change it to your number)
  22.  
  23. RightClickList$(1) = "New" '     <------------ List all your menu items here
  24. RightClickList$(2) = "Open..."
  25. RightClickList$(3) = "-Save" '   <------------ Leading minus makes these Disabled Items (-)
  26. RightClickList$(4) = "-Save As..."
  27. RightClickList$(5) = "---" '     <------------ This means it's a separator (---)
  28. RightClickList$(6) = "Settings..."
  29. RightClickList$(7) = "About"
  30. RightClickList$(8) = "---" '     <------------ (another separator)
  31. RightClickList$(9) = "Exit"
  32.  
  33. ' menustyle% values:      1 = Old Windows style
  34. '                         2 = New Windows style
  35. '                         3 = Dark grey Linux
  36. '                         4 = Blue Glass (semi-transparent)
  37. '                         5 = Custom colors (user defined)
  38.  
  39. '========================================================================================
  40. 'NOTE: menustyle% #5 is for user defined colors.  You can set your own custom colors by
  41. '      changing the menu variables inside the RightClickMenu% FUNCTION (look in there).
  42. '      Then, call RighClickMenu(5) to use your custom colored menu style.
  43. '========================================================================================
  44.  
  45.  
  46. '========================================================================================
  47. '=============================== START DEMO CODE ========================================
  48. '========================================================================================
  49.  
  50. SCREEN _NEWIMAGE(640, 480, 32)
  51.  
  52. PAINT (0, 0), _RGB(33, 66, 99)
  53.  
  54. '=== draw stuff
  55. FOR x = 25 TO 610 STEP 3
  56.     FOR y = 25 TO 300 STEP 3
  57.         PSET (x, y), _RGB(RND * 255, RND * 255, RND * 255)
  58.     NEXT
  59.  
  60. LOCATE 23, 24: COLOR _RGB(255, 255, 255), _RGB(33, 66, 99)
  61. PRINT "Right Click Anywhere for Popup menu."
  62. LOCATE 25, 30: PRINT "Select EXIT to quit."
  63.  
  64. LOCATE 27, 24: PRINT "Press 3 to Enable/Disable: Save"
  65. LOCATE 28, 24: PRINT "Press 4 to Enable/Disable: Save As..."
  66.  
  67. LOCATE 30, 10: PRINT "(keep making selections to cycle through different menu styles)";
  68.  
  69. style% = 5 'Start with menu style 5
  70.  
  71.  
  72.     a% = RightClickMenu%(style%) ' <----- Check for rightclick menu
  73.  
  74.     '=== what did you select?
  75.     IF a% > 0 THEN
  76.         COLOR _RGB(255, 155, 55), _RGB(33, 66, 99)
  77.         LOCATE 21, 25: PRINT "You last selected: "; RightClickList$(a%); SPACE$(25);
  78.         style% = style% + 1: IF style% = 6 THEN style% = 1 'cycle mnu styles
  79.     END IF
  80.  
  81.     '===============================================================================
  82.     'NOTE: You can re-enabled a disabled menu item by removing the leading minus '-'
  83.     'from it's name.  And you can disable an item by adding a leading minus.
  84.     '===============================================================================
  85.  
  86.     '=== Here we disable/enable items 3 & 4 on the fly by pressing 3 or 4.
  87.  
  88.     COLOR _RGB(255, 155, 55), _RGB(33, 66, 99)
  89.         CASE IS = "3" ' Toggle Save menu on off
  90.             LOCATE 27, 63
  91.             IF RightClickList$(3) = "-Save" THEN
  92.                 RightClickList$(3) = "Save": PRINT "ENABLED ";
  93.             ELSE
  94.                 RightClickList$(3) = "-Save": PRINT "DISABLED";
  95.             END IF
  96.         CASE IS = "4"
  97.             LOCATE 28, 63
  98.             IF RightClickList$(4) = "-Save As..." THEN
  99.                 RightClickList$(4) = "Save As...": PRINT "ENABLED ";
  100.             ELSE
  101.                 RightClickList$(4) = "-Save As...": PRINT "DISABLED";
  102.             END IF
  103.     END SELECT
  104.  
  105. LOOP UNTIL a% = 9 'Item 9 (EXIT) exits demo...
  106.  
  107.  
  108. '========================================================================================
  109. '================================= END DEMO CODE ========================================
  110. '========================================================================================
  111.  
  112.  
  113. '========================================================================================
  114. '==================================== FUNCTION ==========================================
  115. '========================================================================================
  116.  
  117. FUNCTION RightClickMenu% (menustyle%)
  118.     '
  119.     'Creates a popup menu at the current mouse x/y position when right button is clicked.
  120.     '
  121.     'This function returns the value of the menu item seleted.  If no selection is made,
  122.     'then the function will return a value of 0.  REQUIRES RightClickList$() array defined.
  123.     '
  124.     'menustyle% = Number of menu style to use. There are 5, and #5 is a custom color menu.
  125.     '             You can set custom menu colors by changing the variables in this FUNCTION.
  126.     '             (look lower down in this function to find those variables noted).
  127.     '
  128.     'SAMPLE USE:  ClickMe% = RightClickMenu%(3)  '<--- Use menu 3. If any selection is made,
  129.     '                                                  the menu item selected is put into
  130.     '                                                  the ClickMe% variable.
  131.     '
  132.     ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  133.  
  134.     Cheese = _MOUSEINPUT ' Check for mouse activity.
  135.  
  136.     IF _MOUSEBUTTON(2) THEN ' If user clicked right button, draw menu....
  137.  
  138.         '============================================================================
  139.         'Set Custom menu colors for menustyle% #5 here...
  140.         '============================================================================
  141.         RCMBorder~& = _RGB(255, 255, 255) '        <--- Border around menu
  142.         RCMBack~& = _RGB(0, 0, 255) '              <--- Basic menu background color
  143.         'menu item colors
  144.         RCMEnText~& = _RGB(255, 255, 255) '        <--- Enabled menu item color
  145.         RCMDisText~& = _RGB(190, 190, 190) '       <--- Disabled menu item color
  146.         'below is the active row colors
  147.         RCMHighBack~& = _RGB(255, 255, 255) '      <--- Highlight background color
  148.         RCMHighEnText~& = _RGB(0, 0, 255) '        <--- Highlight Enabled Text color
  149.         RCMHighDisText~& = _RGB(190, 190, 190) '   <----Highlight Disabled text color
  150.         '============================================================================
  151.  
  152.         '=== fail safes values for failing memories
  153.         IF menustyle% < 1 THEN menustyle% = 1
  154.         IF menustyle% > 5 THEN menustyle% = 5
  155.  
  156.         'Compute Row & Col for LOCATE, and x & y for drawing
  157.         Row = FIX(_MOUSEY / 16): Col = FIX(_MOUSEX / 8)
  158.         x = Col * 8 - 8: y = Row * 16 - 16
  159.  
  160.         '=== Compute BoxWidth based on longest menu item string length
  161.         BoxWidth = 0
  162.         FOR t = 1 TO RightClickItems
  163.             temp = LEN(RightClickList$(t))
  164.             IF LEFT$(RightClickList$(t), 1) = "-" THEN temp = temp - 1
  165.             IF temp > BoxWidth THEN BoxWidth = temp
  166.         NEXT: BoxWidth = BoxWidth * 8
  167.  
  168.         '=== Compute BoxHeight based on num of menu items
  169.         BoxHeight = RightClickItems * 16
  170.  
  171.         '===== Make sure Mouse not too close to edge of screen
  172.         '===== If it is, Adjust position here, move in closer...
  173.         IF _MOUSEX < 20 THEN
  174.             Col = 3: x = Col * 8 - 8:
  175.         END IF
  176.         IF _MOUSEX + BoxWidth + 20 > _WIDTH THEN
  177.             xm = _WIDTH - (BoxWidth + 10)
  178.             Col = FIX(xm / 8): x = Col * 8 - 8:
  179.         END IF
  180.         IF _MOUSEY < 20 THEN
  181.             Row = 2: y = Row * 16 - 16
  182.         END IF
  183.         IF _MOUSEY + BoxHeight + 20 > _HEIGHT THEN
  184.             xy = _HEIGHT - (BoxHeight + 10)
  185.             Row = FIX(xy / 16): y = Row * 16 - 16
  186.         END IF
  187.  
  188.         FirstRow = Row - 1
  189.  
  190.         '=== copy screen using _mem (thanks Steve!)
  191.         DIM m AS _MEM, n AS _MEM
  192.         m = _MEMIMAGE(0)
  193.         n = _MEMNEW(m.SIZE)
  194.         _MEMCOPY m, m.OFFSET, m.SIZE TO n, n.OFFSET
  195.  
  196.         '=== trap until buttons up
  197.         DO
  198.             nibble = _MOUSEINPUT
  199.         LOOP UNTIL NOT _MOUSEBUTTON(2)
  200.  
  201.         SELECT CASE menustyle%
  202.             CASE 1: 'Classic menu
  203.                 '=== Draw Box (10 pix padding)
  204.                 LINE (x - 10, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(214, 211, 206), BF
  205.                 LINE (x + 10 + BoxWidth, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  206.                 LINE (x - 10, y + 10 + BoxHeight)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(66, 65, 66), B
  207.                 LINE (x - 9, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  208.                 LINE (x - 9, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(255, 255, 255), B
  209.                 LINE (x + 9 + BoxWidth, y - 9)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  210.                 LINE (x - 9, y + 9 + BoxHeight)-(x + 9 + BoxWidth, y + 9 + BoxHeight), _RGB(127, 127, 127), B
  211.             CASE 2: 'Win7 style
  212.                 '=== Draw Box (10 pix padding)
  213.                 LINE (x - 10, y - 10)-(x + 9 + BoxWidth, y + 10 + BoxHeight), _RGB(151, 151, 151), B
  214.                 LINE (x - 9, y - 9)-(x + 8 + BoxWidth, y + 9 + BoxHeight), _RGB(245, 245, 245), B
  215.                 LINE (x - 8, y - 8)-(x + 7 + BoxWidth, y + 8 + BoxHeight), _RGB(241, 241, 241), BF
  216.             CASE 3: 'Dark Grey Linux style
  217.                 '=== Draw Box (10 pix padding)
  218.                 LINE (x - 11, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGB(85, 85, 85), BF
  219.                 LINE (x - 9, y - 8)-(x + 8 + BoxWidth, y + 8 + BoxHeight), _RGB(55, 55, 55), BF
  220.             CASE 4: 'Transparent style
  221.                 '=== Draw Box (10 pix padding)
  222.                 LINE (x - 11, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), _RGBA32(0, 0, 0, 150), BF
  223.                 LINE (x - 9, y - 8)-(x + 8 + BoxWidth, y + 8 + BoxHeight), _RGBA32(100, 200, 255, 100), BF
  224.                 '=== save original printmode
  225.                 printmodestatus = _PRINTMODE
  226.                 _PRINTMODE _KEEPBACKGROUND
  227.             CASE 5 'custom colors
  228.                 LINE (x - 11, y - 10)-(x + 10 + BoxWidth, y + 10 + BoxHeight), RCMBorder~&, BF
  229.                 LINE (x - 9, y - 8)-(x + 8 + BoxWidth, y + 8 + BoxHeight), RCMBack~&, BF
  230.         END SELECT
  231.  
  232.         'draw right drop shadow edge
  233.         LINE (x + 11 + BoxWidth, y - 4)-(x + 11 + BoxWidth, y + 11 + BoxHeight), _RGBA32(0, 0, 0, 90), B
  234.         LINE (x + 12 + BoxWidth, y - 3)-(x + 12 + BoxWidth, y + 12 + BoxHeight), _RGBA32(0, 0, 0, 60), B
  235.         LINE (x + 13 + BoxWidth, y - 2)-(x + 13 + BoxWidth, y + 13 + BoxHeight), _RGBA32(0, 0, 0, 40), B
  236.         LINE (x + 14 + BoxWidth, y - 1)-(x + 14 + BoxWidth, y + 14 + BoxHeight), _RGBA32(0, 0, 0, 25), B
  237.         LINE (x + 15 + BoxWidth, y)-(x + 15 + BoxWidth, y + 15 + BoxHeight), _RGBA32(0, 0, 0, 10), B
  238.  
  239.         'draw bottom drop shadow edge
  240.         LINE (x - 4, y + 11 + BoxHeight)-(x + 10 + BoxWidth, y + 11 + BoxHeight), _RGBA32(0, 0, 0, 90), B
  241.         LINE (x - 3, y + 12 + BoxHeight)-(x + 11 + BoxWidth, y + 12 + BoxHeight), _RGBA32(0, 0, 0, 60), B
  242.         LINE (x - 2, y + 13 + BoxHeight)-(x + 12 + BoxWidth, y + 13 + BoxHeight), _RGBA32(0, 0, 0, 40), B
  243.         LINE (x - 1, y + 14 + BoxHeight)-(x + 13 + BoxWidth, y + 14 + BoxHeight), _RGBA32(0, 0, 0, 25), B
  244.         LINE (x, y + 15 + BoxHeight)-(x + 14 + BoxWidth, y + 15 + BoxHeight), _RGBA32(0, 0, 0, 10), B
  245.  
  246.  
  247.         DO
  248.             Cheese = _MOUSEINPUT
  249.  
  250.             '=== if in bounds of menu space
  251.             IF _MOUSEX > x AND _MOUSEX < x + BoxWidth AND _MOUSEY > y AND _MOUSEY < y + BoxHeight THEN
  252.  
  253.                 '=== Draw items
  254.                 IF CurRow <> FIX(_MOUSEY / 16) THEN
  255.                     FOR t = 0 TO RightClickItems - 1
  256.                         IF Row + t - FirstRow = FIX(_MOUSEY / 16) - FirstRow + 1 THEN
  257.                             'If highlighted row, draw highlight colors...
  258.                             SELECT CASE menustyle%
  259.                                 CASE 1: COLOR _RGB(255, 255, 255), _RGB(8, 36, 107) 'classic
  260.                                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN COLOR _RGB(127, 127, 127), _RGB(8, 36, 107)
  261.                                 CASE 2: COLOR _RGB(0, 0, 0), _RGB(215, 225, 235) 'win7
  262.                                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN COLOR _RGB(127, 127, 127), _RGB(215, 225, 235)
  263.                                 CASE 3: COLOR _RGB(50, 50, 50), _RGB(180, 180, 180) 'dark grey linux
  264.                                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN COLOR _RGB(127, 127, 127), _RGB(180, 180, 180)
  265.                                 CASE 4: COLOR _RGB(130, 255, 255) 'transparent
  266.                                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN COLOR _RGB(127, 127, 127)
  267.                                 CASE 5
  268.                                     COLOR RCMHighEnText~&, RCMHighBack~& 'custom
  269.                                     IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN COLOR RCMHighDisText~&, RCMHighBack~&
  270.  
  271.                             END SELECT
  272.                         ELSE
  273.                             IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  274.                                 SELECT CASE menustyle%
  275.                                     CASE 1: COLOR _RGB(127, 127, 127), _RGB(214, 211, 206) 'classic
  276.                                     CASE 2: COLOR _RGB(127, 127, 127), _RGB(240, 240, 240) 'win7
  277.                                     CASE 3: COLOR _RGB(127, 127, 127), _RGB(55, 55, 55) 'dark grey
  278.                                     CASE 4: COLOR _RGB(127, 127, 127)
  279.                                     CASE 5: COLOR RCMDisText~&, RCMBack~&
  280.                                 END SELECT
  281.                             ELSE
  282.                                 SELECT CASE menustyle%
  283.                                     CASE 1: COLOR _RGB(0, 0, 0), _RGB(214, 211, 206)
  284.                                     CASE 2: COLOR _RGB(0, 0, 0), _RGB(240, 240, 240)
  285.                                     CASE 3: COLOR _RGB(213, 209, 199), _RGB(55, 55, 55)
  286.                                     CASE 4: COLOR _RGB(200, 200, 200)
  287.                                     CASE 5: COLOR RCMEnText~&, RCMBack~&
  288.                                 END SELECT
  289.                             END IF
  290.                         END IF
  291.                         padme = BoxWidth / 8 - LEN(RightClickList$(t + 1))
  292.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN padme = padme + 1
  293.                         IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  294.                         LOCATE Row + t, Col - 1
  295.                         IF RightClickList$(t + 1) = "---" THEN
  296.                             SELECT CASE menustyle%
  297.                                 CASE 1: COLOR _RGB(127, 127, 127), _RGB(214, 211, 206)
  298.                                 CASE 2: COLOR _RGB(208, 208, 208), _RGB(240, 240, 240)
  299.                                 CASE 3: COLOR _RGB(127, 127, 127), _RGB(55, 55, 55)
  300.                                 CASE 4: COLOR _RGB(0, 0, 0)
  301.                                 CASE 5: COLOR RCMDisText~&, RCMBack~&
  302.                             END SELECT
  303.                             PRINT STRING$((BoxWidth / 8) + 2, 196);
  304.                         ELSE
  305.                             IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  306.                                 PRINT " "; RIGHT$(RightClickList$(t + 1), LEN(RightClickList$(t + 1)) - 1); pad$; " ";
  307.                             ELSE
  308.                                 PRINT " "; RightClickList$(t + 1); pad$; " ";
  309.                             END IF
  310.                             SELECT CASE menustyle%
  311.                                 CASE 2: 'win7 box around highlight area
  312.                                     '=== Draw box around highlighted
  313.                                     IF Row + t - FirstRow = FIX(_MOUSEY / 16) - FirstRow + 1 THEN
  314.                                         BoxRow = FIX(_MOUSEY / 16): by = BoxRow * 16 - 16
  315.                                         LINE (x - 8, by + 16)-(x + BoxWidth + 7, by + 31), _RGB(174, 207, 247), B
  316.                                     END IF
  317.                                 CASE 3: 'dark grey
  318.                                     '=== Draw box around highlighted
  319.                                     IF Row + t - FirstRow = FIX(_MOUSEY / 16) - FirstRow + 1 THEN
  320.                                         BoxRow = FIX(_MOUSEY / 16): by = BoxRow * 16 - 16
  321.                                         LINE (x - 8, by + 16)-(x + BoxWidth + 7, by + 31), _RGB(240, 240, 240), B
  322.                                     END IF
  323.                             END SELECT
  324.                         END IF
  325.                     NEXT
  326.                 END IF
  327.  
  328.                 '=== left click makes a selection
  329.                 IF _MOUSEBUTTON(1) THEN
  330.                     sel = FIX(_MOUSEY / 16) - FirstRow + 1
  331.                     'only select if not a seperator and not disabled
  332.                     IF RightClickList$(sel) <> "---" THEN
  333.                         IF LEFT$(RightClickList$(sel), 1) <> "-" THEN
  334.                             RightClickMenu% = sel: EXIT DO
  335.                         END IF
  336.                     END IF
  337.                 END IF
  338.  
  339.                 '=== right click closes menu
  340.                 IF _MOUSEBUTTON(2) THEN EXIT DO
  341.  
  342.             ELSE
  343.  
  344.                 '=== Draw items
  345.                 IF FIX(_MOUSEY / 16) <> CurRow THEN
  346.                     FOR t = 0 TO RightClickItems - 1
  347.                         padme = BoxWidth / 8 - LEN(RightClickList$(t + 1))
  348.                         IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN padme = padme + 1
  349.                         IF padme > 0 THEN pad$ = SPACE$(padme) ELSE pad$ = ""
  350.                         LOCATE Row + t, Col - 1
  351.                         IF RightClickList$(t + 1) = "---" THEN
  352.                             SELECT CASE menustyle%
  353.                                 CASE 1: COLOR _RGB(127, 127, 127), _RGB(214, 211, 206) 'classic
  354.                                 CASE 2: COLOR _RGB(208, 208, 208), _RGB(240, 240, 240) 'win7
  355.                                 CASE 3: COLOR _RGB(127, 127, 127), _RGB(55, 55, 55) 'dark grey
  356.                                 CASE 4: COLOR _RGB(0, 0, 0)
  357.                                 CASE 5: COLOR RCMDisText~&, RCMBack~&
  358.                             END SELECT
  359.                             PRINT STRING$((BoxWidth / 8) + 2, 196);
  360.                         ELSE
  361.  
  362.                             IF LEFT$(RightClickList$(t + 1), 1) = "-" THEN
  363.                                 SELECT CASE menustyle%
  364.                                     CASE 1: COLOR _RGB(127, 127, 127), _RGB(214, 211, 206) 'classic
  365.                                     CASE 2: COLOR _RGB(127, 127, 127), _RGB(240, 240, 240) 'win7
  366.                                     CASE 3: COLOR _RGB(127, 127, 127), _RGB(55, 55, 55) 'dark grey
  367.                                     CASE 4: COLOR _RGB(127, 127, 127)
  368.                                     CASE 5: COLOR RCMDisText~&, RCMBack~&
  369.                                 END SELECT
  370.                                 PRINT " "; RIGHT$(RightClickList$(t + 1), LEN(RightClickList$(t + 1)) - 1); pad$; " ";
  371.                             ELSE
  372.                                 SELECT CASE menustyle%
  373.                                     CASE 1: COLOR _RGB(0, 0, 0), _RGB(214, 211, 206) 'classic
  374.                                     CASE 2: COLOR _RGB(0, 0, 0), _RGB(240, 240, 240) 'win7
  375.                                     CASE 3: COLOR _RGB(213, 209, 199), _RGB(55, 55, 55) 'dark grey
  376.                                     CASE 4: COLOR _RGB(200, 200, 200)
  377.                                     CASE 5: COLOR RCMEnText~&, RCMBack~&
  378.                                 END SELECT
  379.                                 PRINT " "; RightClickList$(t + 1); pad$; " ";
  380.                             END IF
  381.  
  382.                         END IF
  383.                     NEXT
  384.                 END IF
  385.  
  386.                 IF _MOUSEBUTTON(1) OR _MOUSEBUTTON(2) THEN EXIT DO
  387.  
  388.             END IF
  389.  
  390.             '=== Mark current row mouse is in
  391.             CurRow = FIX(_MOUSEY / 16)
  392.  
  393.         LOOP
  394.  
  395.         '=== restore screen
  396.         _MEMCOPY n, n.OFFSET, n.SIZE TO m, m.OFFSET
  397.         _MEMFREE m: _MEMFREE n
  398.  
  399.         '=== restore original printmode
  400.         IF menustyle% = 4 THEN
  401.             SELECT CASE printmodestatus
  402.                 CASE 1: _PRINTMODE _KEEPBACKGROUND
  403.                 CASE 2: _PRINTMODE _ONLYBACKGROUND
  404.                 CASE 3: _PRINTMODE _FILLBACKGROUND
  405.             END SELECT
  406.         END IF
  407.  
  408.     END IF
  409.  
  410. '================================================================================
  411. '================================================================================
  412.