# ===============================================================================
# Copyright 2013 Jake Ross
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

# ============= enthought library imports =======================
from __future__ import absolute_import

from traits.has_traits import HasTraits, on_trait_change
from traits.trait_types import List, Event, Bool, Button, Str, Any
from traits.traits import Property
from traitsui.editors import EnumEditor, ButtonEditor
from traitsui.extras.checkbox_column import CheckboxColumn as _CheckboxColumn
from traitsui.group import HGroup, VGroup
from traitsui.item import UItem, Item
from traitsui.table_column import ObjectColumn as _ObjectColumn
from traitsui.view import View

from pychron.core.fits.fit import Fit
from pychron.core.ui.table_editor import myTableEditor
from pychron.envisage.icon_button_editor import icon_button_editor
from pychron.pychron_constants import FIT_TYPES, FIT_ERROR_TYPES


class ColumnMixin(object):
    pass


class ObjectColumn(_ObjectColumn):
    text_font = 'modern 10'


class CheckboxColumn(_CheckboxColumn):
    text_font = 'modern 10'


class FitSelector(HasTraits):
    fits = List(Fit)
    update_needed = Event
    suppress_refresh_unknowns = Bool
    save_event = Event

    fit_klass = Fit
    command_key = Bool
    auto_update = Bool(True)

    plot_button = Button('Plot')
    default_error_type = 'SD'

    show_all_button = Event
    show_state = Bool
    show_all_label = Property(depends_on='show_state')

    use_all_button = Button('Toggle Save')