Thread: [Waba-commits] CVS: waba/src/linux debug.c,NONE,1.1 debug.h,NONE,1.1 gdk-pixbuf-xlibrgb.c,NONE,1.1 g
Status: Abandoned
Brought to you by:
bornet
From: Manfred R. <mr...@us...> - 2004-12-20 23:37:41
|
Update of /cvsroot/waba/waba/src/linux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27256 Added Files: debug.c debug.h gdk-pixbuf-xlibrgb.c gdk-pixbuf-xlibrgb.h jar.c jar.h jar2host.h nm_linux_a.c nm_linux_a.h nm_linux_b.c nm_linux_b.h nm_linux_c.c nm_linux_c.h ui_gtk.c ui_gtk.h ui_none.c ui_none.h ui_pgui.c ui_pgui.h ui_x.c ui_x.h Log Message: Added to correct location --- NEW FILE: debug.c --- /* $Id: debug.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #include "../waba.h" #ifdef DEBUG char* UTF2CSTR(UtfString *utf) { typedef char buf[255]; static buf utf_buf[16]; static int ix = 0; char *b; ix++; ix&=15; b = &utf_buf[ix][0]; xstrncpy(b, utf->str, utf->len); b[utf->len]=0; return b; } #else /* !DEBUG */ /* * static void _dummy_(char* d, ...) {} */ #endif --- NEW FILE: debug.h --- /* $Id: debug.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __WABA_DEBUG_H #define __WABA_DEBUG_H #ifdef DEBUG #define DPUTS puts #define DPRINTF printf char* UTF2CSTR(UtfString *utf); #else /* !DEBUG */ static void _dummy_(char* d, ...){}; # define DPUTS _dummy_ # define DPRINTF _dummy_ # define UTF2CSTR(utf) "" #endif #endif /* WABA_DEBUG_H */ --- NEW FILE: gdk-pixbuf-xlibrgb.c --- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "MPL"); you may not use this file except in * compliance with the MPL. You may obtain a copy of the MPL at * http://www.mozilla.org/MPL/ * * Software distributed under the MPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL * for the specific language governing rights and limitations under the * MPL. * * Alternatively, the contents of this file may be used under the * terms of the GNU Library General Public License (the "LGPL"), in * which case the provisions of the LGPL are applicable instead of * those above. If you wish to allow use of your version of this file * only under the terms of the LGPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and [...3691 lines suppressed...] return image_info->display; return NULL; } /** * xlib_rgb_get_screen: * * Queries the screen that XlibRGB is using. * * Return value: An X screen. **/ Screen * xlib_rgb_get_screen (void) { if (image_info) return image_info->screen; return NULL; } --- NEW FILE: gdk-pixbuf-xlibrgb.h --- /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "MPL"); you may not use this file except in * compliance with the MPL. You may obtain a copy of the MPL at * http://www.mozilla.org/MPL/ * * Software distributed under the MPL is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL * for the specific language governing rights and limitations under the * MPL. * * Alternatively, the contents of this file may be used under the * terms of the GNU Library General Public License (the "LGPL"), in * which case the provisions of the LGPL are applicable instead of * those above. If you wish to allow use of your version of this file * only under the terms of the LGPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the LGPL. If you do not delete the * provisions above, a recipient may use your version of this file * under either the MPL or the LGPL. */ /* * This code is derived from GdkRgb. * For more information on GdkRgb, see http://www.levien.com/gdkrgb/ * Raph Levien <ra...@ac...> */ /* Ported by Christopher Blizzard to Xlib. With permission from the * original authors of this file, the contents of this file are also * redistributable under the terms of the Mozilla Public license. For * information about the Mozilla Public License, please see the * license information at http://www.mozilla.org/MPL/ */ /* This code is copyright the following authors: * Raph Levien <ra...@ac...> * Manish Singh <ma...@gt...> * Tim Janik <ti...@gt...> * Peter Mattis <pe...@xc...> * Spencer Kimball <sp...@xc...> * Josh MacDonald <jm...@xc...> * Christopher Blizzard <bli...@re...> * Owen Taylor <ot...@re...> * Shawn T. Amundson <amu...@gt...> */ #ifndef __XLIB_RGB_H__ #define __XLIB_RGB_H__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <X11/Intrinsic.h> #include <glib.h> typedef struct _XlibRgbCmap XlibRgbCmap; struct _XlibRgbCmap { unsigned int colors[256]; unsigned char lut[256]; /* for 8-bit modes */ }; void xlib_rgb_init (Display *display, Screen *screen); void xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth); unsigned long xlib_rgb_xpixel_from_rgb (guint32 rgb); void xlib_rgb_gc_set_foreground (GC gc, guint32 rgb); void xlib_rgb_gc_set_background (GC gc, guint32 rgb); typedef enum { XLIB_RGB_DITHER_NONE, XLIB_RGB_DITHER_NORMAL, XLIB_RGB_DITHER_MAX } XlibRgbDither; void xlib_draw_rgb_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride); void xlib_draw_rgb_image_dithalign (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride, int xdith, int ydith); void xlib_draw_rgb_32_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride); void xlib_draw_gray_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride); XlibRgbCmap * xlib_rgb_cmap_new (guint32 *colors, int n_colors); void xlib_rgb_cmap_free (XlibRgbCmap *cmap); void xlib_draw_indexed_image (Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride, XlibRgbCmap *cmap); /* Below are some functions which are primarily useful for debugging and experimentation. */ Bool xlib_rgb_ditherable (void); void xlib_rgb_set_verbose (Bool verbose); /* experimental colormap stuff */ void xlib_rgb_set_install (Bool install); void xlib_rgb_set_min_colors (int min_colors); Colormap xlib_rgb_get_cmap (void); Visual * xlib_rgb_get_visual (void); XVisualInfo * xlib_rgb_get_visual_info (void); int xlib_rgb_get_depth (void); Display * xlib_rgb_get_display (void); Screen * xlib_rgb_get_screen (void); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __XLIB_RGB_H__ */ --- NEW FILE: jar.c --- /* $Id: jar.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 2000, 2001 Chirag Kantharia This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <zlib.h> #include "jar.h" #include "jar2host.h" /* provide swap or not depending of the endianess of the host */ #define err_exit(msg) { perror(msg); exit(-1); } unsigned char * getClassFrmOffset(FILE *, struct CentralDirRecord *, int *); unsigned char * loadClassFrmJar(char * jar, char * classname, int * size) { FILE * fp; unsigned char * class; char * classfilename; int classfilename_len; volatile int ret, i, len; #ifdef _DEBUG unsigned int tmp4; #endif struct EndCentralDirRecord endrec; class = NULL; len = strlen(classname); if(!(classfilename = malloc(len + 7))) err_exit("malloc"); strncpy(classfilename, classname, len); strncpy(classfilename + len, ".class", 6); classfilename[len + 6] = '\0'; classfilename_len = len + 6; if (!(fp = fopen(jar, "r"))) err_exit("fopen"); ret = fseek(fp, -22, SEEK_END); if (ret != 0) err_exit("fseek"); #ifdef _DEBUG ret = fread(&tmp4, sizeof(unsigned int), 1, fp); if (ret != 1) err_exit("fread"); tmp4 = jar2host_l( tmp4 ); if (tmp4 != END_OF_CENTRAL_DIR_SIGNATURE) err_exit("end of central dir signature"); fseek(fp, -sizeof(unsigned int), SEEK_CUR); #endif ret = fread(&endrec, sizeof(struct EndCentralDirRecord), 1, fp); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ endrec.sig = jar2host_l( endrec.sig ); endrec.this_disk_num = jar2host_s( endrec.this_disk_num ); endrec.start_disk_num_with_cdr = jar2host_s( endrec.start_disk_num_with_cdr ); endrec.this_disk_nentries = jar2host_s( endrec.this_disk_nentries ); endrec.nentries = jar2host_s( endrec.nentries ); endrec.cd_size = jar2host_l( endrec.cd_size ); endrec.cd_offset = jar2host_l( endrec.cd_offset ); endrec.zip_file_comment_len = jar2host_s( endrec.zip_file_comment_len ); #ifdef _DEBUG printf("sig = %p\n", (int *)endrec.sig); printf("nentries = %d\n", endrec.nentries); printf("cd_size = %d\n", endrec.cd_size); printf("cd_offset = %d\n", endrec.cd_offset); printf("zip_file_comment_len = %d\n", endrec.zip_file_comment_len); if (endrec.zip_file_comment_len > 0) { char * comment; if (!(comment = malloc(endrec.zip_file_comment_len + 1))) err_exit("malloc"); ret = fread(comment, 1, endrec.zip_file_comment_len, fp); if (ret != endrec.zip_file_comment_len) err_exit("fread"); comment[endrec.zip_file_comment_len] = '\0'; printf("zip_file_comment = %s\n", comment); free(comment); } #else if (endrec.zip_file_comment_len > 0) fseek(fp, endrec.zip_file_comment_len, SEEK_CUR); #endif ret = fseek(fp, endrec.cd_offset, SEEK_SET); if (ret != 0) err_exit("fseek"); for(i = 0; i < endrec.nentries; i++) { struct CentralDirRecord cdr; char * filename; char * extra_field; char * file_comment; ret = fread(&cdr, sizeof(struct CentralDirRecord), 1, fp); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ cdr.sig = jar2host_l( cdr.sig ); cdr.version_created = jar2host_s( cdr.version_created ); cdr.version_req = jar2host_s( cdr.version_req ); cdr.flag = jar2host_s( cdr.flag ); cdr.compression_method = jar2host_s( cdr.compression_method ); cdr.mtime = jar2host_s( cdr.mtime ); cdr.mdate = jar2host_s( cdr.mdate ); cdr.crc = jar2host_l( cdr.crc ); cdr.csize = jar2host_l( cdr.csize ); cdr.ucsize = jar2host_l( cdr.ucsize ); cdr.fnlen = jar2host_s( cdr.fnlen ); cdr.eflen = jar2host_s( cdr.eflen ); cdr.fcommentlen = jar2host_s( cdr.fcommentlen ); cdr.disknum = jar2host_s( cdr.disknum ); cdr.ifattr = jar2host_s( cdr.ifattr ); cdr.efattr = jar2host_l( cdr.efattr ); cdr.lhoff = jar2host_l( cdr.lhoff ); if (cdr.fnlen > 0) { if (!(filename = malloc(cdr.fnlen + 1))) err_exit("malloc"); ret = fread(filename, 1, cdr.fnlen, fp); if (ret != cdr.fnlen) err_exit("fread"); filename[cdr.fnlen] = '\0'; } #ifdef _DEBUG if (cdr.eflen > 0) { if (!(extra_field = malloc(cdr.eflen + 1))) err_exit("malloc"); ret = fread(extra_field, 1, cdr.eflen, fp); if (ret != cdr.eflen) err_exit("fread"); extra_field[cdr.eflen] = '\0'; printf("extra_field = %s\n", extra_field); free(extra_field); } #else if (cdr.eflen > 0) fseek(fp, cdr.eflen, SEEK_CUR); #endif #ifdef _DEBUG if (cdr.fcommentlen > 0) { if (!(file_comment = malloc(cdr.fcommentlen + 1))) err_exit("malloc"); ret = fread(file_comment, 1, cdr.fcommentlen, fp); if (ret != cdr.fcommentlen) err_exit("fread"); file_comment[cdr.fcommentlen] = '\0'; printf("file_comment: %s\n", file_comment); free(file_comment); } #else if (cdr.fcommentlen > 0) fseek(fp, cdr.fcommentlen, SEEK_CUR); #endif if (strncmp(classfilename, filename, classfilename_len) == 0) { int real_size; class = getClassFrmOffset(fp, &cdr, &real_size); *size = real_size; break; } } fclose(fp); free(classfilename); return class; } unsigned char * getClassFrmOffset(FILE * jarfile, struct CentralDirRecord * cdr, int * rsize) { struct LocalFileHeader lfh; Bytef * next_in, * next_out; z_stream z; int ret; int _csize, _ucsize; ret = fseek(jarfile, cdr->lhoff, SEEK_SET); if (ret != 0) err_exit("fseek"); ret = fread(&lfh, sizeof(struct LocalFileHeader), 1, jarfile); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ lfh.sig = jar2host_l( lfh.sig ); lfh.version_req = jar2host_s( lfh.version_req ); lfh.flag = jar2host_s( lfh.flag ); lfh.compression_method = jar2host_s( lfh.compression_method ); lfh.mtime = jar2host_s( lfh.mtime ); lfh.mdate = jar2host_s( lfh.mdate ); lfh.crc = jar2host_l( lfh.crc ); lfh.csize = jar2host_l( lfh.csize ); lfh.ucsize = jar2host_l( lfh.ucsize ); lfh.fnlen = jar2host_s( lfh.fnlen ); lfh.eflen = jar2host_s( lfh.eflen ); #ifdef _DEBUG // printf("offset = %d\n", offset); #endif #ifdef _DEBUG printf("compression_method = %d\n", lfh.compression_method); #endif #ifdef _DEBUG { char * filename; if (!(filename = malloc(lfh.fnlen + 1))) err_exit("malloc"); ret = fread(filename, lfh.fnlen, 1, jarfile); if (ret != 1) err_exit("fread"); filename[lfh.fnlen] = '\0'; printf("filename = %s\n", filename); free(filename); } #else fseek(jarfile, lfh.fnlen, SEEK_CUR); #endif _csize = (lfh.csize == 0) ? cdr->csize : lfh.csize; _ucsize = (lfh.ucsize == 0) ? cdr->ucsize : lfh.ucsize; if (!(next_in = malloc(_csize))) err_exit("malloc"); ret = fread(next_in, 1, _csize, jarfile); if (ret != _csize) err_exit("fread"); #ifdef _DEBUG printf("compressed data size = %x\n", _csize); printf("uncompressed data size = %x\n", _ucsize); #endif if (lfh.flag & HAS_DATA_DESCRIPTOR) { struct DataDescriptorRecord ddr; ret = fread(&ddr, sizeof(struct DataDescriptorRecord), 1, jarfile); if (ret != 1) err_exit("fread"); /* convert from jar to host the readed informations */ ddr.sig = jar2host_l( ddr.sig ); ddr.crc = jar2host_l( ddr.crc ); ddr.csize = jar2host_l( ddr.csize ); ddr.ucsize = jar2host_l( ddr.ucsize ); #ifdef _DEBUG if (ddr.sig != EXTENDED_LOCAL_FILE_HEADER_SIGNATURE) err_exit("data descriptor signature!"); #endif _csize = ddr.csize; _ucsize = ddr.ucsize; } *rsize = _ucsize; switch(lfh.compression_method) { case 0: next_out = next_in; break; case 8: if (!(next_out = malloc(_ucsize))) err_exit("malloc"); z.next_in = next_in; z.avail_in = _csize; z.next_out = next_out; z.avail_out = _ucsize; z.zalloc = (alloc_func)Z_NULL; z.zfree = (free_func)Z_NULL; z.opaque = Z_NULL; ret = inflateInit2(&z, -MAX_WBITS); if (ret != Z_OK) err_exit("inflateInit2"); while (z.total_in < _csize) { ret = inflate(&z, Z_SYNC_FLUSH); if (ret == Z_STREAM_END) break; if (z.msg) err_exit(z.msg); } ret = inflateEnd(&z); if (ret != Z_OK) err_exit("inflateEnd"); break; } return (unsigned char *)next_out; } --- NEW FILE: jar.h --- /* $Id: jar.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 2000, 2001 Chirag Kantharia This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JAR_H_ #define __JAR_H_ #define LOCAL_FILE_HEADER_SIGNATURE 0x04034b50 #define EXTENDED_LOCAL_FILE_HEADER_SIGNATURE 0x08074b50 #define CENTRAL_FILE_HEADER_SIGNATURE 0x02014b50 #define END_OF_CENTRAL_DIR_SIGNATURE 0x06054b50 #define HAS_DATA_DESCRIPTOR 0x8 struct LocalFileHeader { int sig; /* 0x04034b50 */ short version_req; short flag; short compression_method; short mtime; short mdate; int crc; unsigned int csize; unsigned int ucsize; unsigned short fnlen; unsigned short eflen; } __attribute__ ((packed)); struct CentralDirRecord { int sig; /* 0x02014b50 */ short version_created; short version_req; short flag; short compression_method; short mtime; short mdate; int crc; unsigned int csize; unsigned int ucsize; unsigned short fnlen; unsigned short eflen; unsigned short fcommentlen; unsigned short disknum; short ifattr; int efattr; unsigned int lhoff; } __attribute__ ((packed)); struct EndCentralDirRecord { int sig; /* 0x06054b50 */ unsigned short this_disk_num; unsigned short start_disk_num_with_cdr; unsigned short this_disk_nentries; unsigned short nentries; unsigned int cd_size; unsigned int cd_offset; unsigned short zip_file_comment_len; } __attribute__ ((packed)); struct DataDescriptorRecord { int sig; /* 0x08074b50 */ int crc; int csize; int ucsize; } __attribute__ ((packed)); extern unsigned char * loadClassFrmJar(char * jar, char * classname, int * size); #endif /* #ifndef __JAR_H_ */ --- NEW FILE: jar2host.h --- /* $Id: jar2host.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ * * jar2host.h - definition of jar2host functions * * Copyright (C) 2001 SMARTDATA * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Contributors: * * * */ #ifndef __JAR2HOST_H__ #define __JAR2HOST_H__ #ifdef WORDS_BIGENDIAN /* as the jar files are little endian by default, we must swap */ # define jar2host_l(x) ((__u32)( \ (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) # define jar2host_s(x) ((__u16)( \ (((__u16)(x) & (__u16)0x00ffU) << 8) | \ (((__u16)(x) & (__u16)0xff00U) >> 8) )) #else /* no swap, because we are little endian, same as the jar files */ # define jar2host_l(x) ((unsigned int)(x)) # define jar2host_s(x) ((unsigned short)(x)) #endif /* WORDS_BIGENDIAN */ #endif /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_a.c --- /* $Id: nm_linux_a.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_a.c. Please read it before porting or modify this port. Linux port. =========== */ typedef unsigned long uint32; /* all the needed include */ #include "../waba.h" #ifndef LINUX # error You must define the LINUX symbol as gcc parameter (-DLINUX=1) #endif #ifndef FASTANDBIG uint32 getUInt32(uchar *b) { return (uint32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } uint16 getUInt16(uchar *b) { return (uint16)(((b)[0]<<8)|(b)[1]); } int32 getInt32(uchar *b) { return (int32)( (uint32)((b)[0])<<24 | (uint32)((b)[1])<<16 | (uint32)((b)[2])<<8 | (uint32)((b)[3]) ); } int16 getInt16(uchar *b) { return (int16)(((b)[0]<<8)|(b)[1]); } #endif /* ifndef FASTANDBIG */ #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf) { float64HiLo fhl; fhl.ul.lo = getInt32( buf ); fhl.ul.hi = getInt32( buf + 4 ); return fhl.value; } // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf) { int64HiLo ihl; ihl.ul.lo = getInt32( buf ); ihl.ul.hi = getInt32( buf + 4 ); return ihl.value; } #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf) { uint32 i; float32 f; // we need to make sure we're aligned before casting i = ((uint32)buf[0] << 24) | ((uint32)buf[1] << 16) | ((uint32)buf[2] << 8 ) | (uint32)buf[3]; f = *((float32 *)&i); return f; } /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_a.h --- /* $Id: nm_linux_a.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __NM_LINUX_A_H__ #define __NM_LINUX_A_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_a.c. Please read it before porting or modify this port. Linux port. =========== */ /* all the needed include */ #include <stdlib.h> #include <string.h> #ifndef LINUX # error You must define the LINUX symbol as gcc parameter (-DLINUX=1) #endif #define FREE_ON_EXIT 1 #undef SECURE_CLASS_HEAP //#define SECURE_CLASS_HEAP 1 #ifdef SECURE_CLASS_HEAP # define LOCK_CLASS_HEAP MemSemaphoreReserve(1); # define UNLOCK_CLASS_HEAP MemSemaphoreRelease(1); #else # define LOCK_CLASS_HEAP ; # define UNLOCK_CLASS_HEAP ; #endif /******************************************************************************** TYPE DEFINITIONS ********************************************************************************/ /* for the types, we use the GLib library of the GTK project. See http://www.gtk.org for more informations */ #ifdef USE_GLIB /* use glib for types */ #include <glib.h> #else /* we don't use glib, so we need to define g... types */ #define guchar unsigned char #define gint32 int #define guint32 unsigned int #define gfloat float #define gint16 short #define guint16 unsigned short #define gint int #define guint unsigned int #define gchar char #ifdef WITH_64BITS #define gint64 long long #define guint64 unsigned long long #define gdouble double #endif /* WITH_64BITS */ #define TRUE 1 #define FALSE 0 #endif /* ifdef USE_GLIB ... else ... */ // - uchar is an 8 bit unsigned value #define uchar guchar // - int32 is a signed 32 bit value #define int32 gint32 // - uint32 is an unsigned 32 bit value #define uint32 guint32 // - float32 is a signed 32 bit floating point value #define float32 gfloat // - int16 is a signed 16 bit value #define int16 gint16 // - uint16 is an unsigned 16 bit value #define uint16 guint16 #ifdef WITH_64BITS // - int64 is a signed 64 bit value #define int64 gint64 // - uint64 is an unsigned 64 bit value #define uint64 guint64 // - float64 is a signed 64 bit floating point value #define float64 gdouble // --- define a struct for double and long support in two Var ... // ... the hi/lo decomposition typedef struct { uint32 lo; uint32 hi; } HiLoDoubleOrLong; //... for the double typedef union { float64 value; HiLoDoubleOrLong ul; } float64HiLo; //... for the long typedef union { int64 value; HiLoDoubleOrLong ul; } int64HiLo; #endif /* WITH_64BITS */ /******************************************************************************** TYPE CONVERTERS ********************************************************************************/ #ifdef FASTANDBIG # define getUInt32(b) (uint32)( (uint32)((b)[0])<<24 | \ (uint32)((b)[1])<<16 | \ (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) # define getUInt16(b) (uint16)( ((b)[0]<<8)|(b)[1] ) # define getInt32(b) (int32) ( (uint32)((b)[0])<<24 | \ (uint32)((b)[1])<<16 | \ (uint32)((b)[2])<<8 | (uint32)((b)[3]) ) # define getInt16(b) (int16) ( ((b)[0]<<8)|(b)[1] ) #else uint32 getUInt32(uchar *b); uint16 getUInt16(uchar *b); int32 getInt32(uchar *b); int16 getInt16(uchar *b); #endif /* ifdef FASTANDBIG */ #ifdef WITH_64BITS // get one 64 float value from buf and return it float64 getFloat64bits(uchar *buf); // get one 64 float value from buf and return it int64 getInt64bits(uchar *buf); #endif /* WITH_64BITS */ float32 getFloat32(uchar *buf); /******************************************************************************** "STRING" FUNCTIONS ********************************************************************************/ #define xstrncmp(s1, s2, n) strncmp(s1, s2, n) #define xstrncpy(dst, src, n) strncpy(dst, src, n) #define xstrlen(s) strlen(s) #define xstrcat(dst, src) strcat(dst, src) #define xmemmove(dst, src, size) memmove(dst, src, size) #define xmemzero(mem, len) memset(mem, 0, len ) /******************************************************************************** DYNAMIC ALLOCATION FUNCTIONS ********************************************************************************/ #define xmalloc(size) malloc(size) #define xfree(p) free(p) /******************** TO REMOVE *********************/ #include <stdio.h> /******************************************************************** * Elementary data types ********************************************************************/ // Fixed size data types typedef char SByte; // 8 bits #ifndef __TYPES__ // (Already defined in CW11) typedef unsigned char Byte; #endif typedef short SWord; // 16 bits typedef unsigned short Word; typedef long SDWord; // 32 bits typedef unsigned long DWord; // Logical data types #ifndef __TYPES__ // (Already defined in CW11) typedef unsigned char Boolean; #endif typedef char Char; // Used for character strings typedef unsigned char UChar; typedef short Short; // >= Byte typedef unsigned short UShort; typedef short Int; // >= Word (use short so MPW and CW agree) typedef unsigned short UInt; typedef long Long; // >= DWord typedef unsigned long ULong; typedef short Err; typedef DWord LocalID; // local (card relative) chunk ID /************************************************************ * Pointer Types *************************************************************/ typedef void* VoidPtr; typedef VoidPtr* VoidHand; // Fixed size data types typedef SByte* SBytePtr; #ifndef __TYPES__ // (Already defined in CW11) typedef Byte* BytePtr; #endif typedef SWord* SWordPtr; typedef Word* WordPtr; typedef SDWord* SDWordPtr; typedef DWord* DWordPtr; // Logical data types typedef Boolean* BooleanPtr; typedef Char* CharPtr; typedef UChar* UCharPtr; typedef Short* ShortPtr; typedef UShort* UShortPtr; typedef Int* IntPtr; typedef UInt* UIntPtr; typedef Long* LongPtr; typedef ULong* ULongPtr; // Include the following typedefs if types.h wasn't read. #ifndef __TYPES__ // Generic Pointer types used by Memory Manager // We have to define Ptr as char* because that's what the Mac includes do. typedef char* Ptr; // global pointer typedef Ptr* Handle; // global handle // Function types typedef Long (*ProcPtr)(); #endif /* __TYPES__ */ /************************************************************ * Common constants *************************************************************/ #ifndef NULL # define NULL 0 #endif // NULL // Include the following typedefs if types.h wasn't read. #ifndef __TYPES__ #ifdef __MWERKS__ #if !__option(bool) #ifndef true #define true 1 #endif #ifndef false #define false 0 #endif #endif #else enum {false, true}; #endif #endif /* __TYPES__ */ #endif /* __NM_LINUX_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_b.c --- /* $Id: nm_linux_b.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ [...1489 lines suppressed...] globalNetState = NET_READY_FOR_OPEN; if (!isApplication) { ui_MainLoop(); } stopApp(mainWinObj); if (globalNetState == NET_IS_OPEN) ; // TODO: NetLibClose(globalSocketLibRefNum, false); ui_exit(0); } /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_b.h --- /* $Id: nm_linux_b.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __NM_LINUX_B_H__ #define __NM_LINUX_B_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_b.c. Please read it before porting or modify this port. Linux port. =========== */ /* which GUI to use ? At this time, only GUI_GTK and GUI_PGUI is implemented */ #if defined(GUI_X) # include "ui_x.h" #elif defined(GUI_GTK) # include "ui_gtk.h" #elif defined(GUI_PGUI) # include "ui_pgui.h" #elif defined(GUI_NONE) # include "ui_none.h" #else # error you must define GUI_... to choose a GUI system #endif /* globals */ #define NET_NOT_READY_FOR_OPEN 0 #define NET_READY_FOR_OPEN 1 #define NET_IS_OPEN 2 #define NET_OPEN_FAILED 3 /**************** which are needed ? */ extern WObject globalMainWin; /* extern int32 globalTimerInterval; extern int32 globalTimerStart; extern int classDbCount; extern ULong appCreatorId; extern Word globalSocketLibRefNum; extern int globalNetState; #ifdef QUICKBIND extern int32 postEventMethodMapNum; extern int32 onTimerTickMethodMapNum; #endif */ /*************************************/ /* the size/properties of the MainWindow */ extern int32 hwr_bpp; extern int32 hwr_width; extern int32 hwr_height; extern int isApplication; #define HELPER #define PUBLIC #define WARN_NA(s) printf("### Warning: not implmented: %s\n", #s) #define MEM_CACHING 0 #define MAX_CLASSPATHS 20 static int numClassPaths = -1; static char *classPaths[MAX_CLASSPATHS]; static char *classpath = 0; static int is_ui_inited = 0; HELPER void * ui_init(); uchar *readFileIntoMemory( char *path, int nullTerminate, uint32 *size ); #ifdef WITH_THREAD //*** Isao's Multithread implementation START *** typedef struct { //Use either "syncObj" or "syncMethod", //Not both at the same time. WObject syncObj; WClassMethod* syncMethod; } WSync; typedef struct { WObject signalObj; } WSignal; typedef struct _queue { struct _queue *next; struct _queue *prev; } Queue; typedef struct { Queue queue; /* 'Queue' must be first to use type cast trick. */ WClass* tClass; WObject tObject; WSync wSyncObj; WSignal wSignal; int32 runMethodMapNum; uint32 sleepCountSet; uint32 sleepCountNow; uchar isSleepCountAlreadySet; uchar isWaiting; } WThread; // Thread variables - Isao F. Yamashita 07/25/2000 #define THREAD_LIST_MAX_SIZE 8 extern int InitThread(uint32 stacksize); //*** This "_onThreadStart()" method is called from "start()" method. extern Var ThreadStart(Var stack[]); //*** This "_onThreadStop()" method is called from "stop()" method. extern Var ThreadStop(Var stack[]); //*** This "_onThreadSleep()" method is called from "sleep()" method. extern Var ThreadSleep(Var stack[]); //*** This "_onThreadWait()" method is called from "wait()" method. extern Var ThreadWaitForSignal(Var stack[]); extern Var ThreadSignalAll(Var stack[]); //*** Isao's Multithread implementation END *** //*** This "ThreadCurrentThread()" method is called from "curentThread()" method. extern Var ThreadCurrentThread(Var stack[]); #define THERE_IS_SOME_THREADS (threadListCurrentSize > 0) void tickThread(void); int registerAsSyncronized(WClassMethod* method); void exitFromSyncronized(WClassMethod* method); int enterMonitor(WObject obj); int exitMonitor(WObject obj); #endif /* WITH_THREAD */ /* get/set the properties of the main window */ #endif /* __NM_LINUX_B_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_c.c --- /* $Id: nm_linux_c.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 1998, 1999, 2000 Wabasoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ [...4551 lines suppressed...] /* * Registry destructor */ void RegistryDestroy (WObject registry) { char * fileName; InternalRegistryClose (registry); fileName = (char *) WOBJ_RegistryFileName (registry); free (fileName); } #endif /* #ifdef BEE_BIOS #else */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: nm_linux_c.h --- /* $Id: nm_linux_c.h,v 1.1 2004/12/20 23:37:32 mriem Exp $ */ #ifndef __NM_LINUX_C_H__ #define __NM_LINUX_C_H__ /* Copyright (C) 1998, 1999, 2000 Wabasoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ More help for porting is include in the file nmport_c.c. Please read it before porting or modify this port. Linux port. =========== */ /* default font parameters */ #define DEFAULT_FONT "helvetica" #define DEFAULT_FONT_SIZE 10 /* usefull for some implementation, like Solaris */ #ifndef INADDR_NONE #define INADDR_NONE ((unsigned long) -1) #endif void WindowDestroy(WObject obj); void MainWinDestroy(WObject obj); void GraphicsDestroy(WObject obj); void ImageDestroy(WObject obj); #if WITH_CATALOG_CLASS void CatalogDestroy(WObject obj); #endif void FileDestroy(WObject obj); void SocketDestroy(WObject obj); void SerialPortDestroy(WObject obj); void RegistryDestroy(WObject obj); void EditDestroy(WObject obj); /* to have a explanation of the following structure, see the the file nmport_c.c and my small explanation of how to access class variable below */ extern ClassHook classHooks[]; #define FUNC(f) extern Var f (Var stack[]) /* all the native functions */ FUNC(VmPrintLn); FUNC(VmPrint); FUNC(VmExec); FUNC(VmGetTimeStamp); FUNC(copyArray); FUNC(VmExit); FUNC(VmSleep); FUNC(VmSetDeviceAutoOff); FUNC(VmGetUserName); FUNC(VmGetPlatform); FUNC(VmIsColor); FUNC(FileGetLength); FUNC(FileCreateDir); FUNC(FileReadBytes); FUNC(FileRename); FUNC(FileCreate); FUNC(FileWriteBytes); FUNC(FileListDir); FUNC(FileSeekWaba); FUNC(FileIsDir); FUNC(FileCloseWaba); FUNC(FileIsOpen); FUNC(FileDeleteWaba); FUNC(FileExists); FUNC(ImageCreate); FUNC(ImageFree); FUNC(ImageSetPixels); FUNC(ImageUseImagePalette); FUNC(ImageLoad); FUNC(SoundBeep); FUNC(SoundTone); FUNC(TimeCreate); FUNC(SocketCreate); FUNC(SocketRead); FUNC(SocketWrite); FUNC(SocketSetReadTimeout); FUNC(SocketClose); FUNC(SocketIsOpen); FUNC(WindowCreate); #ifdef WITH_CATALOG_CLASS FUNC(CatalogListCatalogs); FUNC(CatalogAddRecord); FUNC(CatalogSkipBytes); FUNC(CatalogCreate); FUNC(CatalogRead); FUNC(CatalogDeleteRecord); FUNC(CatalogSetRecordPos); FUNC(CatalogGetRecordSize); FUNC(CatalogResizeRecord); FUNC(CatalogWrite); FUNC(CatalogGetRecordCount); FUNC(CatalogClose); FUNC(CatalogIsOpen); FUNC(CatalogDelete); #endif FUNC(GraphicsCopyRect); FUNC(GraphicsClearClip); FUNC(GraphicsSetFont); FUNC(GraphicsSetDrawOp); FUNC(GraphicsSetClip); FUNC(GraphicsSetBackColor); FUNC(GraphicsSetColor); FUNC(GraphicsGetClip); FUNC(GraphicsFillRect); FUNC(GraphicsDrawLine); FUNC(GraphicsTranslate); FUNC(GraphicsDrawDots); FUNC(GraphicsDrawChars); FUNC(GraphicsCreate); FUNC(GraphicsDrawCursor); FUNC(GraphicsSetClip); FUNC(GraphicsFree); FUNC(GraphicsSetForeColor); FUNC(GraphicsSetTextColor); FUNC(GraphicsFillPolygon); FUNC(GraphicsDrawString); FUNC(ConvertStringToInt); FUNC(ConvertFloatToIntBitwise); FUNC(ConvertCharToString); FUNC(ConvertIntToFloatBitwise); FUNC(ConvertFloatToString); FUNC(ConvertDoubleToString); FUNC(ConvertIntToString); FUNC(ConvertLongToString); FUNC(ConvertBooleanToString); FUNC(SoundClipPlay); FUNC(PalmOsPrefSetPalmOsPref); FUNC(PalmOsPrefGetPalmOsPref); FUNC(MainWinCreate); FUNC(MainWinExit); FUNC(MainWinSetTimerInterval); FUNC(SerialPortReadCheck); FUNC(SerialPortRead); FUNC(SerialPortWrite); FUNC(SerialPortSetReadTimeout); FUNC(SerialPortClose); FUNC(SerialPortSetFlowControl); FUNC(SerialPortIsOpen); FUNC(SerialPortCreate); #ifdef WITH_SMARTDATA_CLASSES FUNC(EditCreate); FUNC(EditGetText); FUNC(EditSetText); FUNC(EditDraw); FUNC(EditFocusIn); FUNC(EditFocusOut); FUNC(EditKeyPress); FUNC(EditPenDown); FUNC(EditPenDrag); FUNC(EditEvent); FUNC(EditPaint); #endif /* #ifdef WITH_SMARTDATA_CLASSES */ FUNC(FontMetricsGetStringWidth); FUNC(FontMetricsGetCharWidth); FUNC(FontMetricsCreate); FUNC(FontMetricsGetCharArrayWidth); FUNC(RegistryCreate); FUNC(RegistryReadBytes); FUNC(RegistryWriteBytes); FUNC(RegistrySkipBytes); FUNC(RegistryClose); FUNC(RegistryDelete); FUNC(RegistrySpaceAvailable); /************************************************************************* class waba/fx/Rect *************************************************************************/ // var[0] = Class // var[1] = int x // var[2] = int y // var[3] = int width // var[4] = int height #define WOBJ_RectX(o) (objectPtr(o))[1].intValue #define WOBJ_RectY(o) (objectPtr(o))[2].intValue #define WOBJ_RectWidth(o) (objectPtr(o))[3].intValue #define WOBJ_RectHeight(o) (objectPtr(o))[4].intValue /************************************************************************* class waba/ui/Control *************************************************************************/ // var[0] = Class // var[1] = int x // var[2] = int y // var[3] = int width // var[4] = int height #define WOBJ_ControlX(o) (objectPtr(o))[1].intValue #define WOBJ_ControlY(o) (objectPtr(o))[2].intValue #define WOBJ_ControlWidth(o) (objectPtr(o))[3].intValue #define WOBJ_ControlHeight(o) (objectPtr(o))[4].intValue /************************************************************************* class waba/ui/Window *************************************************************************/ // var[0] = Class // var[n] = ...other locals... // var[n + 1] = hook var - a pointer to the MainWindow // var[n + 2] = hook var - boolean if the Window allready a pixmap or not // // since Window inherits from other classes, we need to calculate the // right base offset to start with when reading/writing to variables extern int _winHookOffset; #define WOBJ_WindowMain(o) (objectPtr(o))[_winHookOffset + 0].refValue #define WOBJ_WindowHookVars 1 /* number of hook var for Window */ /************************************************************************* class waba/ui/MainWindow *************************************************************************/ // var[0] = Class // var[n] = ...other locals... // var[n + 1] = hook var - // extern int _mainWinHookOffset; #define WOBJ_MainWinTimer(o) (objectPtr(o))[_mainWinHookOffset + 0].intValue #define WOBJ_MainWinHookVars 1 /* number of hook var for MainWindow */ /************************************************************************* class waba/fx/Image *************************************************************************/ // var[0] = Class // var[1] = width // var[2] = height // var[3] = hook var - pointer to the pixmap image #define WOBJ_ImageWidth(o) (objectPtr(o))[1].intValue #define WOBJ_ImageHeight(o) (objectPtr(o))[2].intValue #define WOBJ_ImagePixmap(o) (objectPtr(o))[3].refValue /************************************************************************* class waba/io/Socket *************************************************************************/ // var[0] = Class // var[1] = hook var - Socket Id (int32) // var[2] = timeout delay in milliseconds // // NOTE: The SOCKET type is an unsigned 32 bit quantity - this most closely // matches the object type #define WOBJ_SocketFD(o) (objectPtr(o))[1].intValue #define WOBJ_SocketTimeout(o) (objectPtr(o))[2].intValue #ifdef WITH_SMARTDATA_CLASSES /************************************************************************* class ch/smartdata/ui/Edit *************************************************************************/ // var[0] = Class // ... = other local variables // var[n + 0] = Timer blinkTimer // var[n + 1] = Graphics drawg // var[n + 2] = hook var - char * chars // var[n + 3] = hook var - unsigned char * charWidths // var[n + 4] = hook var - ui_FontType * font // var[n + 5] = hook var - int totalCharWidth // var[n + 6] = hook var - int xOffset // var[n + 7] = hook var - int hasFocus // var[n + 8] = hook var - int redraw // var[n + 9] = hook var - int insertPoint // since Edit inherits from other classes, we need to calculate the // right base offset to start with when reading/writing to variables extern int _editHookOffset; #define WOBJ_EditBlinkTimer(o) (objectPtr(o))[_editHookOffset + 0].obj #define WOBJ_EditDrawG(o) (objectPtr(o))[_editHookOffset + 1].obj #define WOBJ_EditFont(o) (objectPtr(o))[_editHookOffset + 2].obj #define WOBJ_EditChars(o) (objectPtr(o))[_editHookOffset + 3].refValue #define WOBJ_EditCharWidths(o) (objectPtr(o))[_editHookOffset + 4].refValue #define WOBJ_EditTotalCharWidth(o) (objectPtr(o))[_editHookOffset + 5].intValue #define WOBJ_EditXOffset(o) (objectPtr(o))[_editHookOffset + 6].intValue #define WOBJ_EditHasFocus(o) (objectPtr(o))[_editHookOffset + 7].intValue #define WOBJ_EditRedraw(o) (objectPtr(o))[_editHookOffset + 8].intValue #define WOBJ_EditInsertPos(o) (objectPtr(o))[_editHookOffset + 9].intValue #define WOBJ_EditHookVars 10 /* number of hook var for Edit */ #endif /* #ifdef WITH_SMARTDATA_CLASSES */ /************************************************************************* class waba/fx/Font *************************************************************************/ // var[0] = Class // var[1] = String name // var[2] = int style // var[3] = int size // #define WOBJ_FontName(o) (objectPtr(o))[1].obj #define WOBJ_FontStyle(o) (objectPtr(o))[2].intValue #define WOBJ_FontSize(o) (objectPtr(o))[3].intValue #define Font_PLAIN 0 #define Font_BOLD 1 /************************************************************************* class waba/fx/FontMetrics *************************************************************************/ // var[0] = Class // var[1] = Font // var[2] = Surface // var[3] = int ascent // var[4] = int descent // var[5] = int leading #define WOBJ_FontMetricsFont(o) (objectPtr(o))[1].obj #define WOBJ_FontMetricsSurface(o) (objectPtr(o))[2].obj #define WOBJ_FontMetricsAscent(o) (objectPtr(o))[3].intValue #define WOBJ_FontMetricsDescent(o) (objectPtr(o))[4].intValue #define WOBJ_FontMetricsLeading(o) (objectPtr(o))[5].intValue /* what type of width we can compute */ #define FM_STRINGWIDTH 1 #define FM_CHARARRAYWIDTH 2 #define FM_CHARWIDTH 3 /************************************************************************* class waba/fx/Graphics *************************************************************************/ // var[0] = Class // var[1] = Surface // var[2] = hook var - isValid flag // var[3] = hook var - pointer to the main window, NULL if it's an Image // var[4] = hook var - pointer to the Pixmap if it's an Image, NULL otherwise // var[5] = hook var - pointer to the drawing pixmap where all draw are made // var[6] = hook var - pointer to the used font // var[7] = hook var - the start x of the clip region // var[8] = hook var - the start y of the clip region // var[9] = hook var - the width of the clip region // var[10] = hook var - the height of the clip region // var[11] = hook var - the operation used for the draw (AND/OR/XOR...) // var[12] = hook var - the value of the red color used for the draw // var[13] = hook var - the value of the green color used for the draw // var[14] = hook var - the value of the blue color used for the draw // var[15] = hook var - the X used for translation // var[16] = hook var - the Y used for translation #define WOBJ_GraphicsSurface(o) (objectPtr(o))[1].obj #define WOBJ_GraphicsIsValid(o) (objectPtr(o))[2].intValue #define WOBJ_GraphicsWindowMain(o) (objectPtr(o))[3].refValue #define WOBJ_GraphicsPixmap(o) (objectPtr(o))[4].refValue #define WOBJ_GraphicsDrawingPixmap(o) (objectPtr(o))[5].refValue #define WOBJ_GraphicsFont(o) (objectPtr(o))[6].refValue #define WOBJ_GraphicsClipRegionX(o) (objectPtr(o))[7].intValue #define WOBJ_GraphicsClipRegionY(o) (objectPtr(o))[8].intValue #define WOBJ_GraphicsClipRegionW(o) (objectPtr(o))[9].intValue #define WOBJ_GraphicsClipRegionH(o) (objectPtr(o))[10].intValue #define WOBJ_GraphicsDrawOp(o) (objectPtr(o))[11].intValue #define WOBJ_GraphicsRED(o) (objectPtr(o))[12].intValue #define WOBJ_GraphicsGREEN(o) (objectPtr(o))[13].intValue #define WOBJ_GraphicsBLUE(o) (objectPtr(o))[14].intValue #define WOBJ_GraphicsTransX(o) (objectPtr(o))[15].intValue #define WOBJ_GraphicsTransY(o) (objectPtr(o))[16].intValue /* how we can draw */ #define DRAW_OVER 1 #define DRAW_AND 2 #define DRAW_OR 3 #define DRAW_XOR 4 /* some constants giving the existing type of drawing */ #define GR_FILLRECT 0 #define GR_DRAWLINE 1 #define GR_FILLPOLY 2 #define GR_DRAWCHARS 3 #define GR_DRAWSTRING 4 #define GR_DOTS 5 #define GR_COPYRECT 6 #define GR_DRAWCURSOR 7 /* existing surface type */ #define SURF_UNKNOWN 0 #define SURF_WINDOW 1 #define SURF_IMAGE 2 /************************************************************************* class waba/fx/SoundClip *************************************************************************/ // var[0] = Class // var[1] = path // var[2] = loaded #define WOBJ_SoundClipPath(o) (objectPtr(o))[1].obj #define WOBJ_SoundClipLoaded(o) (objectPtr(o))[2].intValue #ifdef WITH_CATALOG_CLASS /************************************************************************* class waba/io/Catalog As linux has no catalog, this is not implemented at this time *************************************************************************/ // var[0] = Class // var[1] = hook var - database handle (null if no open db) // var[2] = hook var - database oid // var[3] = hook var - current record position // var[4] = hook var - current record oid // var[5] = hook var - current record memory pointer // var[6] = hook var - current record memory allocation pointer // var[7] = hook var - length of current record // var[8] = hook var - current offset in record // var[9] = hook var - 1 if record has been modified, 0 otherwise #define WOBJ_CatalogHandle(o) (objectPtr(o))[1].refValue #define WOBJ_CatalogOID(o) (objectPtr(o))[2].refValue #define WOBJ_CatalogCurRecPos(o) (objectPtr(o))[3].intValue #define WOBJ_CatalogCurRecOid(o) (objectPtr(o))[4].refValue #define WOBJ_CatalogCurRecPtr(o) (objectPtr(o))[5].refValue #define WOBJ_CatalogCurRecAllocPtr(o) (objectPtr(o))[6].refValue #define WOBJ_CatalogCurRecLen(o) (objectPtr(o))[7].intValue #define WOBJ_CatalogCurRecOffset(o) (objectPtr(o))[8].intValue #define WOBJ_CatalogCurRecModified(o) (objectPtr(o))[9].intValue #define Catalog_READ_ONLY 1 #define Catalog_WRITE_ONLY 2 #define Catalog_READ_WRITE 3 #define Catalog_CREATE 4 #define Catalog_CEDBTYPE 4141 #endif //WITH_CATALOG_CLASS /************************************************************************* class waba/io/File *************************************************************************/ // var[0] = Class // var[1] = String name // var[2] = int mode // var[3] = hook var - file handle #define WOBJ_FileName(o) (objectPtr(o))[1].obj #define WOBJ_FileMode(o) (objectPtr(o))[2].intValue #define WOBJ_FileHandle(o) (objectPtr(o))[3].refValue #define File_DONT_OPEN 0 #define File_READ_ONLY 1 #define File_WRITE_ONLY 2 #define File_READ_WRITE 3 #define File_CREATE 4 /* some file operation */ #define FILE_CREATE_DIR 1 #define FILE_IS_DIR 2 #define FILE_DELETE 3 #define FILE_RENAME 4 #define FILE_EXISTS 5 /************************************************************************* class waba/io/SerialPort *************************************************************************/ // var[0] = Class // var[1] = hook var - Handle #define WOBJ_SerialPortHandle(o) (objectPtr(o))[1].refValue /************************************************************************* class waba/sys/Time *************************************************************************/ // var[0] = Class // var[1] = int year // var[2] = int month // var[3] = int day // var[4] = int hour // var[5] = int minute // var[6] = int second // var[7] = int millis #define WOBJ_TimeYear(o) (objectPtr(o))[1].intValue #define WOBJ_TimeMonth(o) (objectPtr(o))[2].intValue #define WOBJ_TimeDay(o) (objectPtr(o))[3].intValue #define WOBJ_TimeHour(o) (objectPtr(o))[4].intValue #define WOBJ_TimeMinute(o) (objectPtr(o))[5].intValue #define WOBJ_TimeSecond(o) (objectPtr(o))[6].intValue #define WOBJ_TimeMillis(o) (objectPtr(o))[7].intValue /************************************************************************* class waba/io/Registry *************************************************************************/ #ifdef BEE_BIOS // var [0] = Class // var [1] = unsigned char * memory buffer // var [2] = int position into memory buffer // var [3] = int current size of memory buffer // var [4] = int flag indicating that the buffer has been modified // var [5] = char * environment variable name #define WOBJ_RegistryBuffer(o) (objectPtr(o))[1].refValue #define WOBJ_RegistryBufferPos(o) (objectPtr(o))[2].intValue #define WOBJ_RegistryBufferSize(o) (objectPtr(o))[3].intValue #define WOBJ_RegistryBufferDirty(o) (objectPtr(o))[4].intValue #define WOBJ_RegistryVarName(o) (objectPtr(o))[5].refValue #else /* #ifdef BEE_BIOS */ // var[0] = Class // var[1] = char * file name // var[2] = int file descriptor #define WOBJ_RegistryFileName(o) (objectPtr(o))[1].refValue #define WOBJ_RegistryFile(o) (objectPtr(o))[2].intValue #endif /* #ifdef BEE_BIOS #else */ /************************************************************************* functions implemented in ui_xxx.c *************************************************************************/ /* general */ void ui_MainLoop(); int ui_IsColor(); /* timeout related */ void ui_TimeoutSet( WObject win, gint nbOfMillisecond ); /* for the fonts */ ui_FontType *ui_FontCreate( WObject font ); void ui_FontDelete( ui_FontType *theFont ); gint ui_TextWidth( char *theText, ui_FontType *theFont ); gint ui_CharWidth( char theChar, ui_FontType *theFont ); int ui_FontHeight( ui_FontType *theFont ); void ui_FontSetProperties( ui_FontType *theFont, WObject fontMetrics ); gint ui_FontGetYOffset( ui_FontType *theFont ); /* for the draw */ ui_PixmapType *ui_createDrawingPixmap( ui_MainWindowType *mw, ui_Rectangle rect ); void ui_deleteDrawingPixmap( ui_PixmapType *thePixmap ); ui_GraphicsContextType *ui_createGC( WObject gr ); void ui_deleteGC( ui_GraphicsContextType *theGC ); void ui_setTheDrawFunction( ui_GraphicsContextType *theGC, gint32 drawOp ); void ui_ClipTo( ui_GraphicsContextType *theGC, ui_Rectangle rect ); void ui_SetColor( ui_GraphicsContextType *theGC, gint red, gint green, gint blue ); void ui_DrawPixel( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y ); void ui_DrawLine( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x1, gint y1, gint x2, gint y2 ); void ui_DrawText( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, char *theText, ui_FontType *theFont ); void ui_DrawFilledRect( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h ); void ui_DrawFilledPoly( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint *x, gint *y, gint nbPoints, gint transX, gint transY ); void ui_GraphicsRepaint( WObject graphics, ui_PixmapType *drawingPixmap, ui_GraphicsContextType *gc ); /* image related */ ui_GraphicsContextType *ui_createGCFromPixmap( ui_PixmapType *thePixmap, gint32 width, gint32 height ); ui_PixmapType *ui_NewPixmap( gint w, gint h ); void ui_DeletePixmap( ui_PixmapType *thePixmap ); void ui_DrawRGBImage( ui_PixmapType *thePixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h, uchar *rgbbuf ); void ui_DrawPixmap( ui_PixmapType *dstPixmap, ui_GraphicsContextType *theGC, ui_PixmapType *srcPixmap, gint x, gint y, gint dstX, gint dstY, gint w, gint h ); /* for translating the key code to a waba key code */ int32 ui_TranslateKey( Word chr ); #endif /* __NM_LINUX_A_H__ */ /* Local Variables: c-file-style: "smartdata" End: */ --- NEW FILE: ui_gtk.c --- /* $Id: ui_gtk.c,v 1.1 2004/12/20 23:37:32 mriem Exp $ Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* GTK Port. See http://www.gtk.org/ for more informations */ #include "../waba.h" #ifdef WITH_THREAD /* as it seem gtk_main_iteration_do() don't return TRUE when we call gtk_main_quit(), */ /* we use a global variable to finish the program... Bad, but... */ gint isFinish; #endif g_error sucess = {ERRT_NONE,NULL}; g_error mkerror(unsigned char type, char *msg) { g_error e = {type,msg}; return e; } g_error prerror(g_error e) { if (e.type == ERRT_NONE) return sucess; if (!e.msg) e.msg = "?"; printf("*** ERROR ("); switch (e.type) { case ERRT_MEMORY: printf("MEMORY"); break; case ER... [truncated message content] |