// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2021 Torsten Schache, Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.



using System;
using Hiperscan.GtkExtensions.Widgets;
using Hiperscan.ApoIdentCore.Enums;
using Hiperscan.ApoIdentCommon.ApoConfig.Enums;

namespace Hiperscan.Extensions.ApoIdent
{
    public partial class GuiDesigner
    {
        public void InitComboBoxes(Gtk.Widget widget)
        {
            Gtk.ComboBox combobox = widget as Gtk.ComboBox;
            if (combobox != null)
            {
                Gtk.ListStore store = new Gtk.ListStore(typeof(string));
                Gtk.CellRendererText cell_text = new Gtk.CellRendererText();
                cell_text.Scale *= 0.85;
                combobox.PackStart(cell_text, false);
                combobox.SetAttributes(cell_text, "text", 0);
                cell_text.Alignment = Pango.Alignment.Left;
                combobox.Model = store;
                combobox.AppendText(" ");
                combobox.Active = 0;
                combobox.HeightRequest = 5;
            }

            Gtk.Container container = widget as Gtk.Container;
            if (container == null)
                return;

            foreach (Gtk.Widget child in container.Children)
                this.InitComboBoxes(child);
        }

        public OutLinedEnumCombobox<ReferenceQuantityTypes> CreateOutLinedQuantityComboBox(ref Gtk.ComboBox combobox)
        {
            OutLinedEnumCombobox<ReferenceQuantityTypes> tmp = new OutLinedEnumCombobox<ReferenceQuantityTypes>(combobox);
            combobox = null;

            tmp.ErrorColor = ApoIdentColors.LIGHT_RED;
            tmp.OkColor = ApoIdentColors.WHITE;
            tmp.IsValid = false;

            return tmp;
        }

        public OutLinedEnumCombobox<GracePeriodTypes> CreateOutLinedGraceComboBox(ref Gtk.ComboBox combobox)
        {
            OutLinedEnumCombobox<GracePeriodTypes> tmp = new OutLinedEnumCombobox<GracePeriodTypes>(combobox);
            combobox = null;

            tmp.ErrorColor = ApoIdentColors.LIGHT_RED;
            tmp.OkColor = ApoIdentColors.WHITE;
            tmp.IsValid = false;

            return tmp;
        }
    }
}
