# -*- coding: iso-8859-1 -*-

# Inclusion des librairies standards et spécifiques
import wx
import os
import scicalc_param as param
import base.version as version

#------------------------------------------------------------------------------
class MyAboutScreen(object):
  """
  Create an about dialog.
  """
  #----------------------------------------------
  def __init__(self, parent):
    self.parent = parent
    self.titre = parent.__titre__

    self.dialog = wx.Dialog(self.parent, -1, "A propos de %s" % self.titre)

  #----------------------------------------------
  def show(self):
    self.dialog.SetBackgroundColour(wx.WHITE)

    panel = wx.Panel(self.dialog, -1)
    panel.SetBackgroundColour(wx.WHITE)

    panelSizer = wx.BoxSizer(wx.VERTICAL)

    boldFont = wx.Font(panel.GetFont().GetPointSize(),
                      panel.GetFont().GetFamily(),
                      wx.NORMAL, wx.BOLD)

    filename = os.path.join(param.scicalc_dir, 'images', 'AboutBox_200x48.png')
    logo = wx.StaticBitmap(panel, -1, wx.Image(name = filename).ConvertToBitmap())

    lab1 = wx.StaticText(panel, -1, "%s" % self.titre)
    lab1.SetFont(wx.Font(36, boldFont.GetFamily(), wx.ITALIC, wx.BOLD))
    lab1.SetSize(lab1.GetBestSize())

    imageSizer = wx.BoxSizer(wx.HORIZONTAL)
    imageSizer.Add(logo, 0, wx.ALL | wx.ALIGN_CENTRE_VERTICAL, 5)
    imageSizer.Add(lab1, 0, wx.ALL | wx.ALIGN_CENTRE_VERTICAL, 5)

    lab2 = wx.StaticText(panel, -1, "Calculateur Scientifique OpenSource v %s" % version.getVersion())
    lab2.SetFont(boldFont)
    lab2.SetSize(lab2.GetBestSize())

    lab3 = wx.StaticText(panel, -1, "%s est totalement gratuit, vous" % self.titre)
    lab3.SetFont(boldFont)
    lab3.SetSize(lab3.GetBestSize())

    lab4 = wx.StaticText(panel, -1, "pouvez l'utilisez et le modifier comme vous le souhaitez.")
    lab4.SetFont(boldFont)
    lab4.SetSize(lab4.GetBestSize())

    lab5 = wx.StaticText(panel, -1, "Auteur : chris_94100@users.sourceforge.net")
    lab5.SetFont(boldFont)
    lab5.SetSize(lab5.GetBestSize())

    btnOK = wx.Button(panel, wx.ID_OK, "OK")

    panelSizer.Add(imageSizer, 0, wx.ALIGN_CENTRE)
    panelSizer.Add((10, 10)) # Spacer.
    panelSizer.Add(lab2, 0, wx.ALIGN_CENTRE)
    panelSizer.Add((10, 10)) # Spacer.
    panelSizer.Add(lab3, 0, wx.ALIGN_CENTRE)
    panelSizer.Add(lab4, 0, wx.ALIGN_CENTRE)
    panelSizer.Add((10, 10)) # Spacer.
    panelSizer.Add(lab5, 0, wx.ALIGN_CENTRE)
    panelSizer.Add((10, 10)) # Spacer.
    panelSizer.Add(btnOK, 0, wx.ALL | wx.ALIGN_CENTRE, 5)

    panel.SetAutoLayout(True)
    panel.SetSizer(panelSizer)
    panelSizer.Fit(panel)

    topSizer = wx.BoxSizer(wx.HORIZONTAL)
    topSizer.Add(panel, 0, wx.ALL, 10)

    self.dialog.SetAutoLayout(True)
    self.dialog.SetSizer(topSizer)
    topSizer.Fit(self.dialog)

    self.dialog.Centre()

    btn = self.dialog.ShowModal()
    self.dialog.Destroy()
