On 3 Mar 2013, at 04:36, edgar wrote: > > I am starting with a simple program to show a whole note on a staff with a > treble clef. > The user is asked to enter the note name. > The program should let the user know if their input was correct and display a > running score in the window.
OK - that seems straightforward. However, as a design point, I'd caution against letting the user input the answer as "free text" or even "natural language" since you then have to parse what they enter and see if it makes sense... (e.g. I never say "whole note", I'd say semibreve, but both are "correct"...) Rather, I'd offer a list of answers and allow the user to pick one - that removes the parsing aspect and makes things a lot simpler, with no loss of generality... > > Here is the basic algorithm: > > Display window with the following: > > Instruction header - prompts user to enter note name. > staff and clef - (staff is drawn. clef and note are .png) > > Loop { > note is shown on the staff - chosen randomly from a bank of locations. > User enters note name > Program checks user response, tabulates a score and prints a running score > to the window > } > > User selects a quit button which destroys all dynamically allocated widgets. This step is probably unnecessary - if you program is ending, and the process in which it runs is ending, then all the allocated memory will be released by the process anyway... In which case actually making the effort to explicitly destroy allocated widgets is nugatory work... > Here is the code I have so far. It compiles and runs with my png files, but > I don't know how to: Um... OK. Well, I don't think that's the right way to go about this. There are a few things "wrong" with this code... Also, it is making your task more complex than in needs to be, which is a Bad Thing. Time permitting, I'll cobble up a demo and post it, of how this might be done in a more fltk'ish way. Might not be today though. > 1. Get the user's input to the window instead of the console. > I think I can send it to an output box, but I'd like to send > it to the window via an "invisible" box - sort of like the header. This is trivial, but possibly not with the code structured the way you have it. > 2. Loop the sequence. I would also like to keep the code which checks the > answers separate from the code that implements the GUI. Again, trivial, but we need to look at your program structure and see how you can achieve that. Key points though: - There are better ways to draw lines in fltk; where did you get this approach from? It looks really quite... odd... - If you are going to render a lot of musical symbols, loading a musical font (such as Musica or etc.) will be easier than rendering lots of PNG glyphs, and will also anti-alias and scale automatically. - The way the main window is being created and "run" here is holding you back. - You need to see how to subclass a box and derive your own draw() method to handle the drawing of your staff. Anyway, I'll try and make a demo, then post it for you to see. There are easier ways to do what you want! _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk