Index: src/sas/guiframe/report_dialog.py
===================================================================
--- src/sas/guiframe/report_dialog.py	(revision e8bb5b62d717c7b44481a4b621030699e4efdaf4)
+++ src/sas/guiframe/report_dialog.py	(revision e8bb5b62d717c7b44481a4b621030699e4efdaf4)
@@ -0,0 +1,144 @@
+"""
+    Base class for reports. Child classes will need to implement
+    the onSave() method.
+"""
+import wx
+import logging
+import sys
+import wx.html as html
+
+ISPDF = False
+if sys.platform == "win32":
+    _STATICBOX_WIDTH = 450
+    PANEL_WIDTH = 500 
+    PANEL_HEIGHT = 700
+    FONT_VARIANT = 0
+    ISPDF = True
+elif sys.platform == "darwin":
+    _STATICBOX_WIDTH = 480
+    PANEL_WIDTH = 530
+    PANEL_HEIGHT = 700
+    FONT_VARIANT = 1
+    ISPDF = True
+
+class BaseReportDialog(wx.Dialog):
+    
+    def __init__(self, report_list, *args, **kwds):
+        """
+        Initialization. The parameters added to Dialog are:
+        
+        :param report_list: list of html_str, text_str, image for report
+        """
+        kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE
+        super(BaseReportDialog, self).__init__(*args, **kwds)
+        kwds["image"] = 'Dynamic Image'
+
+        # title
+        self.SetTitle("Report")
+        # size
+        self.SetSize((720, 650))
+        # font size
+        self.SetWindowVariant(variant=FONT_VARIANT)
+        # check if tit is MAC
+        self.is_pdf = ISPDF
+        # report string
+        self.report_list = report_list
+        # wild card
+        # pdf supporting only on MAC
+        if self.is_pdf:
+            self.wild_card = ' PDF files (*.pdf)|*.pdf|'
+            self.index_offset = 0
+        else:
+            self.wild_card = ''
+            self.index_offset = 1
+        self.wild_card += 'HTML files (*.html)|*.html|'
+        self.wild_card += 'Text files (*.txt)|*.txt'
+
+    def _setup_layout(self):
+        """
+        Set up layout
+        """
+        hbox = wx.BoxSizer(wx.HORIZONTAL)
+        
+        # buttons
+        button_close = wx.Button(self, wx.ID_OK, "Close")
+        button_close.SetToolTipString("Close this report window.")
+        hbox.Add(button_close)
+        button_close.SetFocus()
+
+        button_preview = wx.Button(self, wx.NewId(), "Preview")
+        button_preview.SetToolTipString("Print preview this report.")
+        button_preview.Bind(wx.EVT_BUTTON, self.onPreview,
+                            id=button_preview.GetId()) 
+        hbox.Add(button_preview)
+
+        button_print = wx.Button(self, wx.NewId(), "Print")
+        button_print.SetToolTipString("Print this report.")
+        button_print.Bind(wx.EVT_BUTTON, self.onPrint,
+                          id=button_print.GetId())
+        hbox.Add(button_print)
+        
+        button_save = wx.Button(self, wx.NewId(), "Save")
+        button_save.SetToolTipString("Save this report.")
+        button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId())
+        hbox.Add(button_save)
+        
+        # panel for report page
+        vbox = wx.BoxSizer(wx.VERTICAL)
+        # html window
+        self.hwindow = html.HtmlWindow(self, style=wx.BORDER)
+        # set the html page with the report string
+        self.hwindow.SetPage(self.report_html)
+        
+        # add panels to boxsizers
+        vbox.Add(hbox)
+        vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)
+
+        self.SetSizer(vbox)
+        self.Centre()
+        self.Show(True)
+
+    def onPreview(self, event=None):
+        """
+        Preview
+        : event: Preview button event
+        """
+        previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)
+        previewh.PreviewText(self.report_html)
+        
+    def onPrint(self, event=None):
+        """
+        Print
+        : event: Print button event
+        """
+        printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)
+        printh.PrintText(self.report_html)
+
+    def OnClose(self, event=None):
+        """
+        Close the Dialog
+        : event: Close button event
+        """
+        self.Close()
+    
+    def HTML2PDF(self, data, filename):
+        """
+        Create a PDF file from html source string.
+        Returns True is the file creation was successful. 
+        : data: html string
+        : filename: name of file to be saved
+        """
+        try:
+            from xhtml2pdf import pisa
+            # open output file for writing (truncated binary)
+            resultFile = open(filename, "w+b")
+            # convert HTML to PDF
+            pisaStatus = pisa.CreatePDF(data, dest=resultFile)
+            # close output file
+            resultFile.close()
+            self.Update()
+            return pisaStatus.err
+        except:
+            logging.error("Error creating pdf: %s" % sys.exc_value)
+        return False
+
Index: src/sas/perspectives/fitting/report_dialog.py
===================================================================
--- src/sas/perspectives/fitting/report_dialog.py	(revision 4ec242ef37ff5f92d91a892156e04d092559af32)
+++ src/sas/perspectives/fitting/report_dialog.py	(revision e8bb5b62d717c7b44481a4b621030699e4efdaf4)
@@ -14,61 +14,35 @@
 
 import wx
