📄 icon.cc
字号:
//**************************************************************//* filename: icon.cc *//* *//**************************************************************//* programmed by: Thomas Wagner *//* last change: 04-05-95 *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include <X11/Xlib.h>#include <X11/Xutil.h>#include "icon.h"extern unsigned long buttonpix, whitepix, blackpix, shadowpix, lightpix, selectpix;extern XContext Windowcontext;Icon::Icon (Display * initdisplay, GC initgc, Window Parentwindow, XFontStruct * fontstruct, int initx, int inity, int initwidth, int initheight, char *text, char *bmptext, short bmpwidth, short bmpheight, int borderwidth, unsigned short initstatus):Window_Info (initdisplay, initgc, Parentwindow, fontstruct, initx, inity, initwidth, initheight, text, borderwidth){ status = initstatus; short depth = DefaultDepth (display, DefaultScreen (display)); pixmap_up = XCreatePixmap (display, window, width, height, depth); pixmap_down = XCreatePixmap (display, window, width, height, depth); if (bmptext != NULL) { if ((bmp = XCreateBitmapFromData (display, window, bmptext, bmpwidth, bmpheight)) == None) { printf ("Failed to create bitmap in window.cc!\n"); exit (0); } } else bmp = 0; bmp_width = bmpwidth; bmp_height = bmpheight;}void Icon::MakeSelectable (){ status |= ICON_SELECTABLE; if (bmp != 0) { XSetForeground (display, gc, blackpix); XSetBackground (display, gc, buttonpix); XCopyPlane (display, bmp, pixmap_up, gc, 0, 0, bmp_width, bmp_height, (int) ((width - bmp_width) * .5), (int) ((height - bmp_height) * .5), 1); XCopyPlane (display, bmp, pixmap_down, gc, 0, 0, bmp_width, bmp_height, (int) ((width - bmp_width) * .5), (int) ((height - bmp_height) * .5), 1); if (status & ICON_SELECTED) DrawIcon (ICON_SELECTED); else DrawIcon (~ICON_SELECTED); } AddSelectedInput (ButtonReleaseMask);}void Icon::MakeUnselectable (){ status &= ~ICON_SELECTABLE; if (bmp != 0) { XSetForeground (display, gc, shadowpix); XSetBackground (display, gc, buttonpix); if (pixmap_up != 0) XCopyPlane (display, bmp, pixmap_up, gc, 0, 0, bmp_width, bmp_height, (int) ((width - bmp_width) * .5), (int) ((height - bmp_height) * .5), 1); if (pixmap_down != 0) XCopyPlane (display, bmp, pixmap_down, gc, 0, 0, bmp_width, bmp_height, (int) ((width - bmp_width) * .5), (int) ((height - bmp_height) * .5), 1); DrawIcon (~ICON_SELECTED); } DelSelectedInput (ButtonReleaseMask);}void Icon::DrawIcon (unsigned short drawstatus){ if (drawstatus & ICON_SELECTED) XCopyArea (display, pixmap_down, window, gc, 0, 0, width, height, 0, 0); else XCopyArea (display, pixmap_up, window, gc, 0, 0, width, height, 0, 0); XFlush (display);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -