Difference between revisions of "CMenu pseudo code - OOP344 20113"

From CDOT Wiki
Jump to: navigation, search
(Created page with '<big><pre> LOOP UNTIL editing is done Draw the Menu -- EDITING THE TITLE OF THE MENU --: IF object is dropdown and it is not dropped THEN Edit The Title Button IF …')
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{OOP344 Index | 20113}}
 +
This pseudo code is tested but is NOT the most efficient way to accomplish the task. Optimize it if possible.
 
<big><pre>
 
<big><pre>
 +
/* EDITING LOOP */
 
LOOP UNTIL editing is done
 
LOOP UNTIL editing is done
 
   Draw the Menu
 
   Draw the Menu
Line 15: Line 18:
 
   Set editing loop to end.
 
   Set editing loop to end.
 
/*-- BROWSING THE MENUITEMS IN MNEU --*/
 
/*-- BROWSING THE MENUITEMS IN MNEU --*/
 +
/* BROWSING LOOP */
 
   LOOP UNTIL menu browsing is done
 
   LOOP UNTIL menu browsing is done
 
     Edit the current menu item and get the key returned
 
     Edit the current menu item and get the key returned
Line 27: Line 31:
 
       set the browsing loop to end
 
       set the browsing loop to end
 
     END IF
 
     END IF
     /* to be continued */
+
     IF the key is DOWN THEN
 +
      Set current to be the next item in the list
 +
      IF this can not be done THEN
 +
        IF Menu is a dropdown THEN
 +
          set the first and current item on menu to be the first item in the list
 +
          draw the Menu
 +
        ELSE
 +
          set the borwsing loop to end
 +
        END IF
 +
      END IF
 +
      IF current index is passed the last one in the mneu THEN
 +
        make the first to point to the next one in the list
 +
        draw the menu
 +
      END IF
 +
    END IF
 +
    IF the key is UP THEN
 +
      Set current to be the previous item in the list
 +
      IF this can not be done THEN
 +
        IF Menu is a dropdown THEN
 +
          set the current item in menu to be the last the list
 +
          set the first item in menu to be NUM items before last in the list,
 +
            (where NUM is the number rows in the menu)
 +
          draw the Menu
 +
        ELSE
 +
          set the borwsing loop to end
 +
        END IF
 +
      END IF
 +
      IF current index is passed the first index in the menu THEN
 +
        set the first index to point to previous one in the list
 +
        draw the menu
 +
      END IF
 +
    END IF
 +
    IF the Key is ESCAPE THEN
 +
      set the menu not to drop,
 +
      set browsing loop to end
 +
      set the edting loop NOT to end
 +
    END IF
 +
    IF the key is right, left, tab or any of the printable characters THEN
 +
      set the browsing loop to end
 +
    END IF
 
   End menu browsing loop
 
   End menu browsing loop
 
End Editing loop
 
End Editing loop
 +
IF Menu is a dropdown THEN
 +
  set the menu not to drop
 +
  hide the menu
 +
END IF
 +
return the last key hit
 
</pre></big>
 
</pre></big>

Latest revision as of 00:57, 30 November 2011


OOP344 | Weekly Schedule | Student List | Teams | Project | Student Resources
This pseudo code is tested but is NOT the most efficient way to accomplish the task. Optimize it if possible.

/* EDITING LOOP */
LOOP UNTIL editing is done
  Draw the Menu
/*-- EDITING THE TITLE OF THE MENU --*/
  IF object is dropdown and it is not dropped THEN
    Edit The Title Button
    IF Button is hit THEN
      Set the menu to drop down when drawn
      draw the menu
      Set Menu browsing Loop to start
    ELSE
      Set Menu browsing Loop NOT to start
    END IF
  END IF
  Set editing loop to end.
/*-- BROWSING THE MENUITEMS IN MNEU --*/
/* BROWSING LOOP */
  LOOP UNTIL menu browsing is done
    Edit the current menu item and get the key returned
    IF the key is ENTER
      IF any of items are selected THEN
        change the key value o SPACE
      END IF
      set the browsing loop to end
    END IF
    IF the key is SPACE THEN
      set the selected index
      set the browsing loop to end
    END IF
    IF the key is DOWN THEN
      Set current to be the next item in the list
      IF this can not be done THEN
        IF Menu is a dropdown THEN
          set the first and current item on menu to be the first item in the list
          draw the Menu
        ELSE
          set the borwsing loop to end
        END IF
      END IF
      IF current index is passed the last one in the mneu THEN
        make the first to point to the next one in the list
        draw the menu
      END IF
    END IF
    IF the key is UP THEN
      Set current to be the previous item in the list
      IF this can not be done THEN
        IF Menu is a dropdown THEN
          set the current item in menu to be the last the list
          set the first item in menu to be NUM items before last in the list, 
             (where NUM is the number rows in the menu)
          draw the Menu
        ELSE
          set the borwsing loop to end
        END IF
      END IF
      IF current index is passed the first index in the menu THEN
        set the first index to point to previous one in the list
        draw the menu
      END IF
    END IF
    IF the Key is ESCAPE THEN
      set the menu not to drop, 
      set browsing loop to end
      set the edting loop NOT to end
    END IF
    IF the key is right, left, tab or any of the printable characters THEN
      set the browsing loop to end
    END IF
  End menu browsing loop
End Editing loop
IF Menu is a dropdown THEN
  set the menu not to drop
  hide the menu
END IF
return the last key hit