forked from yvt/xtbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XTBDrawTest.cpp
58 lines (51 loc) · 1.23 KB
/
XTBDrawTest.cpp
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
//
// XTBDrawTest.cpp
// XTBook
//
// Created by Nexhawks on 4/25/11.
// Copyright 2011 Nexhawks. All rights reserved.
//
#include "XTBDrawTest.h"
#include <tcw/twSDLDC.h>
XTBDrawTest::XTBDrawTest(){
setNeedsDimming(true);
setRect(twRect(0, 0, 160, 160)+getBorderSize());
setTitle(L"Draw");
m_offscreen=new twSDLDC(getClientRect().size());
m_drag=false;
m_offscreen->fillRect(twRGB(255, 255, 255),
twRect(twPoint(0, 0), getClientRect().size()));
}
XTBDrawTest::~XTBDrawTest(){
delete m_offscreen;
}
void XTBDrawTest::backgroundTouched(){
endDialog();
}
void XTBDrawTest::clientMouseDown(const twPoint& pt, twMouseButton button){
if(button==twMB_left){
twSetCapture(this);
m_drag=true;
m_oldMousePos=pt;
}
}
void XTBDrawTest::clientMouseMove(const twPoint& mousePos){
if(m_drag){
m_offscreen->drawLine(twRGB(0, 0, 0),
m_oldMousePos,
mousePos);
invalidate();
m_oldMousePos=mousePos;
}
}
void XTBDrawTest::clientMouseUp(const twPoint& pt, twMouseButton button){
if(button==twMB_left){
twReleaseCapture();
m_drag=false;
}
}
void XTBDrawTest::clientPaint(const twPaintStruct& p){
twDC *dc=p.dc;
dc->bitBlt(m_offscreen,twPoint(0, 0),
twRect(twPoint(0, 0), getClientRect().size()));
}