Skip to content

Commit

Permalink
从 ege.h 中移除 RGBTOBGR
Browse files Browse the repository at this point in the history
正常使用 EGE 过程中不会用到这个宏;
将 `sys_edit::onMessage` 的定义转移至 egegapi.cpp 以便使用 ARGBTOZBGR 宏
  • Loading branch information
chirsz-ever committed Jul 4, 2020
1 parent fa93449 commit 65bcfce
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/ege.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
#endif

#define SHOWCONSOLE 1 // 进入图形模式时,保留控制台的显示
#define RGBTOBGR(color) ((((color) & 0xFF) << 16) | (((color) & 0xFF0000) >> 16) | ((color) & 0xFF00FF00))
#define EGERGBA(r, g, b, a) ( ((r)<<16) | ((g)<<8) | (b) | ((a)<<24) )
#define EGERGB(r, g, b) EGERGBA(r, g, b, 0xFF)
#define EGEARGB(a, r, g, b) EGERGBA(r, g, b, a)
Expand Down
20 changes: 1 addition & 19 deletions src/ege/sys_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,7 @@ class sys_edit : public egeControlBase
}
return 0;
}
LRESULT onMessage(UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_CTLCOLOREDIT) {
HDC dc = (HDC)wParam;
HBRUSH br = ::CreateSolidBrush(RGBTOBGR(m_bgcolor));

::SetBkColor(dc, RGBTOBGR(m_bgcolor));
::SetTextColor(dc, RGBTOBGR(m_color));
::DeleteObject(m_hBrush);
m_hBrush = br;
return (LRESULT)br;
//} else if (message == WM_SETFOCUS) {
// int a = 0;
// int b = 1;
// return 0;
} else {
return ((LRESULT (CALLBACK *)(HWND, UINT, WPARAM, LPARAM))m_callback)(m_hwnd, message, wParam, lParam);
}
//return 0;
}
LRESULT onMessage(UINT message, WPARAM wParam, LPARAM lParam);
void visible(bool bvisible) {
egeControlBase::visible(bvisible);
::ShowWindow(m_hwnd, (int)bvisible);
Expand Down
3 changes: 3 additions & 0 deletions src/ege_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
#define IFATODOB(A, B) ( (A) && (B, 0) )
#define IFNATODOB(A, B) ( (A) || (B, 0) )

// 0xaarrggbb -> 0xaabbggrr
#define RGBTOBGR(color) ((((color) & 0xFF) << 16) | (((color) & 0xFF0000) >> 16) | ((color) & 0xFF00FF00))

// 将 color_t 与 Bitmap Buffer 所用的 0xaarrggbb 格式
// 转换为 COLORREF 所用的 0x00bbggrr,忽略 Alpha 通道
// 仅用于向 GDI32 API 传递颜色时
Expand Down
20 changes: 20 additions & 0 deletions src/egegapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2610,4 +2610,24 @@ ege_uncompress(void *dest, unsigned long *destLen, const void *source, unsigned
}
}

LRESULT sys_edit::onMessage(UINT message, WPARAM wParam, LPARAM lParam) {
if (message == WM_CTLCOLOREDIT) {
HDC dc = (HDC)wParam;
HBRUSH br = ::CreateSolidBrush(ARGBTOZBGR(m_bgcolor));

::SetBkColor(dc, ARGBTOZBGR(m_bgcolor));
::SetTextColor(dc, ARGBTOZBGR(m_color));
::DeleteObject(m_hBrush);
m_hBrush = br;
return (LRESULT)br;
//} else if (message == WM_SETFOCUS) {
// int a = 0;
// int b = 1;
// return 0;
} else {
return ((LRESULT (CALLBACK *)(HWND, UINT, WPARAM, LPARAM))m_callback)(m_hwnd, message, wParam, lParam);
}
//return 0;
}

} // namespace ege

0 comments on commit 65bcfce

Please sign in to comment.