mirror of https://github.com/buggins/dlangui.git
code cleanup
This commit is contained in:
parent
4429bca35c
commit
2d14cc78a8
|
@ -15,24 +15,24 @@ enum LogLevel : int {
|
||||||
__gshared LogLevel logLevel = LogLevel.Info;
|
__gshared LogLevel logLevel = LogLevel.Info;
|
||||||
__gshared std.stdio.File logFile;
|
__gshared std.stdio.File logFile;
|
||||||
|
|
||||||
public void setLogLevel(LogLevel level) {
|
void setLogLevel(LogLevel level) {
|
||||||
logLevel = level;
|
logLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStdoutLogger() {
|
void setStdoutLogger() {
|
||||||
logFile = stdout;
|
logFile = stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStderrLogger() {
|
void setStderrLogger() {
|
||||||
logFile = stderr;
|
logFile = stderr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFileLogger(File file) {
|
void setFileLogger(File file) {
|
||||||
logFile = file;
|
logFile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Log {
|
class Log {
|
||||||
public static string logLevelName(LogLevel level) {
|
static string logLevelName(LogLevel level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LogLevel.Fatal: return "F";
|
case LogLevel.Fatal: return "F";
|
||||||
case LogLevel.Error: return "E";
|
case LogLevel.Error: return "E";
|
||||||
|
@ -43,7 +43,7 @@ class Log {
|
||||||
default: return "?";
|
default: return "?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void log(S...)(LogLevel level, S args) {
|
static void log(S...)(LogLevel level, S args) {
|
||||||
if (logLevel >= level && logFile.isOpen) {
|
if (logLevel >= level && logFile.isOpen) {
|
||||||
SysTime ts = Clock.currTime();
|
SysTime ts = Clock.currTime();
|
||||||
logFile.writef("%04d-%02d-%02d %02d:%02d:%02d.%03d %s ", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second, ts.fracSec.msecs, logLevelName(level));
|
logFile.writef("%04d-%02d-%02d %02d:%02d:%02d.%03d %s ", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second, ts.fracSec.msecs, logLevelName(level));
|
||||||
|
@ -51,27 +51,27 @@ class Log {
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void v(S...)(S args) {
|
static void v(S...)(S args) {
|
||||||
if (logLevel >= LogLevel.Trace && logFile.isOpen)
|
if (logLevel >= LogLevel.Trace && logFile.isOpen)
|
||||||
log(LogLevel.Trace, args);
|
log(LogLevel.Trace, args);
|
||||||
}
|
}
|
||||||
public static void d(S...)(S args) {
|
static void d(S...)(S args) {
|
||||||
if (logLevel >= LogLevel.Debug && logFile.isOpen)
|
if (logLevel >= LogLevel.Debug && logFile.isOpen)
|
||||||
log(LogLevel.Debug, args);
|
log(LogLevel.Debug, args);
|
||||||
}
|
}
|
||||||
public static void i(S...)(S args) {
|
static void i(S...)(S args) {
|
||||||
if (logLevel >= LogLevel.Info && logFile.isOpen)
|
if (logLevel >= LogLevel.Info && logFile.isOpen)
|
||||||
log(LogLevel.Info, args);
|
log(LogLevel.Info, args);
|
||||||
}
|
}
|
||||||
public static void w(S...)(S args) {
|
static void w(S...)(S args) {
|
||||||
if (logLevel >= LogLevel.Warn && logFile.isOpen)
|
if (logLevel >= LogLevel.Warn && logFile.isOpen)
|
||||||
log(LogLevel.Warn, args);
|
log(LogLevel.Warn, args);
|
||||||
}
|
}
|
||||||
public static void e(S...)(S args) {
|
static void e(S...)(S args) {
|
||||||
if (logLevel >= LogLevel.Error && logFile.isOpen)
|
if (logLevel >= LogLevel.Error && logFile.isOpen)
|
||||||
log(LogLevel.Error, args);
|
log(LogLevel.Error, args);
|
||||||
}
|
}
|
||||||
public static void f(S...)(S args) {
|
static void f(S...)(S args) {
|
||||||
if (logLevel >= LogLevel.Fatal && logFile.isOpen)
|
if (logLevel >= LogLevel.Fatal && logFile.isOpen)
|
||||||
log(LogLevel.Fatal, args);
|
log(LogLevel.Fatal, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ module dlangui.graphics.drawbuf;
|
||||||
|
|
||||||
public import dlangui.core.types;
|
public import dlangui.core.types;
|
||||||
|
|
||||||
public uint blendARGB(uint dst, uint src, uint alpha) {
|
uint blendARGB(uint dst, uint src, uint alpha) {
|
||||||
uint srcr = (src >> 16) & 0xFF;
|
uint srcr = (src >> 16) & 0xFF;
|
||||||
uint srcg = (src >> 8) & 0xFF;
|
uint srcg = (src >> 8) & 0xFF;
|
||||||
uint srcb = (src >> 0) & 0xFF;
|
uint srcb = (src >> 0) & 0xFF;
|
||||||
|
@ -18,10 +18,10 @@ public uint blendARGB(uint dst, uint src, uint alpha) {
|
||||||
|
|
||||||
class DrawBuf : RefCountedObject {
|
class DrawBuf : RefCountedObject {
|
||||||
protected Rect _clipRect;
|
protected Rect _clipRect;
|
||||||
public @property int width() { return 0; }
|
@property int width() { return 0; }
|
||||||
public @property int height() { return 0; }
|
@property int height() { return 0; }
|
||||||
public @property ref Rect clipRect() { return _clipRect; }
|
@property ref Rect clipRect() { return _clipRect; }
|
||||||
public @property void clipRect(const ref Rect rect) {
|
@property void clipRect(const ref Rect rect) {
|
||||||
_clipRect = rect;
|
_clipRect = rect;
|
||||||
_clipRect.intersect(Rect(0, 0, width, height));
|
_clipRect.intersect(Rect(0, 0, width, height));
|
||||||
}
|
}
|
||||||
|
@ -38,29 +38,29 @@ class DrawBuf : RefCountedObject {
|
||||||
rc.bottom = height;
|
rc.bottom = height;
|
||||||
return !rc.empty();
|
return !rc.empty();
|
||||||
}
|
}
|
||||||
public void beforeDrawing() { }
|
void beforeDrawing() { }
|
||||||
public void afterDrawing() { }
|
void afterDrawing() { }
|
||||||
public uint * scanLine(int y) { return null; }
|
uint * scanLine(int y) { return null; }
|
||||||
abstract public void resize(int width, int height);
|
abstract void resize(int width, int height);
|
||||||
abstract public void fill(uint color);
|
abstract void fill(uint color);
|
||||||
public void fillRect(int left, int top, int right, int bottom, uint color) {
|
void fillRect(int left, int top, int right, int bottom, uint color) {
|
||||||
fillRect(Rect(left, top, right, bottom), color);
|
fillRect(Rect(left, top, right, bottom), color);
|
||||||
}
|
}
|
||||||
abstract public void fillRect(Rect rc, uint color);
|
abstract void fillRect(Rect rc, uint color);
|
||||||
abstract public void drawGlyph(int x, int y, ubyte[] src, int srcdx, int srcdy, uint color);
|
abstract void drawGlyph(int x, int y, ubyte[] src, int srcdx, int srcdy, uint color);
|
||||||
public void clear() {}
|
void clear() {}
|
||||||
public ~this() { clear(); }
|
~this() { clear(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ColorDrawBufBase : DrawBuf {
|
class ColorDrawBufBase : DrawBuf {
|
||||||
int _dx;
|
int _dx;
|
||||||
int _dy;
|
int _dy;
|
||||||
public @property override int width() { return _dx; }
|
@property override int width() { return _dx; }
|
||||||
public @property override int height() { return _dy; }
|
@property override int height() { return _dy; }
|
||||||
public override void fillRect(int left, int top, int right, int bottom, uint color) {
|
override void fillRect(int left, int top, int right, int bottom, uint color) {
|
||||||
fillRect(Rect(left, top, right, bottom), color);
|
fillRect(Rect(left, top, right, bottom), color);
|
||||||
}
|
}
|
||||||
public override void drawGlyph(int x, int y, ubyte[] src, int srcdx, int srcdy, uint color) {
|
override void drawGlyph(int x, int y, ubyte[] src, int srcdx, int srcdy, uint color) {
|
||||||
bool clipping = !_clipRect.empty();
|
bool clipping = !_clipRect.empty();
|
||||||
for (int yy = 0; yy < srcdy; yy++) {
|
for (int yy = 0; yy < srcdy; yy++) {
|
||||||
int liney = y + yy;
|
int liney = y + yy;
|
||||||
|
@ -89,7 +89,7 @@ class ColorDrawBufBase : DrawBuf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void fillRect(Rect rc, uint color) {
|
override void fillRect(Rect rc, uint color) {
|
||||||
if (applyClipping(rc)) {
|
if (applyClipping(rc)) {
|
||||||
for (int y = rc.top; y < rc.bottom; y++) {
|
for (int y = rc.top; y < rc.bottom; y++) {
|
||||||
uint * row = scanLine(y);
|
uint * row = scanLine(y);
|
||||||
|
@ -109,22 +109,22 @@ class ColorDrawBufBase : DrawBuf {
|
||||||
|
|
||||||
class ColorDrawBuf : ColorDrawBufBase {
|
class ColorDrawBuf : ColorDrawBufBase {
|
||||||
uint[] _buf;
|
uint[] _buf;
|
||||||
public this(int width, int height) {
|
this(int width, int height) {
|
||||||
resize(width, height);
|
resize(width, height);
|
||||||
}
|
}
|
||||||
public override uint * scanLine(int y) {
|
override uint * scanLine(int y) {
|
||||||
if (y >= 0 && y < _dy)
|
if (y >= 0 && y < _dy)
|
||||||
return _buf.ptr + _dx * y;
|
return _buf.ptr + _dx * y;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public override void resize(int width, int height) {
|
override void resize(int width, int height) {
|
||||||
if (_dx == width && _dy == height)
|
if (_dx == width && _dy == height)
|
||||||
return;
|
return;
|
||||||
_dx = width;
|
_dx = width;
|
||||||
_dy = height;
|
_dy = height;
|
||||||
_buf.length = _dx * _dy;
|
_buf.length = _dx * _dy;
|
||||||
}
|
}
|
||||||
public override void fill(uint color) {
|
override void fill(uint color) {
|
||||||
int len = _dx * _dy;
|
int len = _dx * _dy;
|
||||||
uint * p = _buf.ptr;
|
uint * p = _buf.ptr;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
|
|
|
@ -20,10 +20,10 @@ struct FontDef {
|
||||||
immutable FontFamily _family;
|
immutable FontFamily _family;
|
||||||
immutable string _face;
|
immutable string _face;
|
||||||
immutable ubyte _pitchAndFamily;
|
immutable ubyte _pitchAndFamily;
|
||||||
public @property FontFamily family() { return _family; }
|
@property FontFamily family() { return _family; }
|
||||||
public @property string face() { return _face; }
|
@property string face() { return _face; }
|
||||||
public @property ubyte pitchAndFamily() { return _pitchAndFamily; }
|
@property ubyte pitchAndFamily() { return _pitchAndFamily; }
|
||||||
public this(FontFamily family, string face, ubyte putchAndFamily) {
|
this(FontFamily family, string face, ubyte putchAndFamily) {
|
||||||
_family = family;
|
_family = family;
|
||||||
_face = face;
|
_face = face;
|
||||||
_pitchAndFamily = pitchAndFamily;
|
_pitchAndFamily = pitchAndFamily;
|
||||||
|
@ -33,7 +33,7 @@ struct FontDef {
|
||||||
/**
|
/**
|
||||||
* Font implementation based on Win32 API system fonts.
|
* Font implementation based on Win32 API system fonts.
|
||||||
*/
|
*/
|
||||||
public class Win32Font : Font {
|
class Win32Font : Font {
|
||||||
HFONT _hfont;
|
HFONT _hfont;
|
||||||
int _size;
|
int _size;
|
||||||
int _height;
|
int _height;
|
||||||
|
@ -47,16 +47,16 @@ public class Win32Font : Font {
|
||||||
GlyphCache _glyphCache;
|
GlyphCache _glyphCache;
|
||||||
|
|
||||||
/// need to call create() after construction to initialize font
|
/// need to call create() after construction to initialize font
|
||||||
public this() {
|
this() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// do cleanup
|
/// do cleanup
|
||||||
public ~this() {
|
~this() {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// cleanup resources
|
/// cleanup resources
|
||||||
public override void clear() {
|
override void clear() {
|
||||||
if (_hfont !is null)
|
if (_hfont !is null)
|
||||||
{
|
{
|
||||||
DeleteObject(_hfont);
|
DeleteObject(_hfont);
|
||||||
|
@ -102,7 +102,7 @@ public class Win32Font : Font {
|
||||||
return g[0];
|
return g[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Glyph * getCharGlyph(dchar ch) {
|
override Glyph * getCharGlyph(dchar ch) {
|
||||||
uint glyphIndex = getGlyphIndex(ch);
|
uint glyphIndex = getGlyphIndex(ch);
|
||||||
if (!glyphIndex)
|
if (!glyphIndex)
|
||||||
return null;
|
return null;
|
||||||
|
@ -185,7 +185,7 @@ public class Win32Font : Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw text string to buffer
|
// draw text string to buffer
|
||||||
public override void drawText(DrawBuf buf, int x, int y, const dchar[] text, uint color) {
|
override void drawText(DrawBuf buf, int x, int y, const dchar[] text, uint color) {
|
||||||
int[] widths;
|
int[] widths;
|
||||||
int charsMeasured = measureText(text, widths, 3000);
|
int charsMeasured = measureText(text, widths, 3000);
|
||||||
for (int i = 0; i < charsMeasured; i++) {
|
for (int i = 0; i < charsMeasured; i++) {
|
||||||
|
@ -204,7 +204,7 @@ public class Win32Font : Font {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int measureText(const dchar[] text, ref int[] widths, int maxWidth) {
|
override int measureText(const dchar[] text, ref int[] widths, int maxWidth) {
|
||||||
if (_hfont is null || _drawbuf is null || text.length == 0)
|
if (_hfont is null || _drawbuf is null || text.length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
wstring utf16text = toUTF16(text);
|
wstring utf16text = toUTF16(text);
|
||||||
|
@ -238,7 +238,7 @@ public class Win32Font : Font {
|
||||||
return measured;
|
return measured;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool create(FontDef * def, int size, int weight, bool italic) {
|
bool create(FontDef * def, int size, int weight, bool italic) {
|
||||||
if (!isNull())
|
if (!isNull())
|
||||||
clear();
|
clear();
|
||||||
LOGFONTA lf;
|
LOGFONTA lf;
|
||||||
|
@ -279,14 +279,14 @@ public class Win32Font : Font {
|
||||||
_glyphCache.cleanup();
|
_glyphCache.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public @property override int size() { return _size; }
|
@property override int size() { return _size; }
|
||||||
public @property override int height() { return _height; }
|
@property override int height() { return _height; }
|
||||||
public @property override int weight() { return _weight; }
|
@property override int weight() { return _weight; }
|
||||||
public @property override int baseline() { return _baseline; }
|
@property override int baseline() { return _baseline; }
|
||||||
public @property override bool italic() { return _italic; }
|
@property override bool italic() { return _italic; }
|
||||||
public @property override string face() { return _face; }
|
@property override string face() { return _face; }
|
||||||
public @property override FontFamily family() { return _family; }
|
@property override FontFamily family() { return _family; }
|
||||||
public @property override bool isNull() { return _hfont is null; }
|
@property override bool isNull() { return _hfont is null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,13 +299,13 @@ class Win32FontManager : FontManager {
|
||||||
FontDef*[string] _faceByName;
|
FontDef*[string] _faceByName;
|
||||||
|
|
||||||
/// initialize in constructor
|
/// initialize in constructor
|
||||||
public this() {
|
this() {
|
||||||
instance = this;
|
instance = this;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// initialize font manager by enumerating of system fonts
|
/// initialize font manager by enumerating of system fonts
|
||||||
public bool init() {
|
bool init() {
|
||||||
Log.i("Win32FontManager.init()");
|
Log.i("Win32FontManager.init()");
|
||||||
Win32ColorDrawBuf drawbuf = new Win32ColorDrawBuf(1,1);
|
Win32ColorDrawBuf drawbuf = new Win32ColorDrawBuf(1,1);
|
||||||
LOGFONTA lf;
|
LOGFONTA lf;
|
||||||
|
@ -329,7 +329,7 @@ class Win32FontManager : FontManager {
|
||||||
FontRef _emptyFontRef;
|
FontRef _emptyFontRef;
|
||||||
|
|
||||||
/// get font by properties
|
/// get font by properties
|
||||||
public override ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face) {
|
override ref FontRef getFont(int size, int weight, bool italic, FontFamily family, string face) {
|
||||||
Log.i("getFont()");
|
Log.i("getFont()");
|
||||||
FontDef * def = findFace(family, face);
|
FontDef * def = findFace(family, face);
|
||||||
if (def !is null) {
|
if (def !is null) {
|
||||||
|
@ -391,7 +391,7 @@ class Win32FontManager : FontManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// find font face definition by family and face
|
/// find font face definition by family and face
|
||||||
public FontDef * findFace(FontFamily family, string face) {
|
FontDef * findFace(FontFamily family, string face) {
|
||||||
// by face only
|
// by face only
|
||||||
FontDef * res = findFace(face);
|
FontDef * res = findFace(face);
|
||||||
if (res !is null)
|
if (res !is null)
|
||||||
|
@ -412,7 +412,7 @@ class Win32FontManager : FontManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// register enumerated font
|
/// register enumerated font
|
||||||
public bool registerFont(FontFamily family, string fontFace, ubyte pitchAndFamily) {
|
bool registerFont(FontFamily family, string fontFace, ubyte pitchAndFamily) {
|
||||||
Log.d("registerFont(", family, ",", fontFace, ")");
|
Log.d("registerFont(", family, ",", fontFace, ")");
|
||||||
_fontFaces ~= FontDef(family, fontFace, pitchAndFamily);
|
_fontFaces ~= FontDef(family, fontFace, pitchAndFamily);
|
||||||
_faceByName[fontFace] = &_fontFaces[$ - 1];
|
_faceByName[fontFace] = &_fontFaces[$ - 1];
|
||||||
|
@ -420,12 +420,12 @@ class Win32FontManager : FontManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// clear usage flags for all entries
|
/// clear usage flags for all entries
|
||||||
public override void checkpoint() {
|
override void checkpoint() {
|
||||||
_activeFonts.checkpoint();
|
_activeFonts.checkpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// removes entries not used after last call of checkpoint() or cleanup()
|
/// removes entries not used after last call of checkpoint() or cleanup()
|
||||||
public override void cleanup() {
|
override void cleanup() {
|
||||||
_activeFonts.cleanup();
|
_activeFonts.cleanup();
|
||||||
//_list.cleanup();
|
//_list.cleanup();
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ class Win32Window : Window {
|
||||||
private HWND _hwnd;
|
private HWND _hwnd;
|
||||||
string _caption;
|
string _caption;
|
||||||
Win32ColorDrawBuf _drawbuf;
|
Win32ColorDrawBuf _drawbuf;
|
||||||
public this(string windowCaption, Window parent) {
|
this(string windowCaption, Window parent) {
|
||||||
_caption = windowCaption;
|
_caption = windowCaption;
|
||||||
_hwnd = CreateWindow(toUTF16z(WIN_CLASS_NAME), // window class name
|
_hwnd = CreateWindow(toUTF16z(WIN_CLASS_NAME), // window class name
|
||||||
toUTF16z(windowCaption), // window caption
|
toUTF16z(windowCaption), // window caption
|
||||||
|
@ -503,7 +503,7 @@ class Win32Window : Window {
|
||||||
_hInstance, // program instance handle
|
_hInstance, // program instance handle
|
||||||
cast(void*)this); // creation parameters
|
cast(void*)this); // creation parameters
|
||||||
}
|
}
|
||||||
public Win32ColorDrawBuf getDrawBuf() {
|
Win32ColorDrawBuf getDrawBuf() {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(_hwnd, &rect);
|
GetClientRect(_hwnd, &rect);
|
||||||
int dx = rect.right - rect.left;
|
int dx = rect.right - rect.left;
|
||||||
|
@ -514,29 +514,29 @@ class Win32Window : Window {
|
||||||
_drawbuf.resize(dx, dy);
|
_drawbuf.resize(dx, dy);
|
||||||
return _drawbuf;
|
return _drawbuf;
|
||||||
}
|
}
|
||||||
public override void show() {
|
override void show() {
|
||||||
ShowWindow(_hwnd, _cmdShow);
|
ShowWindow(_hwnd, _cmdShow);
|
||||||
UpdateWindow(_hwnd);
|
UpdateWindow(_hwnd);
|
||||||
}
|
}
|
||||||
public override @property string windowCaption() {
|
override @property string windowCaption() {
|
||||||
return _caption;
|
return _caption;
|
||||||
}
|
}
|
||||||
public override @property void windowCaption(string caption) {
|
override @property void windowCaption(string caption) {
|
||||||
_caption = caption;
|
_caption = caption;
|
||||||
SetWindowTextW(_hwnd, toUTF16z(_caption));
|
SetWindowTextW(_hwnd, toUTF16z(_caption));
|
||||||
}
|
}
|
||||||
public void onCreate() {
|
void onCreate() {
|
||||||
writeln("Window onCreate");
|
writeln("Window onCreate");
|
||||||
}
|
}
|
||||||
public void onDestroy() {
|
void onDestroy() {
|
||||||
writeln("Window onDestroy");
|
writeln("Window onDestroy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Win32Platform : Platform {
|
class Win32Platform : Platform {
|
||||||
public this() {
|
this() {
|
||||||
}
|
}
|
||||||
public bool registerWndClass() {
|
bool registerWndClass() {
|
||||||
//MSG msg;
|
//MSG msg;
|
||||||
WNDCLASS wndclass;
|
WNDCLASS wndclass;
|
||||||
|
|
||||||
|
@ -557,7 +557,7 @@ class Win32Platform : Platform {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public override int enterMessageLoop() {
|
override int enterMessageLoop() {
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (GetMessage(&msg, null, 0, 0))
|
while (GetMessage(&msg, null, 0, 0))
|
||||||
{
|
{
|
||||||
|
@ -566,7 +566,7 @@ class Win32Platform : Platform {
|
||||||
}
|
}
|
||||||
return msg.wParam;
|
return msg.wParam;
|
||||||
}
|
}
|
||||||
public override Window createWindow(string windowCaption, Window parent) {
|
override Window createWindow(string windowCaption, Window parent) {
|
||||||
return new Win32Window(windowCaption, parent);
|
return new Win32Window(windowCaption, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,16 +628,16 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
||||||
uint * _pixels;
|
uint * _pixels;
|
||||||
HDC _drawdc;
|
HDC _drawdc;
|
||||||
HBITMAP _drawbmp;
|
HBITMAP _drawbmp;
|
||||||
public @property HDC dc() { return _drawdc; }
|
@property HDC dc() { return _drawdc; }
|
||||||
public this(int width, int height) {
|
this(int width, int height) {
|
||||||
resize(width, height);
|
resize(width, height);
|
||||||
}
|
}
|
||||||
public override uint * scanLine(int y) {
|
override uint * scanLine(int y) {
|
||||||
if (y >= 0 && y < _dy)
|
if (y >= 0 && y < _dy)
|
||||||
return _pixels + _dx * (_dy - 1 - y);
|
return _pixels + _dx * (_dy - 1 - y);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public override void clear() {
|
override void clear() {
|
||||||
if (_drawbmp !is null) {
|
if (_drawbmp !is null) {
|
||||||
DeleteObject( _drawbmp );
|
DeleteObject( _drawbmp );
|
||||||
DeleteObject( _drawdc );
|
DeleteObject( _drawdc );
|
||||||
|
@ -646,7 +646,7 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
||||||
_dy = 0;
|
_dy = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void resize(int width, int height) {
|
override void resize(int width, int height) {
|
||||||
if (width< 0)
|
if (width< 0)
|
||||||
width = 0;
|
width = 0;
|
||||||
if (height < 0)
|
if (height < 0)
|
||||||
|
@ -675,12 +675,12 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
||||||
SelectObject(_drawdc, _drawbmp);
|
SelectObject(_drawdc, _drawbmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void fill(uint color) {
|
override void fill(uint color) {
|
||||||
int len = _dx * _dy;
|
int len = _dx * _dy;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
_pixels[i] = color;
|
_pixels[i] = color;
|
||||||
}
|
}
|
||||||
public void drawTo(HDC dc, int x, int y) {
|
void drawTo(HDC dc, int x, int y) {
|
||||||
BitBlt(dc, x, y, _dx, _dx, _drawdc, 0, 0, SRCCOPY);
|
BitBlt(dc, x, y, _dx, _dx, _drawdc, 0, 0, SRCCOPY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue