summaryrefslogtreecommitdiff
path: root/utils/mxtk/mxmatsyswindow.cpp
blob: 3ed089688ef024f920cf1ee4aa96dbae600c56e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
//                 mxToolKit (c) 1999 by Mete Ciragan
//
// file:           mxMatSysWindow.cpp
// implementation: Win32 API
// last modified:  Apr 21 1999, Mete Ciragan
// copyright:      The programs and associated files contained in this
//                 distribution were developed by Mete Ciragan. The programs
//                 are not in the public domain, but they are freely
//                 distributable without licensing fees. These programs are
//                 provided without guarantee or warrantee expressed or
//                 implied.
//
#include "mxtk/mxMatSysWindow.h"
#include <windows.h>

class mxMatSysWindow_i
{
public:
	HDC hdc;
	HGLRC hglrc;
};



mxMatSysWindow::mxMatSysWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
: mxWindow (parent, x, y, w, h, label, style)
{
	d_this = new mxMatSysWindow_i;

	bool error = false;

	if ((d_this->hdc = GetDC ((HWND) getHandle ())) == NULL)
	{
		error = true;
		goto done;
	}

	setDrawFunc (0);

done:
	if (error)
		delete this;
}



mxMatSysWindow::~mxMatSysWindow ()
{
	if (d_this->hdc)
		ReleaseDC ((HWND) getHandle (), d_this->hdc);

	delete d_this;
}



int
mxMatSysWindow::handleEvent (mxEvent *event)
{
	return 0;
}



void
mxMatSysWindow::redraw ()
{
	// makeCurrent ();
	if (d_drawFunc)
		d_drawFunc ();
	else
		draw ();
	// swapBuffers ();
}



void
mxMatSysWindow::draw ()
{
}



int
mxMatSysWindow::makeCurrent ()
{
	return 1;
}



int
mxMatSysWindow::swapBuffers ()
{
	return 0;
}



void
mxMatSysWindow::setDrawFunc (void (*func) (void))
{
	d_drawFunc = func;
}