Documentation for calc-0.0001 (Upd Nov.28 2001)

/*    Although I am far away from thinking this calculator can be useful as an aplication for accounter,
    
    Calc Vers 0.0001     Copyright (C)   2001 Marc Dechico

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    To contact the author:	Marc Dechico
			        Kerfring
			        29390 SCAER France
				tel: 06 80 83 74 99
				Mail: Marc.DECHICO@wanadoo.fr
    
*/

USER'S GUIDE
------------
1) Requirements:
---------------
The compiled programme isn't provided: you have to compile it yourself.
To compile it just cd the installation's directory and type "make"
(you must have installed gcc with c++ and ncurses (library and developpement).
To use the compiled pgm you must have the ncurses and panel library.

2) The programmer:
------------------
I am interested in the web technics but I wanted to know C++ so I made this programme
after reading the book, as a first application in C++.
If you you are interested in this programme, either for advices (I need somes....)
or informations contact me : 

mail: 	Marc.DECHICO@wanadoo.fr

/
 
3)First Step:
-------------
This very simple  calculator is similar with calculators that accounters
have on their desk.

to call the program, cd the installation's directory and type ./calc
A sample example :
to calculate (100 + 50) / 2 = 75 
type 100 
type +
type 50
type /
type 2
type =
you should get :
_________________
!      100 +    !
!       50 /    !
!        2 =    !
!       75      !
!               !
!               !
-----------------


You can type negatives numbers
to calculate (-100 + 50) / -2 = 25 

typ c to clear the window 
type -100
type +
type 50
type /
type -2
type =
type 25
you should get :
_________________
!-     100 +    !
!       50 /    !
!-       2 =    !
!       75      !
!               !
!               !
-----------------
you can also continue the calcul after getting the result like that:
_________________
!-     100 +    !
!       50 /    !
!-       2 =    !
!       75 *    !
!      100 =    !
!      750      !
-----------------

You can type more operations than the window can contain
and  get them again by using the Page up/down and Key up/down keys
Try to type more operations to practice these keys.

You can later modify the number, its sign or the operation in case of errors.
The calculator will automatically recompute the total(s).

Supressing digits:
Put the cursor on the part  you want to mofify with the Key right/left and
the Key up/down.
the delete key suppress the number under the cursor
the backspace key suppress the number at the left of the cursor

Modifying sign:
Put the cursor on the sign.
You don't have to suppress the sign, just type the new one
Positive signs are not printed on the screen to make the negative one more evident.

Modifying operation:
Put the cursor on the operation with the .
You don't have to suppress the operation, just type the new one
4)Operation

4)Control key:
---------------
Type q 			to quit the program.
Type c 			to clear the window.
Type  r			to redraw the contenue of the window...
Type Pag dwn/up 	to get the next/previous page.
Type Key left/right 	to go to next digit to the left/right or go to 
			the next/previous field.
Type Key up/down 	to go to the next/previous cell or line.

Programmer's Guide:
-------------------

1) Requirements:
---------------
No graphic's environment is needed.
mc is very convenient in character mode (type "mc" to try)
To recompile the pgm you must (can) use gcc with the development library
for C++, ncurses, panel and make .
make is less painfull: just cd the installation directory and type make.

2)The different sources files
---------------------------
main.C 	: 	This is the entry in the programme 
glo_Def.h	:	All the class but not the class functions
Mai_Clf.C	: 	Functions owned by  Mai class. Curses Initialisation 
Cal_Clf.C	: 	Functions owned by  Cal class. It handle onee window 
Cel_Clf.C	:	The  father class for  Ope & Res 
Ope_Clf.C	: 	Functions owned by  Op  class. It handle the operation Cell
			(this is the row were the number + the operation is typed
Res_Clf.C	: 	Class function that handle the result Cell
			(this is the row were the result is printed and the operation
			is typed)
Acc_Clf.C	:	Class functions that compute the result
Makefile	:	The make source to compile and link the programme

3)The main module:
------------------
Entry in the programme.
Call the Mai Class process.

3)The Mai Class :
-----------------
Initialize the curses datas
Create the first Cal window and call the Get_Key process.
Will contain future process to create ando switch between several
windows.

4)The Cal Class process
-----------------------
This process handles one window. 

                +------------+ 
                | Mai process| ---------
                +------------+          !
         -----------!                   !
        !       +------------+          !
        !       |  Set_Cur   |          !       Put the cursor at the right place
        !       +------------+          !
        !           !                   !
        !       +------------+          !	
        !       |  get key   |          !       Get the typed key
        !       +------------+          !
        !           !                   !
        !       +------------+          !
        !       |  Call the  |          !	 
        !       |   Cell     |          !       The cell process is handled by the 
        !       |  process   |          !       Op (Operation)  or the  Rs (Result) class	
        !       +------------+          !
        !           !                   !
        !       +------------+          !
        !       |  Call the  |          !       The total is handled by the 
       /!\      |   total    |         /!\       Acc class	
        !       |  process   |          !
        !       +------------+          !
        !           !                   !
        !       +------------+          !
        !       | navigation |          !
        !       | between    |          !
        !       | cell       |          !
        !       +------------+          !
        !           !                   !
        !     N ___________Y            !
        ------- |   end ?  |------------
                -----------
5)The Cel class 
----------------
This is a virtual class father of the Ope and Res Class
with the common datas and functions.

		 
6)The Op Class process
-----------------------
This the process that handles the row were the operation is typed (-   100 +)
This row is named the Operation Cell.

Despite the name used for the process, Get_Cel doesn't get anything but 
but process the data got previously by Get_Key (a navigation key like Pag Dwn or
a digit).
If you typed a digit it will put it at the right place.
If you typed the Key left/right it will move it at the right place.
I hope...!!!!
Some keys gives the control to the calling process.

            +------------+
            | Cal process|----------
            +------------+          !
      ---------- !                  !
      !     +------------+          !	
      !     |  Get_Cel   |          !     Switch to the right field process:
     /!\    +------------+         /!\    Either the sign (Get_Sig),
      !          !                  !     the  number (Get_Nbr),
      !  Y    _____________   N     !     or the operation (Get_Ope).
      !______/ Stay in the \________!
             \    Cell ?   /    
              -------------

7)The Rs Class process
-----------------------
This class is similar to the Op class and handles the result cell (row).

But when the object is created all the cell are computed with a special 
class named Acc (this class has been created to allow to push intermediate
result if brackets are used) actually only one object is used for one window.

Of course neither the  signe or number can be typed or modified, but  the operation's
filed (to use the result for further operations).
		 
8) Problems:
------------

the programme doesn't work correctly under xterm on my computer, only the linux terminal
type is ok (need further informations or help...)
No try process for the errors.
Programming would have been less painful if I had had a better knowledge of what I wanted
to do and of what was possible to do.....

9) The future functionalities.
--------------------------------

Resizing and moving the window (some code is already include in the source).

More than one window on the creen (the Mai Class).

Different way to compute the total : either rounding the result at each step of the 
computing or compute with the maximum precision and rounding before  printing
in the window (as actually done). 

Edit code to type and print the number in different way like 100,567.2 or 100.567,2 or
100,567.23.

Permit the use of bracket to allow calculations like that: 3*(3+2)=15.