diff --git a/ChangeLog b/ChangeLog index eeb020cac..30274b436 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-12-05 David A. Capello + + * src/widgets/statebar.c (status_bar_set_text): Uses dirty + region. This optimized the speed of the loading bar. + + * src/jinete/jsystem.c (ji_flip_dirty_region): Added dirty region. + + * src/file/png_format.c (save_png): Added. + 2007-12-03 David A. Capello * src/raster/sprite.h (struct Sprite): Added "stock" (now the diff --git a/NEWS.txt b/NEWS.txt index 6363136ce..dc61d56eb 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -18,7 +18,7 @@ NEWS + GUI enhanced: + more borders for windows and more spacing between widgets. + better mouse behavior (in Windows). -+ Added support for PNG files (through libpng). ++ Added support to load and save PNG files (through libpng). + Finished the support for ICO files. + Finally screen scaling supported (with double-buffering). This means that you can use a screen of 320x240 between a window of 640x480 diff --git a/makefile.lst b/makefile.lst index aa3d4faee..449a04e5a 100644 --- a/makefile.lst +++ b/makefile.lst @@ -118,7 +118,7 @@ COMMON_SOURCES = \ src/jinete/jalert.c \ src/jinete/jbox.c \ src/jinete/jbutton.c \ - src/jinete/jclipbrd.c \ + src/jinete/jclipboard.c \ src/jinete/jcombox.c \ src/jinete/jdraw.c \ src/jinete/jentry.c \ @@ -137,7 +137,7 @@ COMMON_SOURCES = \ src/jinete/jmenu.c \ src/jinete/jmessage.c \ src/jinete/jpanel.c \ - src/jinete/jqckmenu.c \ + src/jinete/jquickmenu.c \ src/jinete/jrect.c \ src/jinete/jregion.c \ src/jinete/jsep.c \ @@ -150,8 +150,7 @@ COMMON_SOURCES = \ src/jinete/jwidget.c \ src/jinete/jwindow.c \ src/jinete/jxml.c \ - src/jinete/themes/jsimple.c \ - src/jinete/themes/jstand.c \ + src/jinete/themes/jstandard_theme.c \ src/modules/color.c \ src/modules/editors.c \ src/modules/gfx.c \ @@ -214,14 +213,14 @@ COMMON_SOURCES = \ src/widgets/target.c \ src/widgets/toolbar.c -COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \ - $(addsuffix $(OBJ), \ - $(notdir $(basename $(COMMON_SOURCES))))) +COMMON_OBJS = $(addprefix $(OBJ_DIR)/, \ + $(addsuffix $(OBJ), \ + $(notdir $(basename $(COMMON_SOURCES))))) ASE_SOURCES = src/main.c $(COMMON_SOURCES) -ASE_OBJS = $(addprefix $(OBJ_DIR)/, \ - $(addsuffix $(OBJ), \ +ASE_OBJS = $(addprefix $(OBJ_DIR)/, \ + $(addsuffix $(OBJ), \ $(notdir $(basename $(ASE_SOURCES))))) ###################################################################### diff --git a/misc/deps.sh b/misc/deps.sh index 5b944ef96..667137671 100644 --- a/misc/deps.sh +++ b/misc/deps.sh @@ -1,31 +1,20 @@ #! /bin/sh -# Jinete dependencies - GCC="gcc -MM" -CFLAGS="-Iinclude -Ifreetype/include" - -cd jinete -$GCC $CFLAGS src/*.c \ - | sed -e 's/^\([a-z_\-]*\.o\)/obj\/mingw32\/\1/' > makefile.dep -cd .. - -# ASE dependencies - CFLAGS="-I. \ - -Isrc -Ijinete/include -Ilibase \ + -Isrc \ -Ithird_party/lua/include \ -Ithird_party/gfli \ -Ithird_party/intl \ -Ithird_party/libpng \ -Ithird_party/zlib \ -Ithird_party/jpeg \ - -Ijinete/freetype/include \ + -Ithird_party/freetype/include \ -Ithird_party" rm -f makefile.dep -$GCC $CFLAGS jinete/src/*.c \ +$GCC $CFLAGS \ src/*.c \ src/commands/*.c \ src/commands/fx/*.c \ @@ -35,6 +24,7 @@ $GCC $CFLAGS jinete/src/*.c \ src/effect/*.c \ src/file/*.c \ src/intl/*.c \ + src/jinete/*.c \ src/modules/*.c \ src/raster/*.c \ src/script/bindings.c src/script/script.c \ diff --git a/src/core/app.c b/src/core/app.c index 05a8281a5..58f74aabc 100644 --- a/src/core/app.c +++ b/src/core/app.c @@ -240,9 +240,6 @@ void app_loop(void) jmanager_refresh_screen(); } - /* load all startup scripts */ - load_all_scripts(); - /* set background mode for non-GUI modes */ /* if (!(ase_mode & MODE_GUI)) */ /* set_display_switch_mode(SWITCH_BACKAMNESIA); */ diff --git a/src/file/bmp_format.c b/src/file/bmp_format.c index 41335ec24..cf9e45c67 100644 --- a/src/file/bmp_format.c +++ b/src/file/bmp_format.c @@ -31,8 +31,8 @@ #endif -static Sprite *load_BMP (const char *filename); -static int save_BMP (Sprite *sprite); +static Sprite *load_BMP(const char *filename); +static int save_BMP(Sprite *sprite); FileFormat format_bmp = { @@ -500,7 +500,7 @@ static void read_bitfields_image (PACKFILE *f, Image *image, int bpp, BITMAPINFO } } -static Sprite *load_BMP (const char *filename) +static Sprite *load_BMP(const char *filename) { BITMAPFILEHEADER fileheader; BITMAPINFOHEADER infoheader; @@ -618,7 +618,7 @@ static Sprite *load_BMP (const char *filename) return sprite; } -static int save_BMP (Sprite *sprite) +static int save_BMP(Sprite *sprite) { Image *image; PACKFILE *f; diff --git a/src/file/file.c b/src/file/file.c index 5de308250..5720b0b47 100644 --- a/src/file/file.c +++ b/src/file/file.c @@ -442,7 +442,8 @@ int sprite_save(Sprite *sprite) usprintf(buf+ustrlen(buf), "<<- %s", _("RGB format")); fatal = TRUE; } - if (!(file->flags & FILE_SUPPORT_RGBA)) { + if (!(file->flags & FILE_SUPPORT_RGBA) && + _rgba_geta(sprite->bgcolor) < 255) { usprintf(buf+ustrlen(buf), "<<- %s", _("Alpha channel")); } break; @@ -452,7 +453,8 @@ int sprite_save(Sprite *sprite) usprintf(buf+ustrlen(buf), "<<- %s", _("Grayscale format")); fatal = TRUE; } - if (!(file->flags & FILE_SUPPORT_GRAYA)) { + if (!(file->flags & FILE_SUPPORT_GRAYA) && + _graya_geta(sprite->bgcolor) < 255) { usprintf(buf+ustrlen(buf), "<<- %s", _("Alpha channel")); } break; diff --git a/src/file/jpeg_format.c b/src/file/jpeg_format.c index 54fa12669..0b74fd0b5 100644 --- a/src/file/jpeg_format.c +++ b/src/file/jpeg_format.c @@ -38,8 +38,8 @@ #include "jpeglib.h" -static Sprite *load_jpeg(const char *filename); -static int save_jpeg(Sprite *sprite); +static Sprite *load_JPEG(const char *filename); +static int save_JPEG(Sprite *sprite); static int configure_jpeg(void); @@ -47,8 +47,8 @@ FileFormat format_jpeg = { "jpeg", "jpeg,jpg", - load_jpeg, - save_jpeg, + load_JPEG, + save_JPEG, FILE_SUPPORT_RGB | FILE_SUPPORT_GRAY | FILE_SUPPORT_SEQUENCES @@ -90,7 +90,7 @@ static void output_message(j_common_ptr cinfo) console_printf("%s\n", buffer); } -static Sprite *load_jpeg(const char *filename) +static Sprite *load_JPEG(const char *filename) { struct jpeg_decompress_struct cinfo; struct error_mgr jerr; @@ -233,7 +233,7 @@ static Sprite *load_jpeg(const char *filename) return file_sequence_sprite(); } -static int save_jpeg(Sprite *sprite) +static int save_JPEG(Sprite *sprite) { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; diff --git a/src/file/pcx_format.c b/src/file/pcx_format.c index c4799a254..cc8a2cc72 100644 --- a/src/file/pcx_format.c +++ b/src/file/pcx_format.c @@ -31,8 +31,8 @@ #endif -static Sprite *load_PCX (const char *filename); -static int save_PCX (Sprite *sprite); +static Sprite *load_PCX(const char *filename); +static int save_PCX(Sprite *sprite); FileFormat format_pcx = { @@ -46,7 +46,7 @@ FileFormat format_pcx = FILE_SUPPORT_SEQUENCES }; -static Sprite *load_PCX (const char *filename) +static Sprite *load_PCX(const char *filename) { Image *image; PACKFILE *f; @@ -178,7 +178,7 @@ static Sprite *load_PCX (const char *filename) return file_sequence_sprite (); } -static int save_PCX (Sprite *sprite) +static int save_PCX(Sprite *sprite) { PACKFILE *f; Image *image; diff --git a/src/file/png_format.c b/src/file/png_format.c index eb259ebdd..f454ca7dd 100644 --- a/src/file/png_format.c +++ b/src/file/png_format.c @@ -30,12 +30,14 @@ #include "file/file.h" #include "raster/raster.h" #include "script/script.h" + +#define PNG_NO_TYPECAST_NULL #include "png.h" #endif -static Sprite *load_png(const char *filename); -static int save_png(Sprite *sprite); +static Sprite *load_PNG(const char *filename); +static int save_PNG(Sprite *sprite); /* static int configure_png(void); */ @@ -43,8 +45,8 @@ FileFormat format_png = { "png", "png", - load_png, - save_png, + load_PNG, + save_PNG, FILE_SUPPORT_RGB | FILE_SUPPORT_RGBA | FILE_SUPPORT_GRAY | @@ -53,56 +55,18 @@ FileFormat format_png = FILE_SUPPORT_SEQUENCES }; -/* static void progress_monitor(j_common_ptr cinfo) */ -/* { */ -/* if (cinfo->progress->pass_limit > 1) */ -/* do_progress(100 * */ -/* (cinfo->progress->pass_counter) / */ -/* (cinfo->progress->pass_limit-1)); */ -/* } */ - -/* struct error_mgr { */ -/* struct jpeg_error_mgr pub; */ -/* jmp_buf setjmp_buffer; */ -/* }; */ - -/* static void error_exit(j_common_ptr cinfo) */ -/* { */ -/* /\* Display the message. *\/ */ -/* (*cinfo->err->output_message)(cinfo); */ - -/* /\* Return control to the setjmp point. *\/ */ -/* longjmp(((struct error_mgr *)cinfo->err)->setjmp_buffer, 1); */ -/* } */ - -/* static void output_message(j_common_ptr cinfo) */ -/* { */ -/* char buffer[JMSG_LENGTH_MAX]; */ - -/* /\* Format the message. *\/ */ -/* (*cinfo->err->format_message)(cinfo, buffer); */ - -/* /\* Put in the log file if. *\/ */ -/* PRINTF("JPEG library: \"%s\"\n", buffer); */ - -/* /\* Leave the message for the application. *\/ */ -/* console_printf("%s\n", buffer); */ -/* } */ - static void report_png_error(png_structp png_ptr, png_const_charp error) { console_printf("libpng: %s\n", error); } -static Sprite *load_png(const char *filename) +static Sprite *load_PNG(const char *filename) { png_uint_32 width, height, y; unsigned int sig_read = 0; png_structp png_ptr; png_infop info_ptr; int bit_depth, color_type, interlace_type; - int intent, screen_gamma; - int max_screen_colors = 256; int pass, number_passes; int num_palette; png_colorp palette; @@ -186,10 +150,6 @@ static Sprite *load_png(const char *filename) if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr); - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ - screen_gamma = 2.2; - /* Turn on interlace handling. REQUIRED if you are not using * png_read_image(). To see how to handle interlacing passes, * see the png_read_row() method below: @@ -203,6 +163,10 @@ static Sprite *load_png(const char *filename) /* create the output image */ switch (info_ptr->color_type) { + case PNG_COLOR_TYPE_RGB: + case PNG_COLOR_TYPE_RGB_ALPHA: + imgtype = IMAGE_RGB; + break; case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_GRAY_ALPHA: imgtype = IMAGE_GRAYSCALE; @@ -210,10 +174,6 @@ static Sprite *load_png(const char *filename) case PNG_COLOR_TYPE_PALETTE: imgtype = IMAGE_INDEXED; break; - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - imgtype = IMAGE_RGB; - break; default: console_printf("Color type not supported\n)"); png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); @@ -252,13 +212,14 @@ static Sprite *load_png(const char *filename) row_pointer = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); for (pass = 0; pass < number_passes; pass++) { for (y = 0; y < height; y++) { + /* read the line */ png_read_row(png_ptr, row_pointer, png_bytepp_NULL); /* RGB_ALPHA */ if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - unsigned char *src_address = row_pointer; - unsigned long *dst_address = ((unsigned long **)image->line)[y]; - int x, r, g, b, a; + register unsigned char *src_address = row_pointer; + register unsigned long *dst_address = ((unsigned long **)image->line)[y]; + register int x, r, g, b, a; for (x=0; xcolor_type == PNG_COLOR_TYPE_RGB) { - unsigned char *src_address = row_pointer; - unsigned long *dst_address = ((unsigned long **)image->line)[y]; - int x, r, g, b; + register unsigned char *src_address = row_pointer; + register unsigned long *dst_address = ((unsigned long **)image->line)[y]; + register int x, r, g, b; for (x=0; xcolor_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - unsigned char *src_address = row_pointer; - unsigned short *dst_address = ((unsigned short **)image->line)[y]; - int x, k, a; + register unsigned char *src_address = row_pointer; + register unsigned short *dst_address = ((unsigned short **)image->line)[y]; + register int x, k, a; for (x=0; xcolor_type == PNG_COLOR_TYPE_GRAY) { - unsigned char *src_address = row_pointer; - unsigned short *dst_address = ((unsigned short **)image->line)[y]; + register unsigned char *src_address = row_pointer; + register unsigned short *dst_address = ((unsigned short **)image->line)[y]; int x, k; for (x=0; xcolor_type == PNG_COLOR_TYPE_PALETTE) { - unsigned char *src_address = row_pointer; - unsigned char *dst_address = ((unsigned char **)image->line)[y]; - int x, c; + register unsigned char *src_address = row_pointer; + register unsigned char *dst_address = ((unsigned char **)image->line)[y]; + register int x, c; for (x=0; xfrpos == 0 && configure_jpeg() < 0) - return 0; + /* open the file */ + fp = fopen(sprite->filename, "wb"); + if (fp == NULL) + return -1; - /* Options. */ - smooth = get_config_int("JPEG", "Smooth", 0); - quality = get_config_int("JPEG", "Quality", 100); - method = get_config_int("JPEG", "Method", JDCT_DEFAULT); - - /* Open the file for write in it. */ - file = fopen(sprite->filename, "wb"); - if (!file) { - console_printf(_("Error creating file.\n")); + /* Create and initialize the png_struct with the desired error handler + * functions. If you want to use the default stderr and longjump method, + * you can supply NULL for the last three parameters. We also check that + * the library version is compatible with the one used at compile time, + * in case we are using dynamically linked libraries. REQUIRED. + */ + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, + report_png_error, report_png_error); + if (png_ptr == NULL) { + fclose(fp); return -1; } + /* Allocate/initialize the image information data. REQUIRED */ + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) { + fclose(fp); + png_destroy_write_struct(&png_ptr, png_infopp_NULL); + return -1; + } + + /* Set error handling. REQUIRED if you aren't supplying your own + * error handling functions in the png_create_write_struct() call. + */ + if (setjmp(png_jmpbuf(png_ptr))) { + /* If we get here, we had a problem reading the file */ + fclose(fp); + png_destroy_write_struct(&png_ptr, &info_ptr); + return -1; + } + + /* set up the output control if you are using standard C streams */ + png_init_io(png_ptr, fp); + + /* Set the image information here. Width and height are up to 2^31, + * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on + * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, + * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, + * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or + * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST + * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED + */ image = file_sequence_image_to_save(); + width = image->w; + height = image->h; - /* Allocate and initialize JPEG compression object. */ - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - - /* Specify data destination file. */ - jpeg_stdio_dest(&cinfo, file); - - /* Set parameters for compression. */ - cinfo.image_width = image->w; - cinfo.image_height = image->h; - - if (image->imgtype == IMAGE_GRAYSCALE) { - cinfo.input_components = 1; - cinfo.in_color_space = JCS_GRAYSCALE; - } - else { - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; + switch (image->imgtype) { + case IMAGE_RGB: + color_type = _rgba_geta(sprite->bgcolor) < 255 ? + PNG_COLOR_TYPE_RGB_ALPHA: + PNG_COLOR_TYPE_RGB; + break; + case IMAGE_GRAYSCALE: + color_type = _graya_geta(sprite->bgcolor) < 255 ? + PNG_COLOR_TYPE_GRAY_ALPHA: + PNG_COLOR_TYPE_GRAY; + break; + case IMAGE_INDEXED: + color_type = PNG_COLOR_TYPE_PALETTE; + break; } - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, quality, TRUE); - cinfo.dct_method = method; - cinfo.smoothing_factor = smooth; + png_set_IHDR(png_ptr, info_ptr, width, height, 8, color_type, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - /* Start compressor. */ - jpeg_start_compress(&cinfo, TRUE); + if (image->imgtype == IMAGE_INDEXED) { + int c, r, g, b; - /* Create the buffer. */ - buffer_height = 1; - buffer = jmalloc(sizeof(JSAMPROW) * buffer_height); - if (!buffer) { - console_printf(_("Not enough memory for the buffer.\n")); - jpeg_destroy_compress(&cinfo); - fclose(file); - return -1; - } - - for (c=0; c<(int)buffer_height; c++) { - buffer[c] = jmalloc(sizeof(JSAMPLE) * - cinfo.image_width * cinfo.num_components); - if (!buffer[c]) { - console_printf(_("Not enough memory for buffer scanlines.\n")); - for (c--; c>=0; c--) - jfree(buffer[c]); - jfree(buffer); - jpeg_destroy_compress(&cinfo); - fclose(file); - return -1; - } - } - - /* For progress bar. */ - progress.progress_monitor = progress_monitor; - cinfo.progress = &progress; - - /* Write each scan line. */ - while (cinfo.next_scanline < cinfo.image_height) { - /* RGB */ - if (image->imgtype == IMAGE_RGB) { - unsigned long *src_address; - unsigned char *dst_address; - int x, y; - for (y=0; y<(int)buffer_height; y++) { - src_address = ((unsigned long **)image->line)[cinfo.next_scanline+y]; - dst_address = ((unsigned char **)buffer)[y]; - for (x=0; xw; x++) { - c = *(src_address++); - *(dst_address++) = _rgba_getr(c); - *(dst_address++) = _rgba_getg(c); - *(dst_address++) = _rgba_getb(c); - } - } - } - /* Grayscale */ - else { - unsigned short *src_address; - unsigned char *dst_address; - int x, y; - for (y=0; y<(int)buffer_height; y++) { - src_address = ((unsigned short **)image->line)[cinfo.next_scanline+y]; - dst_address = ((unsigned char **)buffer)[y]; - for (x=0; xw; x++) - *(dst_address++) = _graya_getk(*(src_address++)); - } - } - jpeg_write_scanlines(&cinfo, buffer, buffer_height); - } - - /* Destroy all data. */ - for (c=0; c<(int)buffer_height; c++) - jfree(buffer[c]); - jfree(buffer); - - /* Finish compression. */ - jpeg_finish_compress(&cinfo); - - /* Release JPEG compression object. */ - jpeg_destroy_compress(&cinfo); - - /* We can close the output file. */ - fclose(file); - - /* All fine. */ - return 0; -#else - return -1; +#if PNG_MAX_PALETTE_LENGTH != 256 +#error PNG_MAX_PALETTE_LENGTH should be 256 #endif + + /* set the palette if there is one. REQUIRED for indexed-color images */ + palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH + * png_sizeof(png_color)); + /* ... set palette colors ... */ + for (c = 0; c < PNG_MAX_PALETTE_LENGTH; c++) { + file_sequence_get_color(c, &r, &g, &b); + palette[c].red = _rgb_scale_6[r]; + palette[c].green = _rgb_scale_6[g]; + palette[c].blue = _rgb_scale_6[b]; + } + + png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); + } + + /* Write the file header information. */ + png_write_info(png_ptr, info_ptr); + + /* pack pixels into bytes */ + png_set_packing(png_ptr); + + /* non-interlaced */ + number_passes = 1; + + row_pointer = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); + + /* The number of passes is either 1 for non-interlaced images, + * or 7 for interlaced images. + */ + for (pass = 0; pass < number_passes; pass++) { + /* If you are only writing one row at a time, this works */ + for (y = 0; y < height; y++) { + /* RGB_ALPHA */ + if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + register unsigned long *src_address = ((unsigned long **)image->line)[y]; + register unsigned char *dst_address = row_pointer; + register int x, c; + + for (x=0; xcolor_type == PNG_COLOR_TYPE_RGB) { + register unsigned long *src_address = ((unsigned long **)image->line)[y]; + register unsigned char *dst_address = row_pointer; + register int x, c; + + for (x=0; xcolor_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + register unsigned short *src_address = ((unsigned short **)image->line)[y]; + register unsigned char *dst_address = row_pointer; + register int x, c; + + for (x=0; xcolor_type == PNG_COLOR_TYPE_GRAY) { + register unsigned short *src_address = ((unsigned short **)image->line)[y]; + register unsigned char *dst_address = row_pointer; + register int x, c; + + for (x=0; xcolor_type == PNG_COLOR_TYPE_PALETTE) { + register unsigned char *src_address = ((unsigned char **)image->line)[y]; + register unsigned char *dst_address = row_pointer; + register int x; + + for (x=0; xpalette, + as recommended in versions 1.0.5m and earlier of this example; if + libpng mallocs info_ptr->palette, libpng will free it). If you + allocated it with malloc() instead of png_malloc(), use free() instead + of png_free(). */ + png_free(png_ptr, palette); + palette = NULL; + + /* clean up after the write, and free any memory allocated */ + png_destroy_write_struct(&png_ptr, &info_ptr); + + /* close the file */ + fclose(fp); + + /* all right */ + return 0; } -/* static int configure_jpeg(void) */ +/* static int configure_png(void) */ /* { */ /* /\* interactive mode *\/ */ /* if (is_interactive()) { */ diff --git a/src/jinete/jclipbrd.c b/src/jinete/jclipboard.c similarity index 100% rename from src/jinete/jclipbrd.c rename to src/jinete/jclipboard.c diff --git a/src/jinete/jclipbrd.h b/src/jinete/jclipboard.h similarity index 100% rename from src/jinete/jclipbrd.h rename to src/jinete/jclipboard.h diff --git a/src/jinete/jdraw.c b/src/jinete/jdraw.c index ba3c33d9d..3916e09c2 100644 --- a/src/jinete/jdraw.c +++ b/src/jinete/jdraw.c @@ -29,9 +29,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include +#include "jinete/jdraw.h" #include "jinete/jfont.h" #include "jinete/jintern.h" #include "jinete/jlist.h" @@ -188,6 +190,12 @@ void ji_blit_region(JRegion region, int dx, int dy) int c, nrects = JI_REGION_NUM_RECTS(region); JRect rc; + if (ji_dirty_region) { + jregion_translate(region, dx, dy); + ji_add_dirty_region(region); + jregion_translate(region, -dx, -dy); + } + /* blit directly screen to screen *************************************/ if (is_linear_bitmap(ji_screen) && nrects == 1) { rc = JI_REGION_RECTS(region); diff --git a/src/jinete/jentry.c b/src/jinete/jentry.c index 7db3a2a6d..3ef6ac439 100644 --- a/src/jinete/jentry.c +++ b/src/jinete/jentry.c @@ -34,7 +34,7 @@ #include #include -#include "jinete/jclipbrd.h" +#include "jinete/jclipboard.h" #include "jinete/jfont.h" #include "jinete/jmanager.h" #include "jinete/jmessage.h" diff --git a/src/jinete/jinete.h b/src/jinete/jinete.h index 69baeffa0..56e83ca7a 100644 --- a/src/jinete/jinete.h +++ b/src/jinete/jinete.h @@ -37,7 +37,7 @@ #include "jinete/jbase.h" #include "jinete/jbox.h" #include "jinete/jbutton.h" -#include "jinete/jclipbrd.h" +#include "jinete/jclipboard.h" #include "jinete/jcombobox.h" #include "jinete/jdraw.h" #include "jinete/jentry.h" @@ -53,7 +53,7 @@ #include "jinete/jmenu.h" #include "jinete/jmessage.h" #include "jinete/jpanel.h" -#include "jinete/jqckmenu.h" +#include "jinete/jquickmenu.h" #include "jinete/jrect.h" #include "jinete/jregion.h" #include "jinete/jscroll.h" diff --git a/src/jinete/jmanager.c b/src/jinete/jmanager.c index c6090b701..e1d286676 100644 --- a/src/jinete/jmanager.c +++ b/src/jinete/jmanager.c @@ -336,7 +336,7 @@ bool jmanager_poll(JWidget manager, bool all_windows) that aren't the desktop) */ if (msg->type == JM_BUTTONPRESSED) { JWidget window = jwidget_get_window(mouse_widget); - JWidget win_manager = window ? jwindow_get_manager(window): NULL; + JWidget win_manager = window ? jwidget_get_manager(window): NULL; if ((window) && (!jwindow_is_desktop (window)) && @@ -1081,6 +1081,10 @@ static void dispatch_msgs(void) if (msg->type == JM_DRAW) { set_clip(ji_screen, 0, 0, JI_SCREEN_W-1, JI_SCREEN_H-1); + /* dirty rectangles */ + if (ji_dirty_region) + ji_add_dirty_rect(&msg->draw.rect); + release_bitmap(ji_screen); jmouse_show(); } diff --git a/src/jinete/jqckmenu.c b/src/jinete/jquickmenu.c similarity index 99% rename from src/jinete/jqckmenu.c rename to src/jinete/jquickmenu.c index 0023a9d66..39555d88b 100644 --- a/src/jinete/jqckmenu.c +++ b/src/jinete/jquickmenu.c @@ -33,7 +33,7 @@ #include "jinete/jlist.h" #include "jinete/jmenu.h" #include "jinete/jmessage.h" -#include "jinete/jqckmenu.h" +#include "jinete/jquickmenu.h" #include "jinete/jsep.h" #include "jinete/jwidget.h" diff --git a/src/jinete/jqckmenu.h b/src/jinete/jquickmenu.h similarity index 100% rename from src/jinete/jqckmenu.h rename to src/jinete/jquickmenu.h diff --git a/src/jinete/jregion.c b/src/jinete/jregion.c index 04bf65cd4..da84eeb64 100644 --- a/src/jinete/jregion.c +++ b/src/jinete/jregion.c @@ -1,11 +1,11 @@ #include -#include +#include #ifndef min -#define min MIN -#endif +#define min MIN +#endif #ifndef max -#define max MAX +#define max MAX #endif #include diff --git a/src/jinete/jsystem.c b/src/jinete/jsystem.c index 6169fb659..f4db53753 100644 --- a/src/jinete/jsystem.c +++ b/src/jinete/jsystem.c @@ -29,6 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #ifdef ALLEGRO_WINDOWS #include @@ -37,6 +38,7 @@ #include "jinete/jintern.h" #include "jinete/jmanager.h" #include "jinete/jrect.h" +#include "jinete/jregion.h" #include "jinete/jsystem.h" #include "jinete/jtheme.h" #include "jinete/jwidget.h" @@ -44,6 +46,7 @@ /* Global output bitmap. */ BITMAP *ji_screen = NULL; +JRegion ji_dirty_region = NULL; /* Global timer. */ @@ -199,12 +202,80 @@ void ji_set_screen(BITMAP *bmp) JRect rect = jrect_new(0, 0, JI_SCREEN_W, JI_SCREEN_H); jwidget_set_rect(manager, rect); jrect_free(rect); + + if (ji_dirty_region) + jregion_reset(ji_dirty_region, manager->rc); } jmouse_set_cursor(cursor); /* restore mouse cursor */ } } +void ji_add_dirty_rect(JRect rect) +{ + JRegion reg1; + + assert(ji_dirty_region != NULL); + + reg1 = jregion_new(rect, 1); + jregion_union(ji_dirty_region, ji_dirty_region, reg1); + jregion_free(reg1); +} + +void ji_add_dirty_region(JRegion region) +{ + assert(ji_dirty_region != NULL); + + jregion_union(ji_dirty_region, ji_dirty_region, region); +} + +void ji_flip_dirty_region(void) +{ + int c, nrects; + JRect rc; + + assert(ji_dirty_region != NULL); + + nrects = JI_REGION_NUM_RECTS(ji_dirty_region); + + if (nrects == 1) { + rc = JI_REGION_RECTS(ji_dirty_region); + ji_flip_rect(rc); + } + else if (nrects > 1) { + for (c=0, rc=JI_REGION_RECTS(ji_dirty_region); + cx1, rect->y1, + rect->x1, rect->y1, + jrect_w(rect), + jrect_h(rect)); + } + else { + stretch_blit(ji_screen, screen, + rect->x1, + rect->y1, + jrect_w(rect), + jrect_h(rect), + rect->x1 * SCREEN_W / JI_SCREEN_W, + rect->y1 * SCREEN_H / JI_SCREEN_H, + jrect_w(rect) * SCREEN_W / JI_SCREEN_W, + jrect_h(rect) * SCREEN_H / JI_SCREEN_H); + } +} + void ji_set_translation_hook(const char *(*gettext) (const char *msgid)) { strings_hook = gettext; @@ -269,6 +340,9 @@ void jmouse_draw_cursor() /* rectfill(ji_screen, rect->x1, rect->y1, rect->x2-1, rect->y2-1, makecol(0, 0, 255)); */ draw_sprite(ji_screen, sprite_cursor, x, y); + if (ji_dirty_region) + ji_add_dirty_rect(rect); + jrect_free(rect); } } diff --git a/src/jinete/jsystem.h b/src/jinete/jsystem.h index 53a861b02..e705ebb81 100644 --- a/src/jinete/jsystem.h +++ b/src/jinete/jsystem.h @@ -45,9 +45,15 @@ JI_BEGIN_DECLS #define JI_SCREEN_H ((ji_screen == screen) ? SCREEN_H: ji_screen->h) extern struct BITMAP *ji_screen; +extern JRegion ji_dirty_region; void ji_set_screen(struct BITMAP *bmp); +void ji_add_dirty_rect(JRect rect); +void ji_add_dirty_region(JRegion region); +void ji_flip_dirty_region(void); +void ji_flip_rect(JRect rect); + /***********************************************************************/ /* strings related */ diff --git a/src/jinete/jwidget.c b/src/jinete/jwidget.c index 70e65a1a5..d3c5955e9 100644 --- a/src/jinete/jwidget.c +++ b/src/jinete/jwidget.c @@ -609,6 +609,18 @@ JWidget jwidget_get_window(JWidget widget) return NULL; } +JWidget jwidget_get_manager(JWidget widget) +{ + while (widget) { + if (widget->type == JI_MANAGER) + return widget; + + widget = widget->parent; + } + + return ji_get_default_manager(); +} + /* returns a list of parents (you must free the list), if "ascendant" is TRUE the list is build from child to parents, else the list is from parent to children */ @@ -711,8 +723,8 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags) /* cut the top windows areas */ if (flags & JI_GDR_CUTTOPWINDOWS) { - window = jwidget_get_window (widget); - manager = window ? jwindow_get_manager (window): NULL; + window = jwidget_get_window(widget); + manager = window ? jwidget_get_manager(window): NULL; while (manager) { windows_list = manager->children; @@ -730,7 +742,7 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags) } window = jwidget_get_window(manager); - manager = window ? jwindow_get_manager(window): NULL; + manager = window ? jwidget_get_manager(window): NULL; } } @@ -787,7 +799,7 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags) /* limit to the manager area */ window = jwidget_get_window(widget); - manager = window ? jwindow_get_manager(window): NULL; + manager = window ? jwidget_get_manager(window): NULL; while (manager) { view = jwidget_get_view(manager); @@ -805,8 +817,8 @@ JRegion jwidget_get_drawable_region(JWidget widget, int flags) jregion_free (reg1); jrect_free (cpos); - window = jwidget_get_window (manager); - manager = window ? jwindow_get_manager (window): NULL; + window = jwidget_get_window(manager); + manager = window ? jwidget_get_manager(window): NULL; } /* return the region */ @@ -1074,7 +1086,7 @@ void jwidget_invalidate_region(JWidget widget, const JRegion region) jregion_rect_in(region, widget->rc) != JI_RGNOUT) { JRegion reg1 = jregion_new(NULL, 0); JRegion reg2 = jwidget_get_drawable_region(widget, - JI_GDR_CUTTOPWINDOWS); + JI_GDR_CUTTOPWINDOWS); JLink link; jregion_union(reg1, widget->update_region, region); diff --git a/src/jinete/jwidget.h b/src/jinete/jwidget.h index 159c35df4..d04f65015 100644 --- a/src/jinete/jwidget.h +++ b/src/jinete/jwidget.h @@ -165,6 +165,7 @@ void jwidget_replace_child(JWidget widget, JWidget old_child, JWidget jwidget_get_parent(JWidget widget); JWidget jwidget_get_window(JWidget widget); +JWidget jwidget_get_manager(JWidget window); JList jwidget_get_parents(JWidget widget, bool ascendant); JList jwidget_get_children(JWidget widget); JWidget jwidget_pick(JWidget widget, int x, int y); diff --git a/src/jinete/jwindow.c b/src/jinete/jwindow.c index 2e0747f91..7785e30c3 100644 --- a/src/jinete/jwindow.c +++ b/src/jinete/jwindow.c @@ -93,18 +93,6 @@ JWidget jwindow_get_killer(JWidget widget) return window->killer; } -JWidget jwindow_get_manager(JWidget widget) -{ - while (widget) { - if (widget->type == JI_MANAGER) - return widget; - - widget = widget->parent; - } - - return ji_get_default_manager(); -} - void jwindow_moveable(JWidget widget, bool state) { Window *window = jwidget_get_data(widget, JI_WINDOW); @@ -151,8 +139,8 @@ void jwindow_remap(JWidget widget) void jwindow_center(JWidget widget) { - Window *window = jwidget_get_data (widget, JI_WINDOW); - JWidget manager = jwindow_get_manager (widget); + Window *window = jwidget_get_data(widget, JI_WINDOW); + JWidget manager = jwidget_get_manager(widget); if (window->is_autoremap) jwindow_remap(widget); @@ -205,7 +193,7 @@ void jwindow_open_fg(JWidget widget) JWidget manager; jwindow_open(widget); - manager = jwindow_get_manager(widget); + manager = jwidget_get_manager(widget); window->is_foreground = TRUE; @@ -227,12 +215,12 @@ void jwindow_close(JWidget widget, JWidget killer) window->killer = killer; - _jmanager_close_window(jwindow_get_manager(widget), widget, TRUE, TRUE); + _jmanager_close_window(jwidget_get_manager(widget), widget, TRUE, TRUE); } bool jwindow_is_toplevel(JWidget widget) { - JWidget manager = jwindow_get_manager(widget); + JWidget manager = jwidget_get_manager(widget); if (!jlist_empty(manager->children)) return (widget == jlist_first(manager->children)->data); @@ -291,7 +279,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg) switch (msg->type) { case JM_DESTROY: - _jmanager_close_window(jwindow_get_manager(widget), widget, + _jmanager_close_window(jwidget_get_manager(widget), widget, FALSE, FALSE); jfree(window); break; @@ -434,7 +422,7 @@ static bool window_msg_proc(JWidget widget, JMessage msg) static void window_request_size(JWidget widget, int *w, int *h) { Window *window = jwidget_get_data(widget, JI_WINDOW); - JWidget manager = jwindow_get_manager(widget); + JWidget manager = jwidget_get_manager(widget); if (window->is_desktop) { JRect cpos = jwidget_get_child_rect(manager); @@ -629,7 +617,7 @@ static void move_window(JWidget widget, JRect rect, bool use_blit) JRegion manager_refresh_region; JRegion window_refresh_region; JRect old_pos = jrect_new_copy(widget->rc); - JRect man_pos = jwidget_get_rect(jwindow_get_manager (widget)); + JRect man_pos = jwidget_get_rect(jwidget_get_manager(widget)); JMessage msg; msg = jmessage_new(JM_WINMOVE); @@ -673,17 +661,10 @@ static void move_window(JWidget widget, JRect rect, bool use_blit) new_drawable_region); /* add a region to draw areas that were outside the screen */ -/* jregion_reset(reg2, man_pos); */ -/* jregion_subtract(reg1, old_reg, reg2); */ -/* jregion_translate(reg1, */ -/* widget->rc->x1 - old_pos->x1, */ -/* widget->rc->y1 - old_pos->y1); */ -/* jregion_union(window_refresh_region, window_refresh_region, reg1); */ - jregion_copy(reg1, new_drawable_region); jregion_translate(reg1, - old_pos->x1 - widget->rc->x1, - old_pos->y1 - widget->rc->y1); + old_pos->x1 - widget->rc->x1, + old_pos->y1 - widget->rc->y1); jregion_intersect(moveable_region, old_drawable_region, reg1); jregion_subtract(reg1, reg1, moveable_region); @@ -692,21 +673,10 @@ static void move_window(JWidget widget, JRect rect, bool use_blit) widget->rc->y1 - old_pos->y1); jregion_union(window_refresh_region, window_refresh_region, reg1); - /* add a region to draw background areas that will be moved with blit() */ -/* jregion_reset(reg2, widget->rc); */ -/* jregion_subtract(reg1, reg2, new_drawable_region); */ -/* jregion_union(manager_refresh_region, manager_refresh_region, reg1); */ - /* move the window's graphics */ jmouse_hide(); set_clip(ji_screen, man_pos->x1, man_pos->y1, man_pos->x2-1, man_pos->y2-1); -/* blit (ji_screen, ji_screen, */ -/* old_pos->x1, old_pos->y1, */ -/* widget->rc->x1, widget->rc->y1, */ -/* jrect_w(widget->rc), jrect_h(widget->rc)); */ - -/* ji_blit_region(old_drawable_region, */ ji_blit_region(moveable_region, widget->rc->x1 - old_pos->x1, @@ -719,11 +689,8 @@ static void move_window(JWidget widget, JRect rect, bool use_blit) jregion_free(moveable_region); } -/* jwidget_invalidate_region(jwindow_get_manager (widget), */ -/* manager_refresh_region); */ -/* jwidget_invalidate_region(widget, window_refresh_region); */ - jwidget_redraw_region(jwindow_get_manager(widget), - manager_refresh_region); + jwidget_redraw_region(jwidget_get_manager(widget), + manager_refresh_region); jwidget_redraw_region(widget, window_refresh_region); jregion_free(old_reg); diff --git a/src/jinete/jwindow.h b/src/jinete/jwindow.h index 84ccccf2a..92a85d63c 100644 --- a/src/jinete/jwindow.h +++ b/src/jinete/jwindow.h @@ -40,7 +40,6 @@ JWidget jwindow_new(const char *text); JWidget jwindow_new_desktop(void); JWidget jwindow_get_killer(JWidget window); -JWidget jwindow_get_manager(JWidget window); void jwindow_moveable(JWidget window, bool state); void jwindow_sizeable(JWidget window, bool state); diff --git a/src/jinete/themes/jsimple.c b/src/jinete/themes/jsimple.c deleted file mode 100644 index ae446382a..000000000 --- a/src/jinete/themes/jsimple.c +++ /dev/null @@ -1,1576 +0,0 @@ -/* Jinete - a GUI library - * Copyright (c) 2003, 2004, 2005, 2007, David A. Capello - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of the Jinete nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "jinete/jinete.h" -#include "jinete/jintern.h" - -/* data related */ -#include "stdicons.c" -#include "pcx2data.c" - -#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c))) - -#define BGCOLOR (get_bg_color(widget)) - -/* "icons_data" indexes */ -enum { - FIRST_CURSOR = 0, - LAST_CURSOR = 11, - ICON_CHECK_EDGE = 12, - ICON_CHECK_MARK, - ICON_CLOSE, - ICON_MENU_MARK, - ICON_RADIO_EDGE, - ICON_RADIO_MARK, - ICONS, -}; - -static struct { - bool mask : 1; - unsigned char *data; -} icons_data[ICONS] = { - { FALSE, default_theme_cnormal }, - { FALSE, default_theme_cnoradd }, - { FALSE, default_theme_chand }, - { FALSE, default_theme_cmove }, - { FALSE, default_theme_csizetl }, - { FALSE, default_theme_csizet }, - { FALSE, default_theme_csizetr }, - { FALSE, default_theme_csizel }, - { FALSE, default_theme_csizer }, - { FALSE, default_theme_csizebl }, - { FALSE, default_theme_csizeb }, - { FALSE, default_theme_csizebr }, - { FALSE, default_theme_ichecke }, - { FALSE, default_theme_icheckm }, - { FALSE, default_theme_iclose }, - { TRUE, default_theme_imenum }, - { FALSE, default_theme_iradioe }, - { FALSE, default_theme_iradiom }, -}; - -static BITMAP *icons_bitmap[ICONS] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -}; - -static void theme_destroy(void); -static void theme_regen(void); -static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y); -static void theme_init_widget(JWidget widget); -static JRegion theme_get_window_mask(JWidget widget); -static void theme_map_decorative_widget(JWidget widget); -static void theme_draw_box(JWidget widget); -static void theme_draw_button(JWidget widget); -static void theme_draw_check(JWidget widget); -static void theme_draw_entry(JWidget widget); -static void theme_draw_label(JWidget widget); -static void theme_draw_listbox(JWidget widget); -static void theme_draw_listitem(JWidget widget); -static void theme_draw_menu(JWidget widget); -static void theme_draw_menuitem(JWidget widget); -static void theme_draw_panel(JWidget widget); -static void theme_draw_radio(JWidget widget); -static void theme_draw_separator(JWidget widget); -static void theme_draw_slider(JWidget widget); -static void theme_draw_textbox(JWidget widget); -static void theme_draw_view(JWidget widget); -static void theme_draw_view_scrollbar(JWidget widget); -static void theme_draw_view_viewport(JWidget widget); -static void theme_draw_window(JWidget widget); - -static int get_bg_color(JWidget widget); -static void draw_textstring(const char *t, int fg_color, int bg_color, - bool fill_bg, JWidget widget, const JRect rect, - int selected_offset); -static void draw_entry_cursor(JWidget widget, int x, int y); -static void draw_icons(int x, int y, JWidget widget, int edge_icon); -static void draw_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color); -static void fill_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color); - -static bool theme_button_msg_proc (JWidget widget, JMessage msg); - -JTheme jtheme_new_simple(void) -{ - JTheme theme; - - theme = jtheme_new (); - if (!theme) - return NULL; - - theme->name = "Simple Theme"; - theme->check_icon_size = 8; - theme->radio_icon_size = 8; - theme->scrollbar_size = 12; - - theme->destroy = theme_destroy; - theme->regen = theme_regen; - theme->set_cursor = theme_set_cursor; - theme->init_widget = theme_init_widget; - theme->get_window_mask = theme_get_window_mask; - theme->map_decorative_widget = theme_map_decorative_widget; - - jtheme_set_method(theme, JI_BOX, theme_draw_box); - jtheme_set_method(theme, JI_BUTTON, theme_draw_button); - jtheme_set_method(theme, JI_CHECK, theme_draw_check); - jtheme_set_method(theme, JI_ENTRY, theme_draw_entry); - jtheme_set_method(theme, JI_LABEL, theme_draw_label); - jtheme_set_method(theme, JI_LISTBOX, theme_draw_listbox); - jtheme_set_method(theme, JI_LISTITEM, theme_draw_listitem); - jtheme_set_method(theme, JI_MENU, theme_draw_menu); - jtheme_set_method(theme, JI_MENUITEM, theme_draw_menuitem); - jtheme_set_method(theme, JI_PANEL, theme_draw_panel); - jtheme_set_method(theme, JI_RADIO, theme_draw_radio); - jtheme_set_method(theme, JI_SEPARATOR, theme_draw_separator); - jtheme_set_method(theme, JI_SLIDER, theme_draw_slider); - jtheme_set_method(theme, JI_TEXTBOX, theme_draw_textbox); - jtheme_set_method(theme, JI_VIEW, theme_draw_view); - jtheme_set_method(theme, JI_VIEW_SCROLLBAR, theme_draw_view_scrollbar); - jtheme_set_method(theme, JI_VIEW_VIEWPORT, theme_draw_view_viewport); - jtheme_set_method(theme, JI_WINDOW, theme_draw_window); - - return theme; -} - -static void theme_destroy (void) -{ - int c; - - for (c=0; cdesktop_color = makecol(255, 255, 255); - theme->textbox_fg_color = makecol(0, 0, 0); - theme->textbox_bg_color = makecol(255, 255, 255); - - /* fixup cursors */ - - cmap[0] = bitmap_mask_color(ji_screen); - cmap[1] = makecol(0, 0, 0); - cmap[2] = makecol(128, 128, 128); - cmap[3] = makecol(255, 255, 255); - cmap[4] = makecol(192, 192, 192); - cmap[5] = makecol(224, 224, 224); - - mask_cmap[0] = 0; - mask_cmap[1] = 1; - - for (c=0; c= FIRST_CURSOR && icon_index <= LAST_CURSOR) { - if (icons_bitmap[icon_index]) - sprite = icons_bitmap[icon_index]; - - switch (type) { - case JI_CURSOR_NULL: - case JI_CURSOR_NORMAL: - case JI_CURSOR_NORMAL_ADD: - *focus_x = 0; - *focus_y = 0; - break; - case JI_CURSOR_HAND: - *focus_x = 5; - *focus_y = 3; - break; - case JI_CURSOR_MOVE: - *focus_x = 8; - *focus_y = 8; - break; - case JI_CURSOR_SIZE_TL: - case JI_CURSOR_SIZE_T: - case JI_CURSOR_SIZE_TR: - case JI_CURSOR_SIZE_L: - case JI_CURSOR_SIZE_R: - case JI_CURSOR_SIZE_BL: - case JI_CURSOR_SIZE_B: - case JI_CURSOR_SIZE_BR: - *focus_x = 8; - *focus_y = 8; - break; - } - } - - return sprite; -} - -static void theme_init_widget(JWidget widget) -{ -#define BORDER(n) \ - widget->border_width.l = n; \ - widget->border_width.t = n; \ - widget->border_width.r = n; \ - widget->border_width.b = n; - -#define BORDER4(L,T,R,B) \ - widget->border_width.l = L; \ - widget->border_width.t = T; \ - widget->border_width.r = R; \ - widget->border_width.b = B; - - if ((widget->flags & JI_INITIALIZED) && - (widget->type != JI_WINDOW)) - return; - - switch (widget->draw_type) { - - case JI_BOX: - BORDER(0); -/* widget->child_spacing = 2; */ - widget->child_spacing = 4; - break; - - case JI_BUTTON: - BORDER(4); - widget->child_spacing = 0; - break; - - case JI_CHECK: - BORDER(2); -/* widget->child_spacing = 2; */ - widget->child_spacing = 4; - break; - - case JI_ENTRY: - BORDER(3); - break; - - case JI_LABEL: - BORDER(1); - break; - - case JI_LISTBOX: - BORDER(0); - widget->child_spacing = 0; - break; - - case JI_LISTITEM: - BORDER(1); - break; - - case JI_MENU: - case JI_MENUBAR: - case JI_MENUBOX: - BORDER(0); - widget->child_spacing = 0; - break; - - case JI_MENUITEM: - BORDER(2); - widget->child_spacing = 18; - break; - - case JI_PANEL: - BORDER(0); - widget->child_spacing = 3; - break; - - case JI_RADIO: - BORDER(2); -/* widget->child_spacing = 2; */ - widget->child_spacing = 4; - break; - - case JI_SEPARATOR: - /* frame */ - if ((widget->align & JI_HORIZONTAL) && - (widget->align & JI_VERTICAL)) { - BORDER (4); - } - /* horizontal bar */ - else if (widget->align & JI_HORIZONTAL) { - BORDER4 (2, 4, 2, 0); - } - /* vertical bar */ - else { - BORDER4 (4, 2, 0, 2); - } - - if (widget->text) { - if (widget->align & JI_TOP) - widget->border_width.t = jwidget_get_text_height (widget); - else if (widget->align & JI_BOTTOM) - widget->border_width.b = jwidget_get_text_height (widget); - } - break; - - case JI_SLIDER: - BORDER(4); - widget->child_spacing = jwidget_get_text_height (widget); - break; - - case JI_TEXTBOX: - BORDER(2); - widget->child_spacing = 0; - break; - - case JI_VIEW: - BORDER(2); - widget->child_spacing = 0; - break; - - case JI_VIEW_SCROLLBAR: - BORDER(1); - widget->child_spacing = 0; - break; - - case JI_VIEW_VIEWPORT: - BORDER(0); - widget->child_spacing = 0; - break; - - case JI_WINDOW: - if (!jwindow_is_desktop (widget)) { - if (widget->text) { - BORDER4(6, 4+jwidget_get_text_height(widget)+6, 6, 6); -#if 1 /* add close button */ - if (!(widget->flags & JI_INITIALIZED)) { - JWidget button = jbutton_new("x"); - jbutton_set_bevel(button, 0, 0, 0, 0); - jwidget_add_hook(button, JI_WIDGET, - theme_button_msg_proc, NULL); - jwidget_decorative(button, TRUE); - jwidget_add_child(widget, button); - jwidget_set_name(button, "theme_close_button"); - } -#endif - } - else if (!(widget->flags & JI_INITIALIZED)) { - BORDER(3); - } - } - else { - BORDER (0); - } - widget->child_spacing = 4; - break; - - default: - break; - } -} - -static JRegion theme_get_window_mask (JWidget widget) -{ - return jregion_new (widget->rc, 1); -} - -static void theme_map_decorative_widget (JWidget widget) -{ - if (ustrcmp(widget->name, "theme_close_button") == 0) { - JWidget window = widget->parent; - JRect rect = jrect_new(0, 0, 0, 0); - - rect->x2 = jwidget_get_text_height(widget) + 2; - rect->y2 = jwidget_get_text_height(widget) + 2; - - jrect_displace(rect, - window->rc->x2 - 4 - jrect_w(rect), - window->rc->y1 + 4); - - jwidget_set_rect(widget, rect); - jrect_free(rect); - } -} - -static void theme_draw_box(JWidget widget) -{ - jdraw_rectfill (widget->rc, BGCOLOR); -} - -static void theme_draw_button(JWidget widget) -{ - BITMAP *icon_bmp = ji_generic_button_get_icon(widget); - int icon_align = ji_generic_button_get_icon_align(widget); - struct jrect box, text, icon; - int x1, y1, x2, y2; - int fg, bg; - JRect crect; - - jwidget_get_texticon_info(widget, &box, &text, &icon, - icon_align, - icon_bmp ? icon_bmp->w : 0, - icon_bmp ? icon_bmp->h : 0); - - /* with mouse */ -/* if (jwidget_has_mouse(widget)) */ -/* bg = makecol(143, 158, 211); */ - /* without mouse */ - if (jwidget_is_disabled(widget)) { - fg = makecol(255, 255, 255); - bg = makecol(210, 230, 220); - } - else { - fg = jwidget_has_mouse(widget) ? makecol(255, 255, 255): makecol(143, 158, 211); - bg = jwidget_has_mouse(widget) ? makecol(143, 158, 211): makecol(255, 255, 255); - } - - /* selected */ -/* if (jwidget_is_selected(widget)) { */ -/* c1 = makecol(128, 128, 128); */ -/* c2 = makecol(255, 255, 255); */ -/* } */ -/* /\* non-selected *\/ */ -/* else { */ -/* c1 = makecol(255, 255, 255); */ -/* c2 = makecol(128, 128, 128); */ -/* } */ - - /* widget position */ - x1 = widget->rc->x1; - y1 = widget->rc->y1; - x2 = widget->rc->x2-1; - y2 = widget->rc->y2-1; - - /* extern background */ - rectfill(ji_screen, x1, y1, x2, y2, BGCOLOR); - - /* background */ - fill_round_rect(x1, y1, x2, y2, 6, 6, bg); - if (!jwidget_has_mouse(widget)) - draw_round_rect(x1, y1, x2, y2, 6, 6, fg); - - /* get bevel info */ -/* jbutton_get_bevel(widget, bevel); */ - - /* 1st border */ -/* if (jwidget_has_focus(widget)) */ -/* draw_bevel_box(x1, y1, x2, y2, */ -/* makecol(0, 0, 0), makecol(0, 0, 0), bevel); */ -/* else { */ -/* less_bevel(bevel); */ -/* draw_bevel_box(x1, y1, x2, y2, c1, c2, bevel); */ -/* } */ - -/* less_bevel(bevel); */ - - /* 2nd border */ -/* x1++, y1++, x2--, y2--; */ -/* if (jwidget_has_focus(widget)) */ -/* draw_bevel_box(x1, y1, x2, y2, c1, c2, bevel); */ -/* else */ -/* draw_bevel_box(x1, y1, x2, y2, bg, bg, bevel); */ - -/* less_bevel(bevel); */ - - /* more borders */ -/* while ((bevel[0] > 0) || (bevel[1] > 0) || */ -/* (bevel[2] > 0) || (bevel[3] > 0)) { */ -/* x1++, y1++, x2--, y2--; */ -/* draw_bevel_box(x1, y1, x2, y2, bg, bg, bevel); */ -/* less_bevel(bevel); */ -/* } */ - - /* background */ - x1++, y1++, x2--, y2--; -/* rectfill(ji_screen, x1, y1, x2, y2, bg); */ - - /* text */ - crect = jwidget_get_child_rect(widget); - draw_textstring(NULL, fg, bg, FALSE, widget, crect, 1); - jrect_free(crect); - - /* icon */ - if (icon_bmp) { - if (jwidget_is_selected(widget)) - jrect_displace(&icon, 1, 1); - - if (jwidget_is_enabled (widget)) - draw_sprite(ji_screen, icon_bmp, icon.x1, icon.y1); - else { - _ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1+1, icon.y1+1, - makecol(255, 255, 255)); - _ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1, icon.y1, - makecol(128, 128, 128)); - } - } -} - -static void theme_draw_check(JWidget widget) -{ - struct jrect box, text, icon; - int bg; - - jwidget_get_texticon_info(widget, &box, &text, &icon, - ji_generic_button_get_icon_align(widget), - widget->theme->check_icon_size, - widget->theme->check_icon_size); - - /* background */ - jdraw_rectfill (widget->rc, bg = BGCOLOR); - - /* mouse */ - if (jwidget_has_mouse (widget)) - jdraw_rectfill (&box, bg = makecol (224, 224, 224)); - - /* focus */ - if (jwidget_has_focus (widget)) { - jrect_stretch (&box, 1); - jdraw_rect (&box, makecol (0, 0, 0)); - } - - /* text */ - draw_textstring (NULL, -1, bg, FALSE, widget, &text, 0); - - /* icon */ - draw_icons (icon.x1, icon.y1, widget, ICON_CHECK_EDGE); -} - -static void theme_draw_entry(JWidget widget) -{ - bool password = jentry_is_password (widget); - int scroll, cursor, state, selbeg, selend; - const char *text = widget->text; - int c, ch, x, y, w, fg, bg; - int x1, y1, x2, y2; - int cursor_x; - - jtheme_entry_info (widget, &scroll, &cursor, &state, &selbeg, &selend); - - /* main pos */ - x1 = widget->rc->x1; - y1 = widget->rc->y1; - x2 = widget->rc->x2 - 1; - y2 = widget->rc->y2 - 1; - - bg = makecol (255, 255, 255); - - /* 1st border */ - _ji_theme_rectedge (ji_screen, x1, y1, x2, y2, - makecol (128, 128, 128), makecol (255, 255, 255)); - - /* 2nd border */ - x1++, y1++, x2--, y2--; - if (jwidget_has_focus (widget)) - rect (ji_screen, x1, y1, x2, y2, makecol (0, 0, 0)); - else - rect (ji_screen, x1, y1, x2, y2, BGCOLOR); - - /* background border */ - x1++, y1++, x2--, y2--; - rectfill (ji_screen, x1, y1, x2, y2, bg); - - /* draw the text */ - x = widget->rc->x1 + widget->border_width.l; - y = (widget->rc->y1+widget->rc->y2)/2 - jwidget_get_text_height (widget)/2; - - for (c=scroll; ugetat (text, c); c++) { - ch = password ? '*': ugetat (text, c); - - /* normal text */ - bg = -1; - fg = makecol (0, 0, 0); - - /* selected */ - if ((c >= selbeg) && (c <= selend)) { - if (jwidget_has_focus (widget)) - bg = makecol (44, 76, 145); - else - bg = makecol (128, 128, 128); - fg = makecol (255, 255, 255); - } - - /* disabled */ - if (jwidget_is_disabled (widget)) { - bg = -1; - fg = makecol (128, 128, 128); - } - - w = CHARACTER_LENGTH (widget->text_font, ch); - if (x+w > widget->rc->x2-3) - return; - - cursor_x = x; - ji_font_set_aa_mode (widget->text_font, - bg >= 0 ? bg: makecol (255, 255, 255)); - widget->text_font->vtable->render_char (widget->text_font, - ch, fg, bg, ji_screen, x, y); - x += w; - - /* cursor */ - if ((c == cursor) && (state) && (jwidget_has_focus (widget))) - draw_entry_cursor (widget, cursor_x, y); - } - - /* draw the cursor if it is next of the last character */ - if ((c == cursor) && (state) && - (jwidget_has_focus (widget)) && - (jwidget_is_enabled (widget))) - draw_entry_cursor (widget, x, y); -} - -static void theme_draw_label(JWidget widget) -{ - int bg = BGCOLOR; - - jdraw_rectfill (widget->rc, bg); - - draw_textstring (NULL, -1, bg, FALSE, widget, widget->rc, 0); -} - -static void theme_draw_listbox(JWidget widget) -{ - int bg; - - if (jwidget_is_disabled (widget)) - bg = makecol (192, 192, 192); - else - bg = makecol (255, 255, 255); - - jdraw_rectfill (widget->rc, makecol (255, 255, 255)); -} - -static void theme_draw_listitem(JWidget widget) -{ - int fg, bg; - int x, y; - - if (jwidget_is_disabled (widget)) { - bg = makecol (192, 192, 192); - fg = makecol (128, 128, 128); - } - else if (jwidget_is_selected (widget)) { - bg = makecol (44, 76, 145); - fg = makecol (255, 255, 255); - } - else { - bg = makecol (255, 255, 255); - fg = makecol (0, 0, 0); - } - - x = widget->rc->x1+widget->border_width.l; - y = widget->rc->y1+widget->border_width.t; - - if (widget->text) { - /* text */ - jdraw_text(widget->text_font, widget->text, x, y, fg, bg, TRUE); - - /* background */ - _ji_theme_rectfill_exclude - (ji_screen, - widget->rc->x1, widget->rc->y1, - widget->rc->x2-1, widget->rc->y2-1, - x, y, - x+jwidget_get_text_length(widget)-1, - y+jwidget_get_text_height(widget)-1, bg); - } - /* background */ - else { - jdraw_rectfill(widget->rc, bg); - } -} - -static void theme_draw_menu (JWidget widget) -{ - jdraw_rectfill (widget->rc, BGCOLOR); -} - -static void theme_draw_menuitem (JWidget widget) -{ - int c, bg, fg, bar; - int x1, y1, x2, y2; - JRect pos; - - /* TODO assert? */ - if (!widget->parent->parent) - return; - - bar = (widget->parent->parent->type == JI_MENUBAR); - - /* colors */ - if (jwidget_is_disabled (widget)) { - bg = BGCOLOR; - fg = -1; - } - else { - if (jmenuitem_is_highlight (widget)) { - bg = makecol (44, 76, 145); - fg = makecol (255, 255, 255); - } - else if (jwidget_has_mouse (widget)) { - bg = makecol (224, 224, 224); - fg = makecol (0, 0, 0); - } - else { - bg = BGCOLOR; - fg = makecol (0, 0, 0); - } - } - - /* widget position */ - x1 = widget->rc->x1; - y1 = widget->rc->y1; - x2 = widget->rc->x2-1; - y2 = widget->rc->y2-1; - - /* background */ - rectfill (ji_screen, x1, y1, x2, y2, bg); - - /* draw an indicator for selected items */ - if (jwidget_is_selected (widget)) { - BITMAP *icon = icons_bitmap[ICON_MENU_MARK]; - int x = widget->rc->x1+4-icon->w/2; - int y = (widget->rc->y1+widget->rc->y2)/2-icon->h/2; - - if (jwidget_is_enabled(widget)) - draw_character(ji_screen, icon, x, y, fg); - else { - draw_character(ji_screen, icon, x+1, y+1, makecol (255, 255, 255)); - draw_character(ji_screen, icon, x, y, makecol (128, 128, 128)); - } - } - - /* text */ - if (bar) - widget->align = JI_CENTER | JI_MIDDLE; - else - widget->align = JI_LEFT | JI_MIDDLE; - - pos = jwidget_get_rect (widget); - if (!bar) - jrect_displace (pos, widget->child_spacing/2, 0); - draw_textstring (NULL, fg, bg, FALSE, widget, pos, 0); - jrect_free (pos); - - /* for menu-box */ - if (!bar) { - /* draw the arrown (to indicate which this menu has a sub-menu) */ - if (jmenuitem_get_submenu (widget)) { - /* enabled */ - if (jwidget_is_enabled (widget)) { - for (c=0; c<3; c++) - vline (ji_screen, - widget->rc->x2-3-c, - (widget->rc->y1+widget->rc->y2)/2-c, - (widget->rc->y1+widget->rc->y2)/2+c, fg); - } - /* disabled */ - else { - for (c=0; c<3; c++) - vline (ji_screen, - widget->rc->x2-3-c+1, - (widget->rc->y1+widget->rc->y2)/2-c+1, - (widget->rc->y1+widget->rc->y2)/2+c+1, makecol (255, 255, 255)); - for (c=0; c<3; c++) - vline (ji_screen, - widget->rc->x2-3-c, - (widget->rc->y1+widget->rc->y2)/2-c, - (widget->rc->y1+widget->rc->y2)/2+c, makecol (128, 128, 128)); - } - } - /* draw the keyboard shortcut */ - else if (jmenuitem_get_accel (widget)) { - int old_align = widget->align; - char buf[256]; - - pos = jwidget_get_rect (widget); - pos->x2 -= widget->child_spacing/4; - - jaccel_to_string (jmenuitem_get_accel (widget), buf); - - widget->align = JI_RIGHT | JI_MIDDLE; - draw_textstring (buf, fg, bg, FALSE, widget, pos, 0); - widget->align = old_align; - - jrect_free (pos); - } - } -} - -static void theme_draw_panel (JWidget widget) -{ - JWidget c1, c2; - JLink link; - int c; - -/* jdraw_rectfill(widget->rc, */ -/* (jwidget_pick(widget, */ -/* ji_mouse_x(0), */ -/* ji_mouse_y(0)) == widget) ? */ -/* makecol (224, 224, 224): makecol (192, 192, 192)); */ - jdraw_rectfill(widget->rc, makecol (192, 192, 192)); - - JI_LIST_FOR_EACH(widget->children, link) { - if (link->next != widget->children->end) { - c1 = (JWidget)link->data; - c2 = (JWidget)link->next->data; - - if (widget->align & JI_HORIZONTAL) { -/* vline (ji_screen, */ -/* (c1->pos->x+c1->pos->w+c2->pos->x-1)/2, */ -/* widget->rect->y, */ -/* widget->rect->y+widget->rect->h/2-4, makecol (0, 0, 0)); */ - -/* vline (ji_screen, */ -/* (c1->pos->x+c1->pos->w+c2->pos->x-1)/2, */ -/* widget->rect->y+widget->rect->h/2+4, */ -/* widget->rect->y+widget->rect->h-1, makecol (0, 0, 0)); */ - - for (c=-4; c<=4; c+=2) - hline(ji_screen, - c1->rc->x2+2, - (widget->rc->y1+widget->rc->y2)/2+c, - c2->rc->x1-3, makecol(0, 0, 0)); - } - else { -/* hline (ji_screen, */ -/* widget->rect->x, */ -/* (c1->pos->y+c1->pos->h+c2->pos->y-1)/2, */ -/* widget->rect->x+widget->rect->w/2-4, makecol (0, 0, 0)); */ - -/* hline (ji_screen, */ -/* widget->rect->x+widget->rect->w/2+4, */ -/* (c1->pos->y+c1->pos->h+c2->pos->y-1)/2, */ -/* widget->rect->x+widget->rect->w-1, makecol (0, 0, 0)); */ - - for (c=-4; c<=4; c+=2) - vline(ji_screen, - (widget->rc->x1+widget->rc->x2)/2+c, - c1->rc->y2+2, - c2->rc->y1-3, makecol(0, 0, 0)); - } - } - } -} - -static void theme_draw_radio (JWidget widget) -{ - struct jrect box, text, icon; - int bg = BGCOLOR; - - jwidget_get_texticon_info(widget, &box, &text, &icon, - ji_generic_button_get_icon_align(widget), - widget->theme->radio_icon_size, - widget->theme->radio_icon_size); - - /* background */ - jdraw_rectfill (widget->rc, bg); - - /* mouse */ - if (jwidget_has_mouse (widget)) - jdraw_rectfill (&box, bg = makecol (224, 224, 224)); - - /* focus */ - if (jwidget_has_focus (widget)) - rect (ji_screen, box.x1-1, box.y1-1, box.x2, box.y2, - makecol (0, 0, 0)); - - /* text */ - draw_textstring (NULL, -1, bg, FALSE, widget, &text, 0); - - /* icon */ - draw_icons (icon.x1, icon.y1, widget, ICON_RADIO_EDGE); -} - -static void theme_draw_separator (JWidget widget) -{ - int x1, y1, x2, y2; - - /* frame position */ - x1 = widget->rc->x1 + widget->border_width.l/2; - y1 = widget->rc->y1 + widget->border_width.t/2; - x2 = widget->rc->x2 - 1 - widget->border_width.r/2; - y2 = widget->rc->y2 - 1 - widget->border_width.b/2; - - /* background */ - jdraw_rectfill (widget->rc, BGCOLOR); - - /* TOP line */ - if (widget->align & JI_HORIZONTAL) { - hline (ji_screen, x1, y1-1, x2, makecol (128, 128, 128)); - hline (ji_screen, x1, y1, x2, makecol (255, 255, 255)); - } - - /* LEFT line */ - if (widget->align & JI_VERTICAL) { - vline (ji_screen, x1-1, y1, y2, makecol (128, 128, 128)); - vline (ji_screen, x1, y1, y2, makecol (255, 255, 255)); - } - - /* frame */ - if ((widget->align & JI_HORIZONTAL) && - (widget->align & JI_VERTICAL)) { - /* union between the LEFT and TOP lines */ - putpixel (ji_screen, x1-1, y1-1, makecol (128, 128, 128)); - - /* BOTTOM line */ - hline (ji_screen, x1, y2, x2, makecol (128, 128, 128)); - hline (ji_screen, x1-1, y2+1, x2, makecol (255, 255, 255)); - - /* RIGHT line */ - vline (ji_screen, x2, y1, y2, makecol (128, 128, 128)); - vline (ji_screen, x2+1, y1-1, y2, makecol (255, 255, 255)); - - /* union between the RIGHT and BOTTOM lines */ - putpixel (ji_screen, x2+1, y2+1, makecol (255, 255, 255)); - } - - /* text */ - if (widget->text) { - int h = jwidget_get_text_height (widget); - struct jrect r = { x1+h/2, y1-h/2, x2+1-h, y2+1+h }; - draw_textstring (NULL, -1, BGCOLOR, FALSE, widget, &r, 0); - } -} - -#if 1 -/* TODO when Allegro 4.1 will be officially released, replace this - with the get_clip_rect, add_clip_rect, set_clip_rect functions */ -static int my_add_clip_rect (BITMAP *bitmap, int x1, int y1, int x2, int y2) -{ - int u1 = MAX (x1, bitmap->cl); - int v1 = MAX (y1, bitmap->ct); - int u2 = MIN (x2, bitmap->cr-1); - int v2 = MIN (y2, bitmap->cb-1); - - if (u1 > u2 || v1 > v2) - return FALSE; - else - set_clip(bitmap, u1, v1, u2, v2); - - return TRUE; -} -#endif - -static void theme_draw_slider (JWidget widget) -{ -#if 1 - int x, x1, y1, x2, y2, bg, c1, c2; - int min, max, value; - char buf[256]; - - jtheme_slider_info (widget, &min, &max, &value); - - /* main pos */ - x1 = widget->rc->x1; - y1 = widget->rc->y1; - x2 = widget->rc->x2 - 1; - y2 = widget->rc->y2 - 1; - - /* with mouse */ - if (jwidget_has_mouse (widget)) - bg = makecol (224, 224, 224); - /* without mouse */ - else - bg = makecol (192, 192, 192); - - /* 1st border */ - _ji_theme_rectedge (ji_screen, x1, y1, x2, y2, - makecol (128, 128, 128), makecol (255, 255, 255)); - - /* 2nd border */ - x1++, y1++, x2--, y2--; - if (jwidget_has_focus (widget)) - rect (ji_screen, x1, y1, x2, y2, makecol (0, 0, 0)); - else - rect (ji_screen, x1, y1, x2, y2, bg); - - /* 3rd border */ - if (!jwidget_is_selected (widget)) { - c1 = makecol (255, 255, 255); - c2 = makecol (128, 128, 128); - } - else { - c1 = makecol (128, 128, 128); - c2 = makecol (255, 255, 255); - } - - x1++, y1++, x2--, y2--; - _ji_theme_rectedge (ji_screen, x1, y1, x2, y2, c1, c2); - - /* progress bar */ - x1++, y1++, x2--, y2--; - - if (min != max) - x = x1 + (x2-x1) * (value-min) / (max-min); - else - x = x1; - - if (value == min) { - rectfill (ji_screen, x1, y1, x2, y2, bg); - } - else { - rectfill (ji_screen, x1, y1, x, y2, - (jwidget_is_disabled (widget)) ? - bg: makecol (44, 76, 145)); - - if (x < x2) - rectfill (ji_screen, x+1, y1, x2, y2, bg); - } - - /* text */ - { - char *old_text = widget->text; - int cx1, cy1, cx2, cy2; - JRect r; - - usprintf(buf, "%d", value); - - widget->align = JI_CENTER | JI_MIDDLE; - widget->text = buf; - - r = jrect_new(x1, y1, x2+1, y2+1); - - /* TODO when Allegro 4.1 will be officially released, replace this - with the get_clip_rect, add_clip_rect, set_clip_rect functions */ - - cx1 = ji_screen->cl; - cy1 = ji_screen->ct; - cx2 = ji_screen->cr-1; - cy2 = ji_screen->cb-1; - - if (my_add_clip_rect(ji_screen, x1, y1, x, y2)) - draw_textstring(NULL, makecol(255, 255, 255), - jwidget_is_disabled(widget) ? - bg: makecol(44, 76, 145), FALSE, widget, r, 0); - - set_clip(ji_screen, cx1, cy1, cx2, cy2); - - if (my_add_clip_rect(ji_screen, x+1, y1, x2, y2)) - draw_textstring(NULL, makecol (0, 0, 0), bg, FALSE, widget, r, 0); - - set_clip(ji_screen, cx1, cy1, cx2, cy2); - - widget->text = old_text; - jrect_free(r); - } -#else - int min, max, value, bg, c1, c2; - char buf[256]; - JRect pos = jwidget_get_rect(widget); - - jtheme_slider_info(widget, &min, &max, &value); - - /* with mouse */ - if (jwidget_has_mouse(widget)) - bg = makecol(224, 224, 224); - /* without mouse */ - else - bg = makecol(192, 192, 192); - - /* 1st border */ - jdraw_rectedge(pos, makecol(128, 128, 128), makecol(255, 255, 255)); - - /* 2nd border */ - jrect_shrink(pos, 1); - if (jwidget_has_focus(widget)) - jdraw_rect(pos, makecol(0, 0, 0)); - else - jdraw_rect(pos, bg); - - /* 3rd border */ - if (!jwidget_is_selected (widget)) { - c1 = makecol(255, 255, 255); - c2 = makecol(128, 128, 128); - } - else { - c1 = makecol(128, 128, 128); - c2 = makecol(255, 255, 255); - } - - jrect_shrink(pos, 1); - jdraw_rectedge(pos, c1, c2); - - /* background and text */ - jrect_shrink(pos, 1); - - if (min != max) { - char *old_text = widget->text; - int x1, x2; - JRect rc; - - usprintf(buf, "%d", value); - widget->align = JI_CENTER | JI_MIDDLE; - widget->text = buf; - -#if 0 - x = pos->x1 + (pos->x2-pos->x1) * (value-min) / (max-min+1); - w = jwidget_get_text_length(widget)+2; - if (x-w/2 < pos->x1) { - x1 = pos->x1; - x2 = MIN(pos->x1+w, pos->x2); - } - else if (x+w/2 > pos->x2) { - x1 = pos->x2-w; - x2 = pos->x2; - } - else { - x1 = x-w/2; - x2 = x+w/2; - } -#else - if (max == min) { - x1 = pos->x1; - x2 = pos->x2; - } - else { - int x, w; - - w = ji_font_text_len(widget->text_font, "888"); - w = MAX(w, (pos->x2-pos->x1) / (max-min+1)); - x = pos->x1 + ((value-min) * w); - - x1 = x; - if (x1 < pos->x1) - x1 = pos->x1; - x2 = x+w; - if (x2 > pos->x2) - x1 = pos->x2-w; - } -#endif - rc = jrect_new(x1, pos->y1, x2, pos->y2); - - jdraw_rectfill(pos, bg); - jdraw_rectfill(rc, (jwidget_is_disabled(widget)) ? - bg: makecol(44, 76, 145)); - - draw_textstring(NULL, makecol(255, 255, 255), - jwidget_is_disabled(widget) ? - bg: makecol(44, 76, 145), FALSE, widget, rc, 0); - - jrect_free(rc); - widget->text = old_text; - } - - jrect_free(pos); -#endif -} - -static void theme_draw_textbox(JWidget widget) -{ - _ji_theme_textbox_draw(ji_screen, widget, NULL, NULL); -} - -static void theme_draw_view(JWidget widget) -{ - JRect pos = jwidget_get_rect (widget); - - if (jwidget_has_focus(widget)) { - /* 1st border */ - jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); - - /* 2nd border */ - jrect_shrink(pos, 1); - jdraw_rect(pos, makecol (0, 0, 0)); - } - else { - /* 1st border */ - jdraw_rectedge(pos, makecol (128, 128, 128), makecol (255, 255, 255)); - - /* 2nd border */ - jrect_shrink(pos, 1); - jdraw_rect(pos, BGCOLOR); - } - - /* background */ - jrect_shrink(pos, 1); - jdraw_rectfill(pos, BGCOLOR); - - jrect_free (pos); -} - -static void theme_draw_view_scrollbar (JWidget widget) -{ - int x1, y1, x2, y2; - int u1, v1, u2, v2; - int pos, len; - - jtheme_scrollbar_info (widget, &pos, &len); - - x1 = widget->rc->x1; - y1 = widget->rc->y1; - x2 = widget->rc->x2-1; - y2 = widget->rc->y2-1; - - /* border */ - rect (ji_screen, x1, y1, x2, y2, BGCOLOR); - - /* draw the content */ - x1++, y1++, x2--, y2--; - - /* horizontal bar */ - if (widget->align & JI_HORIZONTAL) { - u1 = x1+pos; - v1 = y1; - u2 = x1+pos+len-1; - v2 = y2; - } - /* vertical bar */ - else { - u1 = x1; - v1 = y1+pos; - u2 = x2; - v2 = y1+pos+len-1; - } - - /* background */ - _ji_theme_rectfill_exclude (ji_screen, - x1, y1, x2, y2, - u1, v1, u2, v2, BGCOLOR); - - /* 1st border */ - if (jwidget_is_selected (widget)) - _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, - makecol (128, 128, 128), makecol (255, 255, 255)); - else - _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, - makecol (255, 255, 255), makecol (128, 128, 128)); - - /* bar-block background */ - u1++, v1++, u2--, v2--; - if (jwidget_has_mouse (widget)) - rectfill (ji_screen, u1, v1, u2, v2, makecol (224, 224, 224)); - else - rectfill (ji_screen, u1, v1, u2, v2, BGCOLOR); -#if 0 - int x1, y1, x2, y2; - int u1, v1, u2, v2; - int pos, len; - - jtheme_scrollbar_info (widget, &pos, &len); - - x1 = widget->rc->x1; - y1 = widget->rc->y1; - x2 = widget->rc->x2-1; - y2 = widget->rc->y2-1; - - /* 1st border */ - _ji_theme_rectedge (ji_screen, x1, y1, x2, y2, - makecol (255, 255, 255), makecol (128, 128, 128)); - - /* 2nd border */ - x1++, y1++, x2--, y2--; - rect (ji_screen, x1, y1, x2, y2, BGCOLOR); - - /* draw the content */ - x1++, y1++, x2--, y2--; - - /* horizontal bar */ - if (widget->align & JI_HORIZONTAL) { - u1 = x1+pos; - v1 = y1; - u2 = x1+pos+len-1; - v2 = y2; - } - /* vertical bar */ - else { - u1 = x1; - v1 = y1+pos; - u2 = x2; - v2 = y1+pos+len-1; - } - - /* background */ - _ji_theme_rectfill_exclude (ji_screen, - x1, y1, x2, y2, - u1, v1, u2, v2, BGCOLOR); - - /* 1st border */ - if (jwidget_is_selected (widget)) - _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, - makecol (128, 128, 128), makecol (255, 255, 255)); - else - _ji_theme_rectedge (ji_screen, u1, v1, u2, v2, - makecol (255, 255, 255), makecol (128, 128, 128)); - - /* bar-block background */ - u1++, v1++, u2--, v2--; - if (jwidget_has_mouse (widget)) - rectfill (ji_screen, u1, v1, u2, v2, makecol (224, 224, 224)); - else - rectfill (ji_screen, u1, v1, u2, v2, BGCOLOR); -#endif -} - -static void theme_draw_view_viewport (JWidget widget) -{ - jdraw_rectfill(widget->rc, BGCOLOR); -} - -static void theme_draw_window(JWidget widget) -{ - JRect pos = jwidget_get_rect(widget); - JRect cpos = jwidget_get_child_rect(widget); - - /* extra lines */ - if (!jwindow_is_desktop(widget)) { - jdraw_rect(pos, makecol(0, 0, 0)); - jrect_shrink(pos, 1); - jdraw_rectedge(pos, makecol(255, 255, 255), makecol(128, 128, 128)); - jrect_shrink(pos, 1); - jdraw_rectfill(pos, BGCOLOR); - - /* draw title bar */ - if (widget->text) { - int bg = makecol(44, 76, 145); - - jrect_shrink(pos, 1); -/* pos->y2 = cpos->y1-1; */ - pos->y2 = cpos->y1-3; - jdraw_rectfill(pos, bg); - - jrect_stretch(pos, 1); - jdraw_rectedge(cpos, makecol(128, 128, 128), makecol(255, 255, 255)); - - jdraw_text(widget->text_font, widget->text, - cpos->x1, - pos->y1+jrect_h(pos)/2-text_height(widget->text_font)/2, - makecol(255, 255, 255), bg, FALSE); - } - } - /* desktop */ - else { - jdraw_rectfill(pos, widget->theme->desktop_color); - } - - jrect_free(pos); - jrect_free(cpos); -} - -static int get_bg_color (JWidget widget) -{ - int c = jwidget_get_bg_color (widget); - int decorative = jwidget_is_decorative (widget); - - return c >= 0 ? c: (decorative ? makecol(44, 76, 145): - makecol(255, 255, 255)); -} - -static void draw_textstring (const char *t, int fg_color, int bg_color, - bool fill_bg, JWidget widget, const JRect rect, - int selected_offset) -{ - if (t || widget->text) { - int x, y, w, h; - - if (!t) { - t = widget->text; - w = jwidget_get_text_length (widget); - h = jwidget_get_text_height (widget); - } - else { - w = ji_font_text_len (widget->text_font, t); - h = text_height (widget->text_font); - } - - /* horizontally text alignment */ - - if (widget->align & JI_RIGHT) - x = rect->x2 - w; - else if (widget->align & JI_CENTER) - x = (rect->x1+rect->x2)/2 - w/2; - else - x = rect->x1; - - /* vertically text alignment */ - - if (widget->align & JI_BOTTOM) - y = rect->y2 - h; - else if (widget->align & JI_MIDDLE) - y = (rect->y1+rect->y2)/2 - h/2; - else - y = rect->y1; - - if (jwidget_is_selected (widget)) { - x += selected_offset; - y += selected_offset; - } - - /* background */ - if (bg_color >= 0) { - if (jwidget_is_disabled (widget)) - rectfill (ji_screen, x, y, x+w, y+h, bg_color); - else - rectfill (ji_screen, x, y, x+w-1, y+h-1, bg_color); - } - - /* text */ - if (jwidget_is_disabled (widget)) { - /* TODO avoid this */ - if (fill_bg) /* only to draw the background */ - jdraw_text(widget->text_font, t, x, y, 0, bg_color, fill_bg); - - /* draw white part */ - jdraw_text(widget->text_font, t, x+1, y+1, - makecol(255, 255, 255), bg_color, fill_bg); - - if (fill_bg) - fill_bg = FALSE; - } - - jdraw_text(widget->text_font, t, x, y, - jwidget_is_disabled(widget) ? - makecol(128, 128, 128): (fg_color >= 0 ? fg_color : - makecol(0, 0, 0)), - bg_color, fill_bg); - } -} - -static void draw_entry_cursor(JWidget widget, int x, int y) -{ - int h = jwidget_get_text_height(widget); - - vline(ji_screen, x, y-1, y+h, makecol (0, 0, 0)); - vline(ji_screen, x+1, y-1, y+h, makecol (0, 0, 0)); -} - -static void draw_icons(int x, int y, JWidget widget, int edge_icon) -{ - draw_sprite(ji_screen, icons_bitmap[edge_icon], x, y); - - if (jwidget_is_selected(widget)) - draw_sprite(ji_screen, icons_bitmap[edge_icon+1], x, y); -} - -static void draw_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color) -{ - int old_x1, old_y1, old_x2, old_y2; - get_clip_rect(ji_screen, &old_x1, &old_y1, &old_x2, &old_y2); - - /* horizontal lines */ - hline(ji_screen, x1+radius_w, y1, x2-radius_w, color); - hline(ji_screen, x1+radius_w, y2, x2-radius_w, color); - - /* vertical lines */ - vline(ji_screen, x1, y1+radius_h, y2-radius_h, color); - vline(ji_screen, x2, y1+radius_h, y2-radius_h, color); - - /* top-left corner */ - add_clip_rect(ji_screen, x1, y1, x1+radius_w, y1+radius_h); - ellipse(ji_screen, x1+radius_w, y1+radius_h, radius_w, radius_h, color); - - /* top-right */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); - add_clip_rect(ji_screen, x2-radius_w, y1, x2, y1+radius_h); - ellipse(ji_screen, x2-radius_w, y1+radius_h, radius_w, radius_h, color); - - /* bottom-left */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); - add_clip_rect(ji_screen, x1, y2-radius_h, x1+radius_w, y2); - ellipse(ji_screen, x1+radius_w, y2-radius_h, radius_w, radius_h, color); - - /* bottom-right */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); - add_clip_rect(ji_screen, x2-radius_w, y2-radius_h, x2, y2); - ellipse(ji_screen, x2-radius_h, y2-radius_h, radius_w, radius_h, color); - - /* restore clip */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); -} - -static void fill_round_rect(int x1, int y1, int x2, int y2, int radius_w, int radius_h, int color) -{ - int old_x1, old_y1, old_x2, old_y2; - get_clip_rect(ji_screen, &old_x1, &old_y1, &old_x2, &old_y2); - - /* fill */ - rectfill(ji_screen, x1+radius_w, y1, x2-radius_w, y1+radius_h, color); - rectfill(ji_screen, x1, y1+radius_h, x2, y2-radius_h, color); - rectfill(ji_screen, x1+radius_w, y2-radius_h, x2-radius_w, y2, color); - - /* top-left corner */ - add_clip_rect(ji_screen, x1, y1, x1+radius_w, y1+radius_h); - ellipsefill(ji_screen, x1+radius_w, y1+radius_h, radius_w, radius_h, color); - - /* top-right */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); - add_clip_rect(ji_screen, x2-radius_w, y1, x2, y1+radius_h); - ellipsefill(ji_screen, x2-radius_w, y1+radius_h, radius_w, radius_h, color); - - /* bottom-left */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); - add_clip_rect(ji_screen, x1, y2-radius_h, x1+radius_w, y2); - ellipsefill(ji_screen, x1+radius_w, y2-radius_h, radius_w, radius_h, color); - - /* bottom-right */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); - add_clip_rect(ji_screen, x2-radius_w, y2-radius_h, x2, y2); - ellipsefill(ji_screen, x2-radius_h, y2-radius_h, radius_w, radius_h, color); - - /* restore clip */ - set_clip_rect(ji_screen, old_x1, old_y1, old_x2, old_y2); -} - -/* controls the "X" button in a window to close it */ -static bool theme_button_msg_proc(JWidget widget, JMessage msg) -{ - switch (msg->type) { - - case JM_KEYPRESSED: - if (msg->key.scancode == KEY_ESC) { - jwidget_select(widget); - return TRUE; - } - break; - - case JM_KEYRELEASED: - if (msg->key.scancode == KEY_ESC) { - if (jwidget_is_selected(widget)) { - jwidget_deselect(widget); - jwidget_close_window(widget); - return TRUE; - } - } - break; - } - - return FALSE; -} diff --git a/src/jinete/themes/jstand.c b/src/jinete/themes/jstandard_theme.c similarity index 99% rename from src/jinete/themes/jstand.c rename to src/jinete/themes/jstandard_theme.c index 4593b47e4..559f28cdd 100644 --- a/src/jinete/themes/jstand.c +++ b/src/jinete/themes/jstandard_theme.c @@ -36,7 +36,7 @@ #include "jinete/jintern.h" /* data related */ -#include "stdicons.c" +#include "jstandard_theme_icons.h" #include "pcx2data.c" #define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length ((f), (c))) diff --git a/src/jinete/themes/stdicons.c b/src/jinete/themes/jstandard_theme_icons.h similarity index 100% rename from src/jinete/themes/stdicons.c rename to src/jinete/themes/jstandard_theme_icons.h diff --git a/src/modules/gui.c b/src/modules/gui.c index 15ad1de0c..a79e1cebd 100644 --- a/src/modules/gui.c +++ b/src/modules/gui.c @@ -368,19 +368,21 @@ void gui_feedback(void) /* double buffering? */ if (double_buffering) { -/* jmanager_dispatch_draw_messages(); */ jmouse_draw_cursor(); - if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) { - blit(ji_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); + if (ji_dirty_region) { + ji_flip_dirty_region(); } else { - stretch_blit(ji_screen, screen, - 0, 0, ji_screen->w, ji_screen->h, - 0, 0, SCREEN_W, SCREEN_H); + if (JI_SCREEN_W == SCREEN_W && JI_SCREEN_H == SCREEN_H) { + blit(ji_screen, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); + } + else { + stretch_blit(ji_screen, screen, + 0, 0, ji_screen->w, ji_screen->h, + 0, 0, SCREEN_W, SCREEN_H); + } } - -/* jmanager_dispatch_draw_messages(); */ } } diff --git a/src/modules/tools2.h b/src/modules/tools2.h index 195c8dfd2..6cbd0f1e6 100644 --- a/src/modules/tools2.h +++ b/src/modules/tools2.h @@ -19,12 +19,12 @@ #ifndef MODULES_TOOLS2_H #define MODULES_TOOLS2_H -void SetBrush (const char *string); -void SetDrawMode (const char *string); -void ToolTrace (const char *string); +void SetBrush(const char *string); +void SetDrawMode(const char *string); +void ToolTrace(const char *string); -void ResetConfig (void); -void RestoreConfig (void); +void ResetConfig(void); +void RestoreConfig(void); #endif /* MODULES_TOOLS2_H */ diff --git a/src/script/bindings.c b/src/script/bindings.c index c75193489..91c852682 100644 --- a/src/script/bindings.c +++ b/src/script/bindings.c @@ -544,169 +544,6 @@ static int bind_GetImage2(lua_State *L) return 4; } - -/**********************************************************************/ -/* Extra GUI routines */ - -/* bind load_widget() as "ji_load_widget" */ -static int bind_ji_load_widget(lua_State *L) -{ - JWidget return_value; - const char *filename = lua_tostring(L, 1); - const char *name = lua_tostring(L, 2); - return_value = load_widget(filename, name); /* use "load_widget" */ - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -/** - * The routine "ji_file_select" for LUA scripts really call the - * GUI_FileSelect routine. - */ -static int bind_ji_file_select(lua_State *L) -{ - char *return_value; - const char *message = lua_tostring(L, 1); - const char *init_path = lua_tostring(L, 2); - const char *exts = lua_tostring(L, 3); - return_value = GUI_FileSelect(message, init_path, exts); - if (return_value) { - lua_pushstring(L, return_value); - jfree(return_value); - } - else { - lua_pushnil(L); - } - return 1; -} - -static int bind_ji_color_select(lua_State *L) -{ - char *return_value; - int imgtype = lua_tonumber(L, 1); - const char *color = lua_tostring(L, 2); - return_value = ji_color_select(imgtype, color); - if (return_value) { - lua_pushstring(L, return_value); - jfree(return_value); - } - else { - lua_pushnil(L); - } - return 1; -} - -#if 0 - -/**********************************************************************/ -/* Interface to hook widget's signals with Lua functions **************/ - -/* The system is very simple, in the 4th slot of widget's user data - (widget->user_data[3]), we put a list (GList) of Data3 structures, - each Data3 structure has the references to Lua data. - - First time we hook a signal from Lua, the JI_SIGNAL_DESTROY event - is hooked with the "destroy_signal_for_widgets" routine, it's - necessary to free the references (and memory) used by the widget. - With this, you can't hook the destroy signal with Lua scripts. - - Routine "handle_signals_for_lua_functions" calls the respectives - scripts routines. -*/ - -typedef struct Data3 -{ - int signal; - int function; - int user_data; -} Data3; - -static int destroy_signal_for_widgets (JWidget widget, int user_data) -{ - lua_State *L = get_lua_state (); - Data3 *data3; - JLink link; - - for (it=widget->user_data[3]; it; it=it->next) { - data3 = it->data; - if (data3->function != LUA_NOREF) lua_unref (L, data3->function); - if (data3->user_data != LUA_NOREF) lua_unref (L, data3->user_data); - jfree (data3); - } - - return FALSE; -} - -static int handle_signals_for_lua_functions (JWidget widget, int user_data) -{ - lua_State *L = get_lua_state (); - int ret = FALSE; - Data3 *data3; - JLink link; - - for (it=widget->user_data[3]; it; it=it->next) { - data3 = it->data; - - PRINTF ("CALL HOOK %d %d %d %d\n", - widget->id, data3->signal, data3->function, data3->user_data); - - if ((data3->signal == user_data) && (data3->function != LUA_NOREF)) { - lua_getref (L, data3->function); - push_userdata (L, Type_JWidget, widget); - lua_getref (L, data3->user_data); - do_script_raw (L, 2, 1); - ret = lua_toboolean (L, -1); - lua_pop (L, 1); - } - - PRINTF ("RET VALUE %d\n", ret); - } - - return ret; -} - -static int bind_jwidget_hook_signal (lua_State *L) -{ - JWidget widget = to_userdata (L, Type_JWidget, 1); - int signal = (int)lua_tonumber (L, 2); - int user_data = lua_ref (L, 1); /* lua_pop (L, -1) */ - int function = lua_ref (L, 1); /* lua_pop (L, -1) */ - Data3 *data3; - JHook hook; - - /* check the references */ - function = (function > 0) ? function: LUA_NOREF; - user_data = (user_data > 0) ? user_data: LUA_NOREF; - - /* is the 4th slot of data is empty, means that it's the first time - that we hook a signal in this widget */ - if (!widget->user_data[3]) { - /* hook the destroy signal to clear all the 4th slot data */ - hook = jhook_new (JI_SIGNAL_DESTROY, destroy_signal_for_widgets, 0); - jwidget_hook_signal (widget, hook); - } - - /* create a new Data3 block */ - data3 = jmalloc (sizeof (Data3)); - data3->signal = signal; - data3->function = function; - data3->user_data = user_data; - - /* append this to the 4th slot */ - widget->user_data[3] = jlist_append (widget->user_data[3], data3); - - /* append the hook to the signal that the user wants to hook */ - hook = jhook_new (data3->signal, handle_signals_for_lua_functions, - data3->signal); - jwidget_hook_signal (widget, hook); - - PRINTF ("NEW HOOK %d %d %d %d\n", - widget, data3->signal, data3->function, data3->user_data); - - return 0; -} -#endif - /********************************************************************/ /* Include generated bindings file */ diff --git a/src/script/export.h b/src/script/export.h index 58c26bd5a..f28347fd5 100644 --- a/src/script/export.h +++ b/src/script/export.h @@ -54,23 +54,6 @@ double tanh(double x); bool file_exists(const char *filename); char *get_filename(const char *filename); -/* configuration routines */ - -int get_config_int(const char *section, const char *name, int value); -void set_config_int(const char *section, const char *name, int value); - -const char *get_config_string(const char *section, const char *name, const char *value); -void set_config_string(const char *section, const char *name, const char *value); - -float get_config_float(const char *section, const char *name, float value); -void set_config_float(const char *section, const char *name, float value); - -bool get_config_bool(const char *section, const char *name, bool value); -void set_config_bool(const char *section, const char *name, bool value); - -void get_config_rect(const char *section, const char *name, JRect rect); -void set_config_rect(const char *section, const char *name, JRect rect); - /*===================================================================*/ /* Miscellaneous routines */ /*===================================================================*/ @@ -142,9 +125,6 @@ void SetBrush(const char *string); void SetDrawMode(const char *string); void ToolTrace(const char *string); -void ResetConfig(void); -void RestoreConfig(void); - /* modules/color.c */ const char *get_fg_color(void); @@ -616,510 +596,6 @@ void set_replace_colors(int from, int to, int fuzziness); void set_median_size(int w, int h); -/*===================================================================*/ -/* GUI routines */ -/*===================================================================*/ - -void reload_default_font(void); - -void load_window_pos(JWidget window, const char *section); -void save_window_pos(JWidget window, const char *section); - -JWidget ji_load_widget(const char *filename, const char *name); /* CODE */ - -char *ji_file_select(const char *message, const char *init_path, const char *exts); /* CODE */ -char *ji_color_select(int imgtype, const char *color); /* CODE */ - -/* Alert ************************************************************/ - -JWidget jalert_new(const char *format); -int jalert(const char *format); - -/* Base *************************************************************/ - -#define JI_HORIZONTAL -#define JI_VERTICAL -#define JI_LEFT -#define JI_CENTER -#define JI_RIGHT -#define JI_TOP -#define JI_MIDDLE -#define JI_BOTTOM -#define JI_HOMOGENEOUS -#define JI_WORDWRAP - -#define JI_HIDDEN -#define JI_SELECTED -#define JI_DISABLED -#define JI_HASFOCUS -#define JI_HASMOUSE -#define JI_HASCAPTURE -#define JI_FOCUSREST -#define JI_MAGNETIC -#define JI_EXPANSIVE -#define JI_DECORATIVE -#define JI_AUTODESTROY -#define JI_HARDCAPTURE -#define JI_INITIALIZED - -#define JI_WIDGET -#define JI_BOX -#define JI_BUTTON -#define JI_CHECK -#define JI_COMBOBOX -#define JI_ENTRY -#define JI_IMAGE -#define JI_LABEL -#define JI_LISTBOX -#define JI_LISTITEM -#define JI_MANAGER -#define JI_MENU -#define JI_MENUBAR -#define JI_MENUBOX -#define JI_MENUITEM -#define JI_PANEL -#define JI_RADIO -#define JI_SEPARATOR -#define JI_SLIDER -#define JI_TEXTBOX -#define JI_VIEW -#define JI_VIEW_SCROLLBAR -#define JI_VIEW_VIEWPORT -#define JI_WINDOW -#define JI_USER_WIDGET - -#define JM_OPEN -#define JM_CLOSE -#define JM_DESTROY -#define JM_DRAW -#define JM_IDLE -#define JM_SIGNAL -#define JM_REQSIZE -#define JM_SETPOS -#define JM_WINMOVE -#define JM_DRAWRGN -#define JM_DIRTYCHILDREN -#define JM_CHAR -#define JM_KEYPRESSED -#define JM_KEYRELEASED -#define JM_FOCUSENTER -#define JM_FOCUSLEAVE -#define JM_BUTTONPRESSED -#define JM_BUTTONRELEASED -#define JM_DOUBLECLICK -#define JM_MOUSEENTER -#define JM_MOUSELEAVE -#define JM_MOTION -#define JM_WHEEL - -#define JI_SIGNAL_DIRTY -#define JI_SIGNAL_ENABLE -#define JI_SIGNAL_DISABLE -#define JI_SIGNAL_SELECT -#define JI_SIGNAL_DESELECT -#define JI_SIGNAL_SHOW -#define JI_SIGNAL_HIDE -#define JI_SIGNAL_ADD_CHILD -#define JI_SIGNAL_REMOVE_CHILD -#define JI_SIGNAL_NEW_PARENT -#define JI_SIGNAL_GET_TEXT -#define JI_SIGNAL_SET_TEXT -#define JI_SIGNAL_BUTTON_SELECT -#define JI_SIGNAL_CHECK_CHANGE -#define JI_SIGNAL_RADIO_CHANGE -#define JI_SIGNAL_ENTRY_CHANGE -#define JI_SIGNAL_LISTBOX_CHANGE -#define JI_SIGNAL_LISTBOX_SELECT -#define JI_SIGNAL_MANAGER_EXTERNAL_CLOSE -#define JI_SIGNAL_MANAGER_ADD_WINDOW -#define JI_SIGNAL_MANAGER_REMOVE_WINDOW -#define JI_SIGNAL_MANAGER_LOSTCHAR -#define JI_SIGNAL_MENUITEM_SELECT -#define JI_SIGNAL_SLIDER_CHANGE -#define JI_SIGNAL_WINDOW_CLOSE -#define JI_SIGNAL_WINDOW_RESIZE - -/* Box **************************************************************/ - -JWidget jbox_new(int align); - -/* Button ***********************************************************/ - -JWidget jbutton_new(const char *text); - -/* void jbutton_set_icon(JWidget button, struct BITMAP *icon); */ -/* void jbutton_set_icon_align(JWidget button, int icon_align); */ - -/* void jbutton_set_bevel(JWidget button, int b0, int b1, int b2, int b3); */ -/* void jbutton_get_bevel(JWidget button, int *b4); */ - -/* Check ************************************************************/ - -JWidget jcheck_new(const char *text); - -/* void jcheck_set_icon_align (JWidget check, int icon_align); */ - -/* Combobox *********************************************************/ - -JWidget jcombobox_new(void); - -void jcombobox_editable(JWidget combobox, bool state); -void jcombobox_clickopen(JWidget combobox, bool state); -void jcombobox_casesensitive(JWidget combobox, bool state); - -bool jcombobox_is_editable(JWidget combobox); -bool jcombobox_is_clickopen(JWidget combobox); -bool jcombobox_is_casesensitive(JWidget combobox); - -void jcombobox_add_string(JWidget combobox, const char *string); -void jcombobox_del_string(JWidget combobox, const char *string); -void jcombobox_del_index(JWidget combobox, int index); - -void jcombobox_select_index(JWidget combobox, int index); -void jcombobox_select_string(JWidget combobox, const char *string); -int jcombobox_get_selected_index(JWidget combobox); -const char *jcombobox_get_selected_string(JWidget combobox); - -const char *jcombobox_get_string(JWidget combobox, int index); -int jcombobox_get_index(JWidget combobox, const char *string); -int jcombobox_get_count(JWidget combobox); - -JWidget jcombobox_get_entry_widget(JWidget combobox); - -/* Clipboard ********************************************************/ - -const char *jclipboard_get_text(void); -void jclipboard_set_text(const char *text); - -/* Entry ************************************************************/ - -JWidget jentry_new(int maxsize, const char *format); - -void jentry_readonly(JWidget entry, bool state); -void jentry_password(JWidget entry, bool state); -bool jentry_is_password(JWidget entry); -bool jentry_is_readonly(JWidget entry); - -void jentry_show_cursor(JWidget entry); -void jentry_hide_cursor(JWidget entry); - -void jentry_set_cursor_pos(JWidget entry, int pos); -void jentry_select_text(JWidget entry, int from, int to); -void jentry_deselect_text(JWidget entry); - -/* Image ************************************************************/ - -/* JWidget jimage_new(struct BITMAP *bmp, int align); */ - -/* Label ************************************************************/ - -JWidget jlabel_new(const char *text); - -/* Listbox **********************************************************/ - -JWidget jlistbox_new(void); -JWidget jlistitem_new(const char *text); - -JWidget jlistbox_get_selected_child(JWidget listbox); -int jlistbox_get_selected_index(JWidget listbox); -void jlistbox_select_child(JWidget listbox, JWidget listitem); -void jlistbox_select_index(JWidget listbox, int index); - -void jlistbox_center_scroll(JWidget listbox); - -/* Manager **********************************************************/ - -JWidget ji_get_default_manager(void); - -JWidget jmanager_new(void); -void jmanager_free(JWidget manager); - -void jmanager_run(JWidget manager); -bool jmanager_poll(JWidget manager, bool all_windows); - -void jmanager_send_message(JMessage msg); - -JWidget jmanager_get_focus(void); -JWidget jmanager_get_mouse(void); -JWidget jmanager_get_capture(void); - -void jmanager_set_focus(JWidget widget); -void jmanager_set_mouse(JWidget widget); -void jmanager_set_capture(JWidget widget); -void jmanager_attract_focus(JWidget widget); -void jmanager_free_focus(void); -void jmanager_free_mouse(void); -void jmanager_free_capture(void); -void jmanager_free_widget(JWidget widget); -void jmanager_remove_message(JMessage msg); -void jmanager_remove_messages_for(JWidget widget); -void jmanager_refresh_screen(void); - -/* Menu *************************************************************/ - -JWidget jmenu_new(void); -JWidget jmenubar_new(void); -JWidget jmenubox_new(void); -JWidget jmenuitem_new(const char *text); - -JWidget jmenubox_get_menu(JWidget menubox); -JWidget jmenubar_get_menu(JWidget menubar); -JWidget jmenuitem_get_submenu(JWidget menuitem); -/* JAccel jmenuitem_get_accel(JWidget menuitem); */ - -void jmenubox_set_menu(JWidget menubox, JWidget menu); -void jmenubar_set_menu(JWidget menubar, JWidget menu); -void jmenuitem_set_submenu(JWidget menuitem, JWidget menu); -/* void jmenuitem_set_accel(JWidget menuitem, JAccel accel); */ - -int jmenuitem_is_highlight(JWidget menuitem); - -void jmenu_popup(JWidget menu, int x, int y); - -/* Message **********************************************************/ - -JMessage jmessage_new(int type); -JMessage jmessage_new_copy(JMessage msg); -void jmessage_free(JMessage msg); - -void jmessage_add_dest(JMessage msg, JWidget widget); - -void jmessage_broadcast_to_children(JMessage msg, JWidget widget); -void jmessage_broadcast_to_parents(JMessage msg, JWidget widget); - -void jmessage_set_sub_msg(JMessage msg, JMessage sub_msg); - -/* Panel ************************************************************/ - -JWidget jpanel_new(int align); - -double jpanel_get_pos(JWidget panel); -void jpanel_set_pos(JWidget panel, double pos); - -/* QuickMenu ********************************************************/ - -/* JWidget jmenubar_new_quickmenu(JQuickMenu quick_menu); */ -/* JWidget jmenubox_new_quickmenu(JQuickMenu quick_menu); */ - -/* Radio ************************************************************/ - -JWidget jradio_new(const char *text, int radio_group); - -/* void jradio_set_icon_align(JWidget radio, int icon_align); */ - -int jradio_get_group(JWidget radio); -void jradio_deselect_group(JWidget radio); - -/* Rect *************************************************************/ - -int jrect_w(JRect rect); -int jrect_h(JRect rect); -bool jrect_point_in(JRect rect, int x, int y); - -JRect jrect_new(int x1, int y1, int x2, int y2); -JRect jrect_new_copy(const JRect rect); -void jrect_free(JRect rect); - -void jrect_copy(JRect dst, const JRect src); -void jrect_replace(JRect rect, int x1, int y1, int x2, int y2); - -void jrect_union(JRect r1, const JRect r2); -bool jrect_intersect(JRect r1, const JRect r2); - -void jrect_shrink(JRect rect, int border); -void jrect_stretch(JRect rect, int border); - -void jrect_moveto(JRect rect, int x, int y); -void jrect_displace(JRect rect, int dx, int dy); - -/* Region ***********************************************************/ - -JRegion jregion_new(JRect rect, int size); -void jregion_init(JRegion reg, JRect rect, int size); -void jregion_free(JRegion reg); -void jregion_uninit(JRegion reg); - -bool jregion_copy(JRegion dst, JRegion src); -bool jregion_intersect(JRegion new, JRegion reg1, JRegion reg2); -bool jregion_union(JRegion new, JRegion reg1, JRegion reg2); -bool jregion_append(JRegion dstrgn, JRegion rgn); -/* bool jregion_validate(JRegion badreg, bool *overlap); */ - -/* JRegion jrects_to_region(int nrects, JRect *prect, int ctype); */ - -bool jregion_subtract(JRegion regD, JRegion regM, JRegion regS); -bool jregion_inverse(JRegion newReg, JRegion reg1, JRect invRect); - -int jregion_rect_in(JRegion region, JRect rect); -void jregion_translate(JRegion reg, int x, int y); - -void jregion_reset(JRegion reg, JRect box); -bool jregion_break(JRegion reg); -bool jregion_point_in(JRegion reg, int x, int y, JRect box); - -bool jregion_equal(JRegion reg1, JRegion reg2); -bool jregion_notempty(JRegion reg); -void jregion_empty(JRegion reg); -JRect jregion_extents(JRegion reg); - -/* Separator ********************************************************/ - -JWidget ji_separator_new(const char *text, int align); - -/* Slider ***********************************************************/ - -JWidget jslider_new(int min, int max, int value); - -void jslider_set_value(JWidget slider, int value); -int jslider_get_value(JWidget slider); - -/* System ***********************************************************/ - -/* Textbox **********************************************************/ - -JWidget jtextbox_new(const char *text, int align); - -/* Theme ************************************************************/ - -/* View *************************************************************/ - -JWidget jview_new(void); - -bool jview_has_bars(JWidget view); - -void jview_attach(JWidget view, JWidget viewable_widget); -void jview_maxsize(JWidget view); -void jview_without_bars(JWidget view); - -void jview_set_size(JWidget view, int w, int h); -void jview_set_scroll(JWidget view, int x, int y); -/* void jview_get_scroll(JWidget view, int *x, int *y); */ -/* void jview_get_max_size(JWidget view, int *w, int *h); */ - -void jview_update(JWidget view); - -JWidget jview_get_viewport(JWidget view); -JRect jview_get_viewport_position(JWidget view); - -JWidget jwidget_get_view(JWidget viewable_widget); - -/* Widget ***********************************************************/ - -int ji_register_widget_type(void); - -JWidget jwidget_new(int type); -void jwidget_free(JWidget widget); - -int jwidget_get_type(JWidget widget); -const char *jwidget_get_name(JWidget widget); -const char *jwidget_get_text(JWidget widget); -int jwidget_get_align(JWidget widget); - -void jwidget_set_name(JWidget widget, const char *name); -void jwidget_set_text(JWidget widget, const char *text); -void jwidget_set_align(JWidget widget, int align); - -void jwidget_magnetic(JWidget widget, bool state); -void jwidget_expansive(JWidget widget, bool state); -void jwidget_decorative(JWidget widget, bool state); -void jwidget_autodestroy(JWidget widget, bool state); -void jwidget_focusrest(JWidget widget, bool state); - -bool jwidget_is_magnetic(JWidget widget); -bool jwidget_is_expansive(JWidget widget); -bool jwidget_is_decorative(JWidget widget); -bool jwidget_is_autodestroy(JWidget widget); -bool jwidget_is_focusrest(JWidget widget); - -void jwidget_dirty(JWidget widget); -void jwidget_show(JWidget widget); -void jwidget_hide(JWidget widget); -void jwidget_enable(JWidget widget); -void jwidget_disable(JWidget widget); -void jwidget_select(JWidget widget); -void jwidget_deselect(JWidget widget); - -bool jwidget_is_visible(JWidget widget); -bool jwidget_is_hidden(JWidget widget); -bool jwidget_is_enabled(JWidget widget); -bool jwidget_is_disabled(JWidget widget); -bool jwidget_is_selected(JWidget widget); -bool jwidget_is_deselected(JWidget widget); - -bool jwidget_has_focus(JWidget widget); -bool jwidget_has_mouse(JWidget widget); -bool jwidget_has_capture(JWidget widget); - -void jwidget_add_child(JWidget widget, JWidget child); -void jwidget_remove_child(JWidget widget, JWidget child); -void jwidget_replace_child(JWidget widget, JWidget old_child, JWidget new_child); - -JWidget jwidget_get_parent(JWidget widget); -JWidget jwidget_get_window(JWidget widget); -/* JList jwidget_get_parents(JWidget widget, bool ascendant); */ -/* JList jwidget_get_children(JWidget widget); */ -JWidget jwidget_pick(JWidget widget, int x, int y); -bool jwidget_has_child(JWidget widget, JWidget child); - -JRect jwidget_get_rect(JWidget widget); -JRect jwidget_get_child_rect(JWidget widget); -JRegion jwidget_get_region(JWidget widget); -JRegion jwidget_get_drawable_region(JWidget widget, int flags); -int jwidget_get_bg_color(JWidget widget); -int jwidget_get_text_length(JWidget widget); -int jwidget_get_text_height(JWidget widget); - -void jwidget_noborders(JWidget widget); -void jwidget_set_border(JWidget widget, int l, int t, int r, int b); -void jwidget_set_rect(JWidget widget, JRect rect); -void jwidget_set_static_size(JWidget widget, int w, int h); -void jwidget_set_bg_color(JWidget widget, int color); - -void jwidget_flush_redraw(JWidget widget); -void jwidget_redraw_region(JWidget widget, JRegion region); - -void jwidget_signal_on(JWidget widget); -void jwidget_signal_off(JWidget widget); - -int jwidget_emit_signal(JWidget widget, int signal); - -bool jwidget_send_message(JWidget widget, JMessage msg); -bool jwidget_send_message_after_type(JWidget widget, JMessage msg, int type); -void jwidget_close_window(JWidget widget); -void jwidget_capture_mouse(JWidget widget); -void jwidget_hard_capture_mouse(JWidget widget); -void jwidget_release_mouse(JWidget widget); - -JWidget jwidget_find_name(JWidget widget, const char *name); -bool jwidget_check_underscored(JWidget widget, int scancode); - -/* Window routines **************************************************/ - -JWidget jwindow_new(const char *text); -JWidget jwindow_new_desktop(void); - -JWidget jwindow_get_killer(JWidget window); -JWidget jwindow_get_manager(JWidget window); - -void jwindow_moveable(JWidget window, bool state); -void jwindow_sizeable(JWidget window, bool state); -void jwindow_ontop(JWidget window, bool state); - -void jwindow_remap(JWidget window); -void jwindow_center(JWidget window); -void jwindow_position(JWidget window, int x, int y); -void jwindow_move(JWidget window, JRect rect); - -void jwindow_open(JWidget window); -void jwindow_open_fg(JWidget window); -void jwindow_open_bg(JWidget window); -void jwindow_close(JWidget window, JWidget killer); - -bool jwindow_is_toplevel(JWidget window); -bool jwindow_is_foreground(JWidget window); -bool jwindow_is_desktop(JWidget window); -bool jwindow_is_ontop(JWidget window); - /*===================================================================*/ /* End */ /*===================================================================*/ diff --git a/src/script/genbinds.c b/src/script/genbinds.c index 049e70ef6..44dd0107a 100644 --- a/src/script/genbinds.c +++ b/src/script/genbinds.c @@ -313,134 +313,6 @@ static int bind_get_filename(lua_State *L) return 1; } -static int bind_get_config_int(lua_State *L) -{ - int return_value; - const char *section; - const char *name; - int value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, int, number); - return_value = get_config_int(section, name, value); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_set_config_int(lua_State *L) -{ - const char *section; - const char *name; - int value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, int, number); - set_config_int(section, name, value); - return 0; -} - -static int bind_get_config_string(lua_State *L) -{ - const char *return_value; - const char *section; - const char *name; - const char *value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, const char *, string); - return_value = get_config_string(section, name, value); - lua_pushstring(L, return_value); - return 1; -} - -static int bind_set_config_string(lua_State *L) -{ - const char *section; - const char *name; - const char *value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, const char *, string); - set_config_string(section, name, value); - return 0; -} - -static int bind_get_config_float(lua_State *L) -{ - float return_value; - const char *section; - const char *name; - float value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, float, number); - return_value = get_config_float(section, name, value); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_set_config_float(lua_State *L) -{ - const char *section; - const char *name; - float value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, float, number); - set_config_float(section, name, value); - return 0; -} - -static int bind_get_config_bool(lua_State *L) -{ - bool return_value; - const char *section; - const char *name; - bool value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, bool, boolean); - return_value = get_config_bool(section, name, value); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_set_config_bool(lua_State *L) -{ - const char *section; - const char *name; - bool value; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetArg(3, value, bool, boolean); - set_config_bool(section, name, value); - return 0; -} - -static int bind_get_config_rect(lua_State *L) -{ - const char *section; - const char *name; - JRect rect; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetUD(3, rect, JRect); - get_config_rect(section, name, rect); - return 0; -} - -static int bind_set_config_rect(lua_State *L) -{ - const char *section; - const char *name; - JRect rect; - GetArg(1, section, const char *, string); - GetArg(2, name, const char *, string); - GetUD(3, rect, JRect); - set_config_rect(section, name, rect); - return 0; -} - static int bind_do_progress(lua_State *L) { int progress; @@ -785,18 +657,6 @@ static int bind_ToolTrace(lua_State *L) return 0; } -static int bind_ResetConfig(lua_State *L) -{ - ResetConfig(); - return 0; -} - -static int bind_RestoreConfig(lua_State *L) -{ - RestoreConfig(); - return 0; -} - static int bind_get_fg_color(lua_State *L) { const char *return_value; @@ -3271,2254 +3131,6 @@ static int bind_set_median_size(lua_State *L) return 0; } -static int bind_reload_default_font(lua_State *L) -{ - reload_default_font(); - return 0; -} - -static int bind_load_window_pos(lua_State *L) -{ - JWidget window; - const char *section; - GetUD(1, window, JWidget); - GetArg(2, section, const char *, string); - load_window_pos(window, section); - return 0; -} - -static int bind_save_window_pos(lua_State *L) -{ - JWidget window; - const char *section; - GetUD(1, window, JWidget); - GetArg(2, section, const char *, string); - save_window_pos(window, section); - return 0; -} - -static int bind_jalert_new(lua_State *L) -{ - JWidget return_value; - const char *format; - GetArg(1, format, const char *, string); - return_value = jalert_new(format); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jalert(lua_State *L) -{ - int return_value; - const char *format; - GetArg(1, format, const char *, string); - return_value = jalert(format); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jbox_new(lua_State *L) -{ - JWidget return_value; - int align; - GetArg(1, align, int, number); - return_value = jbox_new(align); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jbutton_new(lua_State *L) -{ - JWidget return_value; - const char *text; - GetArg(1, text, const char *, string); - return_value = jbutton_new(text); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jcheck_new(lua_State *L) -{ - JWidget return_value; - const char *text; - GetArg(1, text, const char *, string); - return_value = jcheck_new(text); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jcombobox_new(lua_State *L) -{ - JWidget return_value; - return_value = jcombobox_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jcombobox_editable(lua_State *L) -{ - JWidget combobox; - bool state; - GetUD(1, combobox, JWidget); - GetArg(2, state, bool, boolean); - jcombobox_editable(combobox, state); - return 0; -} - -static int bind_jcombobox_clickopen(lua_State *L) -{ - JWidget combobox; - bool state; - GetUD(1, combobox, JWidget); - GetArg(2, state, bool, boolean); - jcombobox_clickopen(combobox, state); - return 0; -} - -static int bind_jcombobox_casesensitive(lua_State *L) -{ - JWidget combobox; - bool state; - GetUD(1, combobox, JWidget); - GetArg(2, state, bool, boolean); - jcombobox_casesensitive(combobox, state); - return 0; -} - -static int bind_jcombobox_is_editable(lua_State *L) -{ - bool return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_is_editable(combobox); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jcombobox_is_clickopen(lua_State *L) -{ - bool return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_is_clickopen(combobox); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jcombobox_is_casesensitive(lua_State *L) -{ - bool return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_is_casesensitive(combobox); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jcombobox_add_string(lua_State *L) -{ - JWidget combobox; - const char *string; - GetUD(1, combobox, JWidget); - GetArg(2, string, const char *, string); - jcombobox_add_string(combobox, string); - return 0; -} - -static int bind_jcombobox_del_string(lua_State *L) -{ - JWidget combobox; - const char *string; - GetUD(1, combobox, JWidget); - GetArg(2, string, const char *, string); - jcombobox_del_string(combobox, string); - return 0; -} - -static int bind_jcombobox_del_index(lua_State *L) -{ - JWidget combobox; - int index; - GetUD(1, combobox, JWidget); - GetArg(2, index, int, number); - jcombobox_del_index(combobox, index); - return 0; -} - -static int bind_jcombobox_select_index(lua_State *L) -{ - JWidget combobox; - int index; - GetUD(1, combobox, JWidget); - GetArg(2, index, int, number); - jcombobox_select_index(combobox, index); - return 0; -} - -static int bind_jcombobox_select_string(lua_State *L) -{ - JWidget combobox; - const char *string; - GetUD(1, combobox, JWidget); - GetArg(2, string, const char *, string); - jcombobox_select_string(combobox, string); - return 0; -} - -static int bind_jcombobox_get_selected_index(lua_State *L) -{ - int return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_get_selected_index(combobox); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jcombobox_get_selected_string(lua_State *L) -{ - const char *return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_get_selected_string(combobox); - lua_pushstring(L, return_value); - return 1; -} - -static int bind_jcombobox_get_string(lua_State *L) -{ - const char *return_value; - JWidget combobox; - int index; - GetUD(1, combobox, JWidget); - GetArg(2, index, int, number); - return_value = jcombobox_get_string(combobox, index); - lua_pushstring(L, return_value); - return 1; -} - -static int bind_jcombobox_get_index(lua_State *L) -{ - int return_value; - JWidget combobox; - const char *string; - GetUD(1, combobox, JWidget); - GetArg(2, string, const char *, string); - return_value = jcombobox_get_index(combobox, string); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jcombobox_get_count(lua_State *L) -{ - int return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_get_count(combobox); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jcombobox_get_entry_widget(lua_State *L) -{ - JWidget return_value; - JWidget combobox; - GetUD(1, combobox, JWidget); - return_value = jcombobox_get_entry_widget(combobox); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jclipboard_get_text(lua_State *L) -{ - const char *return_value; - return_value = jclipboard_get_text(); - lua_pushstring(L, return_value); - return 1; -} - -static int bind_jclipboard_set_text(lua_State *L) -{ - const char *text; - GetArg(1, text, const char *, string); - jclipboard_set_text(text); - return 0; -} - -static int bind_jentry_new(lua_State *L) -{ - JWidget return_value; - int maxsize; - const char *format; - GetArg(1, maxsize, int, number); - GetArg(2, format, const char *, string); - return_value = jentry_new(maxsize, format); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jentry_readonly(lua_State *L) -{ - JWidget entry; - bool state; - GetUD(1, entry, JWidget); - GetArg(2, state, bool, boolean); - jentry_readonly(entry, state); - return 0; -} - -static int bind_jentry_password(lua_State *L) -{ - JWidget entry; - bool state; - GetUD(1, entry, JWidget); - GetArg(2, state, bool, boolean); - jentry_password(entry, state); - return 0; -} - -static int bind_jentry_is_password(lua_State *L) -{ - bool return_value; - JWidget entry; - GetUD(1, entry, JWidget); - return_value = jentry_is_password(entry); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jentry_is_readonly(lua_State *L) -{ - bool return_value; - JWidget entry; - GetUD(1, entry, JWidget); - return_value = jentry_is_readonly(entry); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jentry_show_cursor(lua_State *L) -{ - JWidget entry; - GetUD(1, entry, JWidget); - jentry_show_cursor(entry); - return 0; -} - -static int bind_jentry_hide_cursor(lua_State *L) -{ - JWidget entry; - GetUD(1, entry, JWidget); - jentry_hide_cursor(entry); - return 0; -} - -static int bind_jentry_set_cursor_pos(lua_State *L) -{ - JWidget entry; - int pos; - GetUD(1, entry, JWidget); - GetArg(2, pos, int, number); - jentry_set_cursor_pos(entry, pos); - return 0; -} - -static int bind_jentry_select_text(lua_State *L) -{ - JWidget entry; - int from; - int to; - GetUD(1, entry, JWidget); - GetArg(2, from, int, number); - GetArg(3, to, int, number); - jentry_select_text(entry, from, to); - return 0; -} - -static int bind_jentry_deselect_text(lua_State *L) -{ - JWidget entry; - GetUD(1, entry, JWidget); - jentry_deselect_text(entry); - return 0; -} - -static int bind_jlabel_new(lua_State *L) -{ - JWidget return_value; - const char *text; - GetArg(1, text, const char *, string); - return_value = jlabel_new(text); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jlistbox_new(lua_State *L) -{ - JWidget return_value; - return_value = jlistbox_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jlistitem_new(lua_State *L) -{ - JWidget return_value; - const char *text; - GetArg(1, text, const char *, string); - return_value = jlistitem_new(text); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jlistbox_get_selected_child(lua_State *L) -{ - JWidget return_value; - JWidget listbox; - GetUD(1, listbox, JWidget); - return_value = jlistbox_get_selected_child(listbox); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jlistbox_get_selected_index(lua_State *L) -{ - int return_value; - JWidget listbox; - GetUD(1, listbox, JWidget); - return_value = jlistbox_get_selected_index(listbox); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jlistbox_select_child(lua_State *L) -{ - JWidget listbox; - JWidget listitem; - GetUD(1, listbox, JWidget); - GetUD(2, listitem, JWidget); - jlistbox_select_child(listbox, listitem); - return 0; -} - -static int bind_jlistbox_select_index(lua_State *L) -{ - JWidget listbox; - int index; - GetUD(1, listbox, JWidget); - GetArg(2, index, int, number); - jlistbox_select_index(listbox, index); - return 0; -} - -static int bind_jlistbox_center_scroll(lua_State *L) -{ - JWidget listbox; - GetUD(1, listbox, JWidget); - jlistbox_center_scroll(listbox); - return 0; -} - -static int bind_ji_get_default_manager(lua_State *L) -{ - JWidget return_value; - return_value = ji_get_default_manager(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmanager_new(lua_State *L) -{ - JWidget return_value; - return_value = jmanager_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmanager_free(lua_State *L) -{ - JWidget manager; - GetUD(1, manager, JWidget); - jmanager_free(manager); - return 0; -} - -static int bind_jmanager_run(lua_State *L) -{ - JWidget manager; - GetUD(1, manager, JWidget); - jmanager_run(manager); - return 0; -} - -static int bind_jmanager_poll(lua_State *L) -{ - bool return_value; - JWidget manager; - bool all_windows; - GetUD(1, manager, JWidget); - GetArg(2, all_windows, bool, boolean); - return_value = jmanager_poll(manager, all_windows); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jmanager_send_message(lua_State *L) -{ - JMessage msg; - GetUD(1, msg, JMessage); - jmanager_send_message(msg); - return 0; -} - -static int bind_jmanager_get_focus(lua_State *L) -{ - JWidget return_value; - return_value = jmanager_get_focus(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmanager_get_mouse(lua_State *L) -{ - JWidget return_value; - return_value = jmanager_get_mouse(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmanager_get_capture(lua_State *L) -{ - JWidget return_value; - return_value = jmanager_get_capture(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmanager_set_focus(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jmanager_set_focus(widget); - return 0; -} - -static int bind_jmanager_set_mouse(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jmanager_set_mouse(widget); - return 0; -} - -static int bind_jmanager_set_capture(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jmanager_set_capture(widget); - return 0; -} - -static int bind_jmanager_attract_focus(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jmanager_attract_focus(widget); - return 0; -} - -static int bind_jmanager_free_focus(lua_State *L) -{ - jmanager_free_focus(); - return 0; -} - -static int bind_jmanager_free_mouse(lua_State *L) -{ - jmanager_free_mouse(); - return 0; -} - -static int bind_jmanager_free_capture(lua_State *L) -{ - jmanager_free_capture(); - return 0; -} - -static int bind_jmanager_free_widget(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jmanager_free_widget(widget); - return 0; -} - -static int bind_jmanager_remove_message(lua_State *L) -{ - JMessage msg; - GetUD(1, msg, JMessage); - jmanager_remove_message(msg); - return 0; -} - -static int bind_jmanager_remove_messages_for(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jmanager_remove_messages_for(widget); - return 0; -} - -static int bind_jmanager_refresh_screen(lua_State *L) -{ - jmanager_refresh_screen(); - return 0; -} - -static int bind_jmenu_new(lua_State *L) -{ - JWidget return_value; - return_value = jmenu_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenubar_new(lua_State *L) -{ - JWidget return_value; - return_value = jmenubar_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenubox_new(lua_State *L) -{ - JWidget return_value; - return_value = jmenubox_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenuitem_new(lua_State *L) -{ - JWidget return_value; - const char *text; - GetArg(1, text, const char *, string); - return_value = jmenuitem_new(text); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenubox_get_menu(lua_State *L) -{ - JWidget return_value; - JWidget menubox; - GetUD(1, menubox, JWidget); - return_value = jmenubox_get_menu(menubox); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenubar_get_menu(lua_State *L) -{ - JWidget return_value; - JWidget menubar; - GetUD(1, menubar, JWidget); - return_value = jmenubar_get_menu(menubar); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenuitem_get_submenu(lua_State *L) -{ - JWidget return_value; - JWidget menuitem; - GetUD(1, menuitem, JWidget); - return_value = jmenuitem_get_submenu(menuitem); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jmenubox_set_menu(lua_State *L) -{ - JWidget menubox; - JWidget menu; - GetUD(1, menubox, JWidget); - GetUD(2, menu, JWidget); - jmenubox_set_menu(menubox, menu); - return 0; -} - -static int bind_jmenubar_set_menu(lua_State *L) -{ - JWidget menubar; - JWidget menu; - GetUD(1, menubar, JWidget); - GetUD(2, menu, JWidget); - jmenubar_set_menu(menubar, menu); - return 0; -} - -static int bind_jmenuitem_set_submenu(lua_State *L) -{ - JWidget menuitem; - JWidget menu; - GetUD(1, menuitem, JWidget); - GetUD(2, menu, JWidget); - jmenuitem_set_submenu(menuitem, menu); - return 0; -} - -static int bind_jmenuitem_is_highlight(lua_State *L) -{ - int return_value; - JWidget menuitem; - GetUD(1, menuitem, JWidget); - return_value = jmenuitem_is_highlight(menuitem); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jmenu_popup(lua_State *L) -{ - JWidget menu; - int x; - int y; - GetUD(1, menu, JWidget); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - jmenu_popup(menu, x, y); - return 0; -} - -static int bind_jmessage_new(lua_State *L) -{ - JMessage return_value; - int type; - GetArg(1, type, int, number); - return_value = jmessage_new(type); - push_userdata(L, Type_JMessage, return_value); - return 1; -} - -static int bind_jmessage_new_copy(lua_State *L) -{ - JMessage return_value; - JMessage msg; - GetUD(1, msg, JMessage); - return_value = jmessage_new_copy(msg); - push_userdata(L, Type_JMessage, return_value); - return 1; -} - -static int bind_jmessage_free(lua_State *L) -{ - JMessage msg; - GetUD(1, msg, JMessage); - jmessage_free(msg); - return 0; -} - -static int bind_jmessage_add_dest(lua_State *L) -{ - JMessage msg; - JWidget widget; - GetUD(1, msg, JMessage); - GetUD(2, widget, JWidget); - jmessage_add_dest(msg, widget); - return 0; -} - -static int bind_jmessage_broadcast_to_children(lua_State *L) -{ - JMessage msg; - JWidget widget; - GetUD(1, msg, JMessage); - GetUD(2, widget, JWidget); - jmessage_broadcast_to_children(msg, widget); - return 0; -} - -static int bind_jmessage_broadcast_to_parents(lua_State *L) -{ - JMessage msg; - JWidget widget; - GetUD(1, msg, JMessage); - GetUD(2, widget, JWidget); - jmessage_broadcast_to_parents(msg, widget); - return 0; -} - -static int bind_jmessage_set_sub_msg(lua_State *L) -{ - JMessage msg; - JMessage sub_msg; - GetUD(1, msg, JMessage); - GetUD(2, sub_msg, JMessage); - jmessage_set_sub_msg(msg, sub_msg); - return 0; -} - -static int bind_jpanel_new(lua_State *L) -{ - JWidget return_value; - int align; - GetArg(1, align, int, number); - return_value = jpanel_new(align); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jpanel_get_pos(lua_State *L) -{ - double return_value; - JWidget panel; - GetUD(1, panel, JWidget); - return_value = jpanel_get_pos(panel); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jpanel_set_pos(lua_State *L) -{ - JWidget panel; - double pos; - GetUD(1, panel, JWidget); - GetArg(2, pos, double, number); - jpanel_set_pos(panel, pos); - return 0; -} - -static int bind_jradio_new(lua_State *L) -{ - JWidget return_value; - const char *text; - int radio_group; - GetArg(1, text, const char *, string); - GetArg(2, radio_group, int, number); - return_value = jradio_new(text, radio_group); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jradio_get_group(lua_State *L) -{ - int return_value; - JWidget radio; - GetUD(1, radio, JWidget); - return_value = jradio_get_group(radio); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jradio_deselect_group(lua_State *L) -{ - JWidget radio; - GetUD(1, radio, JWidget); - jradio_deselect_group(radio); - return 0; -} - -static int bind_jrect_w(lua_State *L) -{ - int return_value; - JRect rect; - GetUD(1, rect, JRect); - return_value = jrect_w(rect); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jrect_h(lua_State *L) -{ - int return_value; - JRect rect; - GetUD(1, rect, JRect); - return_value = jrect_h(rect); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jrect_point_in(lua_State *L) -{ - bool return_value; - JRect rect; - int x; - int y; - GetUD(1, rect, JRect); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - return_value = jrect_point_in(rect, x, y); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jrect_new(lua_State *L) -{ - JRect return_value; - int x1; - int y1; - int x2; - int y2; - GetArg(1, x1, int, number); - GetArg(2, y1, int, number); - GetArg(3, x2, int, number); - GetArg(4, y2, int, number); - return_value = jrect_new(x1, y1, x2, y2); - push_userdata(L, Type_JRect, return_value); - return 1; -} - -static int bind_jrect_new_copy(lua_State *L) -{ - JRect return_value; - JRect rect; - GetUD(1, rect, JRect); - return_value = jrect_new_copy(rect); - push_userdata(L, Type_JRect, return_value); - return 1; -} - -static int bind_jrect_free(lua_State *L) -{ - JRect rect; - GetUD(1, rect, JRect); - jrect_free(rect); - return 0; -} - -static int bind_jrect_copy(lua_State *L) -{ - JRect dst; - JRect src; - GetUD(1, dst, JRect); - GetUD(2, src, JRect); - jrect_copy(dst, src); - return 0; -} - -static int bind_jrect_replace(lua_State *L) -{ - JRect rect; - int x1; - int y1; - int x2; - int y2; - GetUD(1, rect, JRect); - GetArg(2, x1, int, number); - GetArg(3, y1, int, number); - GetArg(4, x2, int, number); - GetArg(5, y2, int, number); - jrect_replace(rect, x1, y1, x2, y2); - return 0; -} - -static int bind_jrect_union(lua_State *L) -{ - JRect r1; - JRect r2; - GetUD(1, r1, JRect); - GetUD(2, r2, JRect); - jrect_union(r1, r2); - return 0; -} - -static int bind_jrect_intersect(lua_State *L) -{ - bool return_value; - JRect r1; - JRect r2; - GetUD(1, r1, JRect); - GetUD(2, r2, JRect); - return_value = jrect_intersect(r1, r2); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jrect_shrink(lua_State *L) -{ - JRect rect; - int border; - GetUD(1, rect, JRect); - GetArg(2, border, int, number); - jrect_shrink(rect, border); - return 0; -} - -static int bind_jrect_stretch(lua_State *L) -{ - JRect rect; - int border; - GetUD(1, rect, JRect); - GetArg(2, border, int, number); - jrect_stretch(rect, border); - return 0; -} - -static int bind_jrect_moveto(lua_State *L) -{ - JRect rect; - int x; - int y; - GetUD(1, rect, JRect); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - jrect_moveto(rect, x, y); - return 0; -} - -static int bind_jrect_displace(lua_State *L) -{ - JRect rect; - int dx; - int dy; - GetUD(1, rect, JRect); - GetArg(2, dx, int, number); - GetArg(3, dy, int, number); - jrect_displace(rect, dx, dy); - return 0; -} - -static int bind_jregion_new(lua_State *L) -{ - JRegion return_value; - JRect rect; - int size; - GetUD(1, rect, JRect); - GetArg(2, size, int, number); - return_value = jregion_new(rect, size); - push_userdata(L, Type_JRegion, return_value); - return 1; -} - -static int bind_jregion_init(lua_State *L) -{ - JRegion reg; - JRect rect; - int size; - GetUD(1, reg, JRegion); - GetUD(2, rect, JRect); - GetArg(3, size, int, number); - jregion_init(reg, rect, size); - return 0; -} - -static int bind_jregion_free(lua_State *L) -{ - JRegion reg; - GetUD(1, reg, JRegion); - jregion_free(reg); - return 0; -} - -static int bind_jregion_uninit(lua_State *L) -{ - JRegion reg; - GetUD(1, reg, JRegion); - jregion_uninit(reg); - return 0; -} - -static int bind_jregion_copy(lua_State *L) -{ - bool return_value; - JRegion dst; - JRegion src; - GetUD(1, dst, JRegion); - GetUD(2, src, JRegion); - return_value = jregion_copy(dst, src); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_intersect(lua_State *L) -{ - bool return_value; - JRegion new; - JRegion reg1; - JRegion reg2; - GetUD(1, new, JRegion); - GetUD(2, reg1, JRegion); - GetUD(3, reg2, JRegion); - return_value = jregion_intersect(new, reg1, reg2); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_union(lua_State *L) -{ - bool return_value; - JRegion new; - JRegion reg1; - JRegion reg2; - GetUD(1, new, JRegion); - GetUD(2, reg1, JRegion); - GetUD(3, reg2, JRegion); - return_value = jregion_union(new, reg1, reg2); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_append(lua_State *L) -{ - bool return_value; - JRegion dstrgn; - JRegion rgn; - GetUD(1, dstrgn, JRegion); - GetUD(2, rgn, JRegion); - return_value = jregion_append(dstrgn, rgn); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_subtract(lua_State *L) -{ - bool return_value; - JRegion regD; - JRegion regM; - JRegion regS; - GetUD(1, regD, JRegion); - GetUD(2, regM, JRegion); - GetUD(3, regS, JRegion); - return_value = jregion_subtract(regD, regM, regS); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_inverse(lua_State *L) -{ - bool return_value; - JRegion newReg; - JRegion reg1; - JRect invRect; - GetUD(1, newReg, JRegion); - GetUD(2, reg1, JRegion); - GetUD(3, invRect, JRect); - return_value = jregion_inverse(newReg, reg1, invRect); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_rect_in(lua_State *L) -{ - int return_value; - JRegion region; - JRect rect; - GetUD(1, region, JRegion); - GetUD(2, rect, JRect); - return_value = jregion_rect_in(region, rect); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jregion_translate(lua_State *L) -{ - JRegion reg; - int x; - int y; - GetUD(1, reg, JRegion); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - jregion_translate(reg, x, y); - return 0; -} - -static int bind_jregion_reset(lua_State *L) -{ - JRegion reg; - JRect box; - GetUD(1, reg, JRegion); - GetUD(2, box, JRect); - jregion_reset(reg, box); - return 0; -} - -static int bind_jregion_break(lua_State *L) -{ - bool return_value; - JRegion reg; - GetUD(1, reg, JRegion); - return_value = jregion_break(reg); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_point_in(lua_State *L) -{ - bool return_value; - JRegion reg; - int x; - int y; - JRect box; - GetUD(1, reg, JRegion); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - GetUD(4, box, JRect); - return_value = jregion_point_in(reg, x, y, box); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_equal(lua_State *L) -{ - bool return_value; - JRegion reg1; - JRegion reg2; - GetUD(1, reg1, JRegion); - GetUD(2, reg2, JRegion); - return_value = jregion_equal(reg1, reg2); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_notempty(lua_State *L) -{ - bool return_value; - JRegion reg; - GetUD(1, reg, JRegion); - return_value = jregion_notempty(reg); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jregion_empty(lua_State *L) -{ - JRegion reg; - GetUD(1, reg, JRegion); - jregion_empty(reg); - return 0; -} - -static int bind_jregion_extents(lua_State *L) -{ - JRect return_value; - JRegion reg; - GetUD(1, reg, JRegion); - return_value = jregion_extents(reg); - push_userdata(L, Type_JRect, return_value); - return 1; -} - -static int bind_ji_separator_new(lua_State *L) -{ - JWidget return_value; - const char *text; - int align; - GetArg(1, text, const char *, string); - GetArg(2, align, int, number); - return_value = ji_separator_new(text, align); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jslider_new(lua_State *L) -{ - JWidget return_value; - int min; - int max; - int value; - GetArg(1, min, int, number); - GetArg(2, max, int, number); - GetArg(3, value, int, number); - return_value = jslider_new(min, max, value); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jslider_set_value(lua_State *L) -{ - JWidget slider; - int value; - GetUD(1, slider, JWidget); - GetArg(2, value, int, number); - jslider_set_value(slider, value); - return 0; -} - -static int bind_jslider_get_value(lua_State *L) -{ - int return_value; - JWidget slider; - GetUD(1, slider, JWidget); - return_value = jslider_get_value(slider); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jtextbox_new(lua_State *L) -{ - JWidget return_value; - const char *text; - int align; - GetArg(1, text, const char *, string); - GetArg(2, align, int, number); - return_value = jtextbox_new(text, align); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jview_new(lua_State *L) -{ - JWidget return_value; - return_value = jview_new(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jview_has_bars(lua_State *L) -{ - bool return_value; - JWidget view; - GetUD(1, view, JWidget); - return_value = jview_has_bars(view); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jview_attach(lua_State *L) -{ - JWidget view; - JWidget viewable_widget; - GetUD(1, view, JWidget); - GetUD(2, viewable_widget, JWidget); - jview_attach(view, viewable_widget); - return 0; -} - -static int bind_jview_maxsize(lua_State *L) -{ - JWidget view; - GetUD(1, view, JWidget); - jview_maxsize(view); - return 0; -} - -static int bind_jview_without_bars(lua_State *L) -{ - JWidget view; - GetUD(1, view, JWidget); - jview_without_bars(view); - return 0; -} - -static int bind_jview_set_size(lua_State *L) -{ - JWidget view; - int w; - int h; - GetUD(1, view, JWidget); - GetArg(2, w, int, number); - GetArg(3, h, int, number); - jview_set_size(view, w, h); - return 0; -} - -static int bind_jview_set_scroll(lua_State *L) -{ - JWidget view; - int x; - int y; - GetUD(1, view, JWidget); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - jview_set_scroll(view, x, y); - return 0; -} - -static int bind_jview_update(lua_State *L) -{ - JWidget view; - GetUD(1, view, JWidget); - jview_update(view); - return 0; -} - -static int bind_jview_get_viewport(lua_State *L) -{ - JWidget return_value; - JWidget view; - GetUD(1, view, JWidget); - return_value = jview_get_viewport(view); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jview_get_viewport_position(lua_State *L) -{ - JRect return_value; - JWidget view; - GetUD(1, view, JWidget); - return_value = jview_get_viewport_position(view); - push_userdata(L, Type_JRect, return_value); - return 1; -} - -static int bind_jwidget_get_view(lua_State *L) -{ - JWidget return_value; - JWidget viewable_widget; - GetUD(1, viewable_widget, JWidget); - return_value = jwidget_get_view(viewable_widget); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_ji_register_widget_type(lua_State *L) -{ - int return_value; - return_value = ji_register_widget_type(); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_new(lua_State *L) -{ - JWidget return_value; - int type; - GetArg(1, type, int, number); - return_value = jwidget_new(type); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwidget_free(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_free(widget); - return 0; -} - -static int bind_jwidget_get_type(lua_State *L) -{ - int return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_type(widget); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_get_name(lua_State *L) -{ - const char *return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_name(widget); - lua_pushstring(L, return_value); - return 1; -} - -static int bind_jwidget_get_text(lua_State *L) -{ - const char *return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_text(widget); - lua_pushstring(L, return_value); - return 1; -} - -static int bind_jwidget_get_align(lua_State *L) -{ - int return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_align(widget); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_set_name(lua_State *L) -{ - JWidget widget; - const char *name; - GetUD(1, widget, JWidget); - GetArg(2, name, const char *, string); - jwidget_set_name(widget, name); - return 0; -} - -static int bind_jwidget_set_text(lua_State *L) -{ - JWidget widget; - const char *text; - GetUD(1, widget, JWidget); - GetArg(2, text, const char *, string); - jwidget_set_text(widget, text); - return 0; -} - -static int bind_jwidget_set_align(lua_State *L) -{ - JWidget widget; - int align; - GetUD(1, widget, JWidget); - GetArg(2, align, int, number); - jwidget_set_align(widget, align); - return 0; -} - -static int bind_jwidget_magnetic(lua_State *L) -{ - JWidget widget; - bool state; - GetUD(1, widget, JWidget); - GetArg(2, state, bool, boolean); - jwidget_magnetic(widget, state); - return 0; -} - -static int bind_jwidget_expansive(lua_State *L) -{ - JWidget widget; - bool state; - GetUD(1, widget, JWidget); - GetArg(2, state, bool, boolean); - jwidget_expansive(widget, state); - return 0; -} - -static int bind_jwidget_decorative(lua_State *L) -{ - JWidget widget; - bool state; - GetUD(1, widget, JWidget); - GetArg(2, state, bool, boolean); - jwidget_decorative(widget, state); - return 0; -} - -static int bind_jwidget_autodestroy(lua_State *L) -{ - JWidget widget; - bool state; - GetUD(1, widget, JWidget); - GetArg(2, state, bool, boolean); - jwidget_autodestroy(widget, state); - return 0; -} - -static int bind_jwidget_focusrest(lua_State *L) -{ - JWidget widget; - bool state; - GetUD(1, widget, JWidget); - GetArg(2, state, bool, boolean); - jwidget_focusrest(widget, state); - return 0; -} - -static int bind_jwidget_is_magnetic(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_magnetic(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_expansive(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_expansive(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_decorative(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_decorative(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_autodestroy(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_autodestroy(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_focusrest(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_focusrest(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_dirty(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_dirty(widget); - return 0; -} - -static int bind_jwidget_show(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_show(widget); - return 0; -} - -static int bind_jwidget_hide(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_hide(widget); - return 0; -} - -static int bind_jwidget_enable(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_enable(widget); - return 0; -} - -static int bind_jwidget_disable(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_disable(widget); - return 0; -} - -static int bind_jwidget_select(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_select(widget); - return 0; -} - -static int bind_jwidget_deselect(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_deselect(widget); - return 0; -} - -static int bind_jwidget_is_visible(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_visible(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_hidden(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_hidden(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_enabled(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_enabled(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_disabled(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_disabled(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_selected(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_selected(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_is_deselected(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_is_deselected(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_has_focus(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_has_focus(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_has_mouse(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_has_mouse(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_has_capture(lua_State *L) -{ - bool return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_has_capture(widget); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_add_child(lua_State *L) -{ - JWidget widget; - JWidget child; - GetUD(1, widget, JWidget); - GetUD(2, child, JWidget); - jwidget_add_child(widget, child); - return 0; -} - -static int bind_jwidget_remove_child(lua_State *L) -{ - JWidget widget; - JWidget child; - GetUD(1, widget, JWidget); - GetUD(2, child, JWidget); - jwidget_remove_child(widget, child); - return 0; -} - -static int bind_jwidget_replace_child(lua_State *L) -{ - JWidget widget; - JWidget old_child; - JWidget new_child; - GetUD(1, widget, JWidget); - GetUD(2, old_child, JWidget); - GetUD(3, new_child, JWidget); - jwidget_replace_child(widget, old_child, new_child); - return 0; -} - -static int bind_jwidget_get_parent(lua_State *L) -{ - JWidget return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_parent(widget); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwidget_get_window(lua_State *L) -{ - JWidget return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_window(widget); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwidget_pick(lua_State *L) -{ - JWidget return_value; - JWidget widget; - int x; - int y; - GetUD(1, widget, JWidget); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - return_value = jwidget_pick(widget, x, y); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwidget_has_child(lua_State *L) -{ - bool return_value; - JWidget widget; - JWidget child; - GetUD(1, widget, JWidget); - GetUD(2, child, JWidget); - return_value = jwidget_has_child(widget, child); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_get_rect(lua_State *L) -{ - JRect return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_rect(widget); - push_userdata(L, Type_JRect, return_value); - return 1; -} - -static int bind_jwidget_get_child_rect(lua_State *L) -{ - JRect return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_child_rect(widget); - push_userdata(L, Type_JRect, return_value); - return 1; -} - -static int bind_jwidget_get_region(lua_State *L) -{ - JRegion return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_region(widget); - push_userdata(L, Type_JRegion, return_value); - return 1; -} - -static int bind_jwidget_get_drawable_region(lua_State *L) -{ - JRegion return_value; - JWidget widget; - int flags; - GetUD(1, widget, JWidget); - GetArg(2, flags, int, number); - return_value = jwidget_get_drawable_region(widget, flags); - push_userdata(L, Type_JRegion, return_value); - return 1; -} - -static int bind_jwidget_get_bg_color(lua_State *L) -{ - int return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_bg_color(widget); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_get_text_length(lua_State *L) -{ - int return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_text_length(widget); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_get_text_height(lua_State *L) -{ - int return_value; - JWidget widget; - GetUD(1, widget, JWidget); - return_value = jwidget_get_text_height(widget); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_noborders(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_noborders(widget); - return 0; -} - -static int bind_jwidget_set_border(lua_State *L) -{ - JWidget widget; - int l; - int t; - int r; - int b; - GetUD(1, widget, JWidget); - GetArg(2, l, int, number); - GetArg(3, t, int, number); - GetArg(4, r, int, number); - GetArg(5, b, int, number); - jwidget_set_border(widget, l, t, r, b); - return 0; -} - -static int bind_jwidget_set_rect(lua_State *L) -{ - JWidget widget; - JRect rect; - GetUD(1, widget, JWidget); - GetUD(2, rect, JRect); - jwidget_set_rect(widget, rect); - return 0; -} - -static int bind_jwidget_set_static_size(lua_State *L) -{ - JWidget widget; - int w; - int h; - GetUD(1, widget, JWidget); - GetArg(2, w, int, number); - GetArg(3, h, int, number); - jwidget_set_static_size(widget, w, h); - return 0; -} - -static int bind_jwidget_set_bg_color(lua_State *L) -{ - JWidget widget; - int color; - GetUD(1, widget, JWidget); - GetArg(2, color, int, number); - jwidget_set_bg_color(widget, color); - return 0; -} - -static int bind_jwidget_flush_redraw(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_flush_redraw(widget); - return 0; -} - -static int bind_jwidget_redraw_region(lua_State *L) -{ - JWidget widget; - JRegion region; - GetUD(1, widget, JWidget); - GetUD(2, region, JRegion); - jwidget_redraw_region(widget, region); - return 0; -} - -static int bind_jwidget_signal_on(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_signal_on(widget); - return 0; -} - -static int bind_jwidget_signal_off(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_signal_off(widget); - return 0; -} - -static int bind_jwidget_emit_signal(lua_State *L) -{ - int return_value; - JWidget widget; - int signal; - GetUD(1, widget, JWidget); - GetArg(2, signal, int, number); - return_value = jwidget_emit_signal(widget, signal); - lua_pushnumber(L, return_value); - return 1; -} - -static int bind_jwidget_send_message(lua_State *L) -{ - bool return_value; - JWidget widget; - JMessage msg; - GetUD(1, widget, JWidget); - GetUD(2, msg, JMessage); - return_value = jwidget_send_message(widget, msg); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_send_message_after_type(lua_State *L) -{ - bool return_value; - JWidget widget; - JMessage msg; - int type; - GetUD(1, widget, JWidget); - GetUD(2, msg, JMessage); - GetArg(3, type, int, number); - return_value = jwidget_send_message_after_type(widget, msg, type); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwidget_close_window(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_close_window(widget); - return 0; -} - -static int bind_jwidget_capture_mouse(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_capture_mouse(widget); - return 0; -} - -static int bind_jwidget_hard_capture_mouse(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_hard_capture_mouse(widget); - return 0; -} - -static int bind_jwidget_release_mouse(lua_State *L) -{ - JWidget widget; - GetUD(1, widget, JWidget); - jwidget_release_mouse(widget); - return 0; -} - -static int bind_jwidget_find_name(lua_State *L) -{ - JWidget return_value; - JWidget widget; - const char *name; - GetUD(1, widget, JWidget); - GetArg(2, name, const char *, string); - return_value = jwidget_find_name(widget, name); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwidget_check_underscored(lua_State *L) -{ - bool return_value; - JWidget widget; - int scancode; - GetUD(1, widget, JWidget); - GetArg(2, scancode, int, number); - return_value = jwidget_check_underscored(widget, scancode); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwindow_new(lua_State *L) -{ - JWidget return_value; - const char *text; - GetArg(1, text, const char *, string); - return_value = jwindow_new(text); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwindow_new_desktop(lua_State *L) -{ - JWidget return_value; - return_value = jwindow_new_desktop(); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwindow_get_killer(lua_State *L) -{ - JWidget return_value; - JWidget window; - GetUD(1, window, JWidget); - return_value = jwindow_get_killer(window); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwindow_get_manager(lua_State *L) -{ - JWidget return_value; - JWidget window; - GetUD(1, window, JWidget); - return_value = jwindow_get_manager(window); - push_userdata(L, Type_JWidget, return_value); - return 1; -} - -static int bind_jwindow_moveable(lua_State *L) -{ - JWidget window; - bool state; - GetUD(1, window, JWidget); - GetArg(2, state, bool, boolean); - jwindow_moveable(window, state); - return 0; -} - -static int bind_jwindow_sizeable(lua_State *L) -{ - JWidget window; - bool state; - GetUD(1, window, JWidget); - GetArg(2, state, bool, boolean); - jwindow_sizeable(window, state); - return 0; -} - -static int bind_jwindow_ontop(lua_State *L) -{ - JWidget window; - bool state; - GetUD(1, window, JWidget); - GetArg(2, state, bool, boolean); - jwindow_ontop(window, state); - return 0; -} - -static int bind_jwindow_remap(lua_State *L) -{ - JWidget window; - GetUD(1, window, JWidget); - jwindow_remap(window); - return 0; -} - -static int bind_jwindow_center(lua_State *L) -{ - JWidget window; - GetUD(1, window, JWidget); - jwindow_center(window); - return 0; -} - -static int bind_jwindow_position(lua_State *L) -{ - JWidget window; - int x; - int y; - GetUD(1, window, JWidget); - GetArg(2, x, int, number); - GetArg(3, y, int, number); - jwindow_position(window, x, y); - return 0; -} - -static int bind_jwindow_move(lua_State *L) -{ - JWidget window; - JRect rect; - GetUD(1, window, JWidget); - GetUD(2, rect, JRect); - jwindow_move(window, rect); - return 0; -} - -static int bind_jwindow_open(lua_State *L) -{ - JWidget window; - GetUD(1, window, JWidget); - jwindow_open(window); - return 0; -} - -static int bind_jwindow_open_fg(lua_State *L) -{ - JWidget window; - GetUD(1, window, JWidget); - jwindow_open_fg(window); - return 0; -} - -static int bind_jwindow_open_bg(lua_State *L) -{ - JWidget window; - GetUD(1, window, JWidget); - jwindow_open_bg(window); - return 0; -} - -static int bind_jwindow_close(lua_State *L) -{ - JWidget window; - JWidget killer; - GetUD(1, window, JWidget); - GetUD(2, killer, JWidget); - jwindow_close(window, killer); - return 0; -} - -static int bind_jwindow_is_toplevel(lua_State *L) -{ - bool return_value; - JWidget window; - GetUD(1, window, JWidget); - return_value = jwindow_is_toplevel(window); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwindow_is_foreground(lua_State *L) -{ - bool return_value; - JWidget window; - GetUD(1, window, JWidget); - return_value = jwindow_is_foreground(window); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwindow_is_desktop(lua_State *L) -{ - bool return_value; - JWidget window; - GetUD(1, window, JWidget); - return_value = jwindow_is_desktop(window); - lua_pushboolean(L, return_value); - return 1; -} - -static int bind_jwindow_is_ontop(lua_State *L) -{ - bool return_value; - JWidget window; - GetUD(1, window, JWidget); - return_value = jwindow_is_ontop(window); - lua_pushboolean(L, return_value); - return 1; -} - const luaL_reg bindings_routines[] = { { "MAX", bind_MAX }, { "MIN", bind_MIN }, @@ -5550,16 +3162,6 @@ const luaL_reg bindings_routines[] = { { "tanh", bind_tanh }, { "file_exists", bind_file_exists }, { "get_filename", bind_get_filename }, - { "get_config_int", bind_get_config_int }, - { "set_config_int", bind_set_config_int }, - { "get_config_string", bind_get_config_string }, - { "set_config_string", bind_set_config_string }, - { "get_config_float", bind_get_config_float }, - { "set_config_float", bind_set_config_float }, - { "get_config_bool", bind_get_config_bool }, - { "set_config_bool", bind_set_config_bool }, - { "get_config_rect", bind_get_config_rect }, - { "set_config_rect", bind_set_config_rect }, { "do_progress", bind_do_progress }, { "add_progress", bind_add_progress }, { "del_progress", bind_del_progress }, @@ -5604,8 +3206,6 @@ const luaL_reg bindings_routines[] = { { "SetBrush", bind_SetBrush }, { "SetDrawMode", bind_SetDrawMode }, { "ToolTrace", bind_ToolTrace }, - { "ResetConfig", bind_ResetConfig }, - { "RestoreConfig", bind_RestoreConfig }, { "get_fg_color", bind_get_fg_color }, { "get_bg_color", bind_get_bg_color }, { "set_fg_color", bind_set_fg_color }, @@ -5845,236 +3445,6 @@ const luaL_reg bindings_routines[] = { { "get_convmatr_by_name", bind_get_convmatr_by_name }, { "set_replace_colors", bind_set_replace_colors }, { "set_median_size", bind_set_median_size }, - { "reload_default_font", bind_reload_default_font }, - { "load_window_pos", bind_load_window_pos }, - { "save_window_pos", bind_save_window_pos }, - { "ji_load_widget", bind_ji_load_widget }, - { "ji_file_select", bind_ji_file_select }, - { "ji_color_select", bind_ji_color_select }, - { "jalert_new", bind_jalert_new }, - { "jalert", bind_jalert }, - { "jbox_new", bind_jbox_new }, - { "jbutton_new", bind_jbutton_new }, - { "jcheck_new", bind_jcheck_new }, - { "jcombobox_new", bind_jcombobox_new }, - { "jcombobox_editable", bind_jcombobox_editable }, - { "jcombobox_clickopen", bind_jcombobox_clickopen }, - { "jcombobox_casesensitive", bind_jcombobox_casesensitive }, - { "jcombobox_is_editable", bind_jcombobox_is_editable }, - { "jcombobox_is_clickopen", bind_jcombobox_is_clickopen }, - { "jcombobox_is_casesensitive", bind_jcombobox_is_casesensitive }, - { "jcombobox_add_string", bind_jcombobox_add_string }, - { "jcombobox_del_string", bind_jcombobox_del_string }, - { "jcombobox_del_index", bind_jcombobox_del_index }, - { "jcombobox_select_index", bind_jcombobox_select_index }, - { "jcombobox_select_string", bind_jcombobox_select_string }, - { "jcombobox_get_selected_index", bind_jcombobox_get_selected_index }, - { "jcombobox_get_selected_string", bind_jcombobox_get_selected_string }, - { "jcombobox_get_string", bind_jcombobox_get_string }, - { "jcombobox_get_index", bind_jcombobox_get_index }, - { "jcombobox_get_count", bind_jcombobox_get_count }, - { "jcombobox_get_entry_widget", bind_jcombobox_get_entry_widget }, - { "jclipboard_get_text", bind_jclipboard_get_text }, - { "jclipboard_set_text", bind_jclipboard_set_text }, - { "jentry_new", bind_jentry_new }, - { "jentry_readonly", bind_jentry_readonly }, - { "jentry_password", bind_jentry_password }, - { "jentry_is_password", bind_jentry_is_password }, - { "jentry_is_readonly", bind_jentry_is_readonly }, - { "jentry_show_cursor", bind_jentry_show_cursor }, - { "jentry_hide_cursor", bind_jentry_hide_cursor }, - { "jentry_set_cursor_pos", bind_jentry_set_cursor_pos }, - { "jentry_select_text", bind_jentry_select_text }, - { "jentry_deselect_text", bind_jentry_deselect_text }, - { "jlabel_new", bind_jlabel_new }, - { "jlistbox_new", bind_jlistbox_new }, - { "jlistitem_new", bind_jlistitem_new }, - { "jlistbox_get_selected_child", bind_jlistbox_get_selected_child }, - { "jlistbox_get_selected_index", bind_jlistbox_get_selected_index }, - { "jlistbox_select_child", bind_jlistbox_select_child }, - { "jlistbox_select_index", bind_jlistbox_select_index }, - { "jlistbox_center_scroll", bind_jlistbox_center_scroll }, - { "ji_get_default_manager", bind_ji_get_default_manager }, - { "jmanager_new", bind_jmanager_new }, - { "jmanager_free", bind_jmanager_free }, - { "jmanager_run", bind_jmanager_run }, - { "jmanager_poll", bind_jmanager_poll }, - { "jmanager_send_message", bind_jmanager_send_message }, - { "jmanager_get_focus", bind_jmanager_get_focus }, - { "jmanager_get_mouse", bind_jmanager_get_mouse }, - { "jmanager_get_capture", bind_jmanager_get_capture }, - { "jmanager_set_focus", bind_jmanager_set_focus }, - { "jmanager_set_mouse", bind_jmanager_set_mouse }, - { "jmanager_set_capture", bind_jmanager_set_capture }, - { "jmanager_attract_focus", bind_jmanager_attract_focus }, - { "jmanager_free_focus", bind_jmanager_free_focus }, - { "jmanager_free_mouse", bind_jmanager_free_mouse }, - { "jmanager_free_capture", bind_jmanager_free_capture }, - { "jmanager_free_widget", bind_jmanager_free_widget }, - { "jmanager_remove_message", bind_jmanager_remove_message }, - { "jmanager_remove_messages_for", bind_jmanager_remove_messages_for }, - { "jmanager_refresh_screen", bind_jmanager_refresh_screen }, - { "jmenu_new", bind_jmenu_new }, - { "jmenubar_new", bind_jmenubar_new }, - { "jmenubox_new", bind_jmenubox_new }, - { "jmenuitem_new", bind_jmenuitem_new }, - { "jmenubox_get_menu", bind_jmenubox_get_menu }, - { "jmenubar_get_menu", bind_jmenubar_get_menu }, - { "jmenuitem_get_submenu", bind_jmenuitem_get_submenu }, - { "jmenubox_set_menu", bind_jmenubox_set_menu }, - { "jmenubar_set_menu", bind_jmenubar_set_menu }, - { "jmenuitem_set_submenu", bind_jmenuitem_set_submenu }, - { "jmenuitem_is_highlight", bind_jmenuitem_is_highlight }, - { "jmenu_popup", bind_jmenu_popup }, - { "jmessage_new", bind_jmessage_new }, - { "jmessage_new_copy", bind_jmessage_new_copy }, - { "jmessage_free", bind_jmessage_free }, - { "jmessage_add_dest", bind_jmessage_add_dest }, - { "jmessage_broadcast_to_children", bind_jmessage_broadcast_to_children }, - { "jmessage_broadcast_to_parents", bind_jmessage_broadcast_to_parents }, - { "jmessage_set_sub_msg", bind_jmessage_set_sub_msg }, - { "jpanel_new", bind_jpanel_new }, - { "jpanel_get_pos", bind_jpanel_get_pos }, - { "jpanel_set_pos", bind_jpanel_set_pos }, - { "jradio_new", bind_jradio_new }, - { "jradio_get_group", bind_jradio_get_group }, - { "jradio_deselect_group", bind_jradio_deselect_group }, - { "jrect_w", bind_jrect_w }, - { "jrect_h", bind_jrect_h }, - { "jrect_point_in", bind_jrect_point_in }, - { "jrect_new", bind_jrect_new }, - { "jrect_new_copy", bind_jrect_new_copy }, - { "jrect_free", bind_jrect_free }, - { "jrect_copy", bind_jrect_copy }, - { "jrect_replace", bind_jrect_replace }, - { "jrect_union", bind_jrect_union }, - { "jrect_intersect", bind_jrect_intersect }, - { "jrect_shrink", bind_jrect_shrink }, - { "jrect_stretch", bind_jrect_stretch }, - { "jrect_moveto", bind_jrect_moveto }, - { "jrect_displace", bind_jrect_displace }, - { "jregion_new", bind_jregion_new }, - { "jregion_init", bind_jregion_init }, - { "jregion_free", bind_jregion_free }, - { "jregion_uninit", bind_jregion_uninit }, - { "jregion_copy", bind_jregion_copy }, - { "jregion_intersect", bind_jregion_intersect }, - { "jregion_union", bind_jregion_union }, - { "jregion_append", bind_jregion_append }, - { "jregion_subtract", bind_jregion_subtract }, - { "jregion_inverse", bind_jregion_inverse }, - { "jregion_rect_in", bind_jregion_rect_in }, - { "jregion_translate", bind_jregion_translate }, - { "jregion_reset", bind_jregion_reset }, - { "jregion_break", bind_jregion_break }, - { "jregion_point_in", bind_jregion_point_in }, - { "jregion_equal", bind_jregion_equal }, - { "jregion_notempty", bind_jregion_notempty }, - { "jregion_empty", bind_jregion_empty }, - { "jregion_extents", bind_jregion_extents }, - { "ji_separator_new", bind_ji_separator_new }, - { "jslider_new", bind_jslider_new }, - { "jslider_set_value", bind_jslider_set_value }, - { "jslider_get_value", bind_jslider_get_value }, - { "jtextbox_new", bind_jtextbox_new }, - { "jview_new", bind_jview_new }, - { "jview_has_bars", bind_jview_has_bars }, - { "jview_attach", bind_jview_attach }, - { "jview_maxsize", bind_jview_maxsize }, - { "jview_without_bars", bind_jview_without_bars }, - { "jview_set_size", bind_jview_set_size }, - { "jview_set_scroll", bind_jview_set_scroll }, - { "jview_update", bind_jview_update }, - { "jview_get_viewport", bind_jview_get_viewport }, - { "jview_get_viewport_position", bind_jview_get_viewport_position }, - { "jwidget_get_view", bind_jwidget_get_view }, - { "ji_register_widget_type", bind_ji_register_widget_type }, - { "jwidget_new", bind_jwidget_new }, - { "jwidget_free", bind_jwidget_free }, - { "jwidget_get_type", bind_jwidget_get_type }, - { "jwidget_get_name", bind_jwidget_get_name }, - { "jwidget_get_text", bind_jwidget_get_text }, - { "jwidget_get_align", bind_jwidget_get_align }, - { "jwidget_set_name", bind_jwidget_set_name }, - { "jwidget_set_text", bind_jwidget_set_text }, - { "jwidget_set_align", bind_jwidget_set_align }, - { "jwidget_magnetic", bind_jwidget_magnetic }, - { "jwidget_expansive", bind_jwidget_expansive }, - { "jwidget_decorative", bind_jwidget_decorative }, - { "jwidget_autodestroy", bind_jwidget_autodestroy }, - { "jwidget_focusrest", bind_jwidget_focusrest }, - { "jwidget_is_magnetic", bind_jwidget_is_magnetic }, - { "jwidget_is_expansive", bind_jwidget_is_expansive }, - { "jwidget_is_decorative", bind_jwidget_is_decorative }, - { "jwidget_is_autodestroy", bind_jwidget_is_autodestroy }, - { "jwidget_is_focusrest", bind_jwidget_is_focusrest }, - { "jwidget_dirty", bind_jwidget_dirty }, - { "jwidget_show", bind_jwidget_show }, - { "jwidget_hide", bind_jwidget_hide }, - { "jwidget_enable", bind_jwidget_enable }, - { "jwidget_disable", bind_jwidget_disable }, - { "jwidget_select", bind_jwidget_select }, - { "jwidget_deselect", bind_jwidget_deselect }, - { "jwidget_is_visible", bind_jwidget_is_visible }, - { "jwidget_is_hidden", bind_jwidget_is_hidden }, - { "jwidget_is_enabled", bind_jwidget_is_enabled }, - { "jwidget_is_disabled", bind_jwidget_is_disabled }, - { "jwidget_is_selected", bind_jwidget_is_selected }, - { "jwidget_is_deselected", bind_jwidget_is_deselected }, - { "jwidget_has_focus", bind_jwidget_has_focus }, - { "jwidget_has_mouse", bind_jwidget_has_mouse }, - { "jwidget_has_capture", bind_jwidget_has_capture }, - { "jwidget_add_child", bind_jwidget_add_child }, - { "jwidget_remove_child", bind_jwidget_remove_child }, - { "jwidget_replace_child", bind_jwidget_replace_child }, - { "jwidget_get_parent", bind_jwidget_get_parent }, - { "jwidget_get_window", bind_jwidget_get_window }, - { "jwidget_pick", bind_jwidget_pick }, - { "jwidget_has_child", bind_jwidget_has_child }, - { "jwidget_get_rect", bind_jwidget_get_rect }, - { "jwidget_get_child_rect", bind_jwidget_get_child_rect }, - { "jwidget_get_region", bind_jwidget_get_region }, - { "jwidget_get_drawable_region", bind_jwidget_get_drawable_region }, - { "jwidget_get_bg_color", bind_jwidget_get_bg_color }, - { "jwidget_get_text_length", bind_jwidget_get_text_length }, - { "jwidget_get_text_height", bind_jwidget_get_text_height }, - { "jwidget_noborders", bind_jwidget_noborders }, - { "jwidget_set_border", bind_jwidget_set_border }, - { "jwidget_set_rect", bind_jwidget_set_rect }, - { "jwidget_set_static_size", bind_jwidget_set_static_size }, - { "jwidget_set_bg_color", bind_jwidget_set_bg_color }, - { "jwidget_flush_redraw", bind_jwidget_flush_redraw }, - { "jwidget_redraw_region", bind_jwidget_redraw_region }, - { "jwidget_signal_on", bind_jwidget_signal_on }, - { "jwidget_signal_off", bind_jwidget_signal_off }, - { "jwidget_emit_signal", bind_jwidget_emit_signal }, - { "jwidget_send_message", bind_jwidget_send_message }, - { "jwidget_send_message_after_type", bind_jwidget_send_message_after_type }, - { "jwidget_close_window", bind_jwidget_close_window }, - { "jwidget_capture_mouse", bind_jwidget_capture_mouse }, - { "jwidget_hard_capture_mouse", bind_jwidget_hard_capture_mouse }, - { "jwidget_release_mouse", bind_jwidget_release_mouse }, - { "jwidget_find_name", bind_jwidget_find_name }, - { "jwidget_check_underscored", bind_jwidget_check_underscored }, - { "jwindow_new", bind_jwindow_new }, - { "jwindow_new_desktop", bind_jwindow_new_desktop }, - { "jwindow_get_killer", bind_jwindow_get_killer }, - { "jwindow_get_manager", bind_jwindow_get_manager }, - { "jwindow_moveable", bind_jwindow_moveable }, - { "jwindow_sizeable", bind_jwindow_sizeable }, - { "jwindow_ontop", bind_jwindow_ontop }, - { "jwindow_remap", bind_jwindow_remap }, - { "jwindow_center", bind_jwindow_center }, - { "jwindow_position", bind_jwindow_position }, - { "jwindow_move", bind_jwindow_move }, - { "jwindow_open", bind_jwindow_open }, - { "jwindow_open_fg", bind_jwindow_open_fg }, - { "jwindow_open_bg", bind_jwindow_open_bg }, - { "jwindow_close", bind_jwindow_close }, - { "jwindow_is_toplevel", bind_jwindow_is_toplevel }, - { "jwindow_is_foreground", bind_jwindow_is_foreground }, - { "jwindow_is_desktop", bind_jwindow_is_desktop }, - { "jwindow_is_ontop", bind_jwindow_is_ontop }, { NULL, NULL } }; @@ -6126,103 +3496,6 @@ struct _bindings_constants bindings_constants[] = { { "DITHERING_ORDERED", DITHERING_ORDERED }, { "CURVE_LINEAR", CURVE_LINEAR }, { "CURVE_SPLINE", CURVE_SPLINE }, - { "JI_HORIZONTAL", JI_HORIZONTAL }, - { "JI_VERTICAL", JI_VERTICAL }, - { "JI_LEFT", JI_LEFT }, - { "JI_CENTER", JI_CENTER }, - { "JI_RIGHT", JI_RIGHT }, - { "JI_TOP", JI_TOP }, - { "JI_MIDDLE", JI_MIDDLE }, - { "JI_BOTTOM", JI_BOTTOM }, - { "JI_HOMOGENEOUS", JI_HOMOGENEOUS }, - { "JI_WORDWRAP", JI_WORDWRAP }, - { "JI_HIDDEN", JI_HIDDEN }, - { "JI_SELECTED", JI_SELECTED }, - { "JI_DISABLED", JI_DISABLED }, - { "JI_HASFOCUS", JI_HASFOCUS }, - { "JI_HASMOUSE", JI_HASMOUSE }, - { "JI_HASCAPTURE", JI_HASCAPTURE }, - { "JI_FOCUSREST", JI_FOCUSREST }, - { "JI_MAGNETIC", JI_MAGNETIC }, - { "JI_EXPANSIVE", JI_EXPANSIVE }, - { "JI_DECORATIVE", JI_DECORATIVE }, - { "JI_AUTODESTROY", JI_AUTODESTROY }, - { "JI_HARDCAPTURE", JI_HARDCAPTURE }, - { "JI_INITIALIZED", JI_INITIALIZED }, - { "JI_WIDGET", JI_WIDGET }, - { "JI_BOX", JI_BOX }, - { "JI_BUTTON", JI_BUTTON }, - { "JI_CHECK", JI_CHECK }, - { "JI_COMBOBOX", JI_COMBOBOX }, - { "JI_ENTRY", JI_ENTRY }, - { "JI_IMAGE", JI_IMAGE }, - { "JI_LABEL", JI_LABEL }, - { "JI_LISTBOX", JI_LISTBOX }, - { "JI_LISTITEM", JI_LISTITEM }, - { "JI_MANAGER", JI_MANAGER }, - { "JI_MENU", JI_MENU }, - { "JI_MENUBAR", JI_MENUBAR }, - { "JI_MENUBOX", JI_MENUBOX }, - { "JI_MENUITEM", JI_MENUITEM }, - { "JI_PANEL", JI_PANEL }, - { "JI_RADIO", JI_RADIO }, - { "JI_SEPARATOR", JI_SEPARATOR }, - { "JI_SLIDER", JI_SLIDER }, - { "JI_TEXTBOX", JI_TEXTBOX }, - { "JI_VIEW", JI_VIEW }, - { "JI_VIEW_SCROLLBAR", JI_VIEW_SCROLLBAR }, - { "JI_VIEW_VIEWPORT", JI_VIEW_VIEWPORT }, - { "JI_WINDOW", JI_WINDOW }, - { "JI_USER_WIDGET", JI_USER_WIDGET }, - { "JM_OPEN", JM_OPEN }, - { "JM_CLOSE", JM_CLOSE }, - { "JM_DESTROY", JM_DESTROY }, - { "JM_DRAW", JM_DRAW }, - { "JM_IDLE", JM_IDLE }, - { "JM_SIGNAL", JM_SIGNAL }, - { "JM_REQSIZE", JM_REQSIZE }, - { "JM_SETPOS", JM_SETPOS }, - { "JM_WINMOVE", JM_WINMOVE }, - { "JM_DRAWRGN", JM_DRAWRGN }, - { "JM_DIRTYCHILDREN", JM_DIRTYCHILDREN }, - { "JM_CHAR", JM_CHAR }, - { "JM_KEYPRESSED", JM_KEYPRESSED }, - { "JM_KEYRELEASED", JM_KEYRELEASED }, - { "JM_FOCUSENTER", JM_FOCUSENTER }, - { "JM_FOCUSLEAVE", JM_FOCUSLEAVE }, - { "JM_BUTTONPRESSED", JM_BUTTONPRESSED }, - { "JM_BUTTONRELEASED", JM_BUTTONRELEASED }, - { "JM_DOUBLECLICK", JM_DOUBLECLICK }, - { "JM_MOUSEENTER", JM_MOUSEENTER }, - { "JM_MOUSELEAVE", JM_MOUSELEAVE }, - { "JM_MOTION", JM_MOTION }, - { "JM_WHEEL", JM_WHEEL }, - { "JI_SIGNAL_DIRTY", JI_SIGNAL_DIRTY }, - { "JI_SIGNAL_ENABLE", JI_SIGNAL_ENABLE }, - { "JI_SIGNAL_DISABLE", JI_SIGNAL_DISABLE }, - { "JI_SIGNAL_SELECT", JI_SIGNAL_SELECT }, - { "JI_SIGNAL_DESELECT", JI_SIGNAL_DESELECT }, - { "JI_SIGNAL_SHOW", JI_SIGNAL_SHOW }, - { "JI_SIGNAL_HIDE", JI_SIGNAL_HIDE }, - { "JI_SIGNAL_ADD_CHILD", JI_SIGNAL_ADD_CHILD }, - { "JI_SIGNAL_REMOVE_CHILD", JI_SIGNAL_REMOVE_CHILD }, - { "JI_SIGNAL_NEW_PARENT", JI_SIGNAL_NEW_PARENT }, - { "JI_SIGNAL_GET_TEXT", JI_SIGNAL_GET_TEXT }, - { "JI_SIGNAL_SET_TEXT", JI_SIGNAL_SET_TEXT }, - { "JI_SIGNAL_BUTTON_SELECT", JI_SIGNAL_BUTTON_SELECT }, - { "JI_SIGNAL_CHECK_CHANGE", JI_SIGNAL_CHECK_CHANGE }, - { "JI_SIGNAL_RADIO_CHANGE", JI_SIGNAL_RADIO_CHANGE }, - { "JI_SIGNAL_ENTRY_CHANGE", JI_SIGNAL_ENTRY_CHANGE }, - { "JI_SIGNAL_LISTBOX_CHANGE", JI_SIGNAL_LISTBOX_CHANGE }, - { "JI_SIGNAL_LISTBOX_SELECT", JI_SIGNAL_LISTBOX_SELECT }, - { "JI_SIGNAL_MANAGER_EXTERNAL_CLOSE", JI_SIGNAL_MANAGER_EXTERNAL_CLOSE }, - { "JI_SIGNAL_MANAGER_ADD_WINDOW", JI_SIGNAL_MANAGER_ADD_WINDOW }, - { "JI_SIGNAL_MANAGER_REMOVE_WINDOW", JI_SIGNAL_MANAGER_REMOVE_WINDOW }, - { "JI_SIGNAL_MANAGER_LOSTCHAR", JI_SIGNAL_MANAGER_LOSTCHAR }, - { "JI_SIGNAL_MENUITEM_SELECT", JI_SIGNAL_MENUITEM_SELECT }, - { "JI_SIGNAL_SLIDER_CHANGE", JI_SIGNAL_SLIDER_CHANGE }, - { "JI_SIGNAL_WINDOW_CLOSE", JI_SIGNAL_WINDOW_CLOSE }, - { "JI_SIGNAL_WINDOW_RESIZE", JI_SIGNAL_WINDOW_RESIZE }, { NULL, 0 } }; diff --git a/src/script/script.c b/src/script/script.c index 4f8a3eec1..f22e296af 100644 --- a/src/script/script.c +++ b/src/script/script.c @@ -27,6 +27,7 @@ #include "core/dirs.h" #include "modules/editors.h" #include "modules/sprites.h" +#include "modules/tools2.h" #include "script/bindings.h" #include "script/script.h" #include "widgets/editor.h" @@ -42,202 +43,191 @@ static lua_State *L; static int running = 0; -static void prepare (void); -static void release (void); +static void prepare(void); +static void release(void); /* Installs all the scripting capability. */ -int init_module_script (void) +int init_module_script(void) { /* create the main lua state */ - L = lua_open (); + L = lua_open(); if (!L) return -1; /* setup the garbage collector */ - lua_setgcthreshold (L, 0); + lua_setgcthreshold(L, 0); /* install the base library */ - lua_baselibopen (L); -/* lua_tablibopen (L); */ -/* lua_iolibopen (L); */ -/* lua_strlibopen (L); */ -/* lua_mathlibopen (L); */ -/* lua_dblibopen (L); */ + lua_baselibopen(L); +/* lua_tablibopen(L); */ +/* lua_iolibopen(L); */ +/* lua_strlibopen(L); */ +/* lua_mathlibopen(L); */ +/* lua_dblibopen(L); */ /* export C routines to use in Lua scripts */ - register_bindings (L); + register_bindings(L); /* object metatable */ - register_lua_object_metatable (); + register_lua_object_metatable(); return 0; } /* Removes the scripting feature. */ -void exit_module_script (void) +void exit_module_script(void) { /* remove object metatable */ - unregister_lua_object_metatable (); + unregister_lua_object_metatable(); /* delete Lua state */ - lua_close (L); + lua_close(L); L = NULL; } -lua_State *get_lua_state (void) +lua_State *get_lua_state(void) { return L; } -int script_is_running (void) +int script_is_running(void) { return (running > 0) ? TRUE: FALSE; } -void script_show_err (lua_State *L, int err) +void script_show_err(lua_State *L, int err) { switch (err) { case 0: /* nothing */ break; case LUA_ERRRUN: - console_printf ("** lua error (run): %s\n", lua_tostring (L, -1)); + console_printf("** lua error (run): %s\n", lua_tostring(L, -1)); break; case LUA_ERRFILE: - console_printf ("** lua error (file): %s\n", lua_tostring (L, -1)); + console_printf("** lua error (file): %s\n", lua_tostring(L, -1)); break; case LUA_ERRSYNTAX: - console_printf ("** lua error (syntax): %s\n", lua_tostring (L, -1)); + console_printf("** lua error (syntax): %s\n", lua_tostring(L, -1)); break; case LUA_ERRMEM: - console_printf ("** lua error (mem): %s\n", lua_tostring (L, -1)); + console_printf("** lua error (mem): %s\n", lua_tostring(L, -1)); break; case LUA_ERRERR: - console_printf ("** lua error (err): %s\n", lua_tostring (L, -1)); + console_printf("** lua error (err): %s\n", lua_tostring(L, -1)); break; default: - console_printf ("** lua error (unknown): %s\n", lua_tostring (L, -1)); + console_printf("** lua error (unknown): %s\n", lua_tostring(L, -1)); break; } } -int do_script_raw (lua_State *L, int nargs, int nresults) +int do_script_raw(lua_State *L, int nargs, int nresults) { int err; - prepare (); + prepare(); - err = lua_pcall (L, nargs, nresults, 0); + err = lua_pcall(L, nargs, nresults, 0); if (err != 0) - script_show_err (L, err); + script_show_err(L, err); - release (); + release(); return err; } -int do_script_expr (const char *exp) +int do_script_expr(const char *exp) { - int err = luaL_loadbuffer (L, exp, ustrlen (exp), exp); + int err = luaL_loadbuffer(L, exp, ustrlen(exp), exp); prepare (); if (err == 0) - err = lua_pcall (L, 0, LUA_MULTRET, 0); + err = lua_pcall(L, 0, LUA_MULTRET, 0); if (err != 0) - script_show_err (L, err); + script_show_err(L, err); - release (); + release(); return err; } -int do_script_file (const char *filename) +int do_script_file(const char *filename) { int found = FALSE; char buf[512]; int err; - PRINTF ("Calling script file \"%s\"\n", filename); + PRINTF("Calling script file \"%s\"\n", filename); - if (exists (filename)) { - ustrcpy (buf, filename); + if (exists(filename)) { + ustrcpy(buf, filename); found = TRUE; } else { DIRS *it, *dirs; - usprintf (buf, "scripts/%s", filename); - dirs = filename_in_datadir (buf); + usprintf(buf, "scripts/%s", filename); + dirs = filename_in_datadir(buf); for (it=dirs; it; it=it->next) { - if (exists (it->path)) { - ustrcpy (buf, it->path); + if (exists(it->path)) { + ustrcpy(buf, it->path); found = TRUE; break; } } - dirs_free (dirs); + dirs_free(dirs); } if (!found) { - console_printf (_("File not found: \"%s\"\n"), filename); + console_printf(_("File not found: \"%s\"\n"), filename); return -1; } - prepare (); + prepare(); - err = luaL_loadfile (L, buf); + err = luaL_loadfile(L, buf); if (err == 0) - err = lua_pcall (L, 0, LUA_MULTRET, 0); + err = lua_pcall(L, 0, LUA_MULTRET, 0); if (err != 0) - script_show_err (L, err); + script_show_err(L, err); - release (); + release(); return err; } -void load_all_scripts (void) -{ - struct al_ffblk fi; - DIRS *it, *dirs; - char buf[512]; - int done; - - dirs = filename_in_datadir ("scripts/*.lua"); - for (it=dirs; it; it=it->next) { - done = al_findfirst (it->path, &fi, FA_RDONLY | FA_SYSTEM | FA_ARCH); - while (!done) { - replace_filename (buf, it->path, fi.name, sizeof (buf)); - do_script_file (buf); - done = al_findnext (&fi); - } - al_findclose (&fi); - } - dirs_free (dirs); -} - -static void prepare (void) +/** + * Prepare the application to run a script. + */ +static void prepare(void) { if (running == 0) { - console_open (); - update_global_script_variables (); + ResetConfig(); + console_open(); + update_global_script_variables(); } running++; } -static void release (void) +/** + * Restore the configuration of the application after running a + * script. + */ +static void release(void) { running--; if (running == 0) { - console_close (); + RestoreConfig(); + console_close(); if (current_editor) - set_current_sprite (editor_get_sprite (current_editor)); + set_current_sprite(editor_get_sprite(current_editor)); } } diff --git a/src/script/script.h b/src/script/script.h index d44251398..bf4848787 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -24,18 +24,16 @@ #include "lua.h" #include "lualib.h" -int init_module_script (void); -void exit_module_script (void); +int init_module_script(void); +void exit_module_script(void); -lua_State *get_lua_state (void); +lua_State *get_lua_state(void); -int script_is_running (void); -void script_show_err (lua_State *L, int err); +int script_is_running(void); +void script_show_err(lua_State *L, int err); -int do_script_raw (lua_State *L, int nargs, int nresults); -int do_script_expr (const char *expr); -int do_script_file (const char *filename); - -void load_all_scripts (void); +int do_script_raw(lua_State *L, int nargs, int nresults); +int do_script_expr(const char *expr); +int do_script_file(const char *filename); #endif /* SCRIPT_H */ diff --git a/src/widgets/statebar.c b/src/widgets/statebar.c index 6678f903d..c2f1ee230 100644 --- a/src/widgets/statebar.c +++ b/src/widgets/statebar.c @@ -150,7 +150,7 @@ void status_bar_set_text(JWidget widget, int msecs, const char *format, ...) widget->text = buf ? jstrdup (buf) : NULL; status_bar->timeout = ji_clock + JI_TICKS_PER_SEC*msecs/1000; - jwidget_dirty (widget); + jwidget_dirty(widget); } } @@ -177,6 +177,8 @@ void status_bar_add_progress(JWidget widget, int max) status_bar->progress[n].max = max; status_bar->progress[n].pos = 0; + ji_dirty_region = jregion_new(NULL, 0); + jwidget_dirty(widget); } @@ -193,6 +195,9 @@ void status_bar_del_progress(JWidget widget) jmanager_dispatch_messages(); rest(5); jwidget_dirty(widget); + + jregion_free(ji_dirty_region); + ji_dirty_region = NULL; } status_bar->nprogress--;