2013-04-06 11:54:19 +00:00
|
|
|
/*
|
2013-06-15 11:09:02 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
2013-05-03 14:36:17 +00:00
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
2013-04-06 11:54:19 +00:00
|
|
|
*
|
2013-05-03 14:36:17 +00:00
|
|
|
* http://chibios-gfx.com/license.html
|
2013-04-06 11:54:19 +00:00
|
|
|
*/
|
|
|
|
|
2013-05-06 04:44:47 +00:00
|
|
|
/**
|
|
|
|
* @file include/gwin/slider.h
|
|
|
|
* @brief GWIN Graphic window subsystem header file.
|
|
|
|
*
|
|
|
|
* @defgroup Slider Slider
|
|
|
|
* @ingroup GWIN
|
|
|
|
*
|
|
|
|
* @details Create sliders with different styles
|
|
|
|
*
|
|
|
|
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
|
|
|
|
* @pre GWIN_NEED_SLIDER must be set to TRUE in your gfxconf.h
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2013-04-06 11:54:19 +00:00
|
|
|
#ifndef _GWIN_SLIDER_H
|
|
|
|
#define _GWIN_SLIDER_H
|
|
|
|
|
2013-06-06 04:33:32 +00:00
|
|
|
/* This file is included within "gwin/gwidget.h" */
|
2013-04-06 11:54:19 +00:00
|
|
|
|
|
|
|
#define GEVENT_GWIN_SLIDER (GEVENT_GWIN_FIRST+1)
|
|
|
|
|
2013-07-07 09:40:37 +00:00
|
|
|
typedef struct GEventGWinSlider {
|
2013-04-06 11:54:19 +00:00
|
|
|
GEventType type; // The type of this event (GEVENT_GWIN_BUTTON)
|
|
|
|
GHandle slider; // The slider that is returning results
|
|
|
|
int position;
|
|
|
|
} GEventGWinSlider;
|
|
|
|
|
|
|
|
// There are currently no GEventGWinSlider listening flags - use 0
|
|
|
|
|
2013-04-05 14:19:16 +00:00
|
|
|
// A slider window
|
2013-07-07 09:40:37 +00:00
|
|
|
typedef struct GSliderObject {
|
2013-06-06 04:33:32 +00:00
|
|
|
GWidgetObject w;
|
2013-07-05 15:45:24 +00:00
|
|
|
#if GINPUT_NEED_TOGGLE
|
|
|
|
uint16_t t_dn;
|
|
|
|
uint16_t t_up;
|
|
|
|
#endif
|
|
|
|
#if GINPUT_NEED_DIAL
|
|
|
|
uint16_t dial;
|
|
|
|
#endif
|
2013-06-06 04:33:32 +00:00
|
|
|
coord_t dpos;
|
2013-04-06 11:54:19 +00:00
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
int pos;
|
|
|
|
} GSliderObject;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create a slider window.
|
|
|
|
* @return NULL if there is no resultant drawing area, otherwise a window handle.
|
|
|
|
*
|
|
|
|
* @param[in] gb The GSliderObject structure to initialise. If this is NULL the structure is dynamically allocated.
|
2013-06-24 12:58:37 +00:00
|
|
|
* @param[in] pInit The initialization parameters to use
|
2013-06-06 04:33:32 +00:00
|
|
|
*
|
2013-06-10 07:18:01 +00:00
|
|
|
* @note The drawing color and the background color get set to the current defaults. If you haven't called
|
|
|
|
* @p gwinSetDefaultColor() or @p gwinSetDefaultBgColor() then these are White and Black respectively.
|
|
|
|
* @note The font gets set to the current default font. If you haven't called @p gwinSetDefaultFont() then there
|
|
|
|
* is no default font and text drawing operations will no nothing.
|
|
|
|
* @note A slider remembers its normal drawing state. If there is a window manager then it is automatically
|
|
|
|
* redrawn if the window is moved or its visibility state is changed.
|
|
|
|
* @note The initial slider range is from 0 to 100 with an initial position of 0.
|
|
|
|
* @note A slider supports mouse, toggle and dial input.
|
|
|
|
* @note When assigning a toggle, only one toggle is supported per role. If you try to assign more than
|
|
|
|
* one toggle to a role it will forget the previous toggle. Two roles are supported:
|
|
|
|
* Role 0 = toggle for down, Role 1 = toggle for up.
|
|
|
|
* @note When assigning a dial, only one dial is supported. If you try to assign more than one dial
|
|
|
|
* it will forget the previous dial. Only dial role 0 is supported.
|
2013-04-06 11:54:19 +00:00
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
GHandle gwinSliderCreate(GSliderObject *gb, const GWidgetInit *pInit);
|
2013-04-06 11:54:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the slider range.
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a slider window)
|
|
|
|
* @param[in] min The minimum value
|
|
|
|
* @param[in] max The maximum value
|
|
|
|
* @note Sets the position to the minimum value.
|
|
|
|
* @note The slider is not automatically drawn. Call gwinSliderDraw() after changing the range.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
void gwinSliderSetRange(GHandle gh, int min, int max);
|
2013-04-06 11:54:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the slider position.
|
|
|
|
*
|
|
|
|
* @param[in] gh The window handle (must be a slider window)
|
|
|
|
* @param[in] pos The new position
|
|
|
|
* @note If the new position is outside the slider range then the position
|
|
|
|
* is set to the closest end of the range.
|
|
|
|
* @note The slider is not automatically drawn. Call gwinSliderDraw() after changing the position.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
void gwinSliderSetPosition(GHandle gh, int pos);
|
2013-05-27 10:53:34 +00:00
|
|
|
|
2013-04-06 11:54:19 +00:00
|
|
|
/**
|
|
|
|
* @brief Get the current slider position.
|
|
|
|
* @return The slider position
|
|
|
|
*
|
2013-04-05 14:19:16 +00:00
|
|
|
* @param[in] gh The window handle (must be a slider window)
|
2013-04-06 11:54:19 +00:00
|
|
|
*
|
|
|
|
* @note The use of a listener to get the slider position is recommended if you
|
|
|
|
* want continuous updates on the slider position.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2013-07-07 09:40:37 +00:00
|
|
|
#define gwinSliderGetPosition(gh) (((GSliderObject *)(gh))->pos)
|
2013-04-06 11:54:19 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-06 04:33:32 +00:00
|
|
|
* @brief Some custom slider drawing routines
|
|
|
|
* @details These function may be passed to @p gwinSetCustomDraw() to get different slider drawing styles
|
2013-04-06 11:54:19 +00:00
|
|
|
*
|
2013-06-06 04:33:32 +00:00
|
|
|
* @param[in] gw The widget (which must be a slider)
|
2013-04-06 11:54:19 +00:00
|
|
|
* @param[in] param A parameter passed in from the user
|
|
|
|
*
|
|
|
|
* @note In your custom slider drawing function you may optionally call this
|
|
|
|
* standard functions and then draw your extra details on top.
|
2013-06-06 04:33:32 +00:00
|
|
|
* @note The standard functions below ignore the param parameter except for @p gwinSliderDraw_Image().
|
|
|
|
* @note The image custom draw function @p gwinSliderDraw_Image() uses param to pass in the gdispImage pointer.
|
|
|
|
* The image must be already opened before calling @p gwinSetCustomDraw(). The image is tiled to fill
|
|
|
|
* the active area of the slider. The normal colors apply to the border and inactive area and the dividing line
|
|
|
|
* between the active and inactive areas.
|
|
|
|
* No checking is done to compare the dimensions of the slider to the size of the image.
|
|
|
|
* Note text is drawn on top of the image.
|
|
|
|
* @note These custom drawing routines don't have to worry about setting clipping as the framework
|
|
|
|
* sets clipping to the object window prior to calling these routines.
|
2013-04-06 11:54:19 +00:00
|
|
|
*
|
|
|
|
* @api
|
2013-06-06 04:33:32 +00:00
|
|
|
* @{
|
2013-04-06 11:54:19 +00:00
|
|
|
*/
|
2013-06-06 04:33:32 +00:00
|
|
|
void gwinSliderDraw_Std(GWidgetObject *gw, void *param);
|
|
|
|
void gwinSliderDraw_Image(GWidgetObject *gw, void *param);
|
|
|
|
/* @} */
|
2013-04-06 11:54:19 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _GWIN_SLIDER_H */
|
|
|
|
/** @} */
|
|
|
|
|