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

📄 selecticon.cc

📁 模糊聚类分析的源程序!
💻 CC
字号:
//**************************************************************//*   filename: selecticon.cc                                  *//*                                                            *//**************************************************************//* programmed by: Thomas Wagner                               *//* last change: 12-05-95                                      *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include "selecticon.h"extern unsigned long buttonpix, blackpix, shadowpix, lightpix;SelectIcon::SelectIcon (Display * initdisplay,	    GC initgc,	    BigWindow * initParent,	    XFontStruct * fontstruct,	    int initx, int inity, int initwidth, int initheight,	    char *inittext,	    char *initbmptext,	    short bmpwidth, short bmpheight,	    int initactionnumber,	    unsigned short initstatus):Icon (initdisplay,      initgc,      initParent->GetWindow (),      fontstruct,      initx, inity, initwidth, initheight,      inittext,      initbmptext,      bmpwidth, bmpheight,      DEFAULT_BDWIDTH,      initstatus){  ParentWindow = initParent;  actionnumber = initactionnumber;  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, HIGH);  DrawBorder (pixmap_down, LOW);  if (bmp != 0) {    if (status & ICON_SELECTABLE)      XSetForeground (display, gc, blackpix);    else      XSetForeground (display, gc, shadowpix);    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);  }  SetSelectedInput (ExposureMask		    | ButtonPressMask		    | ButtonReleaseMask		    | LeaveWindowMask		    | EnterWindowMask);  MapMe ();};void SelectIcon::Selectme (){  status |= ICON_SELECTED;  list->SelectChange (this);}void SelectIcon::HandleEvent (XEvent * Event){  static char buttonpressed = 0;  switch (Event->type) {  case Expose:    if (Event->xexpose.count == 0)      DrawIcon (status);    break;  case ButtonPress:    if (Event->xbutton.button == Button1) {      if (status & ICON_SELECTABLE) {	buttonpressed = 1;	DrawIcon (ICON_SELECTED);      } else	XBell (display, 100);    }    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_SELECTED) &&	  (status & ICON_SELECTABLE) &&	  (buttonpressed == 1)) {	Selectme ();	ParentWindow->Action (actionnumber, 0);      }      buttonpressed = 0;    }    break;  case EnterNotify:    if (buttonpressed)      DrawIcon (ICON_SELECTED);    break;  case LeaveNotify:    if ((buttonpressed) &&	!(status & ICON_SELECTED))      DrawIcon (~ICON_SELECTED);    break;  }}SelectIconlist::SelectIconlist (){  selecticon = NULL;  status = SELECTICONLIST_ISMAPPED;}SelectIconlist::~SelectIconlist (){  if (selecticon != NULL)    delete selecticon;  if (Next != NULL)    delete Next;}void SelectIconlist::MakeallSelectable (){  SelectIconlist *temp = this;  SelectIcon *acuteicon;  while (temp->selecticon != NULL) {    acuteicon = temp->selecticon;    acuteicon->MakeSelectable ();    temp = temp->Next;  }}void SelectIconlist::MakeallUnselectable (){  SelectIconlist *temp = this;  SelectIcon *acuteicon;  while (temp->selecticon != NULL) {    acuteicon = temp->selecticon;    acuteicon->MakeUnselectable ();    temp = temp->Next;  }}void SelectIconlist::MoveSelectIcons (int xdiff, int ydiff){  SelectIconlist *temp = this;  SelectIcon *acuteicon;  while (temp->selecticon != NULL) {    acuteicon = temp->selecticon;    acuteicon->x += xdiff;    acuteicon->y += ydiff;    XMoveWindow (acuteicon->display,		 acuteicon->window,		 acuteicon->x,		 acuteicon->y);    temp = temp->Next;  }}void SelectIconlist::MakeIconSelectable (int theactionnumber){  SelectIcon *theicon = GetSelectIcon (theactionnumber);  theicon->MakeSelectable ();}void SelectIconlist::MakeIconUnselectable (int theactionnumber){  SelectIcon *theicon = GetSelectIcon (theactionnumber);  theicon->MakeUnselectable ();}void SelectIconlist::SelectanIcon (int theactionnumber){  SelectIcon *theicon = GetSelectIcon (theactionnumber);  theicon->Selectme ();}void SelectIconlist::UnselectanIcon (int theactionnumber){  SelectIcon *theicon = GetSelectIcon (theactionnumber);  theicon->status &= ~ICON_SELECTED;  theicon->DrawIcon (~ICON_SELECTED);;}SelectIcon *SelectIconlist::GetSelectIcon (int theactionnumber){  SelectIconlist *temp = this;  while (temp->selecticon != NULL) {    if (temp->selecticon->actionnumber == theactionnumber)      return temp->selecticon;    temp = temp->Next;  }  return NULL;}void SelectIconlist::MapMe (){  status |= SELECTICONLIST_ISMAPPED;  SelectIconlist *temp = this;  SelectIcon *acuteicon;  while (temp->selecticon != NULL) {    acuteicon = temp->selecticon;    acuteicon->MapMe ();    temp = temp->Next;  }}void SelectIconlist::UnmapMe (){  status &= ~SELECTICONLIST_ISMAPPED;  SelectIconlist *temp = this;  SelectIcon *acuteicon;  while (temp->selecticon != NULL) {    acuteicon = temp->selecticon;    acuteicon->UnmapMe ();    temp = temp->Next;  }}void SelectIconlist::operator+= (SelectIcon * newselecticon){  SelectIconlist *temp = this;  while (temp->selecticon != NULL)    temp = temp->Next;  temp->selecticon = newselecticon;  temp->Next = new SelectIconlist ();  temp->Next->Next = NULL;  newselecticon->list = this;}int SelectIconlist::GetSelectedvalue (){  SelectIconlist *temp = this;  SelectIcon *acuteicon, *selectedicon = NULL;	//temp->selecticon;  while (temp->selecticon != NULL) {    acuteicon = temp->selecticon;    if ((acuteicon->status & ICON_SELECTED) &&	(acuteicon->status & ICON_SELECTABLE))      selectedicon = acuteicon;    temp = temp->Next;  }  if (selectedicon != NULL)    return selectedicon->actionnumber;  else    return 0;}void SelectIconlist::SelectChange (SelectIcon * selectme){  SelectIconlist *temp = this;  while (temp->selecticon != 0) {    if (temp->selecticon != selectme) {      temp->selecticon->DelStatus (ICON_SELECTED);      temp->selecticon->DrawIcon (~ICON_SELECTED);;    } else      temp->selecticon->DrawIcon (ICON_SELECTED);    temp = temp->Next;  }}

⌨️ 快捷键说明

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