Ejemplo n.º 1
0
boolean clickcolorpopup (Point pt, RGBColor *rgb) {
	
	long result;
	short lo, hi;
	
	if (!flpopupinit)
		flpopupinit = initcolorpopup ();
	
	setcursortype (cursorisarrow);
	
	CalcMenuSize (colormenu);
	
	InsertMenu (colormenu, hierMenu);

	LocalToGlobal (&pt);
	
	result = PopUpMenuSelect (colormenu, pt.v, pt.h, -1);

	DeleteMenu ((**colormenu).menuID);
	
	lo = LoWord (result);
	
	hi = HiWord (result);
	
	if (hi > 0) { /*something was selected*/
	
		*rgb = (*ctable) [lo - 1].rgb;
		
		return (true);
		}
	
	return (false);
	} /*clickcolorpopup*/
Ejemplo n.º 2
0
IPopupMenu* IGraphicsCarbon::CreateIPopupMenu(IPopupMenu* pMenu, IRECT* pAreaRect)
{
  // Get the plugin gui frame rect within the host's window
  HIRect rct;
  HIViewGetFrame(this->mView, &rct);

  // Get the host's window rect within the screen
  Rect wrct;
  GetWindowBounds(this->mWindow, kWindowContentRgn, &wrct);

  #ifdef RTAS_API
  int xpos = wrct.left + this->GetLeftOffset() + pAreaRect->L;
  int ypos = wrct.top + this->GetTopOffset() + pAreaRect->B + 5;
  #else
  HIViewRef contentView;
  HIViewFindByID(HIViewGetRoot(this->mWindow), kHIViewWindowContentID, &contentView);
  HIViewConvertRect(&rct, HIViewGetSuperview((HIViewRef)this->mView), contentView);

  int xpos = wrct.left + rct.origin.x + pAreaRect->L;
  int ypos = wrct.top + rct.origin.y + pAreaRect->B + 5;
  #endif

  MenuRef menuRef = CreateMenu(pMenu);

  if (menuRef)
  {
    int32_t popUpItem = 1;
    int32_t PopUpMenuItem = PopUpMenuSelect(menuRef, ypos, xpos, popUpItem);

    short result = LoWord(PopUpMenuItem) - 1;
    short menuIDResult = HiWord(PopUpMenuItem);
    IPopupMenu* resultMenu = 0;

    if (menuIDResult != 0)
    {
      MenuRef usedMenuRef = GetMenuHandle(menuIDResult);

      if (usedMenuRef)
      {
        if (GetMenuItemRefCon(usedMenuRef, 0, (URefCon*)&resultMenu) == noErr)
        {
          resultMenu->SetChosenItemIdx(result);
        }
      }
    }

    CFRelease(menuRef);

    return resultMenu;
  }
  else
  {
    return 0;
  }
}
Ejemplo n.º 3
0
void PopupMenu::showPopup(GuiCanvas* canvas, S32 x /* = -1 */, S32 y /* = -1 */)
{
   if(x < 0 || y < 0)
   {
      Point2I p = canvas->getCursorPos();
      x = p.x;
      y = p.y;
   }

   PopUpMenuSelect(mData->mMenu, y, x, 0);
}
Ejemplo n.º 4
0
/****************************************************************
   PopClick() gets called when there is a click in a dialog item
   that might be a popup item.  It determines if the click is
   in a popup and if so handles the click.  It brings up the
   popup on the item that was last selected for this menu.  It
   returns true if the item was a popup item and the mouse was
   released on a valid item.
   In that case, it also stores the value returned
   by PopUpMenuSelect in *result (a long containing the menu and
   item ID selected).  If the item selected was in this menu (as
   opposed to one of its submenus), that item is stored in the
   lastItemSelected field for this popup in the popTable.  In
   that case, the item is also checked, and the previously
   selected item is unchecked.

   For a click on a static popup item, PopClick returns false,
   returns 0 in *result and doesn't call PopUpMenuSelect.

   -- On the IBM, this simply gets the index value of the selected item.

****************************************************************/
Boolean PopClick(DialogPtr theDialog, short itemHit, LONGPTR result)
{
#ifndef IBM
   GrafPtr        savePort;
   short          theType;
   Rect           popBox;
   Rect           titleBox;
   MenuHandle     theMenu;
   long           res;
   short          count;
   char           name[256];
   Handle         itemHandle;
#else
	HANDLE itemHandle;
#endif
   short          i;
   
   #ifndef IBM
   if (OverridePopClick(theDialog, itemHit, result)) return true;
   #endif
   
   for ( i = 0 ; i < sa_numPopUps ; i++ )
      if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == itemHit) )
         break;

   if (i == sa_numPopUps || sa_popTable[i].bStatic) {
      *result = 0;
      return false;
   }

 #ifdef IBM
   itemHandle = GetDlgItem (theDialog, itemHit);
   sa_popTable[i].lastItemSelected =
    // (SendMessage (itemHandle, CB_GETCURSEL, 0, 0L)+1);  //Combo box item ID's begin at 0
     (SendMessage ((HWND)itemHandle, CB_GETCURSEL, 0, 0L)+1);  //Combo box item ID's begin at 0
	
	return FALSE;
 #else
   GetPortGrafPtr(&savePort);
   SetPortDialogPort(theDialog);
   theMenu = GetMenuHandle(sa_popTable[i].menuID);

   if (sa_popTable[i].drawProc == nil)       // grow items to match size of pop-box
      for ( count = CountMenuItems(theMenu) ; count >= 1 ; count-- ) {
         GetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
         strcat(name, "     ");
         my_c2pstr(name);
         SetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
      }

   if (sa_popTable[i].titleItemNum) {
      GetDialogItem(theDialog,sa_popTable[i].titleItemNum,&theType,&itemHandle,&titleBox);
      InvertRect(&titleBox);
   }
   GetDialogItem(theDialog,sa_popTable[i].popupItemNum,&theType,&itemHandle,&popBox);
   LocalToGlobal((Point *)(&popBox.top));
   LocalToGlobal((Point *)(&popBox.bottom));
   res = PopUpMenuSelect( theMenu, popBox.top + 1, popBox.left + 1, sa_popTable[i].lastItemSelected );
   if (sa_popTable[i].titleItemNum)
      InvertRect(&titleBox);
   if (LoWord(res) && (HiWord(res) == sa_popTable[i].menuID)) {
      SetItemMark(theMenu, sa_popTable[i].lastItemSelected, noMark);
      sa_popTable[i].lastItemSelected = LoWord(res);
      SetItemMark(theMenu, sa_popTable[i].lastItemSelected, kCheckMark);
   }

   if (sa_popTable[i].drawProc == nil)       // shrink items back to normal
      for ( count = CountMenuItems(theMenu) ; count >= 1 ; count-- ) {
         GetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
         name[strlen(name) - 5] = 0;
         my_c2pstr(name);
         SetMenuItemText(theMenu, count, (StringPtr)name);
         my_p2cstr((StringPtr)name);
      }

   *result = res;

   SetPortGrafPort(savePort);

   if (LoWord(res)) {
      PopDraw(sa_popTable[i].dialogPtr, sa_popTable[i].popupItemNum);
      return true;
   }

   return false;
 #endif //IBM
}