advOptionsBox :: G.WindowClass window => window -> IO G.VBox
advOptionsBox win = do
    vbox <- G.vBoxNew False 4
    ----
    okButton <- G.buttonNewFromStock G.stockOk
    cancelButton <- G.buttonNewFromStock G.stockCancel
    bottomBox <- G.hBoxNew False 2
    sep <- G.hSeparatorNew
    mapM_ (\b -> G.boxPackEnd bottomBox b  G.PackNatural 2) [okButton,cancelButton]
    ----
    G.on cancelButton G.buttonActivated $ G.widgetDestroy win
    pms <- getInputPrms
    case pms of
        Right advpms -> do
            [sdEntry,aMxEnt, aMnEnt,mTrdEnt] <-  sequence $ replicate 4 G.entryNew
            let entries = [sdEntry,aMxEnt, aMnEnt,mTrdEnt]
            mapM_ (\ent -> do
                G.entrySetWidthChars ent 4
                G.entrySetMaxLength ent 4) entries
            let values = [searchDepth advpms, alignMax advpms, alignMin advpms, minTrend advpms]
            mapM (uncurry G.entrySetText) $ zip entries (map show values)
            let sdText = "Determines the number of refinements to parameters."
            let maxTxt = "The maximum number of adjacent chains to align."
            let minTxt = "The minimum number of adjacent chains to align."
            let trdTxt = "The minimum number of points to which a trend can be fitted."
            buttons <- mapM G.buttonNewWithLabel $ replicate 4 "What is This"
            mapM_ (uncurry onButtDo) $ zip buttons [sdText,maxTxt,minTxt,trdTxt]
            let strings = [" Search dept ", "Alignment maximum ","Alignment minimum ", "Trend minimum " ]
            otheBoxes <- mapM (\(str,w) ->  labelLeftofWidgetE (str++" ") 2  w True) $ zip strings buttons
            let hBoxes =  otheBoxes
            mapM_ (\(b,w) -> G.boxPackEnd b w G.PackNatural 2) $ zip hBoxes entries
            tableWithList <- tableWithWidgetList True hBoxes True 3
            G.boxPackStart vbox tableWithList G.PackNatural 4
            mapM_ (ioButtAct okButton advpms entries) [strings]
            ---
        Left str -> print str
    G.boxPackEnd vbox bottomBox G.PackNatural 0
    G.boxPackEnd vbox sep G.PackNatural 2
    return vbox
        where
            onButtDo butt str = G.on butt G.buttonActivated $ runMsgDialog Nothing str Info
            ioButtAct okButton advpms entries strings = do
              G.on okButton G.buttonActivated $ do
            --sdE <- G.entryGetText sdEntry [sdEntry,aMxEnt, aMnEnt,mTrdEnt]
                entered <- mapM G.entryGetText entries
                case validateEntries entered strings of
                    Left [ev,aMx,aMn,mTd] -> do
                        updateSDepth ev advpms
                        updateAlignMax aMx advpms
                        updateAlignMin aMn advpms
                        updateMinTrend mTd advpms
                    Right string -> runMsgDialog Nothing string Error  


