update
This commit is contained in:
parent
20022ebe1d
commit
b2bf457df5
6 changed files with 167 additions and 111 deletions
2
external/ppr
vendored
2
external/ppr
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit f9218619766942366adc6443869aafd8350fb79e
|
||||
Subproject commit 1baa36725d2a75333f1ed0d2b355dfc0398a07be
|
||||
124
src/gui.c
124
src/gui.c
|
|
@ -1,45 +1,8 @@
|
|||
#define _MILSKO
|
||||
#define LOAD_ICONS
|
||||
#include <midas.h>
|
||||
|
||||
MwWidget window, menu = NULL, fileview = NULL, editor = NULL, console = NULL;
|
||||
|
||||
static MwMenu m_about_midas;
|
||||
|
||||
static void image_draw_inject(MwWidget handle) {
|
||||
char version[128];
|
||||
MwPoint p, p2;
|
||||
MwLLColor c = MwParseColor(handle, "#fff");
|
||||
MwLLColor cd = MwParseColor(handle, "#222");
|
||||
MwFLFont f = MwFLBuildFont(0);
|
||||
|
||||
handle->bgcolor = MwParseColor(handle, "#888");
|
||||
|
||||
sprintf(version, "Version %s\n\n\xc2\xa9 Pyrite development team", VERSION);
|
||||
|
||||
p.x = MwGetInteger(handle, MwNwidth) - 16;
|
||||
p.y = MwGetInteger(handle, MwNheight) - 16 - MwTextHeight(handle, f, version) / 2;
|
||||
p2 = p;
|
||||
|
||||
p.x += 1;
|
||||
p.y += 1;
|
||||
MwDrawText(handle, f, &p, version, MwALIGNMENT_END, cd);
|
||||
p = p2;
|
||||
|
||||
MwDrawText(handle, f, &p, version, MwALIGNMENT_END, c);
|
||||
|
||||
MwLLFreeColor(handle->bgcolor);
|
||||
handle->bgcolor = NULL;
|
||||
|
||||
MwLLFreeColor(cd);
|
||||
MwLLFreeColor(c);
|
||||
}
|
||||
|
||||
static void menu_handler(MwWidget handle, void* user, void* client) {
|
||||
if(client == m_about_midas) {
|
||||
gui_version();
|
||||
}
|
||||
}
|
||||
static MwWidget loop;
|
||||
MwWidget window, menu = NULL, fileview = NULL, editor = NULL, console = NULL;
|
||||
|
||||
static void MWAPI resize(MwWidget handle, void* user, void* client) {
|
||||
int ww = MwGetInteger(window, MwNwidth);
|
||||
|
|
@ -48,18 +11,9 @@ static void MWAPI resize(MwWidget handle, void* user, void* client) {
|
|||
int padding = 5;
|
||||
|
||||
if(menu == NULL) {
|
||||
MwMenu m;
|
||||
|
||||
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "File");
|
||||
m = MwMenuAdd(menu, NULL, "Edit");
|
||||
m = MwMenuAdd(menu, NULL, "Project");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "?Help");
|
||||
m_about_midas = MwMenuAdd(menu, m, "About Midas");
|
||||
|
||||
MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL);
|
||||
gui_menu_init();
|
||||
}
|
||||
|
||||
ww -= padding * 2;
|
||||
|
|
@ -106,6 +60,7 @@ static void MWAPI resize(MwWidget handle, void* user, void* client) {
|
|||
console = MwCreateWidget(MwListBoxClass, "console", window, x, y, w, h);
|
||||
|
||||
MwListBoxSet(console, -1, 0, "Midas " VERSION " console");
|
||||
MwListBoxSet(console, -1, 0, "Milsko version " MwVERSION);
|
||||
} else {
|
||||
MwVaApply(console,
|
||||
MwNx, x,
|
||||
|
|
@ -116,6 +71,10 @@ static void MWAPI resize(MwWidget handle, void* user, void* client) {
|
|||
}
|
||||
}
|
||||
|
||||
static void window_close(MwWidget handle, void* user, void* client) {
|
||||
MwDestroyWidget(loop);
|
||||
}
|
||||
|
||||
static void tick(MwWidget handle, void* user, void* client) {
|
||||
dir_tick();
|
||||
}
|
||||
|
|
@ -126,7 +85,9 @@ void gui_init(void) {
|
|||
|
||||
MwLibraryInit();
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
|
||||
loop = MwCreateWidget(NULL, "loop", NULL, 0, 0, 0, 0);
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "window", loop, MwDEFAULT, MwDEFAULT, 640, 480,
|
||||
MwNtitle, "Midas",
|
||||
NULL);
|
||||
|
||||
|
|
@ -161,68 +122,13 @@ void gui_init(void) {
|
|||
resize(window, NULL, NULL);
|
||||
|
||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
||||
MwAddUserHandler(window, MwNcloseHandler, window_close, NULL);
|
||||
|
||||
MwAddUserHandler(loop, MwNtickHandler, tick, NULL);
|
||||
|
||||
MwTimeSleep(50);
|
||||
}
|
||||
|
||||
static void version_ok_activate(MwWidget handle, void* user, void* client) {
|
||||
int i;
|
||||
MwWidget* children = MwGetChildren(user);
|
||||
|
||||
for(i = 0; children[i] != NULL; i++) {
|
||||
if(MwGetClass(children[i]) == MwImageClass) {
|
||||
MwLLPixmap px = MwGetVoid(children[i], MwNpixmap);
|
||||
|
||||
MwVaApply(children[i],
|
||||
MwNpixmap, NULL,
|
||||
NULL);
|
||||
MwLLDestroyPixmap(px);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MwDestroyWidget(user);
|
||||
}
|
||||
|
||||
void gui_version(void) {
|
||||
MwWidget version, image, ok;
|
||||
MwRect rc;
|
||||
int x = MwGetInteger(window, MwNx);
|
||||
int y = MwGetInteger(window, MwNy);
|
||||
int ww = MwGetInteger(window, MwNwidth);
|
||||
int wh = MwGetInteger(window, MwNheight);
|
||||
int bsh = 48;
|
||||
int bh = bsh / 2;
|
||||
int w = 640;
|
||||
int h = 426 + bh;
|
||||
MwLLPixmap px = MwLoadIcon(window, icon_midas);
|
||||
MwSizeHints sh;
|
||||
|
||||
sh.min_width = sh.max_width = w;
|
||||
sh.min_height = sh.max_height = h;
|
||||
|
||||
MwGetScreenSize(window, &rc);
|
||||
|
||||
version = MwVaCreateWidget(MwWindowClass, "window", NULL, x + (ww - w) / 2, y + (wh - h) / 2, w, h,
|
||||
MwNtitle, "Version information",
|
||||
MwNsizeHints, &sh,
|
||||
NULL);
|
||||
|
||||
image = MwVaCreateWidget(MwImageClass, "image", version, 0, 0, w, h - bsh,
|
||||
MwNpixmap, px,
|
||||
NULL);
|
||||
image->draw_inject = image_draw_inject;
|
||||
|
||||
ok = MwVaCreateWidget(MwButtonClass, "btn", version, w - bh * 4 - (bsh - bh) / 2, h - bsh + (bsh - bh) / 2, bh * 4, bh,
|
||||
MwNtext, "OK",
|
||||
NULL);
|
||||
MwAddUserHandler(ok, MwNactivateHandler, version_ok_activate, version);
|
||||
|
||||
MwReparent(version, window);
|
||||
}
|
||||
|
||||
void gui_loop(void) {
|
||||
MwLoop(window);
|
||||
MwLoop(loop);
|
||||
}
|
||||
|
|
|
|||
30
src/gui_menu.c
Normal file
30
src/gui_menu.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include <midas.h>
|
||||
|
||||
static MwMenu m_exit, m_preferences, m_about_midas;
|
||||
|
||||
static void menu_handler(MwWidget handle, void* user, void* client) {
|
||||
if(client == m_exit) {
|
||||
MwDispatchUserHandler(window, MwNcloseHandler, NULL);
|
||||
} else if(client == m_preferences) {
|
||||
gui_preferences();
|
||||
} else if(client == m_about_midas) {
|
||||
gui_version();
|
||||
}
|
||||
}
|
||||
|
||||
void gui_menu_init(void) {
|
||||
MwMenu m;
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "File");
|
||||
m_exit = MwMenuAdd(menu, m, "Exit");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "Edit");
|
||||
m_preferences = MwMenuAdd(menu, m, "Preferences");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "Project");
|
||||
|
||||
m = MwMenuAdd(menu, NULL, "?Help");
|
||||
m_about_midas = MwMenuAdd(menu, m, "About Midas");
|
||||
|
||||
MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL);
|
||||
}
|
||||
23
src/gui_preferences.c
Normal file
23
src/gui_preferences.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include <midas.h>
|
||||
|
||||
static void pref_close(MwWidget handle, void* user, void* client) {
|
||||
MwDestroyWidget(user);
|
||||
}
|
||||
|
||||
void gui_preferences(void) {
|
||||
MwWidget pref;
|
||||
int x = MwGetInteger(window, MwNx);
|
||||
int y = MwGetInteger(window, MwNy);
|
||||
int ww = MwGetInteger(window, MwNwidth);
|
||||
int wh = MwGetInteger(window, MwNheight);
|
||||
int w = 640;
|
||||
int h = 480;
|
||||
|
||||
pref = MwVaCreateWidget(MwWindowClass, "window", NULL, x + (ww - w) / 2, y + (wh - h) / 2, w, h,
|
||||
MwNtitle, "Preferences",
|
||||
NULL);
|
||||
|
||||
MwAddUserHandler(pref, MwNcloseHandler, pref_close, pref);
|
||||
|
||||
MwReparent(pref, window);
|
||||
}
|
||||
89
src/gui_version.c
Normal file
89
src/gui_version.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
#define _MILSKO
|
||||
#include <midas.h>
|
||||
|
||||
static void image_draw_inject(MwWidget handle) {
|
||||
char version[128];
|
||||
MwPoint p, p2;
|
||||
MwLLColor c = MwParseColor(handle, "#fff");
|
||||
MwLLColor cd = MwParseColor(handle, "#222");
|
||||
MwFLFont f = MwFLBuildFont(0);
|
||||
|
||||
handle->bgcolor = MwParseColor(handle, "#888");
|
||||
|
||||
sprintf(version, "Version %s\n\n\xc2\xa9 Pyrite development team", VERSION);
|
||||
|
||||
p.x = MwGetInteger(handle, MwNwidth) - 16;
|
||||
p.y = MwGetInteger(handle, MwNheight) - 16 - MwTextHeight(handle, f, version) / 2;
|
||||
p2 = p;
|
||||
|
||||
p.x += 1;
|
||||
p.y += 1;
|
||||
MwDrawText(handle, f, &p, version, MwALIGNMENT_END, cd);
|
||||
p = p2;
|
||||
|
||||
MwDrawText(handle, f, &p, version, MwALIGNMENT_END, c);
|
||||
|
||||
MwLLFreeColor(handle->bgcolor);
|
||||
handle->bgcolor = NULL;
|
||||
|
||||
MwLLFreeColor(cd);
|
||||
MwLLFreeColor(c);
|
||||
}
|
||||
|
||||
static void version_close(MwWidget handle, void* user, void* client) {
|
||||
int i;
|
||||
MwWidget* children = MwGetChildren(user);
|
||||
|
||||
for(i = 0; children[i] != NULL; i++) {
|
||||
if(MwGetClass(children[i]) == MwImageClass) {
|
||||
MwLLPixmap px = MwGetVoid(children[i], MwNpixmap);
|
||||
|
||||
MwVaApply(children[i],
|
||||
MwNpixmap, NULL,
|
||||
NULL);
|
||||
MwLLDestroyPixmap(px);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MwDestroyWidget(user);
|
||||
}
|
||||
|
||||
void gui_version(void) {
|
||||
MwWidget version, image, ok;
|
||||
MwRect rc;
|
||||
int x = MwGetInteger(window, MwNx);
|
||||
int y = MwGetInteger(window, MwNy);
|
||||
int ww = MwGetInteger(window, MwNwidth);
|
||||
int wh = MwGetInteger(window, MwNheight);
|
||||
int bsh = 48;
|
||||
int bh = bsh / 2;
|
||||
int w = 640;
|
||||
int h = 426 + bh;
|
||||
MwLLPixmap px = MwLoadIcon(window, icon_midas);
|
||||
MwSizeHints sh;
|
||||
|
||||
sh.min_width = sh.max_width = w;
|
||||
sh.min_height = sh.max_height = h;
|
||||
|
||||
MwGetScreenSize(window, &rc);
|
||||
|
||||
version = MwVaCreateWidget(MwWindowClass, "window", NULL, x + (ww - w) / 2, y + (wh - h) / 2, w, h,
|
||||
MwNtitle, "Version information",
|
||||
MwNsizeHints, &sh,
|
||||
NULL);
|
||||
|
||||
image = MwVaCreateWidget(MwImageClass, "image", version, 0, 0, w, h - bsh,
|
||||
MwNpixmap, px,
|
||||
NULL);
|
||||
image->draw_inject = image_draw_inject;
|
||||
|
||||
ok = MwVaCreateWidget(MwButtonClass, "btn", version, w - bh * 4 - (bsh - bh) / 2, h - bsh + (bsh - bh) / 2, bh * 4, bh,
|
||||
MwNtext, "OK",
|
||||
NULL);
|
||||
MwAddUserHandler(ok, MwNactivateHandler, version_close, version);
|
||||
MwAddUserHandler(version, MwNcloseHandler, version_close, version);
|
||||
|
||||
MwReparent(version, window);
|
||||
}
|
||||
10
src/midas.h
10
src/midas.h
|
|
@ -43,9 +43,17 @@ ICONS;
|
|||
#undef ICON
|
||||
|
||||
void gui_init(void);
|
||||
void gui_version(void);
|
||||
void gui_loop(void);
|
||||
|
||||
/* gui_menu.c */
|
||||
void gui_menu_init(void);
|
||||
|
||||
/* gui_version.c */
|
||||
void gui_version(void);
|
||||
|
||||
/* gui_preferences.c */
|
||||
void gui_preferences(void);
|
||||
|
||||
/* dir.c */
|
||||
void dir_init(void);
|
||||
void dir_scan(const char* dir);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue