Author Topic: Ritchie's QB64 Menu Library V1.0 (Finished)  (Read 10687 times)

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Ritchie's QB64 Menu Library V1.0 (Finished)
« on: July 31, 2012, 10:26:17 pm »
Have you ever wanted a simple way to add a Windows menu to your QB64 program?  Well now you can!

Introducing Ritchie's QB64 Menu Library.

With as little as three commands you can have a menu up and running. The menu features full mouse and keyboard support as well as a large set of tools for complete customization.

The included documentation (in PDF format) is written both as a tutorial and reference to the library.  Please let me know what you think as well as any bugs you may find or enhancements you may want.

https://dl.dropbox.com/u/416997/QB64MenuLibraryV1.zip  (678KB)

UPDATE: I added a screenshot of a standard menu created with the library in the screenshot gallery: http://www.qb64.net/gallery/main.php?g2_page=2
« Last Edit: September 02, 2012, 07:17:30 pm by TerryRitchie »

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #1 on: August 05, 2012, 07:36:20 pm »
*bump*

Brought to the top since I've finished the library and it's ready to download.

Billbo

  • Hero Member
  • *****
  • Posts: 1143
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #2 on: August 09, 2012, 07:43:05 am »
TerryRitchie,

This is probably the wrong part
of the forum to ask, but, what
does '*bump*' mean. QB64's
forum is the only place I recall
seeing it.

Bill

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #3 on: August 09, 2012, 08:52:29 am »
TerryRitchie,

This is probably the wrong part
of the forum to ask, but, what
does '*bump*' mean. QB64's
forum is the only place I recall
seeing it.

Bill

When a topic is replied to it's brought to the top of the forum section. *bump* in essence means you are "bumping" it to the top.

Also, did you get a chance to try the menu library?

Billbo

  • Hero Member
  • *****
  • Posts: 1143
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #4 on: August 09, 2012, 09:30:34 am »
TerryRitchie,

Thanks for the speedy reply. You must be on
all the time, like Clippy. Thanks for the *bump*
info.

I am sorry to say that I have not tried you menu
library yet. Most all my programming has been at
the console level and the only time I got into windows
and menus was on my first skinny MAC (the 64K one)
with MS Basic, and later with the LE.

I want to get into windows so I can convert some of
my programs to have menus, etc.

One of my big things is mapping. Under that I include
Great Circle programming, distance between two points
programming, etc. I thought that along with trying to
program windows, your libraries would go a long way
on the menus.

BTW. I scanned you PDF guide. It is well done. I am
sure the rest is, also.

Bill

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #5 on: August 09, 2012, 01:51:26 pm »
The library has nothing to do with Windows.  It gives you the ability to add a menu to any QB64 program you write.  It does not make any Windows calls, it's all pure QB64 code driving the menu.

Billbo

  • Hero Member
  • *****
  • Posts: 1143
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #6 on: August 09, 2012, 03:55:41 pm »
TerryRitchie,

I can't seem to see what I'ma sayin' today.
I did not mean the Windows OS. I should have
indicated 'GUI' with mean. Instead of like when
you used to ask for something on your 'black
screen' and received your answer on you 'black
screen.' I used the term windows because in
the coding for forms uses the term windows,
or window, I do not recall which.

Bill

Cyperium

  • Hero Member
  • *****
  • Posts: 3658
  • Knowledge is good, but understanding is better
    • Cyperium
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #7 on: August 09, 2012, 04:57:25 pm »
Very impressing work. I will definitely use it when I need a menu!

I know the hard work involved since I tried making a windows-style menu myself, I got it to work with some minor bugs but your menu is definitely much better!


Also, very nice that you can hover the mouse over a sub-menu item and still be able to change the selected item using the keyboard, I had some trouble with that when developing my menu-system but got it to work and it was a tell-tale sign that you have given this menu much thought and dedication.

The documentation is very good as well.

I have three suggestions for this library (even though it's good enough as it is):

1) that we are able to make pop-up menues that are located anywhere on the screen, it would basically be a sub-menu without a main-menu.

2) that we are able to put small images to the left of the sub-menu item (perhaps this is already possible manually through code though).

