mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-08 10:23:27 +00:00
add messagebox
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@338 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -3,13 +3,30 @@
|
|||||||
|
|
||||||
#include "../resource/harvard.c"
|
#include "../resource/harvard.c"
|
||||||
|
|
||||||
int main(){
|
MwWidget wmain;
|
||||||
MwWidget w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
|
|
||||||
MwNtitle, "test",
|
|
||||||
NULL);
|
|
||||||
MwWidget lb = MwCreateWidget(MwListBoxClass, "listbox", w, 5, 5, 630, 470);
|
|
||||||
|
|
||||||
MwListBoxInsertMultiple(lb, -1, (char**)harvard, sizeof(harvard) / sizeof(harvard[0]) - 1);
|
void destroy(MwWidget handle, void* user, void* call) {
|
||||||
|
MwDestroyWidget(user);
|
||||||
MwLoop(w);
|
}
|
||||||
|
|
||||||
|
void activate(MwWidget handle, void* user, void* call) {
|
||||||
|
char msg[256];
|
||||||
|
MwWidget msgbox;
|
||||||
|
sprintf(msg, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
|
||||||
|
|
||||||
|
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
||||||
|
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MwWidget lb;
|
||||||
|
wmain = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
|
||||||
|
MwNtitle, "test",
|
||||||
|
NULL);
|
||||||
|
lb = MwCreateWidget(MwListBoxClass, "listbox", wmain, 5, 5, 630, 470);
|
||||||
|
|
||||||
|
MwAddUserHandler(lb, MwNactivateHandler, activate, NULL);
|
||||||
|
MwListBoxInsertMultiple(lb, -1, (char**)harvard, sizeof(harvard) / sizeof(harvard[0]) - 1);
|
||||||
|
|
||||||
|
MwLoop(wmain);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ struct _MwListBox {
|
|||||||
char** list;
|
char** list;
|
||||||
int selected;
|
int selected;
|
||||||
unsigned long click_time;
|
unsigned long click_time;
|
||||||
int pressed;
|
int pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwSizeHints {
|
struct _MwSizeHints {
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ static void frame_mouse_up(MwWidget handle, void* user, void* call) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
||||||
MwListBox lb = handle->parent->internal;
|
MwListBox lb = handle->parent->internal;
|
||||||
MwPoint* p = call;
|
MwPoint* p = call;
|
||||||
if(lb->pressed) {
|
if(lb->pressed) {
|
||||||
int st = 0;
|
int st = 0;
|
||||||
int i;
|
int i;
|
||||||
@@ -64,7 +64,7 @@ static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
|||||||
st = get_first_entry(lb);
|
st = get_first_entry(lb);
|
||||||
for(i = 0; i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) {
|
for(i = 0; i < (h - MwDefaultBorderWidth * 2) / MwTextHeight(handle, "M"); i++) {
|
||||||
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M"))) {
|
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M"))) {
|
||||||
lb->selected = st + i;
|
lb->selected = st + i;
|
||||||
}
|
}
|
||||||
y += MwTextHeight(handle, "M");
|
y += MwTextHeight(handle, "M");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
open(IN, "<", "resource/harvard.txt");
|
open(IN, "<", "resource/harvard.txt");
|
||||||
print("const char* harvard[] = {\n");
|
print("const char* harvard[] = {\n");
|
||||||
while(my $l = <IN>){
|
while (my $l = <IN>) {
|
||||||
$l =~ s/\r?\n$//;
|
$l =~ s/\r?\n$//;
|
||||||
if($l =~ /^[ \t]*[0-9]+\. (.+)$/){
|
if ($l =~ /^[ \t]*[0-9]+\. (.+)$/) {
|
||||||
print(" \"" . $1 . "\",\n");
|
print(" \"" . $1 . "\",\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(" NULL\n");
|
print(" NULL\n");
|
||||||
print("};\n");
|
print("};\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user