-import sys
 import os
 import wx.html as html
-import logging
 
-_STATICBOX_WIDTH = 480
-PANEL_WIDTH = 530
-PANEL_HEIGHT = 700
-FONT_VARIANT = 1
-ISMAC = False
-ISPDF = False
-if sys.platform == "win32":
-    _STATICBOX_WIDTH = 450
-    PANEL_WIDTH = 500
-    PANEL_HEIGHT = 700
-    FONT_VARIANT = 0
-    ISMAC = False
-    ISPDF = True
-elif sys.platform == "darwin":
-    ISMAC = True
-    ISPDF = True
+from sas.guiframe.report_dialog import BaseReportDialog
 
-        
-class ReportDialog(wx.Dialog):
+class ReportDialog(BaseReportDialog):
     """
     The report dialog box.
     """
     
-    def __init__(self, list, *args, **kwds):
+    def __init__(self, report_list, *args, **kwds):
         """
         Initialization. The parameters added to Dialog are:
         
-        :param list: report_list (list of html_str, text_str, image)
+        :param report_list: list of html_str, text_str, image
         from invariant_state
         """
-        kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE
-        wx.Dialog.__init__(self, *args, **kwds)
-        kwds["image"] = 'Dynamic Image'
+        super(ReportDialog, self).__init__(report_list, *args, **kwds)
+
         # title
         self.SetTitle("Report: Fitting")
-        # size
-        self.SetSize((720, 650))
-        # font size
-        self.SetWindowVariant(variant=FONT_VARIANT)
-        # check if tit is MAC
-        self.is_pdf = ISPDF
-        # report string
-        self.report_list = list
+
         # number of images of plot
-        self.nimages = len(list[2])
+        self.nimages = len(self.report_list[2])
         
-        if list[2] != None:
+        if self.report_list[2] != None:
             # put image path in the report string
-            if len(list[2]) == 1:
+            if len(self.report_list[2]) == 1:
                 self.report_html = self.report_list[0] % \
                                     "memory:img_fit0.png"