3) that we are able to use checkbox menu-items (the sub-menu doesn't disappear when clicked but a check is placed to the left of the text). Obviously then we would also need a function to know if the menu is checked or not.



Thanks for a great library, even if you don't choose to implement the things suggested :)
« Last Edit: August 09, 2012, 05:07:27 pm by Cyperium »

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #8 on: August 09, 2012, 06:52:02 pm »
All good suggestion worth exploring, thank you.

The floating menu I planned to work on, although I had in mind a right click menu, but right along the same lines.

The icons to the left of menu entries was something I was hoping to get working for this release. I did originally have it planned, since all menus any more today seem to be that way, but I was running out of time.  School starts back up in a few weeks and I need to get my lesson plans updated before the little buggers come back.

I have seen a few programs that use the check mark method you talked about as well.  That should be easy to implement once I get the left icons workings.

Thanks for the kudos and suggestions.  And yes, as you pointed out, this was no easy task to complete.  Like you said, getting mouse and keyboard to work together was probably the hardest part of the entire project.  I remember thinking when I started writing the menu library that this should be pretty easy ... LOL, it took me three weeks to complete!  Yikes.

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 5856
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #9 on: August 09, 2012, 10:49:26 pm »
I was looking at your menus, and I like (and dislike) them a lot.   What I like about them is they're neat, clean, and easy to use. 

What I dislike is simply that they mimic Window's menus, and follow that same generic layout -- which isn't your fault at all.  I think Windows has did a lot to standardize the way we look and think about things, but at the same time they've reduced the creative flair which people used to program with.  If you've seen one windows menu, you've seen them all.  I miss all the personal little bright clicky buttons and circles and swirls and stuff that people used to program before Windows fell upon us.  Now, everything looks the same -- which is excellent for businesses as it makes training easier; learn one windows application and you've mastered half the others as well already -- but things have lost that individual creative design they used to have.  I'd started with a menu system for my little homework helper, but then tossed it out half-finished.  I just didn't really want to make it look like a windows app.  Nothing against you or your menu maker - it's just a personal quirk I guess.  ;)

A few thoughts for you though:

This is a horizontal menu system.  Have you considered making a vertical menu pop-up?  One that started at the top left and went down instead of across?

You have a SETMENUINDENT command; have you considered making it where you can specify not just one indent amount for the first column, but one for each of the columns...  such as:

SetMenuIndent 0,25
SetMenuIndent 1,1000

The first statement above would move the first menu (menu 0) to the right 25 pixels.   The second statement would move the second menu to the right 1000 pixels.  (Think placing the Help tab on the far right of the menu bar, instead of beside the other tab.)

I'd also love to see a conversion to using arrays over DATA statements.  A change to MakeMenu (MenuArray(x,y)) would be lovely in my opinion.  ;)   (Or an option to swap between styles would be lovely as well, with something like a SetMenuMode command.   0 could use data statements, 1 could use arrays, 2 could read from a CSV file...)  :D

As it is though, it works nicely and is something that I'd probably toss into a program myself if I ever did something business-like.  It makes a nice menu layout, is easy to use, and hasn't given me any problems with the testing I've did with it so far.  :)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.

http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #10 on: August 10, 2012, 10:40:30 am »
Good idea on the MenuIndent!  When I was writing the library I was trying to think of the easiest way to be able to put help menus to the right.  Well, duh, the code is already there, just a little tweaking is in order.

I hear ya on the bland Windows menu looks. I wanted to make something that is familiar for ease of use.  Perhaps when I get some time I can add a few crazy features like circular menus.

I stayed with DATA statements again for ease.  I felt this was the most unintrusive and easiest way to introduce the information to the library, but I do realize that not everyone likes DATA statements, so your different ideas on introducing the menu information will be implemented at some point.

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 5856
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #11 on: August 10, 2012, 12:03:20 pm »
Another reason I was thinking arrays would be better than data statements would be for ease of Toggle Menu statements.  If you stick with DATA, perhaps you could add a AlterMenuCaption (x,y) command, so one could easily change the text of the menu caption.  (Think of something like a spell checker.   One statement would read Spellcheck On; once clicked, the toggle would read Spellcheck Off.)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.

http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 5856
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #12 on: August 10, 2012, 08:52:08 pm »
A few other sidenotes:

Is there a way to specify which set of data the menu uses and restores?   Usually I don't use data very often in a program, but if there is a need for another set of DATA statements not related to the menu, how does one go about specifying which set the menu should use?

It seems like it reads the data once to see how big to make the menu, and then it issues a standard RESTORE to read the data again and fill in the captions and whatnot.   Would the process work if a different set of data was in the program prior to the menu data?

Code: [Select]
    DO WHILE ReadData$ <> "*" '                                                stop looping when encountered
        SubMenu% = SubMenu% + 1 '                                              increment sub menu entry counter
.
. Do more stuff
.
    READ ReadData$ '                                                           read next main menu entry
LOOP
REDIM Menu(MainMenu%, MaxSubMenu%) AS MENU '                                   resize the menu entry array accordingly
RESTORE '                                                                      restore the DATA to be read in again

As I say, I'm not an expert on DATA as I seldom use it, so I'm just curious if it'd play nice with a different set of data in a program as well.

******

Also, both library files have the BI extension (which works fine).  It seems someone on the forum here decided that the headers should be BI and the footers BM files (though any extension works really).  Out of curiosity, did you intend both to be BI files, or was the menu.bi supposed to be menu.bm?   

(And just who the heck set BI/BM as the QB64 standard anyway?  http://qb64.net/wiki/index.php?title=Libraries  Does it really matter what the header/footer is called, as long as a person knows where to put them?)
http://bit.ly/TextImage -- Library of QB64 code to manipulate text and images, as a BM library.

http://bit.ly/Color32 -- A set of color CONST for use in 32 bit mode, as a BI library.

Clippy

  • Hero Member
  • *****
  • Posts: 19291
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #13 on: August 10, 2012, 08:59:14 pm »
That's why they use different extensions so you know where they go. BI files were always included at the beginning in QB. Don't know who started the BM, but it may have been ZomB.

QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 SDL: QB64v0954-win15.7z

TerryRitchie

  • Hero Member
  • *****
  • Posts: 2806
  • Press any key to continue or any other key to quit
Re: Ritchie's QB64 Menu Library V1.0 (Finished)
« Reply #14 on: August 10, 2012, 09:59:44 pm »
A few other sidenotes:

Is there a way to specify which set of data the menu uses and restores?   Usually I don't use data very often in a program, but if there is a need for another set of DATA statements not related to the menu, how does one go about specifying which set the menu should use?

It seems like it reads the data once to see how big to make the menu, and then it issues a standard RESTORE to read the data again and fill in the captions and whatnot.   Would the process work if a different set of data was in the program prior to the menu data?

Code: [Select]
    DO WHILE ReadData$ <> "*" '                                                stop looping when encountered
        SubMenu% = SubMenu% + 1 '                                              increment sub menu entry counter
.
. Do more stuff
.
    READ ReadData$ '                                                           read next main menu entry
LOOP
REDIM Menu(MainMenu%, MaxSubMenu%) AS MENU '                                   resize the menu entry array accordingly
RESTORE '                                                                      restore the DATA to be read in again

As I say, I'm not an expert on DATA as I seldom use it, so I'm just curious if it'd play nice with a different set of data in a program as well.

******

Also, both library files have the BI extension (which works fine).  It seems someone on the forum here decided that the headers should be BI and the footers BM files (though any extension works really).  Out of curiosity, did you intend both to be BI files, or was the menu.bi supposed to be menu.bm?   

(And just who the heck set BI/BM as the QB64 standard anyway?  http://qb64.net/wiki/index.php?title=Libraries  Does it really matter what the header/footer is called, as long as a person knows where to put them?)

Yeah, I should have made note in the documentation that the DATA is restored after the first read through. You need to have the menu DATA as the first DATA statements in your code. Once MAKEMENU has been issued then any remaining DATA can be read in by the rest of the programmer's code.  I'm going to update the documentation to reflect this.  Thank you for pointing this out.

Also, the .BI/.BM thing is a non-issue. You can name the files anything and use $INCLUDE.  I use .BI for the reason Clippy pointed out, that the original QB used this extension.  I actually thought about using .LIB at one point, but that might confuse old-school QB coders.