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

📄 menu.cc

📁 模糊聚类的算法实现程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
		    | ButtonReleaseMask		    | OwnerGrabButtonMask);}Menu::~Menu (){  UnmapMe ();  unsigned short counter;  for (counter = 0; counter < pulldownnumber; counter++) {    delete menuicons[counter]->GetSonPulldownMenu ();    delete menuicons[counter];  }  free (menuicons);  XFreePixmap (display, pixmap);  XFreePixmap (display, markpixmap);}void Menu::MakeUnselectable (){  unsigned short counter;  for (counter = 0; counter < pulldownnumber; counter++)    menuicons[counter]->AddMenuStatus (STATUS_UNSELECTABLE);}void Menu::MakeSelectable (){  unsigned short counter;  for (counter = 0; counter < pulldownnumber; counter++)    menuicons[counter]->DelMenuStatus (STATUS_UNSELECTABLE);}void Menu::AddPulldownMenu (MenuIconInfo * Infos,		       unsigned short number){  unsigned short counter, iconheight, iconwidth, depth, topiconwidth;  pulldownnumber++;  iconwidth = MINMENUWIDTH;  for (counter = 0; counter < number; counter++)    iconwidth = MAX (iconwidth,		     XTextWidth (fontstruct, Infos[counter].bartext, strlen (Infos[counter].bartext)));  iconwidth += MENUHORIZONTALSPACE;  iconheight = height - MENUVERTDISTANCE;  topiconwidth = XTextWidth (fontstruct, Infos[0].bartext, strlen (Infos[0].bartext)) +    2 * MENUHORIZONTALSPACE;  width += topiconwidth;  XResizeWindow (display, window, width, height);  depth = DefaultDepth (display, DefaultScreen (display));  if (pixmap)    XFreePixmap (display, pixmap);  pixmap = XCreatePixmap (display, window, width, height, depth);  DrawMenu ();  MenuIcon **tempicons = (MenuIcon **) malloc (sizeof (MenuIcon *) * (pulldownnumber));  for (counter = 0; counter < pulldownnumber - 1; counter++)    tempicons[counter] = menuicons[counter];  Infos[0].barstatus |= STATUS_CENTER | STATUS_TOP;  tempicons[pulldownnumber - 1] =    new MenuIcon (display, gc, parentwindow, this, fontstruct,		  width - topiconwidth - MENUBORDER, MENUBORDER,		  topiconwidth, iconheight,		  Infos);  menuicons = tempicons;  menuicons[pulldownnumber - 1]->SetSonPulldownMenu (	      new PulldownMenu (display, gc, parentwindow, this, fontstruct,			 x + width - iconwidth - MENUBORDER, y + height + 2,				iconwidth,				Infos + 1, number - 1));// place the pulldown-menu  if (pulldownnumber == 1)    menuicons[0]->GetSonPulldownMenu ()->PlaceMe (x, y + height + 2 * MENUBORDER);  if (pulldownnumber > 1) {    menuicons[pulldownnumber - 1]->GetSonPulldownMenu ()->      PlaceMe ((x + width - topiconwidth) +	       (topiconwidth - menuicons[pulldownnumber - 1]->GetSonPulldownMenu ()->Getwidth ()),	       y + height + 2 * MENUBORDER);    if (pulldownnumber > 2)      menuicons[pulldownnumber - 2]->GetSonPulldownMenu ()->	MoveMe ((menuicons[pulldownnumber - 2]->GetSonPulldownMenu ()->Getwidth () -		 menuicons[pulldownnumber - 2]->Getwidth ()) / 2,		0);  }  XMapWindow (display, window);}void Menu::PlaceMe (unsigned short newx, unsigned short newy){  short xdiff = newx - x, ydiff = newy - y;  unsigned short counter;  x = newx;  y = newy;  XMoveWindow (display, window, x, y);  for (counter = 0; counter < pulldownnumber; counter++)    menuicons[counter]->GetSonPulldownMenu ()->MoveMe (xdiff, ydiff);}void Menu::DrawMenu (){  XSegment linesrightlow[2] =  {    {width - 1, 1, width - 1, height - 1},    {1, height - 1, width - 1, height - 1}  }, lineslefthigh[2] =  {    {0, 0, width - 2, 0},    {0, 0, 0, height - 2}  };  XSetForeground (display, gc, buttonpix);  XFillRectangle (display, pixmap, gc, 0, 0, width, height);  XSetForeground (display, gc, shadowpix);  XDrawSegments (display, pixmap, gc, linesrightlow, 2);  XSetForeground (display, gc, lightpix);  XDrawSegments (display, pixmap, gc, lineslefthigh, 2);}PulldownMenu *Menu::GetPulldownMenu (short index){  return (menuicons[index]->GetSonPulldownMenu ());}void Menu::AddMenuStatus (int addstatus, int menuidentifier){  int counter;  for (counter = 0; (counter < pulldownnumber) && (menuicons[counter]->GetActionnumber () != menuidentifier); counter++);  if (menuicons[counter]->GetActionnumber () == menuidentifier)    menuicons[counter]->AddMenuStatus (addstatus);}void Menu::DelMenuStatus (int delstatus, int menuidentifier){  int counter;  for (counter = 0; (counter < pulldownnumber) && (menuicons[counter]->GetActionnumber () != menuidentifier); counter++);  if (menuicons[counter]->GetActionnumber () == menuidentifier)    menuicons[counter]->DelMenuStatus (delstatus);}void Menu::MapmyPulldownMenu (MenuIcon * my){  unsigned short counter;  for (counter = 0; counter < pulldownnumber; counter++) {    if (menuicons[counter] == my)      my->GetSonPulldownMenu ()->MapMe ();    else      menuicons[counter]->GetSonPulldownMenu ()->UnmapMe ();  }}void Menu::UnmapallPulldownMenus (){  unsigned short counter;  for (counter = 0; counter < pulldownnumber; counter++)    menuicons[counter]->GetSonPulldownMenu ()->UnmapMe ();}void Menu::HandleEvent (XEvent * Event){  switch (Event->type) {  case Expose:    if (Event->xexpose.count == 0)      XCopyArea (display, pixmap, window, gc,		 0, 0, width, height, 0, 0);    break;  }}PulldownMenu::PulldownMenu (Display * initdisplay,	      GC initgc,	      BigWindow * ParentWindow,	      Menu * ParentMenu,	      XFontStruct * fontstruct,	      int initx, int inity, int initwidth,	      MenuIconInfo * Infos,	      unsigned short number):Window_Info (initdisplay,	     initgc,	     ParentWindow->GetWindow (),	     fontstruct,	     initx, inity, initwidth, 20,	     "", 1){  unsigned short counter, iconheight;  iconnumber = number;  parentmenu = ParentMenu;  parentwindow = ParentWindow;  iconheight = fontstruct->max_bounds.descent +    fontstruct->max_bounds.ascent +    MENUVERTDISTANCE;  height = number * iconheight;  width = initwidth;  for (counter = 0; counter < number; counter++)    width = MAX (width,		 XTextWidth (fontstruct, Infos[counter].bartext, strlen (Infos[counter].bartext)));  width += MENUHORIZONTALSPACE * 2;  width += 2 * PULLDOWNBORDER;  height += 2 * PULLDOWNBORDER;  SizeMe (width, height);  short depth = DefaultDepth (display, DefaultScreen (display));  pixmap = XCreatePixmap (display, window, width, height, depth);  DrawBorder (pixmap, HIGH);  menuicons = (MenuIcon **) malloc (sizeof (MenuIcon *) * (number));  for (counter = 0; counter < number; counter++) {    menuicons[counter] = new MenuIcon (display,				       gc,				       parentwindow,				       this,				       fontstruct,		      PULLDOWNBORDER, PULLDOWNBORDER + iconheight * counter,				     width - 2 * PULLDOWNBORDER, iconheight,				       &Infos[counter]);  }  SetSelectedInput (ExposureMask);}void PulldownMenu::MapMe (){/*unsigned short counter;   for(counter=0; counter<iconnumber ;counter++)   {   if(menuicons[counter]->GetSonPulldownMenu()!=NULL)   menuicons[counter]->GetSonPulldownMenu()->UnmapMe();   } */  XMapWindow (display, window);  XRaiseWindow (display, window);}void PulldownMenu::MoveMe (short xdiff, short ydiff){  x += xdiff;  y += ydiff;  XMoveWindow (display, window, x, y);  unsigned short counter;  for (counter = 0; counter < iconnumber; counter++) {    if (menuicons[counter]->GetSonPulldownMenu () != NULL)      menuicons[counter]->GetSonPulldownMenu ()->MoveMe (xdiff, ydiff);  }}void PulldownMenu::UnmapMe (){  XUnmapWindow (display, window);  unsigned short counter;  for (counter = 0; counter < iconnumber; counter++) {    if (menuicons[counter]->GetSonPulldownMenu () != NULL)      menuicons[counter]->GetSonPulldownMenu ()->UnmapMe ();  }}PulldownMenu::~PulldownMenu (){  unsigned short counter;  for (counter = 0; counter < iconnumber; counter++)    delete menuicons[counter];  free (menuicons);  XFreePixmap (display, pixmap);}void PulldownMenu::EnteredMe (MenuIcon * me){  unsigned short counter;  for (counter = 0; counter < iconnumber; counter++) {    if (menuicons[counter]->GetSonPulldownMenu () != NULL) {      if (menuicons[counter] != me)	menuicons[counter]->GetSonPulldownMenu ()->UnmapMe ();      else if (!(menuicons[counter]->GetStatus () & STATUS_UNSELECTABLE))	menuicons[counter]->GetSonPulldownMenu ()->MapMe ();    }  }}void PulldownMenu::HandleEvent (XEvent * Event){  switch (Event->type) {  case Expose:    XCopyArea (display, pixmap, window, gc,	       Event->xgraphicsexpose.x, Event->xgraphicsexpose.y,	       Event->xgraphicsexpose.width, Event->xgraphicsexpose.height,	       Event->xgraphicsexpose.x, Event->xgraphicsexpose.y);    break;  }}

⌨️ 快捷键说明

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