/// ****************************************************************************
/// @file   
/// @author Dr.Neeton
/// @date   2010/X/X - 2016/02/15
/// 
/// @brief  GUCを配置するルートとなるWindows用ウィンドウコンポーネント。
/// 
/// ****************************************************************************

#pragma once

#include "CPL_GUC_Window.h"
#include "CPL_GUC_TextBox.h"
#include "CPL_GUC_MasterLayer.h"

namespace CPL {
namespace GUC {


using CPL_GUC_FrameEventBase = DX::FrameEvent;

// _____________________________________________________________________________
/// @brief 描画を制御するクラス
///
// *****************************************************************************
class FrameEvent
  : public CPL_GUC_FrameEventBase
{
  friend class GUC::Component;

  using ContainerTable = std::vector< wkptr<GUC::MasterLayer> >;
  using SpComponent_ = sdptr<GUC::Component>;

  GUC::Component::SpStaticParam
                  m_sp_static_param_hold; // デストラクタを先に呼ばれないように保持
  sdptr<GUC::Container>
                  m_sp_comp_form_root;
  ContainerTable  m_comp_form_wp_list; // m_comp_form_rootのリストを配列で扱うため
  //int             m_flag_updating;     // アップデート待機中かどうか

  //sdptr<GUC::Component>
  //  hitItemComponent_
  //    ( _in<SpComponent_> in_sp_component
  //    , rio<float       > io_mouse_x
  //    , rio<float       > io_mouse_y
  //    );
  //sdptr<GUC::Component>
  //  hitItemComponent_Child_
  //    ( _in<SpComponent_> in_sp_component
  //    , rio<float       > io_mouse_x
  //    , rio<float       > io_mouse_y
  //    );
  //sdptr<GUC::Component>
  //  hitItemComponent_This_
  //    ( _in<SpComponent_> in_sp_component
  //    , rio<float       > io_mouse_x
  //    , rio<float       > io_mouse_y
  //    );

  //void zzf_UpdateWindowBuffer();
public:
  //FrameEvent();
  FrameEvent
  ( _in<sdptr<DX::Graphics_i_>> in_sp_graphics
  , _in<sdptr<DX::Input      >> in_sp_input = nullptr
  );
  ~FrameEvent();

  bool
    GUC_Initialized
      ( _in<sdptr<DX::Graphics_i_    >> in_sp_graphics
      , _in<sdptr<DX::FontDrawManager>> in_sp_font
      , _in<int                       > in_num_masterlayer = 2
      );

  SDEF On_MouseMove () override;
  SDEF On_MouseDown ( _in<eMouseButton> in_mouse_btn ) override;
  SDEF On_MouseUp   ( _in<eMouseButton> in_mouse_btn ) override;
  SDEF On_MouseWheel( _in<WORD> in_fw_keys, _in<short> in_z_delta ) override;
  SDEF On_KeyDown   ( _in<int> in_virtual_key_code ) override;
  SDEF On_KeyUp     ( _in<int> in_virtual_key_code ) override;
  SDEF On_Char      ( _in<int> in_char_code, _in<int> in_key_data ) override;
  SDEF On_Paint     () override;
  SDEF On_Timer     ( _in<int> in_timer_ID ) override;
  SDEF On_Command
         ( _in<int > in_ctrl_ID
         , _in<int > in_notify_code
         , _in<HWND> in_hdl_ctrl_win
         ) override;
  SDEF On_UserProc
         ( _in<HWND>   in_hdl_window
         , _in<UINT>   in_message
         , _in<WPARAM> in_wparam
         , _in<LPARAM> in_lparam
         ) override;
  SDEF On_Size( _in<eSizeMode> in_size_mode ) override;

  sdptr<GUC::Component> GetMasterLayer( _in<int> in_z_order_idx )
  {
    return m_comp_form_wp_list[ in_z_order_idx ].lock();
  }
};


} // namespace GUC
} // namespace CPL
