📄 window.cc
字号:
//**************************************************************//* filename: window.cc *//* *//**************************************************************//* programmed by: Thomas Wagner *//* last change: 09-05-95 *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include "window.h"#include "icon.h"extern unsigned long buttonpix, whitepix, blackpix, shadowpix, lightpix, selectpix;extern Colormap colormap;extern Visual *visual;XContext Windowcontext = 0;extern Cursor movestartcursor, moveendcursor, delconnectcursor, maincursor, waitcursor, createstartcursor;Window_Info::Window_Info (Display * initdisplay, GC initgc, Window Parentwindow, XFontStruct * initfontstruct, short initx, short inity, short initwidth, short initheight, char *inittext, int borderwidth){ XTextProperty wtitle; gc = initgc; display = initdisplay; x = initx; y = inity; width = initwidth; height = initheight; text = inittext; fontstruct = initfontstruct; window = XCreateSimpleWindow (display, Parentwindow, x, y, width, height, borderwidth, blackpix, buttonpix);/*{ XSetWindowAttributes xswa; xswa.colormap=colormap; xswa.background_pixel=buttonpix; xswa.border_pixel=buttonpix; window=XCreateWindow(display, Parentwindow, x, y, width,height,borderwidth,8,InputOutput,visual, CWColormap|CWBackPixel|CWBorderPixel, &xswa); } */ XStringListToTextProperty (&text, 1, &wtitle); XSetWMName (display, window, &wtitle); if (Windowcontext != 0) XSaveContext (display, window, Windowcontext, (caddr_t) this);};void Window_Info::FixMySize (){ XSizeHints p_xsh; p_xsh.flags = (PPosition | PSize | PMinSize | PMaxSize); p_xsh.width = p_xsh.min_width = p_xsh.max_width = width; p_xsh.height = p_xsh.min_height = p_xsh.max_height = height; p_xsh.x = x; p_xsh.y = y; XSetWMNormalHints (display, window, &p_xsh);}void Window_Info::SetMinSize (short minwidth, short minheight){ XSizeHints p_xsh; p_xsh.flags = (PPosition | PSize | PMinSize); p_xsh.width = p_xsh.min_width = minwidth; p_xsh.height = p_xsh.min_height = minheight; p_xsh.x = x; p_xsh.y = y; XSetWMNormalHints (display, window, &p_xsh);}Window_Info::~Window_Info (){ XDeleteContext (display, window, Windowcontext); XDestroyWindow (display, window);}void Window_Info::SetWindowName (char *newname){ XTextProperty name; XStringListToTextProperty (&newname, 1, &name); XSetWMName (display, window, &name);}void Window_Info::SetIconName (char *newname){ XTextProperty name; XStringListToTextProperty (&newname, 1, &name); XSetWMIconName (display, window, &name);}void Window_Info::DrawBorder (Drawable drawable, unsigned int borderx, unsigned int bordery, unsigned int borderwidth, unsigned int borderheight, unsigned int bordertextx, unsigned int bordertexty, char *bordertext, unsigned int borderstatus){ unsigned int light, shadow; XSegment linesright[4] = { {borderx + borderwidth - 1, bordery + 1, borderx + borderwidth - 1, bordery + borderheight - 1}, {borderx + borderwidth - 2, bordery + 2, borderx + borderwidth - 2, bordery + borderheight - 1}, {borderx + 1, bordery + borderheight - 1, borderx + borderwidth - 1, bordery + borderheight - 1}, {borderx + 2, bordery + borderheight - 2, borderx + borderwidth - 1, bordery + borderheight - 2} } , linesleft[4] = { {borderx, bordery, borderx + borderwidth - 2, bordery}, {borderx, bordery + 1, borderx + borderwidth - 3, bordery + 1}, {borderx, bordery, borderx, bordery + borderheight - 2}, {borderx + 1, bordery, borderx + 1, bordery + borderheight - 3} }; if (borderstatus == HIGH) { light = lightpix; shadow = shadowpix; } else { shadow = lightpix; light = shadowpix; } XSetForeground (display, gc, shadow); XDrawSegments (display, drawable, gc, linesright, 4); XSetForeground (display, gc, light); XDrawSegments (display, drawable, gc, linesleft, 4); if (bordertext != NULL) { XSetForeground (display, gc, blackpix); XDrawString (display, drawable, gc, bordertextx, bordertexty, text, strlen (bordertext)); }}void Window_Info::AddSelectedInput (long input){ XWindowAttributes xwa; XSetWindowAttributes xswa; if (XGetWindowAttributes (display, window, &xwa) != 0) { xswa.event_mask = xwa.your_event_mask | input; XChangeWindowAttributes (display, window, CWEventMask, &xswa); }}void Window_Info:: DelSelectedInput (long input){ XWindowAttributes xwa; XSetWindowAttributes xswa; if (XGetWindowAttributes (display, window, &xwa) != 0) { xswa.event_mask = xwa.your_event_mask & ~input; XChangeWindowAttributes (display, window, CWEventMask, &xswa); }}BigWindow::BigWindow (Display * initdisplay, GC initgc, Window Parentwindow, XFontStruct * initfontstruct, short initx, short inity, short initwidth, short initheight, char *inittext, int borderwidth):Window_Info (initdisplay, initgc, Parentwindow, initfontstruct, initx, inity, initwidth, initheight, inittext, borderwidth){}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -