/*
 *  mdc_canvas_view_windows.h
 *  mdcanvas
 *
 *  Created by Alfredo Kojima on 07/Mar/5.
 *  Copyright 2007 MySQL AB. All rights reserved.
 *
 */

#ifndef _MDC_CANVAS_VIEW_WINDOWS_H_
#define _MDC_CANVAS_VIEW_WINDOWS_H_

#include "mdc_canvas_view_opengl.h"

namespace mdc {


class MYSQLCANVAS_PUBLIC_FUNC WindowsGLCanvasView : public OpenGLCanvasView 
{
public:
  WindowsGLCanvasView(HWND window, int width, int height);
  virtual ~WindowsGLCanvasView();

  virtual bool initialize();

  virtual void make_current();
  virtual void remove_current();
  virtual void swap_buffers();

  virtual void update_view_size(int width, int height);

protected:
  HGLRC _glrc;
  HDC _hdc;
  HWND _window;
  DWORD _fps_timer;

  virtual void start_fps_timer() { _fps_timer= ::GetTickCount(); }
  virtual void stop_fps_timer_and_update_fps() { _fps= ((float)1000.0)/(::GetTickCount() - _fps_timer); }
};


class MYSQLCANVAS_PUBLIC_FUNC WindowsCanvasView : public CanvasView 
{
public:
  WindowsCanvasView(HWND window, int width, int height);
  WindowsCanvasView(HDC context, int width, int height);
  virtual ~WindowsCanvasView();

  virtual bool initialize();

  virtual bool has_gl() const { return false; }

protected:
  HWND _window;
  HDC _hdc;
  PAINTSTRUCT _paint;

  cairo_surface_t *_offline_surface;

  virtual void update_view_size(int width, int height);
  virtual void begin_repaint(int x, int y, int w, int h);
  virtual void end_repaint();
};


class MYSQLCANVAS_PUBLIC_FUNC BufferedWindowsCanvasView : public CanvasView 
{
public:
  BufferedWindowsCanvasView(HWND window, int width, int height);
  virtual ~BufferedWindowsCanvasView();

  virtual bool initialize();

  virtual bool has_gl() const { return false; }

  virtual Surface *create_temp_surface(const Size &size) const;

protected:
  HWND _window;
  HDC _hdc;
  PAINTSTRUCT _paint;
  int _clip_x, _clip_y, _clip_w, _clip_h;

  virtual void scroll_to(const Point &offs);
  virtual void update_view_size(int width, int height);
  virtual void begin_repaint(int x, int y, int w, int h);
  virtual void end_repaint();
};


/*
class MYSQLCANVAS_PUBLIC_FUNC DDBufferedWindowsCanvasView : public CanvasView 
{
public:
  DDBufferedWindowsCanvasView(HWND window, int width, int height);
  virtual ~DDBufferedWindowsCanvasView();

  virtual bool initialize();

  // gl used just for blitting
  virtual bool has_gl() const { return false; }

protected:
  HWND _window;
  LPDIRECTDRAWSURFACE _ddsurface;
  LPDIRECTDRAWSURFACE _ddback;
  LPDIRECTDRAWCLIPPER _clipper;

  int _clip_x, _clip_y, _clip_w, _clip_h;

  virtual void update_view_size(int width, int height);
  virtual void begin_repaint(int x, int y, int w, int h);
  virtual void end_repaint();
};
*/


};


#pragma make_public(mdc::CanvasView)
#pragma make_public(mdc::EventState)
#pragma make_public(mdc::KeyInfo)

#endif /* _MDC_CANVAS_VIEW_WINDOWS_H_ */

