diff --git a/examples/basic/periodic.c b/examples/basic/periodic.c index 646e113..423fe3c 100644 --- a/examples/basic/periodic.c +++ b/examples/basic/periodic.c @@ -2,13 +2,14 @@ #include -#define Columns 4 +#define Columns 5 #define Padding 20 #define PaddingContent 2 MwWidget window, menu, box; MwWidget boxes[32]; int n = 0, row = -1; +MwMenu e; static void resize(MwWidget handle, void* user, void* call) { int w = MwGetInteger(window, MwNwidth); @@ -139,20 +140,75 @@ static MwWidget child(MwWidget w) { return MwGetVoid(w, "VhandledWidget"); } +static void menu_handler(MwWidget handle, void* user, void* call){ + if(call == e) MwDestroyWidget(window); +} + int main() { int i; MwWidget f, w; MwListBoxPacket* pkt; int index; + MwMenu m, m2; + void* v; MwLibraryInit(); window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 800, 800, MwNtitle, "Milsko Periodic Table", + MwNmodernLook, 0, NULL); menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0); + m = MwMenuAdd(menu, NULL, "File"); + MwMenuAdd(menu, m, "New"); + MwMenuAdd(menu, m, "Open"); + MwMenuAdd(menu, m, "Save"); + MwMenuAdd(menu, m, "Save As"); + MwMenuAdd(menu, m, "Print"); + e = MwMenuAdd(menu, m, "Exit"); + + m = MwMenuAdd(menu, NULL, "Edit"); + MwMenuAdd(menu, m, "Undo"); + MwMenuAdd(menu, m, "----"); + MwMenuAdd(menu, m, "Cut"); + MwMenuAdd(menu, m, "Copy"); + MwMenuAdd(menu, m, "Paste"); + MwMenuAdd(menu, m, "----"); + MwMenuAdd(menu, m, "Clear"); + MwMenuAdd(menu, m, "Delete"); + + m = MwMenuAdd(menu, NULL, "View"); + MwMenuAdd(menu, m, "Stack"); + MwMenuAdd(menu, m, "Tile"); + MwMenuAdd(menu, m, "----"); + MwMenuAdd(menu, m, "Day"); + MwMenuAdd(menu, m, "Week"); + MwMenuAdd(menu, m, "Month"); + MwMenuAdd(menu, m, "Year"); + + m = MwMenuAdd(menu, NULL, "Options"); + m2 = MwMenuAdd(menu, m, "Font"); + MwMenuAdd(menu, m2, "Small"); + MwMenuAdd(menu, m2, "Medium"); + MwMenuAdd(menu, m2, "Large"); + m2 = MwMenuAdd(menu, m, "Direction"); + MwMenuAdd(menu, m2, "Up"); + MwMenuAdd(menu, m2, "Down"); + MwMenuAdd(menu, m2, "Left"); + MwMenuAdd(menu, m2, "Right"); + MwMenuAdd(menu, m, "Case Sensitive"); + MwMenuAdd(menu, m, "Word Wrap"); + + m = MwMenuAdd(menu, NULL, "Help"); + MwMenuAdd(menu, m, "On Context"); + MwMenuAdd(menu, m, "On Window"); + MwMenuAdd(menu, m, "Tutorial"); + MwMenuAdd(menu, m, "On Version"); + + MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL); + box = MwVaCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0, MwNorientation, MwVERTICAL, NULL); @@ -196,9 +252,29 @@ int main() { MwListBoxDestroyPacket(pkt); add(f); + f = frame("NumberEntry", -PaddingContent, 24, MwNumberEntryClass, NULL); + add(f); + + f = frame("ProgressBar", -PaddingContent, 24, MwProgressBarClass, + MwNvalue, 25, + NULL); + add(f); + + f = frame("ScrollBar", -PaddingContent, 16, MwScrollBarClass, + MwNorientation, MwHORIZONTAL, + NULL); + add(f); + f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL); add(f); + f = frame("TreeView", -PaddingContent, -PaddingContent, MwTreeViewClass, NULL); + w = child(f); + v = MwTreeViewAdd(w, NULL, NULL, "abc"); + v = MwTreeViewAdd(w, v, NULL, "def"); + v = MwTreeViewAdd(w, v, NULL, "ghi"); + add(f); + if(n != 0) newrow(); if(n == 0) MwDestroyWidget(boxes[row]); diff --git a/src/backend/x11.c b/src/backend/x11.c index de68867..5cdc366 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -140,6 +140,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { int px = x, py = y; XSizeHints sh; + _Xdebug = 1; + r = malloc(sizeof(*r)); MwLLCreateCommon(r); @@ -736,7 +738,7 @@ static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) { } static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { - if(rect->width == 0 || rect->height == 0 || pixmap->common.width == 0 || pixmap->common.height == 0) return; + if(rect->width <= 0 || rect->height <= 0 || pixmap->common.width <= 0 || pixmap->common.height <= 0) return; #ifdef USE_XRENDER if(pixmap->x11.image != NULL && pixmap->x11.use_xrender) { Pixmap px = XCreatePixmap(handle->x11.display, handle->x11.window, pixmap->common.width, pixmap->common.height, pixmap->x11.depth); diff --git a/src/draw.c b/src/draw.c index b6e3705..ae9f701 100644 --- a/src/draw.c +++ b/src/draw.c @@ -117,7 +117,10 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color, int rounde MwRect r = *rect; int roundness = MwGetInteger(handle, MwNroundness); double div; - if(rect->width < 0 || rect->height < 0) return; + if(rect->width <= 0 || rect->height <= 0){ + free(data); + return; + } if(roundness == MwDEFAULT) roundness = DEFAULT_ROUNDNESS; if(roundness >= MAX_ROUNDNESS) roundness = MAX_ROUNDNESS; div = (roundness <= 10) ? 7. : 10.; @@ -191,7 +194,7 @@ void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert MwLLColor col; MwBool rounded = MwGetInteger(handle, MwNroundness) != MwDEFAULT && MwGetInteger(handle, MwNisRounded) != 0; - if(rect->width < 0 || rect->height < 0) return; + if(rect->width <= 0 || rect->height <= 0) return; if(border) { if(!handle->lowlevel->common.supports_transparency) { @@ -350,7 +353,7 @@ static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighte if(roundness == MwDEFAULT) roundness = DEFAULT_ROUNDNESS; if(roundness >= MAX_ROUNDNESS) roundness = MAX_ROUNDNESS; - if(rounded && rect->height >= (roundness * 2) && rect->width >= (roundness * 2) && roundness > 0) { + if(rounded && rect->height >= (roundness * 4) && rect->width >= (roundness * 4) && roundness > 0) { /* top left edge */ for(i = 0; i < BORDER_SMOOTHNESS; i += 2) { MwPoint line[2]; @@ -417,7 +420,7 @@ static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighte } MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker); - if(rounded && rect->height >= (roundness * 2) && rect->width >= (roundness * 2) && roundness > 0) { + if(rounded && rect->height >= (roundness * 4) && rect->width >= (roundness * 4) && roundness > 0) { /* bottom left edge */ for(i = 0; i < BORDER_SMOOTHNESS; i += 2) { MwPoint line[2];