mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
add a messagebox example
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@262 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -135,7 +135,7 @@ else
|
||||
L_CFLAGS += -DUSE_STB_IMAGE
|
||||
endif
|
||||
|
||||
EXAMPLES = examples/example$(EXEC) examples/rotate$(EXEC) examples/image$(EXEC) examples/scrollbar$(EXEC) examples/checkbox$(EXEC)
|
||||
EXAMPLES = examples/example$(EXEC) examples/rotate$(EXEC) examples/image$(EXEC) examples/scrollbar$(EXEC) examples/checkbox$(EXEC) examples/messagebox$(EXEC)
|
||||
|
||||
ifeq ($(OPENGL),1)
|
||||
L_OBJS += src/widget/opengl.o
|
||||
|
||||
20
examples/messagebox.c
Normal file
20
examples/messagebox.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
void ok(MwWidget handle, void* user, void* call) {
|
||||
MwDestroyWidget(user);
|
||||
}
|
||||
|
||||
void spawn(MwWidget handle, void* user, void* call) {
|
||||
MwWidget mb = MwMessageBox(user, "new news arrived!", "title", MwMB_ICONNEWS | 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);
|
||||
|
||||
MwAddUserHandler(btn, MwNactivateHandler, spawn, msg);
|
||||
|
||||
MwLoop(msg);
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#define MwNpixmap "Vpixmap"
|
||||
#define MwNiconPixmap "ViconPixmap"
|
||||
#define MwNsizeHints "VsizeHints"
|
||||
|
||||
#define MwNactivateHandler "Cactivate"
|
||||
#define MwNresizeHandler "Cresize"
|
||||
|
||||
@@ -19,6 +19,7 @@ typedef struct _MwFont MwFont;
|
||||
typedef struct _MwMenu* MwMenu;
|
||||
typedef struct _MwCursor MwCursor;
|
||||
typedef struct _MwEntry* MwEntry;
|
||||
typedef struct _MwSizeHints MwSizeHints;
|
||||
#ifdef _MILSKO
|
||||
typedef struct _MwWidget* MwWidget;
|
||||
#else
|
||||
@@ -108,6 +109,13 @@ struct _MwEntry {
|
||||
MwPoint mouse;
|
||||
};
|
||||
|
||||
struct _MwSizeHints {
|
||||
int min_width;
|
||||
int min_height;
|
||||
int max_width;
|
||||
int max_height;
|
||||
};
|
||||
|
||||
#define MwCursorDataHeight 16
|
||||
struct _MwCursor {
|
||||
int width;
|
||||
|
||||
@@ -258,6 +258,9 @@ void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||
void MwSetVoid(MwWidget handle, const char* key, void* value) {
|
||||
if(strcmp(key, MwNiconPixmap) == 0) {
|
||||
MwLLSetIcon(handle->lowlevel, value);
|
||||
} else if(strcmp(key, MwNsizeHints) == 0) {
|
||||
MwSizeHints* sz = value;
|
||||
MwLLSetSizeHints(handle->lowlevel, sz->min_width, sz->min_height, sz->max_width, sz->max_height);
|
||||
} else {
|
||||
shput(handle->data, key, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user