-- advanced option window
advOptionsBox :: G.WindowClass window => window -> IO G.VBox
advOptionsBox win = do
    vbox <- G.vBoxNew False 4
    ----
    okButton <- G.buttonNewFromStock G.stockOk
    cancelButton <- G.buttonNewFromStock G.stockCancel
    bottomBox <- G.hBoxNew False 2
    sep <- G.hSeparatorNew
    mapM_ (\b -> G.boxPackEnd bottomBox b  G.PackNatural 2) [okButton,cancelButton]
    ----
    G.on cancelButton G.buttonActivated $ G.widgetDestroy win
    pms <- getInputPrms
    case pms of
        Right advpms -> do
            [sdEntry,aMxEnt, aMnEnt,mTrdEnt] <-  sequence $ replicate 4 G.entryNew
            let entries = [sdEntry,aMxEnt, aMnEnt,mTrdEnt]
            mapM_ (\ent -> do
                G.entrySetWidthChars ent 4
                G.entrySetMaxLength ent 4) entries
            let values = [searchDepth advpms, alignMax advpms, alignMin advpms, minTrend advpms]
            mapM (uncurry G.entrySetText) $ zip entries (map show values)
            let sdText = "Determines the number of refinements to parameters."
            let maxTxt = "The maximum number of adjacent chains to align."
            let minTxt = "The minimum number of adjacent chains to align."
            let trdTxt = "The minimum number of points to which a trend can be fitted."
            buttons <- mapM G.buttonNewWithLabel $ replicate 4 "What is This"
            mapM_ (uncurry onButtDo) $ zip buttons [sdText,maxTxt,minTxt,trdTxt]
            let strings = [" Search dept ", "Alignment maximum ","Alignment minimum ", "Trend minimum " ]
            otheBoxes <- mapM (\(str,w) ->  labelLeftofWidgetE (str++" ") 2  w True) $ zip strings buttons
            let hBoxes =  otheBoxes
            mapM_ (\(b,w) -> G.boxPackEnd b w G.PackNatural 2) $ zip hBoxes entries
            tableWithList <- tableWithWidgetList True hBoxes True 3
            G.boxPackStart vbox tableWithList G.PackNatural 4
            mapM_ (ioButtAct okButton advpms entries) [strings]
            ---
        Left str -> print str
    G.boxPackEnd vbox bottomBox G.PackNatural 0
    G.boxPackEnd vbox sep G.PackNatural 2
    return vbox
        where
            onButtDo butt str = G.on butt G.buttonActivated $ runMsgDialog Nothing str Info
            ioButtAct okButton advpms entries strings = do
              G.on okButton G.buttonActivated $ do
            --sdE <- G.entryGetText sdEntry [sdEntry,aMxEnt, aMnEnt,mTrdEnt]
                entered <- mapM G.entryGetText entries
                case validateEntries entered strings of
                    Left [ev,aMx,aMn,mTd] -> do
                        updateSDepth ev advpms
                        updateAlignMax aMx advpms
                        updateAlignMin aMn advpms
                        updateMinTrend mTd advpms
                    Right string -> runMsgDialog Nothing string Error  


-- advanced option window
advOptionsBox win = do
    vbox <- G.vBoxNew False 4
    ----
    okButton <- G.buttonNewFromStock G.stockOk
    cancelButton <- G.buttonNewFromStock G.stockCancel
    bottomBox <- G.hBoxNew False 2
    sep <- G.hSeparatorNew
    mapM_ (\b -> G.boxPackEnd bottomBox b  G.PackNatural 2) [okButton,cancelButton]
    ----
    G.on cancelButton G.buttonActivated $ G.widgetDestroy win
    pms <- getInputPrms
    case pms of
        Right advpms -> do
            [sdEntry,aMxEnt, aMnEnt,mTrdEnt] <-  sequence $ replicate 4 G.entryNew
            let entries = [sdEntry,aMxEnt, aMnEnt,mTrdEnt]
            mapM_ (\ent -> do
                G.entrySetWidthChars ent 4
                G.entrySetMaxLength ent 4) entries
            let values = [searchDepth advpms, alignMax advpms, alignMin advpms, minTrend advpms]
            mapM (uncurry G.entrySetText) $ zip entries (map show values)
            let sdText = "Determines the number of refinements to parameters."
            let maxTxt = "The maximum number of adjacent chains to align."
            let minTxt = "The minimum number of adjacent chains to align."
            let trdTxt = "The minimum number of points to which a trend can be fitted."
            buttons <- mapM G.buttonNewWithLabel $ replicate 4 "What is This"
            mapM_ (uncurry onButtDo) $ zip buttons [sdText,maxTxt,minTxt,trdTxt]
            let strings = [" Search dept ", "Alignment maximum ","Alignment minimum ", "Trend minimum " ]
            otheBoxes <- mapM (\(str,w) ->  labelLeftofWidgetE (str++" ") 2  w True) $ zip strings buttons
            let hBoxes =  otheBoxes
            mapM_ (\(b,w) -> G.boxPackEnd b w G.PackNatural 2) $ zip hBoxes entries
            tableWithList <- tableWithWidgetList True hBoxes True 3
            G.boxPackStart vbox tableWithList G.PackNatural 4
            mapM_ (ioButtAct okButton advpms entries) [strings]
            ---
        Left str -> print str
    G.boxPackEnd vbox bottomBox G.PackNatural 0
    G.boxPackEnd vbox sep G.PackNatural 2
    return vbox
        where
            onButtDo butt str = G.on butt G.buttonActivated $ runMsgDialog Nothing str Info
            ioButtAct okButton advpms entries strings = do
              G.on okButton G.buttonActivated $ do
            --sdE <- G.entryGetText sdEntry [sdEntry,aMxEnt, aMnEnt,mTrdEnt]
                entered <- mapM G.entryGetText entries
                case validateEntries entered strings of
                    Left [ev,aMx,aMn,mTd] -> do
                        updateSDepth ev advpms
                        updateAlignMax aMx advpms
                        updateAlignMin aMn advpms
                        updateMinTrend mTd advpms
                    Right string -> runMsgDialog Nothing string Error  


-- advanced option window