gnome-games_2.28.0.orig.tar.gz

  • PUDN用户
    了解作者
  • Unix_Linux
    开发工具
  • 28MB
    文件大小
  • gz
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 112
    下载次数
  • 2010-04-13 14:21
    上传日期
linux 游戏 源码 包括 麻将 推箱子 国际象棋 四子棋等等
gnome-games_2.28.0.orig.tar.gz
内容介绍
/* X-Chat * Copyright (C) 1998 Peter Zelezny. * * 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 * ========================================================================= * * xtext, the text widget used by X-Chat. * By Peter Zelezny <zed@xchat.org>. * */ #define XCHAT /* using xchat */ #define TINT_VALUE 195 /* 195/255 of the brightness. */ #define MOTION_MONITOR /* URL hilights. */ #define SMOOTH_SCROLL /* line-by-line or pixel scroll? */ #define SCROLL_HACK /* use XCopyArea scroll, or full redraw? */ #undef COLOR_HILIGHT /* Color instead of underline? */ /* Italic is buggy because it assumes drawing an italic string will have identical extents to the normal font. This is only true some of the time, so we can't use this hack yet. */ #undef ITALIC /* support Italic? */ #define GDK_MULTIHEAD_SAFE #define USE_DB /* double buffer */ #define MARGIN 2 /* dont touch. */ #define REFRESH_TIMEOUT 20 #define WORDWRAP_LIMIT 24 #include <config.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include <time.h> #include <unistd.h> #include <gtk/gtk.h> #include "xtext-ggz.h" #ifdef USE_XLIB #include <gdk/gdkx.h> #include <X11/Xlib.h> #include <X11/Xatom.h> #endif #ifdef USE_MMX #include "mmx_cmod.h" #endif #include "xtext.h" #define charlen(str) g_utf8_skip[*(guchar *)(str)] #ifdef WIN32 #include <windows.h> #include <gdk/gdkwin32.h> #endif /* is delimiter */ #define is_del(c) \ (c == ' ' || c == '\n' || c == ')' || c == '(' || \ c == '>' || c == '<' || c == ATTR_RESET || c == ATTR_BOLD || c == 0) #ifdef SCROLL_HACK /* force scrolling off */ #define dontscroll(buf) (buf)->last_pixel_pos = 0x7fffffff #else #define dontscroll(buf) #endif static GtkWidgetClass *parent_class = NULL; struct textentry { struct textentry *next; struct textentry *prev; unsigned char *str; time_t stamp; gint16 str_width; gint16 str_len; gint16 mark_start; gint16 mark_end; gint16 indent; gint16 left_len; gint16 lines_taken; #define RECORD_WRAPS 4 guint16 wrap_offset[RECORD_WRAPS]; unsigned int mb:1; /* is multibyte? */ }; enum { WORD_CLICK, LAST_SIGNAL }; /* values for selection info */ enum { TARGET_UTF8_STRING, TARGET_STRING, TARGET_TEXT, TARGET_COMPOUND_TEXT }; static guint xtext_signals[LAST_SIGNAL]; #ifdef XCHAT char *nocasestrstr (const char *text, const char *tofind); /* util.c */ int xtext_get_stamp_str (time_t, char **); #endif static void gtk_xtext_render_page (GtkXText * xtext); static void gtk_xtext_calc_lines (xtext_buffer *buf, int); #if defined(USE_XLIB) || defined(WIN32) static void gtk_xtext_load_trans (GtkXText * xtext); static void gtk_xtext_free_trans (GtkXText * xtext); #endif static char *gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret); static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline); static void gtk_xtext_adjustment_changed (GtkAdjustment * adj, GtkXText * xtext); static int gtk_xtext_render_ents (GtkXText * xtext, textentry *, textentry *); static void gtk_xtext_recalc_widths (xtext_buffer *buf, int); static void gtk_xtext_fix_indent (xtext_buffer *buf); static int gtk_xtext_find_subline (GtkXText *xtext, textentry *ent, int line); static char *gtk_xtext_conv_color (unsigned char *text, int len, int *newlen); static unsigned char * gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf, int *newlen, int *mb_ret); /* some utility functions first */ #ifndef XCHAT /* xchat has this in util.c */ static char * nocasestrstr (const char *s, const char *tofind) { register const size_t len = strlen (tofind); if (len == 0) return (char *)s; while (toupper(*s) != toupper(*tofind) || strncasecmp (s, tofind, len)) if (*s++ == '\0') return (char *)NULL; return (char *)s; } #endif /* gives width of a 8bit string - with no mIRC codes in it */ static int gtk_xtext_text_width_8bit (GtkXText *xtext, unsigned char *str, int len) { int width = 0; while (len) { width += xtext->fontwidth[*str]; str++; len--; } return width; } #ifdef WIN32 static void win32_draw_bg (GtkXText *xtext, int x, int y, int width, int height) { HDC hdc; HWND hwnd; HRGN rgn; if (xtext->shaded) { /* xtext->pixmap is really a GdkImage, created in win32_tint() */ gdk_draw_image (xtext->draw_buf, xtext->bgc, (GdkImage*)xtext->pixmap, x, y, x, y, width, height); } else { hwnd = GDK_WINDOW_HWND (xtext->draw_buf); hdc = GetDC (hwnd); rgn = CreateRectRgn (x, y, x + width, y + height); SelectClipRgn (hdc, rgn); PaintDesktop (hdc); ReleaseDC (hwnd, hdc); DeleteObject (rgn); } } static void xtext_draw_bg (GtkXText *xtext, int x, int y, int width, int height) { if (xtext->transparent) win32_draw_bg (xtext, x, y, width, height); else gdk_draw_rectangle (xtext->draw_buf, xtext->bgc, 1, x, y, width, height); } #else #define xtext_draw_bg(xt,x,y,w,h) gdk_draw_rectangle(xt->draw_buf, xt->bgc, \ 1,x,y,w,h); #endif /* ========================================= */ /* ========== XFT 1 and 2 BACKEND ========== */ /* ========================================= */ #ifdef USE_XFT static void backend_font_close (GtkXText *xtext) { XftFontClose (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font); #ifdef ITALIC XftFontClose (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->ifont); #endif } static void backend_init (GtkXText *xtext) { if (xtext->xftdraw == NULL) { xtext->xftdraw = XftDrawCreate ( GDK_WINDOW_XDISPLAY (xtext->draw_buf), GDK_WINDOW_XWINDOW (xtext->draw_buf), GDK_VISUAL_XVISUAL (gdk_drawable_get_visual (xtext->draw_buf)), GDK_COLORMAP_XCOLORMAP (gdk_drawable_get_colormap (xtext->draw_buf))); XftDrawSetSubwindowMode (xtext->xftdraw, IncludeInferiors); } } static void backend_deinit (GtkXText *xtext) { if (xtext->xftdraw) { XftDrawDestroy (xtext->xftdraw); xtext->xftdraw = NULL; } } static XftFont * backend_font_open_real (Display *xdisplay, char *name, gboolean italics) { XftFont *font = NULL; PangoFontDescription *fontd; int weight, slant, screen = DefaultScreen (xdisplay); fontd = pango_font_description_from_string (name); if (pango_font_description_get_size (fontd) != 0) { weight = pango_font_description_get_weight (fontd); /* from pangoft2-fontmap.c */ if (weight < (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_LIGHT) / 2) weight = XFT_WEIGHT_LIGHT; else if (weight < (PANGO_WEIGHT_NORMAL + 600) / 2) weight = XFT_WEIGHT_MEDIUM; else if (weight < (600 + PANGO_WEIGHT_BOLD) / 2) weight = XFT_WEIGHT_DEMIBOLD; else if (weight < (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) weight = XFT_WEIGHT_BOLD; else weight = XFT_WEIGHT_BLACK; slant = pango_font_description_get_style (fontd); if (slant == PANGO_STYLE_ITALIC) slant = XFT_SLANT_ITALIC; else if (slant == PANGO_STYLE_OBLIQUE) slant = XFT_SLANT_OBLIQUE; else slant = XFT_SLANT_ROMAN; font = XftFontOpen (xdisplay, screen, XFT_FAMILY, XftTypeString, pango_font_description_get_family (fontd), XFT_CORE, XftTypeBool, False, XFT_SIZE, XftTypeDouble, (double)pango_font_description_get_size (fontd)/PANGO_SCALE, XFT_WEIGHT, XftTypeInteger, weight, XFT_SLANT, XftTypeInteger, italics ? XFT_SLANT_ITALIC : slant, NULL); } pango
评论
    相关推荐