-            elif len(list[2]) == 2:
+            elif len(self.report_list) == 2:
                 self.report_html = self.report_list[0] % \
                                     ("memory:img_fit0.png",
@@ -85,71 +59,11 @@
         self._setup_layout()
         
-    def _setup_layout(self):
-        """
-        Set up layout
-        """
-        hbox = wx.BoxSizer(wx.HORIZONTAL)
-        
-        # buttons
-        id = wx.ID_OK
-        button_close = wx.Button(self, id, "Close")
-        button_close.SetToolTipString("Close this report window.")
-        #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0)
-        hbox.Add(button_close)
-        button_close.SetFocus()
-
-        id = wx.NewId()
-        button_preview = wx.Button(self, id, "Preview")
-        button_preview.SetToolTipString("Print preview this report.")
-        button_preview.Bind(wx.EVT_BUTTON, self.onPreview,
-                            id=button_preview.GetId()) 
-        hbox.Add(button_preview)
-
-        id = wx.NewId()
-        button_print = wx.Button(self, id, "Print")
-        button_print.SetToolTipString("Print this report.")
-        button_print.Bind(wx.EVT_BUTTON, self.onPrint,
-                          id=button_print.GetId())
-        hbox.Add(button_print)
-        
-        id = wx.NewId()
-        button_save = wx.Button(self, id, "Save")
-        button_save.SetToolTipString("Save this report.")
-        button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId())
-        hbox.Add(button_save)
-        
-        # panel for report page
-        #panel = wx.Panel(self, -1)
-        vbox = wx.BoxSizer(wx.VERTICAL)
-        # html window
-        self.hwindow = html.HtmlWindow(self, style=wx.BORDER)
-        # set the html page with the report string
-        self.hwindow.SetPage(self.report_html)
-        
-        # add panels to boxsizers
-        vbox.Add(hbox)
-        vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)
-
-        self.SetSizer(vbox)
-        self.Centre()
-        self.Show(True)
-
     def onSave(self, event=None):
         """
         Save
         """
-        # pdf supporting only on MAC, not on exe
-        if self.is_pdf:
-            wild_card = ' PDF files (*.pdf)|*.pdf|'
-            ind_cor = 0
-        else:
-            wild_card = ''
-            ind_cor = 1
-        wild_card += 'HTML files (*.html)|*.html|'
-        wild_card += 'Text files (*.txt)|*.txt'
-
         #todo: complete saving fig file and as a txt file
         dlg = wx.FileDialog(self, "Choose a file",
-                            wildcard=wild_card,
+                            wildcard=self.wild_card,
                             style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
         dlg.SetFilterIndex(0)  # Set .html files to be default
@@ -166,5 +80,5 @@
         pic_fname = []
         #PDF
-        if ext_num == (0 + 2 * ind_cor):
+        if ext_num == (0 + 2 * self.index_offset):
             # TODO: Sort this case out
             ext = '.pdf'
@@ -216,5 +130,5 @@
             return
         #HTML + png(graph)
-        elif ext_num == (1 - ind_cor):
+        elif ext_num == (1 - self.index_offset):
             ext = '.html'
             for num in range(self.nimages):
@@ -222,5 +136,5 @@
             report_frame = self.report_list[0]
         #TEXT + pdf(graph)
-        elif ext_num == (2 - ind_cor):
+        elif ext_num == (2 - self.index_offset):
             ext = '.txt'
             # changing the image extension actually changes the image
@@ -241,5 +155,5 @@
             pic_fname.append(pic_name)
         #put the image path in html string
-        if ext_num == (1 - ind_cor):
+        if ext_num == (1 - self.index_offset):
             if self.nimages == 1:
                 report = report_frame % os.path.basename(pic_fname[0])
@@ -259,59 +173,2 @@
             self.report_list[2][num].savefig(pic_fname[num])
         
-    def onPreview(self, event=None):
-        """
-        Preview
-        
-        : event: Preview button event
-        """
-        previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)
-        previewh.PreviewText(self.report_html)
-        if event is not None:
-            event.Skip()
-        self.Update()
-    
-    def onPrint(self, event=None):
-        """
-        Print
-        
-        : event: Print button event
-        """
-        printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)
-        printh.PrintText(self.report_html)
-        if event is not None:
-            event.Skip()
-        self.Update()
-        
-    def OnClose(self, event=None):
-        """
-        Close the Dialog
-        
-        : event: Close button event
-        """
-        self.Close()
-        # Reset memory
-        #wx.MemoryFSHandler()
-        if event is not None:
-            event.Skip()
-    
-    def HTML2PDF(self, data, filename):
-        """
-        Create a PDF file from html source string.
-        Returns True is the file creation was successful. 
-        
-        : data: html string
-        : filename: name of file to be saved
-        """
-        try:
-            from xhtml2pdf import pisa
-            # open output file for writing (truncated binary)
-            resultFile = open(filename, "w+b")
-            # convert HTML to PDF
-            pisaStatus = pisa.CreatePDF(data, dest=resultFile)
-            # close output file
-            resultFile.close()
-            self.Update()
-            return pisaStatus.err
-        except:
-            logging.error("Error creating pdf: %s" % sys.exc_value)
-        return False
Index: src/sas/perspectives/invariant/report_dialog.py
===================================================================
--- src/sas/perspectives/invariant/report_dialog.py	(revision 4ec242ef37ff5f92d91a892156e04d092559af32)
+++ src/sas/perspectives/invariant/report_dialog.py	(revision e8bb5b62d717c7b44481a4b621030699e4efdaf4)
@@ -15,116 +15,30 @@
 """
 import wx
-import sys
 import os
 import wx.html as html
-import logging
-ISPDF = False
-if sys.platform == "win32":
-    _STATICBOX_WIDTH = 450
-    PANEL_WIDTH = 500 
-    PANEL_HEIGHT = 700
-    FONT_VARIANT = 0
-    ISMAC = False
-    ISPDF = True
-elif sys.platform == "darwin":
-    _STATICBOX_WIDTH = 480
-    PANEL_WIDTH = 530
-    PANEL_HEIGHT = 700
-    FONT_VARIANT = 1
-    ISMAC = True
-    ISPDF = True
-  
-class ReportDialog(wx.Dialog):
+ 
+from sas.guiframe.report_dialog import BaseReportDialog
+
+class ReportDialog(BaseReportDialog):
     """
     The report dialog box. 
     """
     
-    def __init__(self,  list, *args, **kwds):
+    def __init__(self,  report_list, *args, **kwds):
         """
         Initialization. The parameters added to Dialog are:
         
