# fracbars_globals.py
"""
global variables for fracbars.py
"""
import wx
import fracbars_utils as U

### overall geometry

# width and height of frame (overall window)
FRM_WID = 900  # overriden by -w option on command line
#FRM_HGT = XX  # not needed, will use Fit() to determine height

# space between edge of appframe (outer) and frame (inner)
MARGIN = 20

# heights of fraction bars and rails
# NOTE: combo of FracBar and rail heights determine height of track
FRACBAR_HGT = 35
RAIL_SIZ = 6 # must be an even number!
RAIL_SPACER = 20 # space outside left/right rails
RAIL_START_COLOR = wx.Color(240,240,240)
RAIL_END_COLOR = wx.Color(60,60,60)

# maximum ruler calibration
MAX_RULER = 60

### flags

# flags set by cmd-line options
DEBUG = False
SUPPRESS_HINTS = False
USE_SOUNDS = True

# ways to normalize the set of numerators of the FracBars
# currently on the track
BY_USER = 1  # originally spec'd by user
BY_LCD = 2   # with FracBars' LCD as denom
BY_RULER = 3 # with current ruler as denom
AS_DECIMAL = 4 # convert fraction to decimal (for comparisons)

# processing mode for a given FracBar
# also identifies a "channel" within the track
MAIN = 0
ADD = 1
SUB = 2

# flag value to indicate that we're inside a Paint event
PAINT_EVENT = True

# maximum value for numerator and denominator spin buttons
MAX_NUM_DEN = 12

# MAX_RULER warning to be issued only once per "train"
# flag is set to True by Reset()
LCD_WARNING_ENABLE = True

### colors, fonts

# fraction bar colors
COLORS = ( wx.NamedColor("sky blue"),
           wx.NamedColor("gold"),
           wx.NamedColor("medium orchid"),
           wx.NamedColor("yellow"),
           wx.NamedColor("cadet blue"),
           wx.NamedColor("medium goldenrod"),
           wx.NamedColor("orchid"),
           wx.NamedColor("coral"),
      )

# fraction bar texture files
# this list populated IFF command-line option enables textures
TEXTURES = []
USE_BG_TEXTURES = False

RULER_BG = wx.Bitmap("wood_ruler.png")
TRACK_BG = wx.Bitmap("metal_track.png")

# overall background color: for frame and some panels
BACKGROUND_GRAY = 220
MSG_GRAY = 175
TRACK_GRAY = 205

BACKGROUND_COLOR = U.Gray(BACKGROUND_GRAY)
BACKGROUND_COLORX = wx.Color(200,10,20)  # for debug/analysis
BACKGROUND_BRUSH = wx.Brush(BACKGROUND_COLOR, wx.SOLID)

TRACK_COLOR = U.Gray(TRACK_GRAY)
TRACK_BRUSH = wx.Brush(TRACK_COLOR, wx.SOLID)

FACTORY_BRUSH = BACKGROUND_BRUSH
FACTORY_DRAW_COLOR = U.Gray(MSG_GRAY)

RULER_COLOR = wx.Color(236,188,98)
RESULT_COLOR = wx.Color(100,255,100)
RESULT_BRUSH = wx.Brush(RESULT_COLOR, wx.SOLID)

HINT_COLOR = wx.Color(100,160,50)
UNIT_DOTS = wx.Color(0, 210, 0)

# font used on buttons (and maybe other places)
STDFONT = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)

### ruler data

# INITAL VALUE: number of units (1,2,3, etc.) represented by total width of track
TRACK_UNITS = 2

# INITAL VALUE: selected ruler
RULER_UNITS = 1

# list of ruler names (e.g. "1/15")
RULER_NAMES = [ "1 / %d ths  ruler" % i
                for i in range(MAX_RULER +1) ]

# overrides: some special cases
RULER_NAMES[0] = "Error"
RULER_NAMES[1] = "units ruler"
RULER_NAMES[2] = "halves ruler"
RULER_NAMES[3] = "thirds ruler"

### messages

MSG_WINDOW_BANNER = "FracBars: Fraction Calculator"
MSG_CMDLINE_ERR_VAL_W = "Error in %s: invalid window width: '%s'"
MSG_CMDLINE_ERR_VAL_H = "Error in %s: invalid window height: '%s'"
MSG_CMDLINE_ERR_BADOPT = "Invalid command-line option"
MSG_NEGATIVE = "The result is now a negative number.\nSending the bar back to the factory."
MSG_TOO_LARGE = "The train is too long for the track.\nSending the bar back to the factory."
MSG_BAD_SUM_BANNER = "Oops!"
MSG_CANNOT_MEASURE_BANNER = "Cannot measure these fraction bars!"
MSG_REMOVE_BAR = "Send this fraction bar (%s) back to the factory?"
MSG_REMOVE_BAR_BANNER  = "Remove fraction bar from track"
MSG_FACTORY_HINT = "1. Create a set of fraction bars in the factory, and send them to the track"
MSG_RULER_HINT = '2. Find a ruler that exactly measures the "train" of bars on the track'
MSG_RESULT_HINT = "3. View the result as a fraction"
MSG_WARN_MAX_RULER = """No ruler is available to measure the current
set of fraction bars!

The LCD of the fractions (%d) exceeds the
ruler with the finest calibration (1 / %d ths)."""

# minus sign (Unicode en-dash, longer than a hyphen)
MINUS = u"\u2013"
