mgsLib  1.3
Mermaja's Graphic Screen. A simple C library to build Windows graphic applications from console programs.
mrmSlider.c File Reference

Sliders for the MrMWidgets. More...

Functions

Sliders management functions

These functions create and handle sliders.

int mrmSliderInit (int scr, int orientation, int width, int length, double min, double max, int col, int cCol, int cBcol, int dCol)
 Creates a new slider with the given size, values and colors. More...
 
int mrmSliderDelete (int idx)
 Delete the slider whose reference number is given. More...
 
int mrmSliderSetEnabled (int idx, int enabled)
 Enable or disable slider. More...
 
int mrmSliderSetPos (int idx, int x, int y)
 Places the slider at the given position on the screen. More...
 
int mrmSliderSetColor (int idx, int col, int cCol, int cBcol, int dCol)
 Sets the colors for the slider. More...
 
double mrmSliderSetVal (int idx, double val)
 Sets the value of the slider and modifies the position of the cursor. More...
 
double mrmSliderGetVal (int idx)
 Reads the value of the slider. More...
 

Detailed Description

Author
Germán Fabregat
Date
October 2017

Function Documentation

◆ mrmSliderInit()

int mrmSliderInit ( int  scr,
int  orientation,
int  width,
int  length,
double  min,
double  max,
int  col,
int  cCol,
int  cBcol,
int  dCol 
)

This function is used to create a slider of the given width and length on the given screen, placed in horizontal or vertical position. The minimum value is that of the left for horizontal or top for vertical edge of the slider, being max that of the opposite edge. These names are not related to absoulte values, as min can be greater than max. The value given by the slider is linearly adjusted between these limits, using the slider length and cursor positions, so the granularity is determined by the length. Four colors are also specified, for the slider, cursor body, cursor lines and slider when disabled. In this case colors for the cursor are permuted. The slider is enabled after creation, but it is not placed on screen -and thus visible and usable- until its position is set using the corresponding function.

Parameters
[in]scrGraphic screen where the slider is placed.
[in]orientationCan be MWG_SLHORIZONTAL for an horizontal slider or MWG_SLVERTICAL for a vertical one.
[in]widthWidth in pixels of the slider.
[in]lengthLength in pixels of the slider.
[in]minValue for the left or top edge of the slider.
[in]maxValue for the right or bottom edge of the slider.
[in]colColor for the slider.
[in]cColColor for the cursor body.
[in]cBcolColor for the cursor lines.
[in]dColColor for the slider when disabled. Cursor lines and body colors are permuted in this case.
Returns
The function returns a 0 or positive integer that references the created slider, or a negative value if an error occurred.
Examples:
colorSelect.c.

◆ mrmSliderDelete()

int mrmSliderDelete ( int  idx)

This functions deletes from the system the slider whose reference number is given, releasing all associated resources. The reference number and slider slot are released for further use.

Parameters
[in]idxSlider reference number.
Returns
A negative value in case of error, positive otherwise.

◆ mrmSliderSetEnabled()

int mrmSliderSetEnabled ( int  idx,
int  enabled 
)

This functions sets the enabled state of the slider. When a slider is disabled it appears with the disabled colors and its cursor cannot be moved.

Parameters
[in]idxSlider reference number.
[in]enabled0 to disable the button, nonzero to enable.
Returns
A negative value in case of error, positive otherwise.

◆ mrmSliderSetPos()

int mrmSliderSetPos ( int  idx,
int  x,
int  y 
)

For a slider to be displayed on its screen it has to be placed on a given position. This function has to be used to place the slider at the desired x,y position on the screen.

Parameters
[in]idxSlider reference number.
[in]xHorizontal coordinate of the top left corner of the slider.
[in]yVertical coordinate of the top left corner of the slider.
Returns
A negative value in case of error, positive otherwise.
Examples:
colorSelect.c.

◆ mrmSliderSetColor()

int mrmSliderSetColor ( int  idx,
int  col,
int  cCol,
int  cBcol,
int  dCol 
)

When a slier is created it is given some colors. This function allows the user to change them during execution.

Parameters
[in]idxSlider reference number.
[in]colColor for the slider.
[in]cColColor for the cursor body.
[in]cBcolColor for the cursor lines.
[in]dColColor for the slider when disabled. Cursor lines and body colors are permuted in this case.
Returns
A negative value in case of error, positive otherwise.

◆ mrmSliderSetVal()

double mrmSliderSetVal ( int  idx,
double  val 
)

The value held by a slider is calculated by means of the linear relation among the max and min values the slider lenght and the position of the cursor. This function sets the new cursor value that most approximates the cursor value if it fits inside the slider, and return the previous value.

Parameters
[in]idxSlider reference number.
[in]valNew value for the slider. It is ignored if the calculated cursor position does not fit inside the slider.
Returns
The old value of the slider or MGS_ERRRESNOEXIST in case the button does not exist.

◆ mrmSliderGetVal()

double mrmSliderGetVal ( int  idx)

The value held by a slider is calculated by means of the linear relation among the max and min values the slider lenght and the position of the cursor. This function gets this value.

Parameters
[in]idxSlider reference number.
Returns
The value held by the slider or MGS_ERRRESNOEXIST in case the button does not exist.
Examples:
colorSelect.c.