-        :param list: report_list (list of html_str, text_str, image)
+        :param report_list: list of html_str, text_str, image
         from invariant_state
         """
-        kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE
-        wx.Dialog.__init__(self, *args, **kwds)
-        kwds["image"] = 'Dynamic Image'
+        super(ReportDialog, self).__init__(report_list, *args, **kwds)
+
         # title
         self.SetTitle("Report: Invariant computaion")
-        # size
-        self.SetSize((720, 650))
-        # font size 
-        self.SetWindowVariant(variant=FONT_VARIANT)
 
-        # check if tit is MAC
-        self.is_pdf = ISPDF
-        
-        # report string
-        self.report_list = list
         # put image path in the report string
         self.report_html = self.report_list[0] % "memory:img_inv.png"
         # layout
         self._setup_layout()
-        # wild card
-        # pdf supporting only on MAC
-        if self.is_pdf:
-        	self.wild_card = ' PDF files (*.pdf)|*.pdf|'
-        else:
-        	self.wild_card = ''
-        self.wild_card += 'HTML files (*.html)|*.html|'
-        self.wild_card += 'Text files (*.txt)|*.txt'
-  
-        
-        
-    def _setup_layout(self):
-        """
-        Set up layout
-        """
-        hbox = wx.BoxSizer(wx.HORIZONTAL)
-        
-        # buttons
-        id = wx.ID_OK
-        button_close = wx.Button(self, id, "Close")
-        button_close.SetToolTipString("Close this report window.") 
-        #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0)
-        hbox.Add(button_close)
-        button_close.SetFocus()
-
-        id = wx.NewId()
-        button_preview = wx.Button(self, id, "Preview")
-        button_preview.SetToolTipString("Print preview this report.")
-        button_preview.Bind(wx.EVT_BUTTON, self.onPreview,
-                            id=button_preview.GetId()) 
-        hbox.Add(button_preview)
-
-        id = wx.NewId()
-        button_print = wx.Button(self, id, "Print")
-        button_print.SetToolTipString("Print this report.")
-        button_print.Bind(wx.EVT_BUTTON, self.onPrint,
-                          id=button_print.GetId()) 
-        hbox.Add(button_print)
-        
-        id = wx.NewId()
-        button_save = wx.Button(self, id, "Save" )
-        button_save.SetToolTipString("Save this report.")
-        button_save.Bind(wx.EVT_BUTTON, self.onSave, id = button_save.GetId()) 
-        hbox.Add(button_save)     
-        
-        # panel for report page
-        #panel = wx.Panel(self, -1)
-        vbox = wx.BoxSizer(wx.VERTICAL)
-        # html window
-        self.hwindow = html.HtmlWindow(self,style=wx.BORDER)
-        # set the html page with the report string
-        self.hwindow.SetPage(self.report_html)
-        
-        # add panels to boxsizers
-        vbox.Add(hbox)
-        vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0)
-
-        self.SetSizer(vbox)
-        self.Centre()
-        self.Show(True)
-		
 
     def onSave(self, event=None):
@@ -144,12 +58,7 @@
         fName = dlg.GetPath()
         ext_num = dlg.GetFilterIndex()  
-        # index correction 
-        if not self.is_pdf:
-        	ind_cor = 1 
-        else:
-        	ind_cor = 0 
         #set file extensions  
-        if ext_num == (0 + 2 * ind_cor):
-			# TODO: Sort this case out
+        if ext_num == (0 + 2 * self.index_offset):
+            # TODO: Sort this case out
             ext = '.pdf'
             img_ext = '_img.png'
@@ -186,9 +95,9 @@
             os.remove(pic_fname)
             return
-        elif ext_num == (1 - ind_cor):
+        elif ext_num == (1 - self.index_offset):
             ext = '.html'
             img_ext = '_img4html.png'
             report_frame = self.report_list[0]
-        elif ext_num == (2 - ind_cor):
+        elif ext_num == (2 - self.index_offset):
             ext = '.txt'   
             # changing the image extension actually changes the image
@@ -205,5 +114,5 @@
         pic_fname = os.path.splitext(fName)[0] + img_ext
         #put the image path in html string
-        if ext_num == (1 - ind_cor):
+        if ext_num == (1 - self.index_offset):
             report = report_frame % os.path.basename(pic_fname)
 
@@ -214,54 +123,2 @@
         self.report_list[2].savefig(pic_fname)
         
-            
-    def onPreview(self, event=None):
-        """
-        Preview
-        
-        : event: Preview button event
-        """
-        previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)
-        previewh.PreviewText(self.report_html)
-        if event is not None:
-            event.Skip()
-    
-    def onPrint(self, event=None):
-        """
-        Print
-        
-        : event: Print button event
-        """
-        printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self)
-        printh.PrintText(self.report_html)
-        if event is not None:
-            event.Skip()
-
-    def OnClose(self,event=None):
-        """
-        Close the Dialog
-        
-        : event: Close button event
-        """
-        self.Close()
-    
-    def HTML2PDF(self, data, filename):
-        """
-        Create a PDF file from html source string.
-        Returns True is the file creation was successful. 
-        
-        : data: html string
-        : filename: name of file to be saved
-        """
-        try:
-            from xhtml2pdf import pisa
-            # open output file for writing (truncated binary)
-            resultFile = open(filename, "w+b")
-            # convert HTML to PDF
-            pisaStatus = pisa.CreatePDF(data, dest=resultFile)
-            # close output file
-            resultFile.close()
-            self.Update()
-            return pisaStatus.err
-        except:
-            logging.error("Error creating pdf: %s" % sys.exc_value)
-        return False
