mathmaker  0.4(alpha)
mathmaker_dev/machine/Structure.py
00001 # -*- coding: utf-8 -*-
00002 
00003 # Mathmaker creates automatically maths exercises sheets
00004 # with their answers
00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net>
00006 
00007 # This file is part of Mathmaker.
00008 
00009 # Mathmaker is free software; you can redistribute it and/or modify
00010 # it under the terms of the GNU General Public License as published by
00011 # the Free Software Foundation; either version 3 of the License, or
00012 # any later version.
00013 
00014 # Mathmaker is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 
00019 # You should have received a copy of the GNU General Public License
00020 # along with Mathmaker; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 from lib import error
00024 # ------------------------------------------------------------------------------
00025 # --------------------------------------------------------------------------
00026 # ------------------------------------------------------------------------------
00027 ##
00028 # @class Structure
00029 # @brief Not instanciable mother class of all machine objects.
00030 class Structure(object):
00031 
00032 
00033 
00034 
00035 
00036     # --------------------------------------------------------------------------
00037     ##
00038     #   @brief /!\ Must be redefined. Constructor.
00039     #   @warning Will raise an exception if not redefined
00040     #   @param embedded_machine The machine to be used
00041     #   @param **options Any options
00042     def __init__(self, language):
00043         raise error.NotInstanciableObject(self)
00044 
00045 
00046 
00047 
00048 
00049     # --------------------------------------------------------------------------
00050     ##
00051     #   @brief Returns a deep copy of the object
00052     def clone(self, language):
00053         result = object.__new__(type(self))
00054         result.__init__(language)
00055         return result
00056 
00057 
00058 
00059 
00060     # --------------------------------------------------------------------------
00061     ##
00062     #   @brief /!\ Must be redefined.
00063     #   Write the complete header of the sheet to the output.
00064     #   @warning Will raise an exception if not redefined
00065     def write_document_header(self):
00066         raise error.MethodShouldBeRedefined(self, 'write_document_header')
00067 
00068 
00069 
00070 
00071 
00072     # --------------------------------------------------------------------------
00073     ##
00074     #   @brief /!\ Must be redefined.
00075     #   Writes to the output the command to begin the document
00076     #   @warning Will raise an exception if not redefined
00077     def write_document_begins(self):
00078         raise error.MethodShouldBeRedefined(self, 'write_document_begins')
00079 
00080     ##
00081     #   @brief /!\ Must be redefined.
00082     #   Writes to the output the command displaying an exercise's title plus
00083     #   its number
00084     #   @warning Will raise an exception if not redefined
00085     def write_exercise_number(self):
00086         raise error.MethodShouldBeRedefined(self, 'write_exercise_number')
00087 
00088     ##
00089     #   @brief /!\ Must be redefined.
00090     #   Writes to the output the jump to next page command
00091     #   @warning Will raise an exception if not redefined
00092     def write_jump_to_next_page(self):
00093         raise error.MethodShouldBeRedefined(self, 'write_jump_to_next_page')
00094 
00095     ##
00096     #   @brief /!\ Must be redefined.
00097     #   Writes to the output the exercises counter reinitializing command
00098     #   @warning Will raise an exception if not redefined
00099     def reset_exercises_counter(self):
00100         raise error.MethodShouldBeRedefined(self, 'reset_exercises_counter')
00101 
00102     # --------------------------------------------------------------------------
00103     ##
00104     #   @brief Sets the font_size_offset field
00105     def set_font_size_offset(self, arg):
00106         raise error.MethodShouldBeRedefined(self, 'set_font_size_offset')
00107 
00108     # --------------------------------------------------------------------------
00109     ##
00110     #   @brief Sets the redirect_output_to_str field to True or False
00111     def set_redirect_output_to_str(self, arg):
00112         raise error.MethodShouldBeRedefined(self, 'set_redirect_output_to_str')
00113 
00114     # --------------------------------------------------------------------------
00115     ##
00116     #   @brief Gets the value of redirect_output_to_str field
00117     def redirect_output_to_str(self):
00118         raise error.MethodShouldBeRedefined(self, 'redirect_output_to_str')
00119 
00120     ##
00121     #   @brief turn the size keyword in language matching keyword
00122     #   @warning if you chose a too low or too high value as font_size_offset,
00123     #   @warning then all the text will be either tiny or Huge.
00124     def translate_font_size(self, arg):
00125         raise error.MethodShouldBeRedefined(self, 'translate_font_size')
00126 
00127 
00128     ##
00129     #   @brief /!\ Must be redefined.
00130     #   Writes to the output the end of document command
00131     #   @warning Will raise an exception if not redefined
00132     def write_document_ends(self):
00133         raise error.MethodShouldBeRedefined(self, 'write_document_ends')
00134 
00135     ##
00136     #   @brief /!\ Must be redefined.
00137     #   Writes to the output the new line command
00138     #   @warning Will raise an exception if not redefined
00139     def write_new_line(self, **options):
00140         raise error.MethodShouldBeRedefined(self, 'write_new_line')
00141 
00142     ##
00143     #   @brief /!\ Must be redefined.
00144     #   Writes to the output two commands writing two new lines
00145     #   @warning Will raise an exception if not redefined
00146     def write_new_line_twice(self, **options):
00147         raise error.MethodShouldBeRedefined(self, 'write_new_line_twice')
00148 
00149     ##
00150     #   @brief /!\ Must be redefined.
00151     #   Writes to the output the given string as a mathematical expression
00152     #   @warning Will raise an exception if not redefined
00153     def write_math_style2(self, given_string):
00154         raise error.MethodShouldBeRedefined(self, 'write_math_style2')
00155 
00156     ##
00157     #   @brief /!\ Must be redefined.
00158     #   Writes to the output the given string as a math. expression (2d option)
00159     #   @warning Will raise an exception if not redefined
00160     def write_math_style1(self, given_string):
00161         raise error.MethodShouldBeRedefined(self, 'write_math_style1')
00162 
00163     ##
00164     #   @brief /!\ Must be redefined.
00165     #   Writes to the output the given string
00166     #   @warning Will raise an exception if not redefined
00167     def write(self, given_string, **options):
00168         raise error.MethodShouldBeRedefined(self, 'write')
00169 
00170     ##
00171     #   @brief /!\ Must be redefined.
00172     #   Writes to the output the command setting the text size
00173     #   @warning Will raise an exception if not redefined
00174     def write_set_font_size_to(self, arg):
00175         raise error.MethodShouldBeRedefined(self, 'write_set_font_size_to')
00176 
00177     ##
00178     #   @brief Writes a table filled with the given [strings]
00179     #   @param size : (nb of columns, nb of lines)
00180     #   @param col_widths : [int]
00181     #   @param content : [strings]
00182     #   @options : borders=0|1|2|3... (not implemented yet)
00183     #   @options : unit='inch' etc. (check the possibilities...)
00184     def write_table(self, size, col_widths, content, **options):
00185         raise error.MethodShouldBeRedefined(self, 'write_table')
00186 
00187     ##
00188     #   @brief Writes content arranged like in a table (but can be written
00189     #   @brief without using a table)
00190     #   @param size : (nb of columns, nb of lines)
00191     #   @param col_widths : [int]
00192     #   @param content : [strings]
00193     #   @options : borders=0|1|2|3... (not implemented yet)
00194     #   @options : unit='inch' etc. (check the possibilities...)
00195     def write_layout(self, size, col_widths, content, **options):
00196         raise error.MethodShouldBeRedefined(self, 'write_layout')
00197 
00198     # --------------------------------------------------------------------------
00199     ##
00200     #   @brief /!\ Must be redefined.
00201     #   Returns a string containing the object to be displayed, according to
00202     #   the desired output format (LaTeX etc.)
00203     #   @warning Will raise an exception if not redefined
00204     def type_string(self, objct, **options):
00205         raise error.MethodShouldBeRedefined(self, 'type_string')
00206 
00207 
00208     # --------------------------------------------------------------------------
00209     ##
00210     #   @brief /!\ Must be redefined.
00211     #   Returns a string containing the object to be displayed, according to
00212     #   the desired output format (LaTeX etc.)
00213     #   @warning Will raise an exception if not redefined
00214     def insert_picture(self, drawable_arg, **options):
00215         raise error.MethodShouldBeRedefined(self, 'insert_picture')
00216 
00217 
00218 
00219     # --------------------------------------------------------------------------
00220     ##
00221     #   @brief /!\ Must be redefined.
00222     #   Returns a string containing the object to be displayed, according to
00223     #   the desired output format (LaTeX etc.)
00224     #   @warning Will raise an exception if not redefined
00225     def insert_dashed_hline(self, **options):
00226         raise error.MethodShouldBeRedefined(self, 'insert_dashed_hline')
00227 
00228 
00229 
00230 
00231     # --------------------------------------------------------------------------
00232     ##
00233     #   @brief /!\ Must be redefined.
00234     #   Returns a string containing the object to be displayed, according to
00235     #   the desired output format (LaTeX etc.)
00236     #   @warning Will raise an exception if not redefined
00237     def insert_vspace(self, **options):
00238         raise error.MethodShouldBeRedefined(self, 'insert_vspace')
00239 
00240 
00241 
00242