//!
//! \addtogroup linuxui Linux UI
//! @{
//! 

#ifndef _OVERVIEW_PANEL_H_
#define _OVERVIEW_PANEL_H_

#include <map>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/box.h>
#include "linux_utilities/form_view_base.h"

#include "workbench/wb_overview.h"
#include "workbench/wb_context_ui.h"

class MenuManager;
class OverviewDivision;
class OverviewSection;
class OverviewItemContainer;
class OverviewGroupContainer;

class OverviewPanel : public Gtk::ScrolledWindow, public FormViewBase
{
public:
  OverviewPanel(wb::WBContextUI *wb, wb::OverviewBE *overview, MenuManager* _manager);

  void reset();
  void rebuild_all();

  void select_node(const bec::NodeId& node);
  void refresh_node(const bec::NodeId& node);
  void refresh_children(const bec::NodeId& node);

  virtual bec::UIForm *get_form() const { return _overview_be; }
  virtual std::string get_title() { return _overview_be->get_title(); }
  virtual Gtk::Widget *get_panel() { return this; }
  
  void item_popup_menu(const Gtk::TreeModel::Path &path, guint32 time, OverviewItemContainer *sender);
  
private:

  Gtk::VBox *_container;

  std::map<std::string, OverviewGroupContainer*> _group_containers_by_id;
  std::map<std::string, OverviewItemContainer*> _item_containers_by_id;
  wb::WBContextUI *_wb;

  wb::OverviewBE *_overview_be;
  MenuManager    *_menu_manager;
  
  bool _freeze;
  bool _rebuilding;

  void update_group_note(OverviewGroupContainer *group_container, const bec::NodeId &node);

  void build_division(Gtk::VBox *container, const bec::NodeId &node);
  void build_group(OverviewDivision *division, OverviewGroupContainer *group_container, const bec::NodeId &node, int position= -1);
};


#endif /* _OVERVIEW_PANEL_H_ */

//!                                                                                                                                     
//! @}                                                                                                                                  
//!
