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

📄 menu.cc

📁 模糊聚类分析的源程序!
💻 CC
📖 第 1 页 / 共 2 页
字号:
//**************************************************************//*   filename: menu.cc                                        *//*                                                            *//**************************************************************//* programmed by: Thomas Wagner                               *//* last change: 23-05-95                                      *//**************************************************************#include <stdio.h>#include <stdlib.h>#include "menu.h"#include "window.h"#include "include_bmps/mark.bmp"extern unsigned long buttonpix, blackpix, shadowpix, lightpix;extern Cursor maincursor;MenuIcon::MenuIcon (Display * initdisplay,	  GC initgc,	  BigWindow * initMenuParentWindow,	  Window_Info * Parentwindow,	  XFontStruct * fontstruct,	  int initx, int inity,	  int initwidth, int initheight,	  MenuIconInfo * Infos):Icon (initdisplay,      initgc,      Parentwindow->GetWindow (),      fontstruct,      initx, inity, initwidth, initheight,      Infos->bartext,      NULL, 0, 0,      0, 0){  parent = Parentwindow;  actionnumber = Infos->actionnumber;  value = Infos->value;  status = Infos->barstatus;  menuparentwindow = initMenuParentWindow;  sonpulldownmenu = NULL;  if (status & STATUS_CENTER)    textx = (width - XTextWidth (fontstruct, text, strlen (text))) / 2;  else    textx = MENUHORIZONTALSPACE;  texty = (int) ((height + fontstruct->max_bounds.ascent +      fontstruct->max_bounds.descent) / 2 - fontstruct->max_bounds.descent);  DrawMenuIcon ();  SetSelectedInput (ExposureMask		    | ButtonPressMask		    | ButtonReleaseMask		    | LeaveWindowMask		    | EnterWindowMask		    | PointerMotionMask		    | StructureNotifyMask		    | OwnerGrabButtonMask);  XMapWindow (display, window);};MenuIcon::~MenuIcon (){  UnmapMe ();}void MenuIcon::AddMenuStatus (int addstatus){  SetStatus (status | addstatus);  DrawMenuIcon ();  DrawIcon (~ICON_SELECTED);}void MenuIcon::DelMenuStatus (int delstatus){  SetStatus (status & ~delstatus);  DrawMenuIcon ();  DrawIcon (~ICON_SELECTED);}void MenuIcon::DrawMenuIcon (){  XSetForeground (display, gc, buttonpix);  XFillRectangle (display, pixmap_up, gc, 0, 0, width, height);  XSetForeground (display, gc, shadowpix);  XFillRectangle (display, pixmap_down, gc, 0, 0, width, height);  DrawBorder (pixmap_down, HIGH);  XSetForeground (display, gc, buttonpix);  XFillRectangle (display, pixmap_down, gc, 1, 1, width - 2, height - 2);  XSetForeground (display, gc, shadowpix);  if (!(status & STATUS_UNSELECTABLE))    XSetForeground (display, gc, blackpix);  XDrawString (display, pixmap_up, gc, textx, texty, text, strlen (text));  XSetForeground (display, gc, lightpix);  XDrawString (display, pixmap_down, gc, textx, texty, text, strlen (text));  if ((status & STATUS_MARKED) &&      (GetPulldownMenu () != NULL)) {    if (GetPulldownMenu ()->GetParentmenu ()->Getmarkpixmap () != 0) {      XSetForeground (display, gc, blackpix);      XSetBackground (display, gc, buttonpix);      XCopyPlane (display, GetPulldownMenu ()->GetParentmenu ()->Getmarkpixmap (),		  pixmap_up, gc,		  0, 0, MARKSIZE, MARKSIZE,	     (int) (width - MARKSIZE), (int) ((height - MARKSIZE) * .5), 1);      XSetForeground (display, gc, lightpix);      XSetBackground (display, gc, buttonpix);      XCopyPlane (display, GetPulldownMenu ()->GetParentmenu ()->Getmarkpixmap (),		  pixmap_down, gc,		  0, 0, MARKSIZE, MARKSIZE,	     (int) (width - MARKSIZE), (int) ((height - MARKSIZE) * .5), 1);    }  }  if (!(status & STATUS_TOP) &&      (sonpulldownmenu != NULL)) {    XSegment lines[4];    lines[0].x1 = width - MARKSIZE;    lines[0].y1 = height - 1 - MARKSIZE;    lines[0].x2 = width - 2;    lines[0].y2 = height - 1 - MARKSIZE / 2;    lines[1].x1 = width - MARKSIZE;    lines[1].y1 = height - 1 - MARKSIZE;    lines[1].x2 = width - MARKSIZE;    lines[1].y2 = height - 2;    lines[2].x1 = width - MARKSIZE - 1;    lines[2].y1 = height - 1 - MARKSIZE;    lines[2].x2 = width - MARKSIZE - 1;    lines[2].y2 = height - 2;    lines[3].x1 = width - MARKSIZE;    lines[3].y1 = height - 2;    lines[3].x2 = width - 2;    lines[3].y2 = height - 1 - MARKSIZE / 2;    XSetForeground (display, gc, lightpix);    XDrawSegments (display, pixmap_up, gc, lines, 3);    XSetForeground (display, gc, shadowpix);    XDrawSegments (display, pixmap_up, gc, &(lines[3]), 1);    XSetForeground (display, gc, blackpix);    XSetForeground (display, gc, shadowpix);    XDrawSegments (display, pixmap_down, gc, lines, 3);    XSetForeground (display, gc, buttonpix);    XSetForeground (display, gc, lightpix);    XDrawSegments (display, pixmap_down, gc, &(lines[3]), 1);  }}void MenuIcon::SetSonPulldownMenu (PulldownMenu * setpulldownmenu){  sonpulldownmenu = setpulldownmenu;  if (!(status & STATUS_TOP)) {    setpulldownmenu->PlaceMe (GetPulldownMenu ()->Getx () + width - MARKSIZE,			      GetPulldownMenu ()->Gety () + y);    DrawMenuIcon ();  }}PulldownMenu *MenuIcon::GetPulldownMenu (){  if (status & STATUS_TOP)    return NULL;  else    return (PulldownMenu *) parent;}void MenuIcon::Changetomarked (){  unsigned short counter;  for (counter = 0; counter < GetPulldownMenu ()->Geticonnumber (); counter++) {    if (GetPulldownMenu ()->GetMenuIcon (counter) == this) {      if (!(status & STATUS_MARKED)) {	status |= STATUS_MARKED;	DrawMenuIcon ();      }    } else {      if (GetPulldownMenu ()->GetMenuIcon (counter)->status & STATUS_MARKED) {	GetPulldownMenu ()->GetMenuIcon (counter)->status &= ~STATUS_MARKED;	GetPulldownMenu ()->GetMenuIcon (counter)->DrawMenuIcon ();      }    }  }}void MenuIcon::HandleEvent (XEvent * Event){  switch (Event->type) {  case Expose:    if (Event->xexpose.count == 0)      if (status & STATUS_SELECTED)	DrawIcon (ICON_SELECTED);      else	DrawIcon (~ICON_SELECTED);    break;  case UnmapNotify:    MapMe ();    menuparentwindow->Action (actionnumber, value);    break;  case ButtonPress:    if (Event->xbutton.button == Button1) {      XRaiseWindow (display, menuparentwindow->GetWindow ());      DrawIcon (ICON_SELECTED);      ((Menu *) parent)->SelectMe ();      if ((status & STATUS_TOP) && !(status & STATUS_UNSELECTABLE)) {	sonpulldownmenu->MapMe ();      }    }    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) {	if (status & STATUS_TOP)	  sonpulldownmenu->UnmapMe ();	else	  GetPulldownMenu ()->UnmapMe ();	DrawIcon (~ICON_SELECTED);	if (!(status & STATUS_TOP) &&	    !(status & STATUS_UNSELECTABLE) &&	    !(sonpulldownmenu != NULL)) {	  if (status & STATUS_MARKABLE)	    Changetomarked ();//             menuparentwindow->Action(actionnumber, value);	  UnmapMe ();	}      }    }    break;  case EnterNotify:    if (Event->xcrossing.state & Button1MotionMask) {      if (status & STATUS_TOP) {	if (((Menu *) parent)->IsSelected ()) {	  if (!(status & STATUS_UNSELECTABLE))	    ((Menu *) parent)->MapmyPulldownMenu (this);	  else	    ((Menu *) parent)->MapmyPulldownMenu (NULL);	  DrawIcon (ICON_SELECTED);	}      } else {	status |= STATUS_SELECTED;	DrawIcon (ICON_SELECTED);	if (Event->xcrossing.x > (width - MARKSIZE))	  GetPulldownMenu ()->EnteredMe (this);	else	  GetPulldownMenu ()->EnteredMe (NULL);      }    }    break;  case MotionNotify:    if ((Event->xmotion.x > (width - MARKSIZE)) &&	!(status & STATUS_TOP))      GetPulldownMenu ()->EnteredMe (this);    break;  case LeaveNotify:    if (!(Event->xcrossing.state & Button1Mask) &&	(status & STATUS_TOP)) {      ((Menu *) parent)->UnmapallPulldownMenus ();      ((Menu *) parent)->UnselectMe ();    }    status &= ~STATUS_SELECTED;    DrawIcon (~ICON_SELECTED);    break;  }}Menu::Menu (Display * initdisplay,      GC initgc,      BigWindow * ParentWindow,      XFontStruct * fontstruct,      int initx, int inity):Window_Info (initdisplay,	     initgc,	     ParentWindow->GetWindow (),	     fontstruct,	     initx, inity, 100, 20,	     "", MENUEBORDERWIDTH){  pixmap = 0;  markpixmap = 0;  parentwindow = ParentWindow;  pulldownnumber = 0;  status = MENUSTATUS_DEFAULT;  height = fontstruct->max_bounds.descent +    fontstruct->max_bounds.ascent +    MENUVERTDISTANCE;  width = 2 * MENUBORDER;  if ((markpixmap = XCreateBitmapFromData (display, window, mark_bits,					mark_width, mark_height)) == None) {    printf ("Failed to create markbmp-bitmap in menu.cc!\n");    exit (0);  }  SetSelectedInput (ExposureMask		    | EnterWindowMask		    | LeaveWindowMask		    | ButtonPressMask

⌨️ 快捷键说明

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