forked from pyrite-dev/milsko
messagebox
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@257 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
parent
72ba706b31
commit
22b6c60f45
16 changed files with 3371 additions and 11 deletions
|
|
@ -26,7 +26,7 @@ L_CFLAGS = $(DEPINC) $(CFLAGS) -fPIC -D_MILSKO
|
|||
L_LDFLAGS = $(LDFLAGS)
|
||||
L_LIBS = $(LIBS)
|
||||
|
||||
L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o src/unicode.o
|
||||
L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o src/unicode.o src/color.o src/messagebox.o
|
||||
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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
CC = cl
|
||||
LD = link
|
||||
|
||||
OBJS = src\core.obj src\draw.obj src\default.obj src\lowlevel.obj src\error.obj src\unicode.obj src\font.obj src\boldfont.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\numberentry.obj src\external\ds.obj src\external\image.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\backend\gdi.obj
|
||||
OBJS = src\core.obj src\draw.obj src\default.obj src\lowlevel.obj src\error.obj src\unicode.obj src\font.obj src\color.obj src\messagebox.obj src\boldfont.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\numberentry.obj src\external\ds.obj src\external\image.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\backend\gdi.obj
|
||||
OOOBJS = oosrc\base.obj oosrc\widget\button.obj oosrc\widget\frame.obj oosrc\widget\image.obj oosrc\widget\menu.obj oosrc\widget\opengl.obj oosrc\widget\scrollbar.obj oosrc\widget\submenu.obj oosrc\widget\window.obj oosrc\widget\checkbox.obj oosrc\widget\label.obj oosrc\widget\entry.obj oosrc\widget\numberentry.obj
|
||||
CFLAGS = /nologo /DSTBI_NO_SIMD /D_MILSKO /DUSE_GDI /DUSE_STB_IMAGE /Iinclude
|
||||
CXXFLAGS = /nologo /Iinclude
|
||||
|
|
|
|||
141
doc/index.html
141
doc/index.html
|
|
@ -23,6 +23,21 @@
|
|||
<dd>
|
||||
<a href="#Mw_Constants_h___define_MwDEFAULT_0x0fffffff">#define MwDEFAULT 0x0fffffff</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Constants_h___define_MwMB_ICONMASK_0xf">#define MwMB_ICONMASK 0xf</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Constants_h___define_MwMB_ICONWARNING_0x1">#define MwMB_ICONWARNING 0x1</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Constants_h___define_MwMB_ICONINFO_0x2">#define MwMB_ICONINFO 0x2</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Constants_h___define_MwMB_ICONNOTE_0x3">#define MwMB_ICONNOTE 0x3</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Constants_h___define_MwMB_ICONQUESTION_0x4">#define MwMB_ICONQUESTION 0x4</a>
|
||||
</dd>
|
||||
<dt>
|
||||
<a href="#Mw_Core_h">Mw/Core.h</a>
|
||||
</dt>
|
||||
|
|
@ -176,6 +191,9 @@
|
|||
<dd>
|
||||
<a href="#Mw_Draw_h__MwLoadXPM">MwLoadXPM</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Draw_h__MwParseColorName">MwParseColorName</a>
|
||||
</dd>
|
||||
<dt>
|
||||
<a href="#Mw_Error_h">Mw/Error.h</a>
|
||||
</dt>
|
||||
|
|
@ -200,12 +218,30 @@
|
|||
<dd>
|
||||
<a href="#Mw_Font_h__MwBoldFontData__">MwBoldFontData[]</a>
|
||||
</dd>
|
||||
<dt>
|
||||
<a href="#Mw_Icon_h">Mw/Icon.h</a>
|
||||
</dt>
|
||||
<dd>
|
||||
<a href="#Mw_Icon_h__MwIconInfo__">MwIconInfo[]</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Icon_h__MwIconNote__">MwIconNote[]</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Icon_h__MwIconQuestion__">MwIconQuestion[]</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a href="#Mw_Icon_h__MwIconWarning__">MwIconWarning[]</a>
|
||||
</dd>
|
||||
<dt>
|
||||
<a href="#Mw_LowLevel_h">Mw/LowLevel.h</a>
|
||||
</dt>
|
||||
<dt>
|
||||
<a href="#Mw_MachDep_h">Mw/MachDep.h</a>
|
||||
</dt>
|
||||
<dt>
|
||||
<a href="#Mw_MessageBox_h">Mw/MessageBox.h</a>
|
||||
</dt>
|
||||
<dt>
|
||||
<a href="#Mw_Milsko_h">Mw/Milsko.h</a>
|
||||
</dt>
|
||||
|
|
@ -414,6 +450,41 @@
|
|||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Constants_h___define_MwMB_ICONMASK_0xf">#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">MwMB_ICONMASK</FONT> 0xf</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Icon mask.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Constants_h___define_MwMB_ICONWARNING_0x1">#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">MwMB_ICONWARNING</FONT> 0x1</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Warning icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Constants_h___define_MwMB_ICONINFO_0x2">#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">MwMB_ICONINFO</FONT> 0x2</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Information icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Constants_h___define_MwMB_ICONNOTE_0x3">#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">MwMB_ICONNOTE</FONT> 0x3</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Note icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Constants_h___define_MwMB_ICONQUESTION_0x4">#<B><FONT COLOR="#5F9EA0">define</FONT></B> <FONT COLOR="#B8860B">MwMB_ICONQUESTION</FONT> 0x4</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Question icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_Core_h">Mw/Core.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
|
|
@ -1705,6 +1776,34 @@
|
|||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Draw_h__MwParseColorName">MWDECL MwLLColor <B><FONT COLOR="#0000FF">MwParseColorName</FONT></B> (
|
||||
MwWidget handle,
|
||||
<B><FONT COLOR="#228B22">const</FONT></B> <B><FONT COLOR="#228B22">char</FONT></B>* color
|
||||
);</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Parses a color name.
|
||||
</dd>
|
||||
<dt>
|
||||
Parameter <code>handle</code>
|
||||
</dt>
|
||||
<dd>
|
||||
Widget.
|
||||
</dd>
|
||||
<dt>
|
||||
Parameter <code>color</code>
|
||||
</dt>
|
||||
<dd>
|
||||
Color name.
|
||||
</dd>
|
||||
<dt>
|
||||
Returns
|
||||
</dt>
|
||||
<dd>
|
||||
Color.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_Error_h">Mw/Error.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
|
|
@ -1763,6 +1862,41 @@
|
|||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_Icon_h">Mw/Icon.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
Icon.
|
||||
</dt>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Icon_h__MwIconInfo__">MWDECL <B><FONT COLOR="#228B22">char</FONT></B>* MwIconInfo[];</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Info icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Icon_h__MwIconNote__">MWDECL <B><FONT COLOR="#228B22">char</FONT></B>* MwIconNote[];</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Note icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Icon_h__MwIconQuestion__">MWDECL <B><FONT COLOR="#228B22">char</FONT></B>* MwIconQuestion[];</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Question icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<pre id="Mw_Icon_h__MwIconWarning__">MWDECL <B><FONT COLOR="#228B22">char</FONT></B>* MwIconWarning[];</pre>
|
||||
<dl>
|
||||
<dd>
|
||||
Warning icon.
|
||||
</dd>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_LowLevel_h">Mw/LowLevel.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
|
|
@ -1780,6 +1914,13 @@
|
|||
</dt>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_MessageBox_h">Mw/MessageBox.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
Message box.
|
||||
</dt>
|
||||
</dl>
|
||||
<hr>
|
||||
<h2 align="center" id="Mw_Milsko_h">Mw/Milsko.h</h2>
|
||||
<dl>
|
||||
<dt>
|
||||
|
|
|
|||
|
|
@ -38,4 +38,29 @@ enum MwALIGNMENT {
|
|||
*/
|
||||
#define MwDEFAULT 0x0fffffff
|
||||
|
||||
/*!
|
||||
* %brief Icon mask
|
||||
*/
|
||||
#define MwMB_ICONMASK 0xf
|
||||
|
||||
/*!
|
||||
* %brief Warning icon
|
||||
*/
|
||||
#define MwMB_ICONWARNING 0x1
|
||||
|
||||
/*!
|
||||
* %brief Information icon
|
||||
*/
|
||||
#define MwMB_ICONINFO 0x2
|
||||
|
||||
/*!
|
||||
* %brief Note icon
|
||||
*/
|
||||
#define MwMB_ICONNOTE 0x3
|
||||
|
||||
/*!
|
||||
* %brief Question icon
|
||||
*/
|
||||
#define MwMB_ICONQUESTION 0x4
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -133,6 +133,16 @@ MWDECL MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int
|
|||
*/
|
||||
MWDECL MwLLPixmap MwLoadXPM(MwWidget handle, char** data);
|
||||
|
||||
/* color.c */
|
||||
|
||||
/*!
|
||||
* %brief Parses a color name
|
||||
* %param handle Widget
|
||||
* %param color Color name
|
||||
* %return Color
|
||||
*/
|
||||
MWDECL MwLLColor MwParseColorName(MwWidget handle, const char* color);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -90,6 +90,10 @@ MWDECL void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask);
|
|||
MWDECL void MwLLDetach(MwLL handle, MwPoint* point);
|
||||
MWDECL void MwLLShow(MwLL handle, int show);
|
||||
|
||||
MWDECL void MwLLMakePopup(MwLL handle, MwLL parent);
|
||||
|
||||
MWDECL void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
29
include/Mw/MessageBox.h
Normal file
29
include/Mw/MessageBox.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* $Id$ */
|
||||
/*!
|
||||
* %file Mw/MessageBox.h
|
||||
* %brief Message box
|
||||
*/
|
||||
#ifndef __MW_MESSAGEBOX_H__
|
||||
#define __MW_MESSAGEBOX_H__
|
||||
|
||||
#include <Mw/MachDep.h>
|
||||
#include <Mw/TypeDefs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* %param handle Widget
|
||||
* %param text Text
|
||||
* %param title Title text
|
||||
* %param flag Flag
|
||||
* %return Widget
|
||||
*/
|
||||
MWDECL MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#include <Mw/Constants.h>
|
||||
#include <Mw/Unicode.h>
|
||||
#include <Mw/Icon.h>
|
||||
#include <Mw/MessageBox.h>
|
||||
|
||||
#include <Mw/Widget/Window.h>
|
||||
#include <Mw/Widget/Menu.h>
|
||||
|
|
|
|||
|
|
@ -406,3 +406,12 @@ void MwLLShow(MwLL handle, int show) {
|
|||
ShowWindow(handle->hWnd, show ? SW_NORMAL : SW_HIDE);
|
||||
if(show) SetFocus(handle->hWnd);
|
||||
}
|
||||
|
||||
void MwLLMakePopup(MwLL handle, MwLL parent) {
|
||||
(void)handle;
|
||||
(void)parent;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,3 +452,25 @@ void MwLLShow(MwLL handle, int show) {
|
|||
XUnmapWindow(handle->display, handle->window);
|
||||
}
|
||||
}
|
||||
|
||||
void MwLLMakePopup(MwLL handle, MwLL parent) {
|
||||
Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False);
|
||||
Atom wnddlg = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
|
||||
Atom wndstate = XInternAtom(handle->display, "_NET_WM_STATE", False);
|
||||
Atom wndmodal = XInternAtom(handle->display, "_NET_WM_STATE_MODAL", False);
|
||||
|
||||
XSetTransientForHint(handle->display, handle->window, parent->window);
|
||||
XChangeProperty(handle->display, handle->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wnddlg, 1);
|
||||
XChangeProperty(handle->display, handle->window, wndstate, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmodal, 1);
|
||||
}
|
||||
|
||||
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||
XSizeHints* hints = XAllocSizeHints();
|
||||
hints->flags = PMinSize | PMaxSize;
|
||||
hints->min_width = minx;
|
||||
hints->min_height = miny;
|
||||
hints->max_width = maxx;
|
||||
hints->max_height = maxy;
|
||||
XSetWMSizeHints(handle->display, handle->window, hints, XA_WM_NORMAL_HINTS);
|
||||
XFree(hints);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#include <X11/extensions/Xrender.h>
|
||||
|
|
|
|||
2964
src/color.c
Normal file
2964
src/color.c
Normal file
File diff suppressed because it is too large
Load diff
83
src/draw.c
83
src/draw.c
|
|
@ -52,6 +52,8 @@ MwLLColor MwParseColor(MwWidget handle, const char* text) {
|
|||
r = hex(text + 1, 2);
|
||||
g = hex(text + 3, 2);
|
||||
b = hex(text + 5, 2);
|
||||
} else {
|
||||
return MwParseColorName(handle, text);
|
||||
}
|
||||
|
||||
return MwLLAllocColor(handle->lowlevel, r, g, b);
|
||||
|
|
@ -560,9 +562,26 @@ MwLLPixmap MwLoadImage(MwWidget handle, const char* path) {
|
|||
}
|
||||
|
||||
MwLLPixmap MwLoadRaw(MwWidget handle, unsigned char* rgb, int width, int height) {
|
||||
MwLLPixmap px;
|
||||
MwLLPixmap px;
|
||||
MwLLColor bg = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||
unsigned char* out = malloc(width * height * 4);
|
||||
int y, x;
|
||||
for(y = 0; y < height; y++) {
|
||||
for(x = 0; x < width; x++) {
|
||||
unsigned char* pin = &rgb[(y * width + x) * 4];
|
||||
unsigned char* pout = &out[(y * width + x) * 4];
|
||||
pout[0] = pin[0] * (pin[3] / 255.0) + bg->red * (1.0 - pin[3] / 255.0);
|
||||
pout[1] = pin[1] * (pin[3] / 255.0) + bg->green * (1.0 - pin[3] / 255.0);
|
||||
pout[2] = pin[2] * (pin[3] / 255.0) + bg->blue * (1.0 - pin[3] / 255.0);
|
||||
pout[3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
px = MwLLCreatePixmap(handle->lowlevel, rgb, width, height);
|
||||
MwLLFreeColor(bg);
|
||||
|
||||
px = MwLLCreatePixmap(handle->lowlevel, out, width, height);
|
||||
|
||||
free(out);
|
||||
|
||||
return px;
|
||||
}
|
||||
|
|
@ -576,27 +595,75 @@ void MwGetColor(MwLLColor color, int* red, int* green, int* blue) {
|
|||
typedef struct color {
|
||||
char* key;
|
||||
char* value;
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int a;
|
||||
} color_t;
|
||||
|
||||
MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
|
||||
int col, row, colors, cpp;
|
||||
unsigned char* rgb;
|
||||
MwLLPixmap px;
|
||||
char k[512];
|
||||
color_t* c = NULL;
|
||||
int i;
|
||||
int i, y, x;
|
||||
char* comp;
|
||||
|
||||
sh_new_strdup(c);
|
||||
|
||||
sscanf(data[0], "%d %d %d %d", &col, &row, &colors, &cpp);
|
||||
|
||||
for(i = 0; i < colors; i++) {
|
||||
memcpy(k, data[i + 1], cpp);
|
||||
k[cpp] = 0;
|
||||
printf("%s\n", k);
|
||||
char k[128];
|
||||
char* v = data[i + 1] + cpp + 3;
|
||||
int ind;
|
||||
if(strcmp(v, "None") == 0) {
|
||||
memcpy(k, data[i + 1], cpp);
|
||||
k[cpp] = 0;
|
||||
|
||||
shput(c, k, v);
|
||||
ind = shgeti(c, k);
|
||||
|
||||
c[ind].r = 0;
|
||||
c[ind].g = 0;
|
||||
c[ind].b = 0;
|
||||
c[ind].a = 0;
|
||||
} else {
|
||||
MwLLColor color = MwParseColor(handle, v);
|
||||
|
||||
memcpy(k, data[i + 1], cpp);
|
||||
k[cpp] = 0;
|
||||
|
||||
shput(c, k, v);
|
||||
ind = shgeti(c, k);
|
||||
|
||||
c[ind].r = color->red;
|
||||
c[ind].g = color->green;
|
||||
c[ind].b = color->blue;
|
||||
c[ind].a = 255;
|
||||
|
||||
MwLLFreeColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
rgb = malloc(row * col * 4);
|
||||
rgb = malloc(row * col * 4);
|
||||
comp = malloc(cpp + 1);
|
||||
comp[cpp] = 0;
|
||||
for(y = 0; y < row; y++) {
|
||||
for(x = 0; x < col; x++) {
|
||||
unsigned char* pout = &rgb[(y * col + x) * 4];
|
||||
color_t colent;
|
||||
memcpy(comp, &data[1 + colors + y][x * cpp], cpp);
|
||||
|
||||
colent = shgets(c, comp);
|
||||
|
||||
pout[0] = colent.r;
|
||||
pout[1] = colent.g;
|
||||
pout[2] = colent.b;
|
||||
pout[3] = colent.a;
|
||||
}
|
||||
}
|
||||
free(comp);
|
||||
|
||||
px = MwLoadRaw(handle, rgb, col, row);
|
||||
|
||||
|
|
|
|||
55
src/messagebox.c
Normal file
55
src/messagebox.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* $Id$ */
|
||||
#include <Mw/Milsko.h>
|
||||
|
||||
MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag) {
|
||||
MwWidget window, ok;
|
||||
MwPoint p;
|
||||
int w, h;
|
||||
|
||||
p.x = 0;
|
||||
p.y = 0;
|
||||
|
||||
window = MwVaCreateWidget(MwWindowClass, "messagebox", handle, 0, 0, (w = 512), (h = 32 * 4),
|
||||
MwNtitle, title,
|
||||
NULL);
|
||||
ok = MwVaCreateWidget(MwButtonClass, "ok", window, w - 8 - 64, h - 8 - 24, 64, 24,
|
||||
MwNtext, "OK",
|
||||
NULL);
|
||||
|
||||
if((flag & MwMB_ICONMASK) != 0) {
|
||||
MwWidget icon;
|
||||
MwLLPixmap px;
|
||||
char** data = NULL;
|
||||
|
||||
icon = MwCreateWidget(MwImageClass, "image", window, 16, (h - 48) / 2, 48, 48);
|
||||
|
||||
switch(flag & MwMB_ICONMASK) {
|
||||
case MwMB_ICONWARNING: {
|
||||
data = MwIconWarning;
|
||||
break;
|
||||
}
|
||||
case MwMB_ICONINFO: {
|
||||
data = MwIconInfo;
|
||||
break;
|
||||
}
|
||||
case MwMB_ICONNOTE: {
|
||||
data = MwIconNote;
|
||||
break;
|
||||
}
|
||||
case MwMB_ICONQUESTION: {
|
||||
data = MwIconQuestion;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
px = MwLoadXPM(icon, data);
|
||||
|
||||
MwSetVoid(icon, MwNpixmap, px);
|
||||
}
|
||||
|
||||
MwLLDetach(window->lowlevel, &p);
|
||||
MwLLSetSizeHints(window->lowlevel, w, h, w, h);
|
||||
MwLLMakePopup(window->lowlevel, handle->lowlevel);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ void MwSubMenuAppear(MwWidget handle, MwMenu menu, MwPoint* point) {
|
|||
xswa.override_redirect = True;
|
||||
|
||||
XChangeWindowAttributes(handle->lowlevel->display, handle->lowlevel->window, CWOverrideRedirect, &xswa);
|
||||
XChangeProperty(handle->lowlevel->display, handle->lowlevel->window, wndtype, 4, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
|
||||
XChangeProperty(handle->lowlevel->display, handle->lowlevel->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
|
||||
#endif
|
||||
|
||||
handle->internal = menu;
|
||||
|
|
|
|||
32
tools/color.pl
Executable file
32
tools/color.pl
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env perl
|
||||
# $Id$
|
||||
|
||||
open(IN, "<", "resource/rgb.txt");
|
||||
open(OUT, ">", "src/color.c");
|
||||
|
||||
print(OUT "/* \$Id\$ */\n");
|
||||
print(OUT "#include <Mw/Milsko.h>\n");
|
||||
print(OUT "\n");
|
||||
print(OUT "MwLLColor MwParseColorName(MwWidget handle, const char* color){\n");
|
||||
print(OUT " int r, g, b;\n");
|
||||
print(OUT " ");
|
||||
while (my $l = <IN>) {
|
||||
$l =~ s/\r?\n$//;
|
||||
if ($l =~ /^[ \t]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)$/) {
|
||||
print(OUT "if(strcmp(color, \"$4\") == 0){\n");
|
||||
print(OUT " r = $1;\n");
|
||||
print(OUT " g = $2;\n");
|
||||
print(OUT " b = $3;\n");
|
||||
print(OUT " }else ");
|
||||
}
|
||||
}
|
||||
print(OUT "{\n");
|
||||
print(OUT " r = 0;\n");
|
||||
print(OUT " g = 0;\n");
|
||||
print(OUT " b = 0;\n");
|
||||
print(OUT " }\n");
|
||||
print(OUT " return MwLLAllocColor(handle->lowlevel, r, g, b);\n");
|
||||
print(OUT "}\n");
|
||||
|
||||
close(OUT);
|
||||
close(IN);
|
||||
Loading…
Add table
Add a link
Reference in a new issue