/* * Author: William Chia-Wei Cheng (bill.cheng@acm.org) * * Copyright (C) 2001-2006, William Chia-Wei Cheng. * * This file may be distributed under the terms of the Q Public License * as defined by Trolltech AS of Norway and appearing in the file * LICENSE.QPL included in the packaging of this file. * * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * @(#)$Header: /mm2/home/cvs/bc-src/tgif/const.h,v 1.4 2006/02/10 23:21:19 william Exp $ */ #ifndef _TGIF_CONST_H_ #define _TGIF_CONST_H_ #if __STDC__ || defined(__cplusplus) || defined(c_plusplus) /* ANSI || C++ */ #ifdef _NO_PROTO /* just in case ANSI or C++ doesn't handle function prototypes well */ #define ARGS_DECL(args) () #undef ARGS_DECL_USED #else /* ~_NO_PROTO */ #define ARGS_DECL(args) args #undef ARGS_DECL_USED #define ARGS_DECL_USED 1 #endif /* _NO_PROTO */ #else /* ~(__STDC__ || defined(__cplusplus) || defined(c_plusplus)) */ #define ARGS_DECL(args) () #undef ARGS_DECL_USED #endif /* __STDC__ || defined(__cplusplus) || defined(c_plusplus) */ #include "tgif_dbg.h" #ifndef _NO_LOCALE_SUPPORT #ifdef ENABLE_NLS #define _(text) gettext(text) #define N_(text) text #else /* ~ENABLE_NLS */ #define _(text) text #define N_(text) text #endif /* ENABLE_NLS */ #else /* _NO_LOCALE_SUPPORT */ #define _(text) text #define N_(text) text #endif /* ~_NO_LOCALE_SUPPORT */ #define TOOL_NAME "Tgif" #ifndef NULL #define NULL 0 #endif /* ~NULL */ #ifndef TRUE #define FALSE 0 #define TRUE 1 #endif /* ~TRUE */ #define INVALID (-1) #undef BAD #define BAD (-2) #ifdef WIN32 #define DIR_SEP '\\' #define DIR_SEP_STR "\\" #else /* ~WIN32 */ #define DIR_SEP '/' #define DIR_SEP_STR "/" #endif /* WIN32 */ #define SINGLECOLOR (FALSE) #define MULTICOLOR (TRUE) #define BUTTONSMASK ((Button1Mask)|(Button2Mask)|(Button3Mask)) #ifndef max #define max(A,B) (((A)>(B)) ? (A) : (B)) #define min(A,B) (((A)>(B)) ? (B) : (A)) #endif /* ~max */ #ifndef round #define round(X) (((X) >= 0) ? (int)((X)+0.5) : (int)((X)-0.5)) #endif /* ~round */ #ifndef M_PI #define M_PI 3.14159265358979323846 #endif /* ~M_PI */ #define INT_TOL (1.0e-5) #define EQ_TOL (1.0e-8) #ifndef XK_KP_Left #define XK_KP_Left 0xFF96 #define XK_KP_Up 0xFF97 #define XK_KP_Right 0xFF98 #define XK_KP_Down 0xFF99 #endif /* ~XK_KP_LEFT */ #ifndef XK_KP_Delete #define XK_KP_Insert 0xFF9E #define XK_KP_Delete 0xFF9F #endif /* ~XK_KP_Delete */ #ifndef XK_Page_Up #define XK_Page_Up 0xFF55 #define XK_Page_Down 0xFF56 #endif /* ~XK_Page_Up */ #ifndef XK_KP_Page_Up #define XK_KP_Page_Up 0xFF9A #define XK_KP_Page_Down 0xFF9B #endif /* ~XK_KP_Page_Up */ #ifndef XK_KP_Home #define XK_KP_Home 0xFF95 #define XK_KP_End 0xFF9C #endif /* ~XK_KP_Home */ #ifndef XK_Home #define XK_Home 0xFF50 #define XK_End 0xFF57 #endif /* ~XK_Home */ #define MAX_ZOOMED_IN 3 #define HALF_W(w) (((w)&0x1) ? ((w)>>1)+1 : ((w)>>1)) #define ZOOMED_HALF_W(w) ((zoomedIn) ? ((w)<<(zoomScale-1)) : \ ((((w)>>(zoomScale))&0x1) ? (((w)>>(zoomScale+1))+1) : \ ((w)>>(zoomScale+1)))) #define OFFSET_X(AbsX) ((zoomedIn) ? (((AbsX)-drawOrigX)<>zoomScale)) #define OFFSET_Y(AbsY) ((zoomedIn) ? (((AbsY)-drawOrigY)<>zoomScale)) #define OFFSET_DOUBLE_X(AbsX) \ ((zoomedIn) ? \ (((AbsX)-((double)drawOrigX))*((double)(1<>zoomScale)+drawOrigX) : \ (((OffsetX)<>zoomScale)+drawOrigY) : \ (((OffsetY)<>zoomScale)) #define ZOOMED_DOUBLE_SIZE(AbsSize) ((zoomedIn) ? \ ((AbsSize)*((double)(1<>zoomScale)) #define ABS_SIZE(ZoomedSize) ((zoomedIn) ? ((ZoomedSize)>>zoomScale) : \ ((ZoomedSize)<= (MarkX)-handleSize && \ (PtY) >= (MarkY)-handleSize && (PtX) <= (MarkX)+handleSize && \ (PtY) <= (MarkY)+handleSize) #define MyDashedLine(W,GC,V,N) XDrawLines(mainDisplay,W,GC,V,N,CoordModeOrigin) #define GETINT(category,val,name) ScanValue("%d", &(val), name, category) #define GETFLT(category,val,name) ScanValue("%f", &(val), name, category) #define GETDBL(category,val,name) ScanValue("%lg", &(val), name, category) #define GETSTR(category,val,name) ScanValue("%s", (val), name, category) #define GETDYN(category,val,name) ScanDynStrValue(&(val), name, category) #define GetPinObj(ObjPtr) ((ObjPtr)->detail.r->pin_connected ? \ (ObjPtr)->detail.r->last : (ObjPtr)->detail.r->first) #define GetTextObjFirstStrSeg(ObjPtr) \ ((ObjPtr)->detail.t->minilines.first->first_block->seg) #define GetTextPtrFirstStrSeg(TextPtr) \ ((TextPtr)->minilines.first->first_block->seg) #define MAXSTRING 256 #define MAXPATHLENGTH 256 #define COLORSTRLEN 40 /* geometry stuff */ #define MENU_IMAGE_W 64 #define MENU_IMAGE_H 20 #define CHOICE_IMAGE_W 32 #define CHOICE_IMAGE_H 20 #define SCROLLBAR_W 16 #define RULER_W 20 #define BRDR_W 1 #define WINDOW_PADDING 2 /* object types */ #define OBJ_POLY 0 #define OBJ_BOX 1 #define OBJ_OVAL 2 #define OBJ_TEXT 3 #define OBJ_POLYGON 4 #define OBJ_GROUP 5 #define OBJ_SYM 6 #define OBJ_ICON 7 #define OBJ_ARC 8 #define OBJ_RCBOX 9 #define OBJ_XBM 10 #define OBJ_XPM 11 #define OBJ_PIN 12 /* Please note that pins are not implemented yet! */ #define OBJ_SS 13 /* This is reserved */ /* drawing modes */ #define NOTHING 0 #define DRAWTEXT 1 #define DRAWBOX 2 #define DRAWCORNEROVAL 3 #define DRAWCENTEROVAL 4 #define DRAWEDGECIRCLE 5 #define DRAWPOLY 6 #define DRAWPOLYGON 7 #define DRAWARC 8 #define DRAWEDGEARC 9 #define DRAWRCBOX 10 #define FREEHAND 11 #define VERTEXMODE 12 #define ROTATEMODE 13 #define MAXCHOICES 14 /* stipple patterns */ #define NONEPAT 0 #define SOLIDPAT 1 #define BACKPAT 2 #define SCROLLPAT 7 #define MAXPATTERNS 32 #define NO_TRANSPAT_MODE 0 #define TRANSPAT_MODE 1 #define MAXTRANSPATMODES 2 /* line stuff */ #define LINE_THIN 0 #define LINE_MEDIUM 1 #define LINE_THICK 2 #define LINE_CURVED 3 /* compatibility hack for fileVersion <= 3 */ #define MAXLINEWIDTHS 7 #define LT_STRAIGHT 0 #define LT_SPLINE 1 #define LT_INTSPLINE 2 #define MAXLINETYPES 3 #define LS_PLAIN 0 #define LS_RIGHT 1 #define LS_LEFT 2 #define LS_DOUBLE 3 #define MAXLINESTYLES 4 #define MAXDASHES 9 #define NOCONT (FALSE) #define CONT (TRUE) #define NORB (FALSE) #define RB (TRUE) #define CHANGE_WIDTH 0x1 #define CHANGE_AW 0x2 #define CHANGE_AH 0x4 #define CHANGE_LINE_ALL (CHANGE_WIDTH|CHANGE_AW|CHANGE_AH) #define LCAP_BUTT 0 #define LCAP_ROUND 1 #define LCAP_SQUARE 2 #define MAXLINECAPS 3 #define ASTY_MASK_COMPAT 0x0001 #define ASTY_MASK_FILL 0x0002 #define ASTY_MASK_HALVES 0x000c #define ASTY_MASK_SHAPES 0x0010 #define ASTY_COMPAT 0x0 /* ASTY_MASK_COMPAT */ #define ASTY_FLEX 0x1 /* ASTY_MASK_COMPAT */ #define ASTY_SOLIDPAT 0x0 /* ASTY_MASK_FILL */ #define ASTY_BACKPAT 0x2 /* ASTY_MASK_FILL */ #define ASTY_LF_HALF_ONLY 0x4 /* ASTY_MASK_HALVES */ #define ASTY_RT_HALF_ONLY 0x8 /* ASTY_MASK_HALVES */ #define ASTY_CIRCLE 1 /* not used */ #define ASTY_BOX 2 /* not used */ /* font stuff */ #define FONT_TIM 0 #define FONT_COU 1 #define FONT_HEL 2 #define FONT_CEN 3 #define FONT_SYM 4 #define MAXFONTS 5 #define STYLE_NR 0 #define STYLE_BR 1 #define STYLE_NI 2 #define STYLE_BI 3 #define MAXFONTSTYLES 4 #define FONT_DPI_75 0 #define FONT_DPI_100 1 #define MAXFONTDPIS 2 #define MAXFONTSIZES 6 #define JUST_L 0 #define JUST_C 1 #define JUST_R 2 #define MAXJUSTS 3 #define PUSH_FONT 0 #define PUSH_SZ_UNIT 1 #define PUSH_STYLE 2 #define PUSH_JUST 3 #define PUSH_ROTATE 4 #define PUSH_PEN 5 #define PUSH_FILL 6 #define PUSH_TRANSPAT 7 #define PUSH_VSPACE 8 #define PUSH_COLORINDEX 9 #define PUSH_UNDERLINE_ON 10 #define PUSH_UNDERLINE_Y_OFFSET 11 #define PUSH_DOUBLEBYTE 12 #define NUM_SZ_UNIT_PER_FONT_SIZE 5760 #define NUM_SZ_UNIT_PER_POINT_SIZE 10240 #define FontSizeToSzUnit(font_sz) ((font_sz)*NUM_SZ_UNIT_PER_FONT_SIZE) #define PointSizeToSzUnit(point_sz) ((point_sz)*NUM_SZ_UNIT_PER_POINT_SIZE) /* alignment */ #define ALIGN_N 0 #define ALIGN_L 1 #define ALIGN_C 2 #define ALIGN_R 3 #define ALIGN_T 1 #define ALIGN_M 2 #define ALIGN_B 3 #define ALIGN_S 4 #define MAXALIGNS 5 #define ALIGN_SHIFT (MAXALIGNS) #define ALIGN_NN ((ALIGN_N<