GTK+/Kalkulator 0.0.1 - kalkulator.hpp
< GTK+
#include <gtk/gtk.h>
enum btn_id
{
Button_1 = 1, Button_2 = 2, Button_3 = 3, Button_4 = 4, Button_5 = 5,
Button_6 = 6, Button_7 = 7, Button_8 = 8, Button_9 = 9, Button_0 = 0,
Button_add = 10, Button_sub = 11, Button_multi = 12, Button_div = 13,
Button_result = 14,
Button_comma = 15, Button_back = 16, Button_clear = 17,Button_signed = 18,
Button_addmem = 19, Button_readmem =20, Button_clearmem=21,
NoSelectBtn = 22
};
enum operation_id
{
Add = 1, Sub = 2, Multi = 3, Div = 4, NoSelectOprt = 5
};
class Kalkulator
{
private:
GString *value1;
GString *value2;
operation_id operation;
operation_id prev_operation;
gboolean is_value1;
gboolean is_value2;
gboolean is_result;
btn_id prev_button;
// wykorzystywany do śledzenia poprzednio wciśniętych przycisków
// (prev_button przechwuje tylko ostatnio wciśnięte)
btn_id button_cache_comma;
btn_id button_cache_result;
GList *memory;
public:
Kalkulator();
~Kalkulator();
const char* _btn_id_to_char(btn_id val);
const char* _operation_id_to_char(operation_id val);
btn_id _operation_id_to_btn_id(operation_id val);
void __debug(const gchar* event,bool data);
void calculate(bool);
char* get_value1();
void set_value1(const gchar *val);
bool del_value1();
char* get_value2();
void set_value2(const gchar *val);
bool del_value2();
bool get_is_value1() {return is_value1;};
void set_is_value1(bool val) {is_value1=val;};
bool get_is_value2() {return is_value2;};
void set_is_value2(bool val) {is_value2=val;};
bool get_is_result() {return is_result;};
void set_is_result(bool val) {is_result=val;};
operation_id get_operation() {return operation;};
void set_operation(operation_id val) {operation=val;};
operation_id get_prev_operation() {return prev_operation;};
void set_prev_operation(operation_id val) {prev_operation=val;};
inline btn_id get_button_cache_result() {return button_cache_result;};
inline void set_button_cache_result(btn_id val) {button_cache_result=val;};
btn_id get_prev_button() {return prev_button;};
void set_prev_button(btn_id val) {prev_button=val;};
inline btn_id get_button_cache_comma() {return button_cache_comma;};
inline void set_button_cache_comma(btn_id val) {button_cache_comma=val;};
void add_to_memory(const gchar *val);
void memory_free();
void memory_print();
guint memory_count();
};