![]() |
mgsLib
1.3
Mermaja's Graphic Screen. A simple C library to build Windows graphic applications from console programs.
|
NumPad for the MrMWidgets. More...
Functions | |
Numeric Pad management functions | |
int | mrmNPInit (int bgCol, int nChar, void(*callBack)(void)) |
Creates the NumPad. More... | |
void | mrmNPDelete (void) |
Delete the NumPad if exists. More... | |
int | mrmNPExists (void) |
Check the existence of the NumPad. More... | |
void | mrmNPMove (int x, int y) |
Moves the NumPad to a new position. More... | |
void | mrmNPSetColors (int colKeyNum, int colKeyEsp, int colScr, int colKeyTxt, int colScrTxt, int colDisTxt) |
Sets the colors for the NumPad. More... | |
void | mrmNPGetText (char *res, int n, int *blocked) |
Gets the value on the NumPad as text. More... | |
double | mrmNPGetVal (int *blocked) |
Gets the value on the NumPad as floating point value. More... | |
int mrmNPInit | ( | int | bgCol, |
int | nChar, | ||
void(*)(void) | callBack | ||
) |
This function is used to create the NumPad. 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 NumPad. It also sets a callback function to be invoked when Ok is pressed.
[in] | bgCol | Color for the background of the NumPad window. Use a negative value for the default color. |
[in] | nChar | Maximum number of characters to be accepted by the NumPad. |
[in] | callBack | Function to be called when the text is completed -*Ok* is pressed-. If NULL no function is invoked. |
void mrmNPDelete | ( | void | ) |
This functions deletes the NumPad from the system. A new one can then be created if desired.
int mrmNPExists | ( | void | ) |
Only one NumPad can be present in the system. This function returns true if the NumPad exists, false if not.
void mrmNPMove | ( | int | x, |
int | y | ||
) |
This functions places the NumPad -top left corner- to the indicated position, without altering proportion nor contents. No bounding checks are performed.
[in] | x | Coordinate of the leftmost position. |
[in] | y | Coordinate of the top position. |
void mrmNPSetColors | ( | int | colKeyNum, |
int | colKeyEsp, | ||
int | colScr, | ||
int | colKeyTxt, | ||
int | colScrTxt, | ||
int | colDisTxt | ||
) |
When the NumPad is created default system colors are assigned for its texts and keys. This function allows the user to change them during execution.
[in] | colKeyNum | Color for numeric keys. |
[in] | colKeyEsp | Color for the special keys. |
[in] | colScr | Color for the display screen. |
[in] | colKeyTxt | Color for text on the keys. |
[in] | colScrTxt | Color for text on the display. |
[in] | colDisTxt | Color for the text on the display when it is blocked, that is, from the moment when Ok is pressed until the NumPad value is read. |
void mrmNPGetText | ( | char * | res, |
int | n, | ||
int * | blocked | ||
) |
This function can be called any time while the NumPad exists, and gets its contents as text. It can also read the bloked flag to verifiy if the user has pressed Ok. If the NumPad is blocked, reading its value deletes its contents and resets it to normal state.
[out] | res | Buffer to read the characters. Has to hold at least n + 1 bytes. |
[in] | n | Maximum number of characters to be read. |
[out] | blocked | Pointer to an integer to retrieve the blocked flag. Ignored if NULL. |
double mrmNPGetVal | ( | int * | blocked | ) |
This function can be called any time while the NumPad exists, and gets its contents as a double. Please notice that there can be precission loses if the number of characters is high. It can also read the bloked flag to verifiy if the user has pressed Ok. If the NumPad is blocked, reading its value deletes its contents and resets it to normal state.
[out] | blocked | Pointer to an integer to retrieve the blocked flag. Ignored if NULL. |