implement stuff on gdi backend
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@264 b9cfdab3-6d41-4d17-bbe4-086880011989
@@ -30,7 +30,7 @@ L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldf
|
||||
L_OBJS += src/external/ds.o src/external/image.o
|
||||
L_OBJS += src/widget/window.o src/widget/button.o src/widget/frame.o src/widget/menu.o src/widget/submenu.o src/widget/image.o src/widget/scrollbar.o src/widget/checkbox.o src/widget/label.o src/widget/entry.o src/widget/numberentry.o
|
||||
L_OBJS += src/cursor/default.o src/cursor/cross.o src/cursor/text.o
|
||||
L_OBJS += src/icon/question.o src/icon/warning.o src/icon/note.o src/icon/info.o src/icon/news.o
|
||||
L_OBJS += src/icon/question.o src/icon/warning.o src/icon/note.o src/icon/info.o src/icon/news.o src/icon/error.o
|
||||
|
||||
OOL_CXXFLAGS = $(DEPINC) $(CFLAGS) -std=c++98 -fPIC
|
||||
OOL_LDFLAGS = $(LDFLAGS) -L src
|
||||
|
||||
@@ -6,15 +6,22 @@ void ok(MwWidget handle, void* user, void* call) {
|
||||
}
|
||||
|
||||
void spawn(MwWidget handle, void* user, void* call) {
|
||||
MwWidget mb = MwMessageBox(user, "new news arrived!", "title", MwMB_ICONNEWS | MwMB_BUTTONOK);
|
||||
MwWidget mb = MwMessageBox(user, "news has arrived!", "title", MwMB_ICONNEWS | MwMB_BUTTONOK);
|
||||
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
|
||||
}
|
||||
|
||||
void spawn2(MwWidget handle, void* user, void* call) {
|
||||
MwWidget mb = MwMessageBox(user, "something went wrong!", "title", MwMB_ICONERROR | MwMB_BUTTONOK);
|
||||
MwAddUserHandler(MwMessageBoxGetChild(mb, MwMB_BUTTONOK), MwNactivateHandler, ok, mb);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MwWidget msg = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 300, 100, MwNtitle, "test", NULL);
|
||||
MwWidget btn = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8, 300 - 16, 100 - 16, MwNtext, "press me!", NULL);
|
||||
MwWidget msg = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 300, 100, MwNtitle, "test", NULL);
|
||||
MwWidget btn = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8, 300 - 16, (100 - 16) / 2, MwNtext, "press me!", NULL);
|
||||
MwWidget btn2 = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8 + (100 - 16) / 2, 300 - 16, (100 - 16) / 2, MwNtext, "press me!", NULL);
|
||||
|
||||
MwAddUserHandler(btn, MwNactivateHandler, spawn, msg);
|
||||
MwAddUserHandler(btn2, MwNactivateHandler, spawn2, msg);
|
||||
|
||||
MwLoop(msg);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,11 @@ enum MwALIGNMENT {
|
||||
*/
|
||||
#define MwMB_ICONNEWS 0x5
|
||||
|
||||
/*!
|
||||
* %brief Error icon
|
||||
*/
|
||||
#define MwMB_ICONERROR 0x6
|
||||
|
||||
/*!
|
||||
* %brief Button mask
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* %brief Error icon
|
||||
*/
|
||||
MWDECL char* MwIconError[];
|
||||
|
||||
/*!
|
||||
* %brief Info icon
|
||||
*/
|
||||
|
||||
BIN
resource/icon/error.gif
Normal file
|
After Width: | Height: | Size: 478 B |
BIN
resource/icon/error.png
Normal file
|
After Width: | Height: | Size: 663 B |
|
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 434 B |
|
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
|
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 594 B |
|
Before Width: | Height: | Size: 529 B After Width: | Height: | Size: 529 B |
|
Before Width: | Height: | Size: 498 B After Width: | Height: | Size: 498 B |
@@ -2,8 +2,11 @@
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
typedef struct userdata {
|
||||
MwLL ll;
|
||||
WNDPROC old;
|
||||
MwLL ll;
|
||||
POINT min;
|
||||
POINT max;
|
||||
int min_set;
|
||||
int max_set;
|
||||
} userdata_t;
|
||||
|
||||
static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||
@@ -83,8 +86,39 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||
if(wp == VK_LEFT) n = MwLLKeyLeft;
|
||||
if(wp == VK_RIGHT) n = MwLLKeyRight;
|
||||
if(n != -1) MwLLDispatch(u->ll, key, &n);
|
||||
} else if(msg == WM_GETMINMAXINFO) {
|
||||
if(u->min_set || u->max_set) {
|
||||
LPARAM style = GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||
MINMAXINFO* mmi = (MINMAXINFO*)lp;
|
||||
if(u->min_set) {
|
||||
RECT rc;
|
||||
|
||||
rc.left = 0;
|
||||
rc.top = 0;
|
||||
rc.right = u->min.x;
|
||||
rc.bottom = u->min.y;
|
||||
AdjustWindowRect(&rc, style, FALSE);
|
||||
|
||||
mmi->ptMinTrackSize.x = rc.right - rc.left;
|
||||
mmi->ptMinTrackSize.y = rc.bottom - rc.top;
|
||||
}
|
||||
if(u->max_set) {
|
||||
RECT rc;
|
||||
|
||||
rc.left = 0;
|
||||
rc.top = 0;
|
||||
rc.right = u->min.x;
|
||||
rc.bottom = u->min.y;
|
||||
AdjustWindowRect(&rc, style, FALSE);
|
||||
|
||||
mmi->ptMaxTrackSize.x = rc.right - rc.left;
|
||||
mmi->ptMaxTrackSize.y = rc.bottom - rc.top;
|
||||
}
|
||||
} else {
|
||||
return DefWindowProc(hWnd, msg, wp, lp);
|
||||
}
|
||||
} else {
|
||||
return (u->old == NULL) ? DefWindowProc(hWnd, msg, wp, lp) : CallWindowProc(u->old, hWnd, msg, wp, lp);
|
||||
return DefWindowProc(hWnd, msg, wp, lp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -113,15 +147,12 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
|
||||
RegisterClassEx(&wc);
|
||||
|
||||
r->copy_buffer = 1;
|
||||
r->hWnd = CreateWindow(parent == NULL ? "milsko" : "STATIC", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->hWnd, 0, wc.hInstance, NULL);
|
||||
r->hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->hWnd, 0, wc.hInstance, NULL);
|
||||
r->hInstance = wc.hInstance;
|
||||
|
||||
u->ll = r;
|
||||
if(parent == NULL) {
|
||||
u->old = NULL;
|
||||
} else {
|
||||
u->old = (WNDPROC)SetWindowLongPtr(r->hWnd, GWLP_WNDPROC, (LPARAM)wndproc);
|
||||
}
|
||||
u->ll = r;
|
||||
u->min_set = 0;
|
||||
u->max_set = 0;
|
||||
SetWindowLongPtr(r->hWnd, GWLP_USERDATA, (LPARAM)u);
|
||||
|
||||
if(parent == NULL) {
|
||||
@@ -383,23 +414,22 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
|
||||
}
|
||||
|
||||
void MwLLDetach(MwLL handle, MwPoint* point) {
|
||||
RECT rc, rc2;
|
||||
LPARAM style = GetWindowLongPtr(handle->hWnd, GWL_STYLE);
|
||||
|
||||
style |= WS_OVERLAPPEDWINDOW;
|
||||
|
||||
RECT rc, rc2;
|
||||
GetWindowRect(GetParent(handle->hWnd), &rc);
|
||||
|
||||
GetClientRect(handle->hWnd, &rc2);
|
||||
|
||||
SetWindowLongPtr(handle->hWnd, GWL_STYLE, (LPARAM)WS_OVERLAPPEDWINDOW | WS_VISIBLE);
|
||||
SetParent(handle->hWnd, NULL);
|
||||
|
||||
rc.left += point->x;
|
||||
rc.top += point->y;
|
||||
|
||||
SetWindowPos(handle->hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_NOREDRAW);
|
||||
AdjustWindowRect(&rc2, WS_OVERLAPPEDWINDOW | WS_VISIBLE, FALSE);
|
||||
rc2.right -= rc2.left;
|
||||
rc2.bottom -= rc2.top;
|
||||
|
||||
SetWindowLongPtr(handle->hWnd, GWL_STYLE, style);
|
||||
SetWindowPos(handle->hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
void MwLLShow(MwLL handle, int show) {
|
||||
@@ -414,4 +444,11 @@ void MwLLMakePopup(MwLL handle, MwLL parent) {
|
||||
}
|
||||
|
||||
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||
userdata_t* u = (userdata_t*)GetWindowLongPtr(handle->hWnd, GWLP_USERDATA);
|
||||
|
||||
u->min_set = u->max_set = 1;
|
||||
u->min.x = minx;
|
||||
u->min.y = miny;
|
||||
u->max.x = maxx;
|
||||
u->max.y = maxy;
|
||||
}
|
||||
|
||||
48
src/icon/error.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
/* XPM */
|
||||
char* MwIconError[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"32 32 8 1 ",
|
||||
" c None",
|
||||
". c black",
|
||||
"X c white",
|
||||
"o c gray",
|
||||
"O c gainsboro",
|
||||
"+ c lavender",
|
||||
"@ c DarkSlateGray",
|
||||
"# c SlateGray",
|
||||
/* pixels */
|
||||
" ... ... ",
|
||||
" .Xo. .XX. ",
|
||||
"..XXo. .XXX..",
|
||||
".XXoo. .XXOo.",
|
||||
".XXooo. ......... .XOooo.",
|
||||
" ...Xoo...O+++++++o.. .Xoo...@",
|
||||
" .Xo.#O++XXXXX++Oo. .Xoo.@@@@",
|
||||
" ..#OO+XXXXXX+OOOo.#oo.@@ ",
|
||||
" .OOO+XXXXX++OOOo.@#.@@ ",
|
||||
" .#OOO+XXXX++OOOoo#..@@ ",
|
||||
" .#OOO+XX+++OOOOoo#.@@ ",
|
||||
" .#ooo+++++OOOOo###.@@@ ",
|
||||
" .ooXXXXX+OOO++++##.@@@ ",
|
||||
" .oXXOOOOOOO++OOoo#.@@@ ",
|
||||
" .oo...OOOOO...oo..@@@ ",
|
||||
" .o.....ooo.....o.@@@@ ",
|
||||
" .X.....ooo...@#o.@@@ ",
|
||||
" .oX@@@@.Xoo.@##@oo.@@ ",
|
||||
" .OXo@@.Xo.oX.@@oXo.@@@ ",
|
||||
" .OOXXXXo...oXXXOoo.@@@ ",
|
||||
" ..oOOXo.o.oOOOo..@.@@ ",
|
||||
" ..oOOo.o.oOOo..@##.@ ",
|
||||
" ..o.oXXXXXOOo.o..###. ",
|
||||
" .oo.o.@oXXo...o.@@.#oX... ",
|
||||
" .XXo.X@o....@o.o.@@@.ooXXX. ",
|
||||
" ...XXo..X@X@o@o@X.o.@@@ .oXoo. ",
|
||||
".XXXoo.@@.X.@X@X@.o.@@@@ .Xoo..@",
|
||||
".XXXo.@@@.X.@o@o@.o.@@@ .oo.@@@",
|
||||
"..ooo.@@ .X.....o.@@@@ ...@@ ",
|
||||
" .oo.@ .XXXXooo.@@@ @@@ ",
|
||||
" ...@@ .ooooo.@@@ ",
|
||||
" @@@@ .....@@ "};
|
||||
@@ -25,12 +25,14 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
||||
int w, h;
|
||||
int left = 8;
|
||||
int th;
|
||||
int x = 0;
|
||||
int x = 0;
|
||||
int ww = MwGetInteger(handle, MwNwidth);
|
||||
int wh = MwGetInteger(handle, MwNheight);
|
||||
|
||||
p.x = 0;
|
||||
p.y = 0;
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "messagebox", handle, 0, 0, (w = 512), (h = 32 * 4),
|
||||
window = MwVaCreateWidget(MwWindowClass, "messagebox", handle, ww, wh, (w = 512), (h = 32 * 4),
|
||||
MwNtitle, title,
|
||||
NULL);
|
||||
|
||||
@@ -70,6 +72,10 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
||||
data = MwIconNews;
|
||||
break;
|
||||
}
|
||||
case MwMB_ICONERROR: {
|
||||
data = MwIconError;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
px = MwLoadXPM(icon, data);
|
||||
|
||||