/* 
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 *
 * 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; version 2 of the
 * License.
 * 
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301  USA
 */

#ifndef _WF_TABVIEW_H_
#define _WF_TABVIEW_H_

#include "wf_view.h"

using namespace System::Collections;

namespace MySQL
{
  namespace Forms
  {
    public ref class TabViewImpl : public ViewImpl
    {
    private:
      ::mforms::TabViewType _tabType;
      int _active_index;
      List<ViewImpl^> _pages; // Only used if the tab view is set to have no tabs.
    protected:
      TabViewImpl(::mforms::TabView *self, ::mforms::TabViewType type);

      static bool create(::mforms::TabView *self, ::mforms::TabViewType type);
      static void set_active_tab(::mforms::TabView *self, int index);
      static int get_active_tab(::mforms::TabView *self);
      static int add_page(::mforms::TabView *self, ::mforms::View *page, const std::string& caption);
      static void remove_page(::mforms::TabView *self, ::mforms::View *page);
      static void set_tab_title(::mforms::TabView *self, int tab, const std::string& caption);

      static void tab_changed(System::Object^ sender, TabControlEventArgs^ e);
      static void tab_closing(System::Object^ sender, MySQL::Controls::TabClosingEventArgs^ e);
      static void tab_closed(System::Object^ sender, MySQL::Controls::TabClosedEventArgs^ e);
    public:
      static void init(Manager ^mgr)
      {
        ::mforms::ControlFactory *f= ::mforms::ControlFactory::get_instance();

        DEF_CALLBACK2(bool, ::mforms::TabView*, ::mforms::TabViewType, mgr, f->_tabview_impl, TabViewImpl, create);
        DEF_CALLBACK1(int, ::mforms::TabView*, mgr, f->_tabview_impl, TabViewImpl, get_active_tab);
        DEF_CALLBACK2(void, ::mforms::TabView*, int, mgr, f->_tabview_impl, TabViewImpl, set_active_tab);
        DEF_CALLBACK3(int, ::mforms::TabView*, ::mforms::View*, const std::string&, mgr, f->_tabview_impl, TabViewImpl, add_page);
        DEF_CALLBACK2(void, ::mforms::TabView*, ::mforms::View*, mgr, f->_tabview_impl, TabViewImpl, remove_page);
        DEF_CALLBACK3(void, ::mforms::TabView*, int, const std::string&, mgr, f->_tabview_impl, TabViewImpl, set_tab_title);
      }
    };
  };
};

#endif
