errorbox.cc

来自「模糊聚类的算法实现程序」· CC 代码 · 共 73 行

CC
73
字号
//**************************************************************//*   filename: errorbox.cc                                    *//*                                                            *//**************************************************************//* programmed by: Thomas Wagner                               *//* last change:  (XXX: not updated)                           *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include "errorbox.h"extern unsigned long whitepix, redpix;extern Cursor waitcursor;ErrorBox::ErrorBox (Display * initdisplay,	  GC initgc,	  MainWindow * Parentwindow,	  XFontStruct * initfontstruct,	  int initx, int inity,	  int initwidth, int initheight):Window_Info (initdisplay,	     initgc, Parentwindow->GetWindow (),	     initfontstruct,	     initx, inity,	     initwidth, initheight,	     NULL,	     1){  ChangeText (text);  SetSelectedInput (ExposureMask | ButtonPressMask);}void ErrorBox::Redraw (){  XSetForeground (display, gc, redpix);  XFillRectangle (display, window, gc, 0, 0, width, height);  XSetForeground (display, gc, whitepix);  if (text != NULL) {    short textx, texty;    textx = (int) ((width - XTextWidth (fontstruct, text, 					strlen (text))) * .5) + 1;    texty = (int) ((height + fontstruct->max_bounds.ascent +     fontstruct->max_bounds.descent) * .5 - fontstruct->max_bounds.descent);    XDrawString (display, window, gc, textx, texty, text, strlen (text));  }}void ErrorBox::ChangeText (char *newtext){  text = newtext;  Redraw ();}void ErrorBox::HandleEvent (XEvent * Event){  switch (Event->type) {  case Expose:    if (Event->xexpose.count == 0)      Redraw ();    break;  case ButtonPress:    if (Event->xbutton.button == Button1)      UnmapMe ();  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?