home *** CD-ROM | disk | FTP | other *** search
- /*
- #### # # # #
- # # # # # The FreeWare C library for
- # # ## ### # # # # ### RISC OS machines
- # # # # # # # # # # # ___________________________________
- # # #### ### ## # # # #
- # # # # # # # # # # Please refer to the accompanying
- #### ### #### # # ##### # ### documentation for conditions of use
- ________________________________________________________________________
-
- File: Icon.h
- Author: Copyright © 1992 Jason Williams
- Version: 1.00 (22 Mar 1992)
- Purpose: High-level icon handling routines
- */
-
-
- #ifndef __dl_icon_h
- #define __dl_icon_h
-
- #ifndef __dl_wimp_h
- #include "Wimp.h"
- #endif
-
-
- /* Icon_BarIcon ---------------------------------------------------------
- * This function places an icon on the iconbar. It makes a "normal"
- * sprite-only icon, with the "normal" default flags. If you want an
- * icon that is not this default, then create it yourself (it isn't hard!)
- *
- * If you wish to attach handlers/menus to the baricon, then remember
- * it's handle, and pass this to Event_Claim...
- * (Or wait for release 2 of DeskLib, which should have an Event_BarIcon)
- *
- * Pass in "spritename" - the name of a sprite in the Wimp Sprite pool
- * and "pos", which should be iconbar_LEFT or iconbar_RIGHT
- * The correct size of the icon will be determined and used
- * Returns: The icon handle of the created icon
- */
- extern icon_handle Icon_BarIcon(char *spritename, window_handle pos);
-
-
- extern void Icon_Select(window_handle window, icon_handle icon);
- /* If the given icon is currently deselected, it is selected */
-
- extern void Icon_Deselect(window_handle window, icon_handle icon);
- /* If the given icon is currently selected, it is deselected */
-
- void Icon_Select3d(window_handle window, icon_handle icon);
- /* Just the same as Icon_Select, but forces redraw of the area around the
- * icon so that the 3-d border is redrawn indented/unindented as appropriate
- */
-
- extern void Icon_Deselect3d(window_handle window, icon_handle icon);
- /* Just the same as Icon_Deselect, but forces redraw of the area around the
- * icon so that the 3-d border is redrawn indented/unindented as appropriate
- */
-
-
-
- extern void Icon_Shade(window_handle window, icon_handle icon);
- /*
- * if the icon is currently unshaded (active) it is shaded (made inactive)
- * This includes removing the caret from the icon.
- */
-
- extern void Icon_Unshade(window_handle window, icon_handle icon);
- /* if the icon is currently shaded (inactive) it is unshaded (made active) */
-
-
-
- extern void Icon_ForceWindowRedraw(window_handle window, icon_handle icon);
- /* Force Redraws the area of WINDOW surrounding the icon, *including*
- * the 3-d border (validation string "b<bordertype>")
- */
-
- #define Icon_ForceRedraw(wind, icon) Wimp_SetIconState(wind, icon, 0, 0);
- /* Forces the WIMP to redraw (just) the icon */
-
-
-
- extern void Icon_SetCaret(window_handle window, icon_handle icon);
- /*
- * This routine sets the caret within the requested icon. It places the
- * caret at the (righthand) end of the text in the icon. If the icon is not
- * a text icon, then the function returns quietly
- */
-
- extern void Icon_LoseCaret(window_handle window, icon_handle icon);
- /* Icon_LoseCaret
- * This routine ensures that the caret is *not* contained within the
- * designated icon. Only sets a new position if the icon currently contains
- * the caret.
- */
-
-
-
- extern void Icon_SetInteger(window_handle w, icon_handle i, int value);
- /*
- * Sets the given icon's text to hold the number in "value". (and redraws icon)
- * If the number is too long (too many digits) it will be truncated to fit.
- * If unable to set the text (incorrect icon type), it returns quietly
- */
-
- extern void Icon_SetDouble(window_handle w, icon_handle i,
- double value, int decimalplaces);
- /*
- * Sets the given icon's text to hold the number in "value". (and redraws icon)
- * Only the first "decimalplaces" digits after the decimal point are
- * printed. If the number is too long (too many digits) it will be truncated
- * to fit. This may affect the accuracy or actual value of the number.
- * If unable to set the text (incorrect icon type), it returns quietly
- */
-
- extern void Icon_SetText(window_handle w, icon_handle i, char *text);
- /*
- * Copies the text string into the icon's indirected string buffer (and redraws)
- * If unable to set the text (incorrect icon type), it returns quietly
- * If text passed in is a NULL pointer, sets icon text to " "
- */
-
- extern void Icon_printf(window_handle window, icon_handle icon,
- char *format, ...);
- /*
- * Exactly the same as sprintf, but instead of passing in a string into which
- * the result is written, you pass in the window+icon identifier of an
- * indirected icon. (Anything other than an indirected icon will return
- * quietly with NO effect)
- * e.g Icon_printf(window, 5, "%d bytes copied", current);
- */
-
-
-
- extern double Icon_GetDouble(window_handle w, icon_handle i);
- /*
- * Gets the given icon's text and returns it in the form of a "double"
- * floating-point value. 0 will be returned from any error/invalid text
- */
-
- extern int Icon_GetInteger(window_handle w, icon_handle i);
- /*
- * Gets the given icon's text and returns it in the form of an integer
- * numeric value. 0 will be returned from any error/invalid text
- */
-
- extern void Icon_GetText(window_handle w, icon_handle i, char *text);
- /*
- * Copies the text string from the icon (sprite name, text, or indirected)
- * into the array pointed to by "text"
- */
-
-
-
- extern void Icon_SetRadios(window_handle window,
- icon_handle first, icon_handle last,
- icon_handle onradio);
- /*
- * Pass in a group of icons (specified by lowest-numbered icon and
- * highest-numbered icon), and the icon from this group that you want
- * selected. All icons except the one you want selected will be deselected.
- */
-
- extern int Icon_WhichRadio(window_handle window,
- icon_handle first, icon_handle last);
- /*
- * This function accepts parameters for the first (lowest numbered) and
- * last (highest numnbered) in a group of icons (generally a group of radio
- * buttons). It returns the icon number of the first icon it finds within
- * this range which is selected (or "last" if none are selected).
- * Use it to find which of a group of radios is selected.
- */
-
-
-
- /*
- * Waits for the given number of centiseconds.
- * This is a MULTITASKING wait - although your program will do nothing,
- * the rest of the desktop will continue to run.
- * The wait is aborted after the given time, or as soon as an event is
- * received. If an attempt is made to re-enter ClickWait(), it will return
- * immediately (i.e. if a click event causes ClickWait to ba called, then
- * a second click while "waiting" from the first click will have no effect.
- */
- extern void Icon_ClickWait(int waittime);
-
-
-
- /*
- * Starts a drag operation based on the given icon.
- * This is mainly used in "save as" windows to start drags of the file icon
- * when it is clicked on, but may be useful elsewhere.
- *
- * Currently NOT DragASprite compatible... Anyone want to remedy this?
- */
- extern void Icon_StartDrag(window_handle window, icon_handle icon);
-
-
-
- /* =========================================================================
- * Special high-level icon functions:
- * Slider icons: See "DeskLib.Libraries.Icon.c.Slider" for details
- */
-
- extern int Icon_SetSlider(window_handle window,
- icon_handle baseicon, icon_handle slidericon,
- int sliderpos);
- /* Sets a slider icon-pair to the specified position (specify as a
- * percentage). Values < 0 and > 1000 are clipped, and the value to which the
- * slider has been set is returned.
- */
-
- extern int Icon_UpdateSlider(window_handle window,
- icon_handle baseicon, icon_handle slidericon,
- int lastpos);
- /* (call on null events while slider being dragged)
- * Calculates a new slider percentage from the mouse pointer position.
- * If this differs from lastpos, the slider is updated (by recreating the
- * slidericon to the new length.
- * returns the new slider position percentage value.
- * NOTE: Slider update is achieved by DELETING and re-creating the slider
- * icon. This relies upon no icons of a lower icon handle having been deleted!
- */
-
- extern int Icon_UpdateSlider(window_handle window,
- icon_handle baseicon, icon_handle slidericon,
- int lastpos);
- /* (call on null events while slider being dragged)
- * Calculates a new slider percentage from the mouse pointer position.
- * If this differs from lastpos, the slider is updated (by recreating the
- * slidericon to the new length.
- * returns the new slider position percentage value.
- * NOTE: Slider update is achieved by DELETING and re-creating the slider
- * icon. This relies upon no icons of a lower icon handle having been deleted!
- */
-
- extern int Icon_DragSlider(window_handle window,
- icon_handle baseicon, icon_handle slidericon);
- /* Initiates the drag operation on a slider. Call this when you get a click
- * in either baseicon or slidericon.
- * Returns the new percentage represented by the slider (remember this so
- * you can pass it in to Icon_UpdateSlider to save unnecessary (flickery)
- * update.)
- * NOTE: It is up to you to turn on NULL events and remember that
- * Icon_UpdateSlider must be called on each poll...
- * An alternative is to make the 2 slider icons use button type ALWAYS, and
- * check the mouse button state yourself to see whether a drag needs to be
- * started/continued...
- */
-
- extern int Icon_ReadSlider(window_handle window,
- icon_handle baseicon, icon_handle slidericon);
- /* Given a slider icon-pair, returns a percentage representing the state */
-
-
- #endif
-