⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onofficon.cc

📁 模糊聚类的算法实现程序
💻 CC
字号:
//**************************************************************//*   filename: onofficon.cc                                   *//*                                                            *//**************************************************************//* programmed by: Thomas Wagner                               *//* last change: 15-05-95                                      *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include "onofficon.h"extern unsigned long  buttonpix, whitepix, blackpix, shadowpix, lightpix, selectpix, redpix;extern Cursor movestartcursor, moveendcursor, delconnectcursor, maincursor,  waitcursor, createstartcursor;OnOffIcon::OnOffIcon (Display * initdisplay,	   GC initgc,	   BigWindow * initParentWindow,	   XFontStruct * fontstruct,	   int initx, int inity, int initwidth, int initheight,	   char *inittext,	   char *bmptext,	   short bmpwidth, short bmpheight,	   int initactionnumber,	   unsigned short initstatus):Icon (initdisplay,      initgc,      initParentWindow->GetWindow (),      fontstruct,      initx, inity,      initwidth, initheight,      inittext,      bmptext,      bmpwidth, bmpheight,      ONOFFICON_BDWIDTH,      initstatus){  actionnumber = initactionnumber;  ParentWindow = initParentWindow;  if (status & ICON_LIGHTICON) {    XSetForeground (display, gc, buttonpix);    XFillRectangle (display, pixmap_up, gc, 0, 0, width, height);    XFillRectangle (display, pixmap_down, gc, 0, 0, width, height);    DrawBorder (pixmap_up, LOW);    DrawBorder (pixmap_down, LOW);    XSetForeground (display, gc, blackpix);    XFillRectangle (display, pixmap_up, gc, 1, 1, width - 2, height - 2);    XSetForeground (display, gc, redpix);    XFillRectangle (display, pixmap_down, gc, 1, 1, width - 2, height - 2);    SetBorderColor (buttonpix);  } else {    short textx, texty;    textx = (int) ((width - XTextWidth (fontstruct, text, strlen (text))) * .5);    texty = (int) ((height + fontstruct->max_bounds.ascent +     fontstruct->max_bounds.descent) * .5 - fontstruct->max_bounds.descent);    XSetForeground (display, gc, buttonpix);    XSetBackground (display, gc, buttonpix);    XFillRectangle (display, pixmap_up, gc, 0, 0, width, height);    XFillRectangle (display, pixmap_down, gc, 0, 0, width, height);    DrawBorder (pixmap_up, 0, 0,		width, height, textx, texty, text, HIGH);    DrawBorder (pixmap_down, 0, 0,		width, height, textx, texty, text, LOW);  }  if (bmp != 0) {    if (status & ICON_SELECTABLE)      XSetForeground (display, gc, blackpix);    else      XSetForeground (display, gc, shadowpix);    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);  }  SetSelectedInput (ExposureMask |		    ButtonPressMask |		    ButtonReleaseMask |		    LeaveWindowMask |		    EnterWindowMask);};OnOffIcon::~OnOffIcon (){  UnmapMe ();}void OnOffIcon::HandleEvent (XEvent * Event){  static char buttonpressed = 0;  switch (Event->type) {  case Expose:    if (Event->xexpose.count == 0) {      if (status & ICON_SELECTED)	DrawIcon (ICON_SELECTED);      else	DrawIcon (~ICON_SELECTED);    }    break;  case ButtonPress:    if ((Event->xbutton.button == Button1) &&	(status & ICON_SELECTABLE)) {      if (status & ICON_SELECTED)	DrawIcon (~ICON_SELECTED);      else	DrawIcon (ICON_SELECTED);      buttonpressed = 1;    }    break;  case ButtonRelease:    if (Event->xbutton.button == Button1) {      if (Event->xbutton.x <= width &&	  Event->xbutton.y <= height &&	  Event->xbutton.y >= -DEFAULT_BDWIDTH &&	  Event->xbutton.x >= -DEFAULT_BDWIDTH &&	  (status & ICON_SELECTABLE)) {	if (status & ICON_SELECTED) {	  status &= ~ICON_SELECTED;	  ParentWindow->Action (actionnumber, SWITCHOFF);	} else {	  status |= ICON_SELECTED;	  ParentWindow->Action (actionnumber, SWITCHON);	}      }      buttonpressed = 0;    }    break;  case EnterNotify:    if (buttonpressed) {      if (status & ICON_SELECTED)	DrawIcon (~ICON_SELECTED);      else	DrawIcon (ICON_SELECTED);    }    break;  case LeaveNotify:    if (buttonpressed) {      if (status & ICON_SELECTED)	DrawIcon (ICON_SELECTED);      else	DrawIcon (~ICON_SELECTED);    }    break;  }}

⌨️ 快捷键说明

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