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

Keyboard for the MrMWidgets. More...

Functions

Keyboard management functions

These functions create and handle the Keyboard.

int mrmKeyboardInit (int bgCol, int nChar, void(*callBack)(void))
 Creates the Keyboard. More...
 
void mrmKeyboardDelete (void)
 Delete the Keyboard if exists. More...
 
int mrmKeyboardExists (void)
 Check the existence of the Keyboard. More...
 
void mrmKeyboardMove (int x, int y)
 Moves the Keyboard to a new position. More...
 
void mrmKeyboardSetColors (int colKeyChar, int colKeyEsp, int colAltOff, int colAltOn, int colScr, int colKeyTxt, int colScrTxt, int colDisTxt)
 Sets the colors for the Keyboard. More...
 
void mrmKeyboardGetText (char *res, int *blocked)
 Gets the text on the Keyboard. More...
 

Detailed Description

Author
Germán Fabregat
Date
October 2017

Function Documentation

◆ mrmKeyboardInit()

int mrmKeyboardInit ( int  bgCol,
int  nChar,
void(*)(void)  callBack 
)

This function is used to create the Keyboard. Only one can be present in the system, so the call will fail if one already exists. The function sets the background color and max. number of characters accepted by the Keyboard. It also sets a callback function to be invoked when Ok is pressed.

Parameters
[in]bgColColor for the background of the Keyboard window. Use a negative value for the default color.
[in]nCharMaximum number of characters to be accepted by the Keyboard.
[in]callBackFunction to be called when the text is completed -*Ok* is pressed-. If NULL no function is invoked.
Returns
The function returns a 0 or positive integer that references the NumPad screen, or a negative value if an error occurred.

◆ mrmKeyboardDelete()

void mrmKeyboardDelete ( void  )

This functions deletes the Keyboard from the system. A new one can then be created if desired.

◆ mrmKeyboardExists()

int mrmKeyboardExists ( void  )

Only one Keyboard can be present in the system. This function returns true if the Keyboard exists, false if not.

Returns
The function returns 1 if the Keyboard exists, 0 if not.

◆ mrmKeyboardMove()

void mrmKeyboardMove ( int  x,
int  y 
)

This functions places the Keyboard -top left corner- to the indicated position, without altering proportion nor contents. No bounding checks are performed.

Parameters
[in]xCoordinate of the leftmost position.
[in]yCoordinate of the top position.

◆ mrmKeyboardSetColors()

void mrmKeyboardSetColors ( int  colKeyChar,
int  colKeyEsp,
int  colAltOff,
int  colAltOn,
int  colScr,
int  colKeyTxt,
int  colScrTxt,
int  colDisTxt 
)

When the Keyboard is created default system colors are assigned for its texts and keys. This function allows the user to change them during execution.

Parameters
[in]colKeyCharColor for the character keys.
[in]colKeyEspColor for the special keys.
[in]colAltOffColor for the alternate character set key when is not active.
[in]colAltOnColor for the alternate character set key when is active.
[in]colScrColor for the display screen.
[in]colKeyTxtColor for text on the keys.
[in]colScrTxtColor for text on the display.
[in]colDisTxtColor for the text on the display when it is blocked, that is, from the moment when Ok is pressed until the Keyboard value is read.

◆ mrmKeyboardGetText()

void mrmKeyboardGetText ( char *  res,
int *  blocked 
)

This function can be called any time while the Keyboard exists, and gets its contents as text. It can also read the bloked flag to verifiy if the user has pressed Ok. If the Keyboard is blocked, reading its value deletes its contents and resets it to normal state.

Parameters
[out]resBuffer to read the characters. Has to hold at least the max. number of characters of the keyboard + 1 bytes.
[out]blockedPointer to an integer to retrieve the blocked flag. Ignored if NULL.