# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Wed Nov 25 10:49:41 2009

import wx
import sys

# begin wxGlade: dependencies
import wx.grid
# end wxGlade

from Grid import ResultsGrid
from Frame import Frame

# begin wxGlade: extracode

# end wxGlade

class ResultsWindow(Frame):
    def __init__(self, *args, **kwds):
        self.columns=['word','match']+kwds["columns"]
        del kwds['columns']
        self.rowcursor=0
        # begin wxGlade: ResultsWindow.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.statusbar = self.CreateStatusBar(3, 0)
        self.grid = ResultsGrid(self)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        self.InitializeGrid()
        self.Bind(wx.EVT_CLOSE, self.OnClose)

    def __set_properties(self):
        # begin wxGlade: ResultsWindow.__set_properties
        self.SetTitle("Results")
        self.SetSize((640, 480))
        self.statusbar.SetStatusWidths([-1, -1, -1])
        # statusbar fields
        statusbar_fields = ["", "", ""]
        for i in range(len(statusbar_fields)):
            self.statusbar.SetStatusText(statusbar_fields[i], i)
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: ResultsWindow.__do_layout
        resultswindow_sizer = wx.BoxSizer(wx.VERTICAL)
        resultswindow_sizer.Add(self.grid, 1, wx.EXPAND, 0)
        self.SetSizer(resultswindow_sizer)
        self.Layout()
        self.Centre()
        # end wxGlade
    
    def InitializeGrid(self):
        self.grid.SetNumberRows(0)
        self.grid.SetNumberCols(len(self.columns))
        for colnum,name in enumerate(self.columns):
            self.grid.SetColLabelValue(colnum, name.title())
        self.grid.AutoSizeColumns()
    
    def OnClose(self,event):
        parent=self.GetParent()
        parent.outputwindow=None
        parent.generator.Stop()
        parent.stop=True
        self.Destroy()
    
    def SetStatus(self, message, index=0):
        self.statusbar.SetStatusText(message, index)

    def ClearStatus(self):
        n=self.statusbar.GetFieldsCount()
        for i in range(0,n):
            self.statusbar.SetStatusText("",i)
        
# end of class ResultsWindow


