1 /* 2 * Copyright (C) 1987-2008 Sun Microsystems, Inc. All Rights Reserved. 3 * Copyright (C) 2008-2011 Robert Ancell 4 * 5 * This program is free software: you can redistribute it and/or modify it under 6 * the terms of the GNU General Public License as published by the Free Software 7 * Foundation, either version 2 of the License, or (at your option) any later 8 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the 9 * license. 10 */ 11 12 #ifndef MATH_EQUATION_H 13 #define MATH_EQUATION_H 14 15 #include <glib-object.h> 16 #include <gtk/gtk.h> 17 18 #include "mp.h" 19 #include "math-variables.h" 20 #include "mp-serializer.h" 21 22 G_BEGIN_DECLS 23 24 #define MATH_TYPE_EQUATION (math_equation_get_type ()) 25 #define MATH_EQUATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), math_equation_get_type(), MathEquation)) 26 #define MATH_EQUATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MATH_TYPE_EQUATION, MathEquationClass)) 27 28 typedef struct MathEquationPrivate MathEquationPrivate; 29 30 typedef struct 31 { 32 GtkTextBuffer parent_instance; 33 MathEquationPrivate *priv; 34 } MathEquation; 35 36 typedef struct 37 { 38 GtkTextBufferClass parent_class; 39 } MathEquationClass; 40 41 typedef enum { 42 NORMAL, 43 SUPERSCRIPT, 44 SUBSCRIPT 45 } NumberMode; 46 47 GType math_equation_get_type(void); 48 MathEquation *math_equation_new(void); 49 50 MathVariables *math_equation_get_variables(MathEquation *equation); 51 52 gunichar math_equation_get_digit_text(MathEquation *equation, guint digit); 53 54 void math_equation_set_status(MathEquation *equation, const gchar *status); 55 const gchar *math_equation_get_status(MathEquation *equation); 56 57 gboolean math_equation_is_empty(MathEquation *equation); 58 gboolean math_equation_is_result(MathEquation *equation); 59 gchar *math_equation_get_display(MathEquation *equation); 60 gchar *math_equation_get_equation(MathEquation *equation); 61 gboolean math_equation_get_number(MathEquation *equation, MPNumber *z); 62 63 void math_equation_set_number_mode(MathEquation *equation, NumberMode mode); 64 NumberMode math_equation_get_number_mode(MathEquation *equation); 65 66 void math_equation_set_accuracy(MathEquation *equation, gint accuracy); 67 gint math_equation_get_accuracy(MathEquation *equation); 68 69 void math_equation_set_show_thousands_separators(MathEquation *equation, gboolean visible); 70 gboolean math_equation_get_show_thousands_separators(MathEquation *equation); 71 72 void math_equation_set_show_trailing_zeroes(MathEquation *equation, gboolean visible); 73 gboolean math_equation_get_show_trailing_zeroes(MathEquation *equation); 74 75 void math_equation_set_number_format(MathEquation *equation, MpDisplayFormat format); 76 MpDisplayFormat math_equation_get_number_format(MathEquation *equation); 77 78 void math_equation_set_base(MathEquation *equation, gint base); 79 gint math_equation_get_base(MathEquation *equation); 80 81 void math_equation_set_word_size(MathEquation *equation, gint word_size); 82 gint math_equation_get_word_size(MathEquation *equation); 83 84 void math_equation_set_angle_units(MathEquation *equation, MPAngleUnit angle_unit); 85 MPAngleUnit math_equation_get_angle_units(MathEquation *equation); 86 87 void math_equation_set_source_currency(MathEquation *equation, const gchar *currency); 88 const gchar *math_equation_get_source_currency(MathEquation *equation); 89 90 void math_equation_set_target_currency(MathEquation *equation, const gchar *currency); 91 const gchar *math_equation_get_target_currency(MathEquation *equation); 92 93 void math_equation_set_source_units(MathEquation *equation, const gchar *units); 94 const gchar *math_equation_get_source_units(MathEquation *equation); 95 96 void math_equation_set_target_units(MathEquation *equation, const gchar *units); 97 const gchar *math_equation_get_target_units(MathEquation *equation); 98 99 gboolean math_equation_in_solve(MathEquation *equation); 100 101 const MPNumber *math_equation_get_answer(MathEquation *equation); 102 MpSerializer *math_equation_get_serializer(MathEquation *equation); 103 104 void math_equation_copy(MathEquation *equation); 105 void math_equation_paste(MathEquation *equation); 106 void math_equation_undo(MathEquation *equation); 107 void math_equation_redo(MathEquation *equation); 108 void math_equation_store(MathEquation *equation, const gchar *name); 109 void math_equation_recall(MathEquation *equation, const gchar *name); 110 void math_equation_set(MathEquation *equation, const gchar *text); 111 void math_equation_set_number(MathEquation *equation, const MPNumber *x); 112 void math_equation_insert(MathEquation *equation, const gchar *text); 113 void math_equation_insert_digit(MathEquation *equation, guint digit); 114 void math_equation_insert_numeric_point(MathEquation *equation); 115 void math_equation_insert_number(MathEquation *equation, const MPNumber *x); 116 void math_equation_insert_subtract(MathEquation *equation); 117 void math_equation_insert_exponent(MathEquation *equation); 118 void math_equation_solve(MathEquation *equation); 119 void math_equation_factorize(MathEquation *equation); 120 void math_equation_delete(MathEquation *equation); 121 void math_equation_backspace(MathEquation *equation); 122 void math_equation_clear(MathEquation *equation); 123 void math_equation_shift(MathEquation *equation, gint count); 124 void math_equation_toggle_bit(MathEquation *equation, guint bit); 125 126 G_END_DECLS 127 128 #endif /* MATH_EQUATION_H */ 129