# fracbars_help.py

release_history = """
1.0.0: 10-Apr-07: emailed to A. Judkis
1.0.1: 15-Apr-07: fading of palette message, using threading module
1.0.2: 16-Apr-07: work on help text
1.0.3: 16-Apr-07: refactoring" "globals" module overused
1.0.4: 17-Apr-07: "rails" on track, delete bar --> send back to factory
1.0.5: 18-Apr-07: using clipping to fix use of metallic bitmap file
1.0.6: 18-Apr-07: fix memory leak with wx.Effects
1.0.7: 16-Apr-07: use img2py to store images as strings, not Windows .bmp files
1.0.8: 27-Apr-07: rework fading (now it's in, not out) using threads and locks
                  use wx.Sound
1.0.10: 1-May-07: left and right rails on track, no more fading of hints
1.0.11: 2-May-07: unit length work
1.0.12: 7-May:07: redo layout and hints
1.0.13: 11-May-07: add checkbox for auto-display of result

1.1.0: 16-May-07:
         rework images, including bar textures
         no more fracbars_images.py
         help tab for command-line options
1.1.1: 18-May-07: rework DCs, trying to eliminate Mac "nested DCs" bug
1.1.2: 30-May-07: errors send bars back to factory
1.1.3: 8-Mar-08: splash screen
1.1.4: 16-Feb-09, 8-Apr-09: some refactoring, better use of layout tools,
         optparse module, tweak help window
"""

__date__ = '8-Apr-2009'
__version__ = "1.1.4"

import wx
import fracbars_globals as G

DSIZ = wx.DefaultSize
DPOS = wx.DefaultPosition

ovw_text = """
FracBars: Fraction Calculator

Version %s
%s
""" % (__version__, __date__)

pg1_text = """
At the top of the window, use the arrows to set the
numerator and denominator of a fraction. This
builds a fraction bar in the "factory" next to
the fraction. Use the "Send bar to track" button to
load the fraction bar onto the gray track in the middle
of the window.

Create one or more additional fraction bars and send
them to the track in the same way. As you add bars to
the track, they form a "train".

What about the "Send bar (subtract)" button? Instead of
adding the new bar to the end of the train, this button
subtracts the bar from the current train. What does that
mean? Give it a try -- you'll see.

In this release, you can send only one fraction bar to
the track with the "subtract" button. After you do this,
you cannot send any more fraction bars to the track.

Extras:

1. Click on any of the fraction bars currently on the
track to remove that bar from the track and send it
back to the "factory".
"""

pg2_text = """
The "train" of fraction bars on the track represents an
addition problem -- maybe with a subtraction thrown in
at the end. The length of the train is the sum of the
fractions.

To determine the answer to the problem, find a ruler
that measures the train exactly. Use the arrow button
at the left of the ruler to switch rulers until you
find an appropriate one. There might be more than one
such ruler.

The calculator gives you some help -- when you select an
appropriate ruler, a beep sounds and the ruler
tick-marks that provide the exact measurements turn RED.

Extras:

1. Hold down the <Ctrl> key and click anywhere in the
track to "rotate" the bars: the first bar moves to the
end of the train. (This doesn't work if the last bar
is a "subtract" bar.)

"""

pg3_text = """
When you've found an appropriate ruler, click the
"Show result" button. This displays both the fraction
addition/subtraction problem and the answer next to
the button.

If you check the "Show automatically" checkbox below the
"Show result" button, you don't need to press the button
at all. Whenever a valid ruler is selected, the calculator
updates the result automatically.

Use the "Clear" button to empty both the factory and the
track, and to unload the curent ruler. That makes it easy
to start over again.

Extras:

1. Try measuring a train that has just one fraction bar.
You can find many rulers that measure this bar -- these
measurements represent a family of equivalent fractions.
"""

# these values will be used by optparse() cmd-line processing, also
W_OPT = "set the window width (in pixels)"
N_OPT = "don't display usage hints at startup"
S_OPT = "don't use sounds"
T_OPT = "use textures for fraction bars, instead of solid colors"
D_OPT = "send debugging information to the command window"

pg_opts_text = """
If you start the Fraction Calculator by typing a command
line (instead of point-and-click), you can include options
on the command line. Example:

   python fracbars.py -w 1050 -n

The following options are available:

-w WIDTH
       %s

-n     %s

-s     %s

-t     %s

-d     %s
""" % (W_OPT, N_OPT, S_OPT, T_OPT, D_OPT)

class HelpNtbk(wx.Notebook):
    """
    show help window in multi-page Notebook
    """
    def __init__(self, parent, posn=DPOS, size=DSIZ):
        wx.Notebook.__init__(self, parent, -1, posn, size)

        # overview
        ovw = wx.Panel(self, -1)
        self.AddPage(ovw, "About")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        ovw.SetSizer(sizer)
        ovw_ctrl = wx.StaticText(ovw, -1, ovw_text,
                             DPOS, DSIZ, wx.ALIGN_CENTER_HORIZONTAL)
        ovw_ctrl.SetFont(wx.Font(16, wx.ROMAN, wx.NORMAL, wx.BOLD))
        ovw_ctrl.SetForegroundColour(wx.BLUE)
        sizer.Add(ovw_ctrl, 1, wx.EXPAND)
        sizer.Layout()
        ovw.Fit()

        # page 1
        pg1 = wx.Panel(self)
        self.AddPage(pg1, "Step 1")
        pg1_ctrl = wx.StaticText(pg1, -1, pg1_text)

        # page 2
        pg2 = wx.Panel(self)
        self.AddPage(pg2, "Step 2")
        pg2_ctrl = wx.StaticText(pg2, -1, pg2_text)

        # page 3
        pg3 = wx.Panel(self)
        self.AddPage(pg3, "Step 3")
        pg3_ctrl = wx.StaticText(pg3, -1, pg3_text)

        # options page
        pg_opts = wx.Panel(self)
        self.AddPage(pg_opts, "Command-Line Options")
        pg_opts_ctrl = wx.StaticText(pg_opts, -1, pg_opts_text)

        # set font on all non-overview pages
        for p in [pg1_ctrl, pg2_ctrl, pg3_ctrl, pg_opts_ctrl]:
            p.SetFont(wx.Font(12, wx.ROMAN, wx.NORMAL, wx.NORMAL))

class HelpDlg(wx.Dialog):
    def __init__(self):
        wx.Dialog.__init__(self, None, -1, "Fraction Bars Help")

        # create notebook
        hlp = HelpNtbk(self, DPOS, DSIZ)

        # create ID_OK button: clicking this automatically closes dialog
        # (no event-handler needed)
        btn = wx.Button(self, wx.ID_OK, "Close")
        btn.SetFont(G.STDFONT)
        btn.SetDefault()

        # arrange vertically
        box = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(box)
        box.Add(hlp, 0)
        box.Add((9.9,5))
        box.Add(btn, 0, wx.ALIGN_CENTER)
        box.Add((9.9,5))
        
        self.Layout()
        self.Fit()
