#include "calcHsm.h"
#include <stdlib.h>
#include <stdio.h>
Functions | |
stnext | on (int signal, void *param) |
stnext | ready (int signal, void *param) |
stnext | result (int signal, void *param) |
stnext | begin (int signal, void *param) |
stnext | negated1 (int signal, void *param) |
stnext | operand1 (int signal, void *param) |
stnext | zero1 (int signal, void *param) |
stnext | int1 (int signal, void *param) |
stnext | frac1 (int signal, void *param) |
stnext | error (int signal, void *param) |
stnext | opEntered (int signal, void *param) |
stnext | negated2 (int signal, void *param) |
stnext | operand2 (int signal, void *param) |
stnext | zero2 (int signal, void *param) |
stnext | int2 (int signal, void *param) |
stnext | frac2 (int signal, void *param) |
void | calchsm_init (Ihandle *tb) |
void | calchsm_signal (int signal, void *param) |
void | zero (void) |
void | negate (void) |
void | append (char c) |
double | calc (double operand1, double operand2, char operator_) |
Variables | |
simplehsm_t | hsm = {NULL} |
Ihandle * | textbox = NULL |
BOOL | clear_on_next |
BOOL | negative |
double | _operand1 |
char | _operator |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void append | ( | char | c | ) |
Append a character to the textbox input, if the clear_on_next variable is set then clear the textbox first
c | The character to insert |
stnext begin | ( | int | signal, | |
void * | param | |||
) |
The 'begin' state functon
signal | The signal to handle | |
param | The accompaning parameter |
double calc | ( | double | operand1, | |
double | operand2, | |||
char | operator_ | |||
) |
Calculate the result of a function
operand1 | The first operand | |
operand2 | The second operand | |
operator_ | The operator (+, -, *, /) to use |
void calchsm_init | ( | Ihandle * | tb | ) |
Initialize the calc state machine
tb | The IUP textbox widget that the calc state machine will use |
void calchsm_signal | ( | int | signal, | |
void * | param | |||
) |
Send a signal to the calc state machine
signal | The signal to send | |
param | An optional parameter |
stnext error | ( | int | signal, | |
void * | param | |||
) |
The 'error' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext frac1 | ( | int | signal, | |
void * | param | |||
) |
The 'frac1' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext frac2 | ( | int | signal, | |
void * | param | |||
) |
The 'frac2' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext int1 | ( | int | signal, | |
void * | param | |||
) |
The 'int1' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext int2 | ( | int | signal, | |
void * | param | |||
) |
The 'int2' state functon
signal | The signal to handle | |
param | The accompaning parameter |
void negate | ( | void | ) |
Clear the textbox input and replace with a '-0' string also set the negative variable
stnext negated1 | ( | int | signal, | |
void * | param | |||
) |
The 'negated1' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext negated2 | ( | int | signal, | |
void * | param | |||
) |
The 'negated2' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext on | ( | int | signal, | |
void * | param | |||
) |
The 'on' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext opEntered | ( | int | signal, | |
void * | param | |||
) |
The 'opEntered' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext operand1 | ( | int | signal, | |
void * | param | |||
) |
The 'operand1' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext operand2 | ( | int | signal, | |
void * | param | |||
) |
The 'operand2' state functon
signal | The signal to handle | |
param | The accompaning parameter |
IupSetAttribute(textbox, "VALUE", "ERROR"); simplehsm_transition_state(&hsm, error);
IupSetAttribute(textbox, "VALUE", "ERROR"); simplehsm_transition_state(&hsm, error);
stnext ready | ( | int | signal, | |
void * | param | |||
) |
The 'ready' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext result | ( | int | signal, | |
void * | param | |||
) |
The 'result' state functon
signal | The signal to handle | |
param | The accompaning parameter |
void zero | ( | void | ) |
Clear the textbox input and replace with a '0' string also reset the negative variable
stnext zero1 | ( | int | signal, | |
void * | param | |||
) |
The 'zero1' state functon
signal | The signal to handle | |
param | The accompaning parameter |
stnext zero2 | ( | int | signal, | |
void * | param | |||
) |
The 'zero2' state functon
signal | The signal to handle | |
param | The accompaning parameter |
double _operand1 |
The first operand
char _operator |
The current operator
BOOL clear_on_next |
If this flag is set we clear the textbox and replace text with new character on the next signal
simplehsm_t hsm = {NULL} |
The Calc state machine object
BOOL negative |
If this flag is set the current operand will be negative
Ihandle* textbox = NULL |
The IUP textbox widget