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

Selection lists for the MrMWidgets. More...

Functions

Selection lists management functions

These functions create and handle selection lists.

int mrmSelectionInit (int scr, int width, int height, int nSel, char **text, int cols, int mode)
 Creates a new selection with the given settings. More...
 
int mrmSelectionDelete (int idx)
 Delete the selection whose reference number is given. More...
 
int mrmSelectionSetEnabled (int idx, int enabled)
 Enable or disable selection. More...
 
int mrmSelectionSetPos (int idx, int x, int y)
 Places the selection at the given position on the screen. More...
 
int mrmSelectionSetOptionsPos (int idx, int *points)
 Places the options of selection at the given relative positions. More...
 
int mrmSelectionSetColor (int idx, int nCol, int bCol, int fCol, int dCol)
 Sets the colors for the selection. More...
 
int mrmSelectionSetFont (int idx, int sz, int a, char *fn, int s)
 Sets the font for the selection texts. More...
 
int mrmSelectionSetFontColor (int idx, int nCol, int sCol, int dCol, int dsCol)
 Sets the colors for the selection texts. More...
 
int mrmSelectionSetVal (int idx, int val)
 Sets the value of the selection. More...
 
int mrmSelectionGetVal (int idx)
 Reads the value of the selection. More...
 

Detailed Description

Author
Germán Fabregat
Date
October 2017

Function Documentation

◆ mrmSelectionInit()

int mrmSelectionInit ( int  scr,
int  width,
int  height,
int  nSel,
char **  text,
int  cols,
int  mode 
)

This function is used to create a selection with its options evenly displayed in several columns on a rectangle of the given width and height on the given screen. The number of options is indicated as well as an array of texts, one for each option. The working mode can be selected as being multiple or unique selection; the symbol or method for displaying the selected options can also be configured.

Parameters
[in]scrGraphic screen where the selection is placed.
[in]widthWidth in pixels of a rectangle to arrange the selection list.
[in]heightHeight in pixels of a rectangle to arrange the selection list.
[in]nSelNumber of selections.
[in]textList of texts to be displayed for each option.
[in]colsNumber of columns to arrange the selections. If not valid -0, negative or greater than the number of options- a list of points has to be passed later.
[in]modeSpecifies the selection mode -unique or multiple selection, by oring one of MWG_SCUNIQUE or MWG_SCMULTI- and the display mode -oring one of MWG_SCROUND, MWG_SCSQUARE, MWG_SCSYMBOL or MWG_SCNONE-. If one of the first two is used, a size for the box has to be ored in the lower byte of the parameter; if MWG_SCSYMBOL is used, the character to be used is ored in the low byte.
Returns
The function returns a 0 or positive integer that references the created selection, or a negative value if an error occurred.
Examples:
colorStar.c.

◆ mrmSelectionDelete()

int mrmSelectionDelete ( int  idx)

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

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

◆ mrmSelectionSetEnabled()

int mrmSelectionSetEnabled ( int  idx,
int  enabled 
)

This functions sets the enabled state of the Selection. When a selection is disabled it appears with the disabled colors and cannot be cliked.

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

◆ mrmSelectionSetPos()

int mrmSelectionSetPos ( int  idx,
int  x,
int  y 
)

For a selection to be displayed on its screen it has to be placed on a given position. This function has to be used to place the selection at the desired x,y position on the screen. All item coordinates are to be relative to this point.

Parameters
[in]idxSelection reference number.
[in]xHorizontal coordinate of the top left corner of the selection.
[in]yVertical coordinate of the top left corner of the Selection.
Returns
A negative value in case of error, positive otherwise.
Examples:
colorStar.c.

◆ mrmSelectionSetOptionsPos()

int mrmSelectionSetOptionsPos ( int  idx,
int *  points 
)

This function allows individual placement of each option for a selection. The positions are relative to the position of the selection. All item coordinates are be relative to this point.

Parameters
[in]idxSelection reference number.
[in]pointsVector of x, y coordinates for each selection option.
Returns
A negative value in case of error, positive otherwise.
Examples:
colorStar.c.

◆ mrmSelectionSetColor()

int mrmSelectionSetColor ( int  idx,
int  nCol,
int  bCol,
int  fCol,
int  dCol 
)

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

Parameters
[in]idxSelection reference number.
[in]nColColor for the selection figure.
[in]bColColor for the selection figure border.
[in]fColColor for the selection figure fill when selected.
[in]dColColor for the selection figure when disabled.
Returns
A negative value in case of error, positive otherwise.

◆ mrmSelectionSetFont()

int mrmSelectionSetFont ( int  idx,
int  sz,
int  a,
char *  fn,
int  s 
)

When a selection is created its texts are assigned default font and colors. This function allows to set the font for the texts.

Parameters
[in]idxSelection reference number.
[in]szSize of the font.
[in]aRotation angle in degrees.
[in]fnPointer to a string containing the font name. If it is NULL the standard font is used.
[in]sStyle of the font. The three lower bits mean from 0 to 2 italic, underline and strikeout. The higher bits a weight ranging from 0 to 1000. The constants MGS_ITALIC, MGS_UNDERLINE and MGS_STRIKEOUT can be ored to form the lower three bits. MGS_LIGHT, MGS_BOLD and MGS_HEAVY are three predefined values for the weight that can also be ored.
Returns
A negative value in case of error, positive otherwise.
Examples:
colorStar.c.

◆ mrmSelectionSetFontColor()

int mrmSelectionSetFontColor ( int  idx,
int  nCol,
int  sCol,
int  dCol,
int  dsCol 
)

When a selection is created its texts are assigned default font and colors. This function allows to set colors for the texts. In case no change is wanted for the selected options text, just use the same colors.

Parameters
[in]idxSelection reference number.
[in]nColColor for the text when not selected.
[in]sColColor for the text when selected.
[in]dColColor for the text when not selected and the selection is disabled.
[in]dsColColor for the text when selected and the selection is disabled.
Returns
A negative value in case of error, positive otherwise.
Examples:
colorStar.c.

◆ mrmSelectionSetVal()

int mrmSelectionSetVal ( int  idx,
int  val 
)

Each selection holds a value that represents the selected options. This function sets the value and returns the previous one. No correctness verification is performed.

Parameters
[in]idxSelection reference number.
[in]valNew value for the selection.
Returns
The old value of the selection or MGS_ERRRESNOEXIST in case the selection does not exist.

◆ mrmSelectionGetVal()

int mrmSelectionGetVal ( int  idx)

Each selection holds a value that represents the selected options. This function gets this value.

Parameters
[in]idxSelection reference number.
Returns
The value of the selection or MGS_ERRRESNOEXIST in case the selection does not exist.
Examples:
colorStar.c.