home *** CD-ROM | disk | FTP | other *** search
- ICONMEU1.DOC
-
- Instruction file for Turbo Pascal Icon Menu Maker - by Bill Tavolga
- Version 1.0
-
- Files in this group:
- ICON-MK.EXE Program for constructing up to 32 icons per file
- ICONTST1.EXE Program to demonstrate use of constructed icons in menu
- ICONTST1.PAS Source code for above
- ICON-DEM.DAT Sample file of icons
- ICON.1 Sample file of menu parameters (use with ICONTST1)
- ICONMEU1.TPU Unit to be used with ICONTST1 or your own program
- IMOUSE.PAS Unit of basic mouse functions used here
- IMOUSE.TPU Compiled mouse unit
-
- Requirements:
- Turbo Pascal 5.0
- PC-type hardware with EGA or VGA graphics
- Mouse and mouse driver (loaded)
- (and patience to experiment)
-
- General purpose:
- This is for the programmer who is looking for a shortcut to making MAC-
- like mouse-controlled icon-menus for his programs.
- The procedure is first to create a file of icons. The menu in your own
- program will use two procedures. The DISPLAY_ICONS procedure permits you
- to select several icons from your file and paint them on the screen. The
- USE_ICON_MENU procedure waits until a mouse button is pressed. At this
- point four values are returned to the program: the x and y coordinates of
- the mouse cursor, the button status (1 for left, 2 for right, etc.), and the
- icon number that was selected (0 if none). The most frequent use of this
- procedure would be in a loop that would continue until a particular icon is
- selected. Within the loop the returned values can be used for any other
- programming tasks, except something that interferes with the display of the
- icons or mouse operation. See ICONTST1.PAS for a sample.
-
- Getting started
- (read this especially if you are an inexperienced programmer):
- As a first step, just run program ICONTST1.EXE. Choose the internally
- programmed option (C). Be sure that your mouse driver has been loaded.
- Pressing any mouse button anywhere on the screen gives you an output of:
- icon selected (0 if none), x-y coordinates, and button status. This option is
- programmed so that clicking the left mouse button over icon "EXIT" will quit
- the program, otherwise the loop continues. Your icon is selected only when
- the left mouse button is pressed, but the button must be released before any
- action takes place.
- Exit the program, and run it again, but this time choose the B option:
- text-file of menu parameters. (If you have any problems, it may be that the
- data files are not in the default directory.) The demonstration textfile is
- ICON.1 . The menu display will be a bit different. If you examine ICON.1,
- you will see it is an ASCII file with the following:
- icon-dem.dat
- 7 10 21 13 8
- 5
- The first line is a demonstration file of icon data; next is an array of five
- numbers that represent the ordinal position of the icons in the file, i.e., you
- will use the seventh, tenth, twenty-first, etc., in that order; lastly is the
- position of the icon you will use to exit the program. Within limits, you can
- change this file to use any of the available icons in any order. In Version 1.0
- of this program, a maximum of five icons can be used in a menu. If the
- number of icons you choose is less than the maximum of five, then a zero
- must be added to the array. The number in line 3 cannot be greater than the
- number of icons used. The unit ICONMEU1.TPU will catch some of these
- errors, but the programmer has the responsibility to stay within proper
- limits.
- Finally, run the program again and try the A option. You may find new
- and wonderful ways of crashing your system, but if you use the Turbo
- Pascal 5.0 environment, it will catch most of your errors. Make sure that the
- icon file, e.g., ICON-DEM.DAT, is in the path. Enter the array with spaces
- between the numbers, thus: 2 5 7. The last number must be a zero if the
- array contains fewer than five numbers, and each number may not be less
- than 1 or more than 32. The last item can only be equal to or less than the
- number of array members, and not zero.
-
- Icon constructor (ICON-MK.EXE):
- This program creates the icons that you use in your menu. Each icon
- consists of a rectangle 24 pixels across and 20 pixels high, and a file of 32
- such icons is generated and saved in a format that can be used by
- ICONMEU1.TPU. The program permits you to use a previously saved file of
- icons or create a new file. The file ICON-DEM.DAT is supplied with a few
- samples for you to start with.
- After the file is selected, the screen displays all the component icons
- (including blanks), and a drawing area. The mouse is used for all operations.
- Clicking the mouse over an existing icon (or blank area over an icon
- number), brings up that icon: left button for editing; right button to blank
- out and begin drawing. Draw the icon within the squares area: left button
- to fill a square; right button to clear. By holding down a button, you can
- create or clear a line of squares. Each square represents a pixel in the icon,
- and as you draw within the squares area, the icon is created over its
- number. A red dot marks the currently active icon.
- In this way, you can create your new icons or redraw old ones. When
- finished, click the mouse left button over either SAVE or EXIT. The latter
- will quit the program without saving your work, so be careful.
-
- Icon testing program (ICONTST1.PAS):
- The source code of this program is supplied to show you how the
- ICONMENU system works, and to give you a model of how you can create your
- own MAC-like mouse menus.
- There are some absolute requirements: you must be in EGA or VGA
- graphics, and the mouse driver must be loaded.
-
- The DISPLAY_ICONS procedure must be given the following parameters:
- ICON_FILE_NAME : This is a string type variable which can be defined
- as a file name with or without a complete path. Anything goes, as long as
- the program can find the file. The program will halt if the file cannot be
- found or the file is not the right format or size. This file must have been
- created by the ICON-MK.EXE program.
- ICS : This is an array of bytes of the type ICON_ARRAY (defined in
- ICONMEU1.TPU). It contains a maximum of 5 bytes, each with a value of from
- 1 to 32, representing the icon number in the above file. If the array has
- fewer than 5 members, then a final zero must be added so that the program
- will know when to stop loading icons.
- Finally, you must enter the foreground and background colors for the
- icons. Numbers can be used, but it is convenient to enter the names of the
- 16 standard colors as defined in Turbo Pascal.
- This procedure also checks for the presence of a mouse driver, and sets
- the screen size to 650x350.
-
- The USE_ICON_MENU procedure receives the necessary values from the
- above procedure. Although mouse movement is still possible, the program is
- otherwise suspended until any mouse button is pressed. To use this
- procedure repetitively, you must place it in a loop (as shown in
- ICONTST1.PAS). At each button press, four values are passed:
- icon_selected : Returns byte representing the ordinal value of the icon
- selected. If the mouse was not clicked over an icon, the returned value is
- zero. When the mouse cursor is over an icon and the left button pressed, the
- icon is selected, but no action takes place until the button is released. This
- is to prevent "dragging" the cursor over the icons. When selecting an icon,
- the left button should be "clicked." Note that the mouse cursor shape
- changes when it moves over the icon area.
- x and y : These are of type word and represent the coordinates of the
- mouse cursor at the time of button press. The x values range 0 to 649, and
- y values range 0 to 349.
- button : This is also of type word, and remains zero if no button
- pressed. Left button generates 1; right button - 2; both buttons - 3. If you
- have a 3-button mouse, the middle button generates 4.
- The programmer is free to use the mouse and virtually all other screen
- functions in conjunction with this icon menu. Obviously if the program
- erases the display, then it is necessary to use the DISPLAY_ICONS procedure
- again.
-
- IMOUSE.PAS : This file is included here for the convenience of the
- programmer. The file consists of several basic mouse functions, and should
- work with most mouse drivers (I have tested them with Microsoft Mouse and
- Logitech Mouse). The file IMOUSE.TPU is the compiled unit used in the icon
- menu programs.
-
- These programs have all been generated by Turbo Pascal 5.0 from
- Borland International.
-
- =======================================================================
-
- These files and programs are provided for the convenience and
- enjoyment of any Turbo Pascal programmers. You are welcome to use,
- misuse, copy, and distribute this material in any way.
-
- However, I do have a version 2.0 of this material with a few additional
- features. The DISPLAY_ICONS in version 2.0 has the following additional input
- parameters:
- An option of placing the icon menu anywhere on the screen.
- An option of displaying the icons horizontally as well as vertically.
- As many icons as will fit across or down the screen can be displayed.
- For a registration fee of $15, I shall send a copy of version 2.0 and you
- will be notified of any further improvements or modifications. The files will
- be sent on a 5.25" (360K) disk, unless a 3.5" (720K) disk is requested.
- Comments and suggestions from users would be appreciated and, if
- feasible, could be added to subsequent versions. I know there are other
- similar programs available, but this one has the virtue of being cheap and
- may have some features appropriate to your particular application.
- Please send comments, checks, etc., to:
- William N. Tavolga
- 5151 Windward Ave.
- Sarasota, FL 34242
- Phone: (813) 349-6221
- CIS: 76360,45
-
- The author is not responsible for any damage to your computer, loss of
- time, or loss of hair resulting from the use of any of this software.