/* 
 * Copyright (c) 2007, 2011, 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 _WB_COMPONENT_BASIC_H_
#define _WB_COMPONENT_BASIC_H_

// Basic Model Handling (layers etc)

#include "wb_component.h"


namespace wb {

  // basic tool names
  #define WB_TOOL_SELECT     "basic/select"
  #define WB_TOOL_HAND       "basic/hand"
  #define WB_TOOL_DELETE     "basic/delete"
  #define WB_TOOL_LAYER      "basic/layer"
  #define WB_TOOL_NOTE       "basic/note"
  #define WB_TOOL_IMAGE      "basic/image"
  #define WB_TOOL_ZOOM_IN    "basic/zoomin"
  #define WB_TOOL_ZOOM_OUT   "basic/zoomout"

  class WBComponentBasic : public WBComponent
  {
  public:
    WBComponentBasic(WBContext *wb);
    virtual ~WBComponentBasic();

    static std::string name() { return "basic"; }
    virtual std::string get_name() { return WBComponentBasic::name(); }
    virtual std::string get_diagram_class_name() { return model_Diagram::static_class_name(); }

    void delete_selection();
    
  protected:
    virtual void load_app_options(bool update);

    // Canvas Handling
    virtual void setup_canvas_tool(ModelDiagramForm *view, const std::string &tool);

    // Toolbar Handling
    virtual app_ToolbarRef get_tools_toolbar();
    virtual app_ToolbarRef get_tool_options(const std::string &tool);

    virtual std::vector<std::string> get_command_dropdown_items(const std::string &option);

    virtual grt::ListRef<app_ShortcutItem> get_shortcut_items();

    virtual bool handles_figure(const model_ObjectRef &object);

    virtual void activate_canvas_object(const model_ObjectRef &figure, bool newwindow);

  private:
    std::map<std::string, app_ToolbarRef> _toolbars;
    grt::ListRef<app_ShortcutItem> _shortcuts;

    // Model Objects
    void place_layer(ModelDiagramForm *view, const MySQL::Geometry::Rect &rect);
    grt::ValueRef place_layer_grt(grt::GRT *grt, ModelDiagramForm *view, 
                                      const MySQL::Geometry::Rect &rect);

    void delete_object(ModelDiagramForm *view, const MySQL::Geometry::Point &pos);
    virtual model_ObjectRef clone_object(const model_ObjectRef &object, const model_LayerRef &destlayer, grt::CopyContext &copy_context, bool copy_only);

    virtual bool delete_model_object(const model_ObjectRef &object, std::map<std::string,bool> &options);

    void reset_tool(ModelDiagramForm *view, void*);
    bool handle_motion_event(ModelDiagramForm*, MySQL::Geometry::Point, mdc::EventState, void*);
    bool handle_button_event(ModelDiagramForm*, mdc::MouseButton, bool, MySQL::Geometry::Point, mdc::EventState, void*);
  };

};


#endif 
