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

📄 actionicon.cc

📁 模糊聚类分析的源程序!
💻 CC
字号:
//**************************************************************//*   filename: actionicon.cc                                  *//*                                                            *//**************************************************************//* programmed by: Thomas Wagner                               *//* last change: 23-05-95 (XXX: not updated)                   *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include "actionicon.h"extern unsigned long  buttonpix, whitepix, blackpix, shadowpix, lightpix, selectpix;extern Cursor movestartcursor, moveendcursor, delconnectcursor, maincursor,  waitcursor, createstartcursor;ActionIcon::ActionIcon (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,      ACTIONICON_BDWIDTH,      initstatus){  actionnumber = initactionnumber;  ParentWindow = initParentWindow;  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 |		    FocusChangeMask |		    LeaveWindowMask |		    EnterWindowMask);  MapMe ();};ActionIcon::~ActionIcon (){  UnmapMe ();}void ActionIcon::HandleEvent (XEvent * Event){  switch (Event->type) {  case Expose:    if (Event->xexpose.count == 0)      DrawIcon (status);    break;  case ButtonPress:    switch (Event->xbutton.button) {    case Button1:      if (status & ICON_SELECTABLE) {	DrawIcon (ICON_SELECTED);	status |= ICON_SELECTED;      } else	XBell (display, 100);      break;    case Button2:      if ((status & ICON_SELECTABLE) &&	  (status & ICON_REPEATEDCLICK)) {	XGrabPointer (display,		      window,		      TRUE,		      0,		      GrabModeAsync,		      GrabModeAsync,		      window,		      maincursor,		      CurrentTime);	DrawIcon (ICON_SELECTED);	status |= ICON_SELECTED;	status |= ICON_REPEATSELECTED;// create FocusIn-Event	XSetInputFocus (display, DefaultRootWindow (display), RevertToNone, CurrentTime);	XSetInputFocus (display, window, RevertToNone, CurrentTime);      } else	XBell (display, 100);      break;    }    break;  case FocusIn:		// used to create repeated clicks    if ((status & ICON_SELECTED) &&	(status & ICON_REPEATEDCLICK)) {      ParentWindow->Action (actionnumber, 0);// create FocusIn-Event      XSetInputFocus (display, DefaultRootWindow (display), RevertToNone, CurrentTime);      XSetInputFocus (display, window, RevertToNone, CurrentTime);    }    break;  case ButtonRelease:    XUngrabPointer (display, CurrentTime);    if (status & ICON_SELECTED) {      if (status & ICON_SELECTABLE) {	if (Event->xbutton.x <= width &&	    Event->xbutton.y <= height &&	    Event->xbutton.y >= -DEFAULT_BDWIDTH &&	    Event->xbutton.x >= -DEFAULT_BDWIDTH) {	  DrawIcon (~ICON_SELECTED);	  status &= ~ICON_SELECTED;	  if (Event->xbutton.button == Button1)	    ParentWindow->Action (actionnumber, 0);	}      }      if (Event->xbutton.button == Button2)	status &= ~ICON_REPEATSELECTED;      status &= ~ICON_SELECTED;    }    break;  case EnterNotify:    if (status & ICON_SELECTED)      DrawIcon (ICON_SELECTED);    if ((status & ICON_REPEATEDCLICK) &&	(status & ICON_REPEATSELECTED))      XSetInputFocus (display, window, RevertToNone, CurrentTime);    break;  case LeaveNotify:    if (status & ICON_SELECTED)      DrawIcon (~ICON_SELECTED);    if (status & ICON_REPEATEDCLICK)      XSetInputFocus (display, DefaultRootWindow (display), RevertToNone, CurrentTime);    break;  }}

⌨️ 快捷键说明

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