forked from zao/foo_wave_seekbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGdiFallback.h
66 lines (54 loc) · 1.48 KB
/
GdiFallback.h
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
// Copyright Lars Viklund 2008 - 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#pragma once
#include "frontend_sdk/VisualFrontend.h"
#include "waveform_sdk/Optional.h"
namespace wave
{
struct mem_dc : CDC
{
CBitmap bmp;
CBitmapHandle old_bmp;
CSize size;
explicit mem_dc(HDC src_dc)
{
CreateCompatibleDC(src_dc);
}
mem_dc(HDC src_dc, wave::size s)
{
CreateCompatibleDC(src_dc);
bmp.CreateCompatibleBitmap(src_dc, s.cx, s.cy);
old_bmp = SelectBitmap(bmp);
}
~mem_dc()
{
SelectBitmap(old_bmp);
}
};
struct gdi_fallback_frontend : visual_frontend
{
gdi_fallback_frontend(HWND wnd, wave::size, visual_frontend_callback& callback, visual_frontend_config& conf);
~gdi_fallback_frontend();
void clear();
void draw();
void present();
void on_state_changed(state s);
private:
void create_objects();
void release_objects();
void update_data();
void update_positions();
CPoint orientate(CPoint);
CWindow wnd;
bool cached_rects_valid;
wave::optional<CRect> last_play_rect;
wave::optional<CRect> last_seek_rect;
std::unique_ptr<mem_dc> wave_dc, shaded_wave_dc;
std::unique_ptr<CPen> pen_foreground, pen_highlight, pen_selection;
std::unique_ptr<CBrush> brush_background;
visual_frontend_callback& callback;
};
}
extern "C" __declspec(dllexport) frontend_entrypoint* _cdecl g_gdi_entrypoint();