- void toplevel_window::create_window()
- {
-
- // Windowを作成する
- CreateWindowEx(
- WS_EX_APPWINDOW,
- name_.c_str(),
- title_.c_str(),
- 0 ,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- static_cast<boost::uint32_t>(ceil(width_ /** dpiX / 96.f*/)),
- static_cast<boost::uint32_t>(ceil(height_ /** dpiY / 96.f*/)),
- NULL,
- NULL,
- HINST_THISCOMPONENT,
- this
- );
- }
-
- void toplevel_window::create_device()
- {
-
- // 入力_.reset(new input(HINST_THISCOMPONENT,hwnd_));
- HRESULT hr = S_OK;
-
-
- //ウィンドウの現在の幅、高さを求める
- RECT rc;
- GetClientRect( hwnd_, &rc );
- boost::uint32_t width = rc.right - rc.left;
- boost::uint32_t height = rc.bottom - rc.top;
-
- {
- //wic_imaging_factory_.CreateInstance(CLSID_WICImagingFactory);
- // bitmap_ = load_bitmap_from_file(render_target_,wic_imaging_factory_,L"myship.png");
- }
-
- if(!render_target_)
- {
- RECT rc;
- GetClientRect(hwnd_, &rc);
-
- D2D1_SIZE_U size = D2D1::SizeU(
- rc.right - rc.left,
- rc.bottom - rc.top
- );
-
- const D2D1_PIXEL_FORMAT format =
- D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
- D2D1_ALPHA_MODE_PREMULTIPLIED);
-
- const D2D1_RENDER_TARGET_PROPERTIES target_prop =
- D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,format);
-
- THROW_IFERR(factory_->CreateHwndRenderTarget(
- target_prop,
- D2D1::HwndRenderTargetProperties(hwnd_, size,D2D1_PRESENT_OPTIONS_IMMEDIATELY),
- &render_target_
- ));
- // Create a DC render target
- //D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
- // D2D1_RENDER_TARGET_TYPE_DEFAULT,
- // D2D1::PixelFormat(
- // DXGI_FORMAT_B8G8R8A8_UNORM,
- // D2D1_ALPHA_MODE_IGNORE
- // ) , 0.0, 0.0,
- // D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE
- // );
-
- //THROW_IFERR(factory_->CreateDCRenderTarget(
- // &props,
- // &render_target_
- // ));
- }
- }
-
- void toplevel_window::discard_device()
- {
- safe_release(render_target_);
- }
-
- void toplevel_window::create_device_independent_resources()
- {
- // Direct2DFactory の生成
-
- if(!factory_){
-#if defined(DEBUG) || defined(_DEBUG)
- D2D1_FACTORY_OPTIONS options;
- options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION ;
- THROW_IFERR(D2D1CreateFactory(
- D2D1_FACTORY_TYPE_SINGLE_THREADED,
- options,
- &factory_
- ));
-#else
- THROW_IFERR(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory_));
-#endif
-
- }
-
- if(!write_factory_){
- THROW_IFERR(::DWriteCreateFactory(
- DWRITE_FACTORY_TYPE_SHARED,
- __uuidof(IDWriteFactory),
- reinterpret_cast<IUnknown**>(&write_factory_)
- ));
- }
-
-
- //wic_imaging_factory_.CreateInstance(CLSID_WICImagingFactory);
-
- //thunk_proc_ = (WNDPROC)thunk_.getCode();
- layout_rect_ = D2D1::RectF(0.0f,0.0f,width_,height_);
- // Text Formatの作成
- THROW_IFERR(write_factory_->CreateTextFormat(
- L"メイリオ", // Font family name.
- NULL, // Font collection (NULL sets it to use the system font collection).
- DWRITE_FONT_WEIGHT_REGULAR,
- DWRITE_FONT_STYLE_NORMAL,
- DWRITE_FONT_STRETCH_NORMAL,
- 24.0f,
- L"ja-jp",
- &write_text_format_
- ));
-
- }
-
- LRESULT toplevel_window::window_proc(HWND hwnd,boost::uint32_t message, WPARAM wParam, LPARAM lParam)
- {
-
-