void CCustomMenu::DrawItem( LPDRAWITEMSTRUCT lpStruct )
{
	if (lpStruct->CtlType==ODT_MENU)
	{
		if(lpStruct->itemData == NULL)
			return;
		unsigned int m_state = lpStruct->itemState;
		CDC* pDC = CDC::FromHandle(lpStruct->hDC);

		CString str =  ((CMenuItem*)(lpStruct->itemData))->m_MenuText;
		int MenuID = ((CMenuItem*)(lpStruct->itemData))->m_MenuType;

		CRect Rect = lpStruct->rcItem;
		pDC->SetBkMode(TRANSPARENT);
		switch(MenuID)
		{
		case -2:	//顶层菜单
			{
				DrawTopMenuBk(pDC,Rect,(m_state & ODS_SELECTED)||(m_state & 0x0040)); //0x0040 ==ODS_HOTLIGHT
				SetMenuItemText(pDC,str.GetBuffer(0),Rect);
				break;
			}
		case -1:
			{	
				SetMenuItemText(pDC,str.GetBuffer(0),Rect);
				break;
			}
		case 0:
			{
				DrawSepMenu(pDC,Rect);
				break;
			}
		default:
			{	
				if (m_RandColor)
				{
					int srcred = rand() % 255;
					int srcblue = rand() % 255;
					int srcgreen = rand() % 255;
					int desred = rand() % 255;
					int desblue = rand() % 255;
					int desgreen = rand() % 255;
					DrawMenuBk(pDC,Rect,RGB(srcred,srcgreen,srcblue),RGB(desred,desgreen,desblue),m_state & ODS_SELECTED);
				}
				else
				{
					DrawMenuBk(pDC,Rect,0xfaa0,0xf00ff,m_state & ODS_SELECTED);
				}
				SetMenuItemText(pDC,str.GetBuffer(0),Rect);
				break;
			}
		}
	}
}
    void UpdateUI(HWND hwnd)
    {
        if (g_pEngine->IsRecording() != bRecording)
        {
            bRecording = g_pEngine->IsRecording();
            if (bRecording)
            {
                SetMenuItemText(GetMenu(hwnd), ID_CAPTURE_RECORD, L"Stop Recording");
            }
            else
            {
                SetMenuItemText(GetMenu(hwnd), ID_CAPTURE_RECORD, L"Start Recording");
            }
        }

        if (g_pEngine->IsPreviewing() != bPreviewing)
        {
            bPreviewing = g_pEngine->IsPreviewing();
            if (bPreviewing)
            {
                SetMenuItemText(GetMenu(hwnd), ID_CAPTURE_PREVIEW, L"Stop Preview");
            }
            else
            {
                SetMenuItemText(GetMenu(hwnd), ID_CAPTURE_PREVIEW, L"Start Preview");
            }
        }
        BOOL bEnableRecording = TRUE;
        BOOL bEnablePhoto = TRUE;

        if (bRecording)
        {
            _SetStatusText(L"Recording");
        }
        else if (g_pEngine->IsPreviewing())
        {
            _SetStatusText(L"Previewing");
        }
        else
        {
            _SetStatusText(L"Please select a device or start preview (using the default device).");
            bEnableRecording = FALSE;
        }

        if (!g_pEngine->IsPreviewing() || g_pEngine->IsPhotoPending())
        {
            bEnablePhoto = FALSE;
        }

        EnableMenuItem(GetMenu(hwnd), ID_CAPTURE_RECORD, bEnableRecording ? MF_ENABLED : MF_GRAYED);
        EnableMenuItem(GetMenu(hwnd), ID_CAPTURE_TAKEPHOTO, bEnablePhoto ? MF_ENABLED : MF_GRAYED);
    }
EXPORT(sqInt) primitiveSetMenuItemText(void) {
	ConstStr255Param constStr255;
	MenuHandle menuHandle;
	sqInt menuHandleOop;
	sqInt anInteger;
	char *str255;
	sqInt _return_value;

	menuHandleOop = interpreterProxy->stackValue(2);
	anInteger = interpreterProxy->stackIntegerValue(1);
	interpreterProxy->success(interpreterProxy->isBytes(interpreterProxy->stackValue(0)));
	str255 = ((char *) (interpreterProxy->firstIndexableField(interpreterProxy->stackValue(0))));
	if (interpreterProxy->failed()) {
		return null;
	}
	menuHandle = ((MenuHandle) (interpreterProxy->positive64BitValueOf(menuHandleOop)));
	if (!(ioCheckMenuHandle(menuHandle))) {
		_return_value = interpreterProxy->success(0);
		if (interpreterProxy->failed()) {
			return null;
		}
		interpreterProxy->popthenPush(4, _return_value);
		return null;
	}
	constStr255 = ((ConstStr255Param) str255);
	SetMenuItemText(menuHandle,anInteger,constStr255);
	return null;
}
Exemple #4
0
void TrayIcon::RestoreWindowFromTray(bool abIconOnly /*= false*/, bool abDontCallShowWindow /*= false*/)
{
	if (!abIconOnly)
	{
		gpConEmu->SetWindowMode(gpConEmu->GetWindowMode());

		if (!abDontCallShowWindow && !IsWindowVisible(ghWnd))
		{
			gpConEmu->ShowWindow(SW_SHOW);
		}

		apiSetForegroundWindow(ghWnd);
	}

	if (IsWindowVisible(ghWnd))
	{
		//EnableMenuItem(GetSystemMenu(ghWnd, false), ID_TOTRAY, MF_BYCOMMAND | MF_ENABLED);
		HMENU hMenu = gpConEmu->mp_Menu->GetSysMenu(/*ghWnd, false*/);
		SetMenuItemText(hMenu, ID_TOTRAY, TRAY_ITEM_HIDE_NAME);
	}

	//for (int i = 0; i < countof(mn_SysItemId); i++)
	//{
	//	EnableMenuItem(hMenu, mn_SysItemId[i], MF_BYCOMMAND | mn_SysItemState[i]);
	//}

	if (!gpSet->isAlwaysShowTrayIcon)
		RemoveTrayIcon();
	else
		UpdateTitle();
}
Exemple #5
0
void TrayIcon::HideWindowToTray(LPCTSTR asInfoTip /* = NULL */)
{
	if (gpConEmu->InQuakeAnimation())
	{
		_ASSERTE(FALSE && "Calling TrayIcon::HideWindowToTray from QuakeAnimation");
		return;
	}

	mb_InHidingToTray = true;

	ShowTrayIcon(asInfoTip);

	if (IsWindowVisible(ghWnd))
	{
		gpConEmu->ShowWindow(SW_HIDE);
	}
	HMENU hMenu = gpConEmu->mp_Menu->GetSysMenu(/*ghWnd, false*/);
	SetMenuItemText(hMenu, ID_TOTRAY, TRAY_ITEM_RESTORE_NAME);
	mb_InHidingToTray = false;
	//for (int i = 0; i < countof(mn_SysItemId); i++)
	//{
	//	MENUITEMINFO mi = {sizeof(mi)};
	//	mi.fMask = MIIM_STATE;
	//	GetMenuItemInfo(hMenu, mn_SysItemId[i], FALSE, &mi);
	//	mn_SysItemState[i] = (mi.fState & (MFS_DISABLED|MFS_GRAYED|MFS_ENABLED));
	//	EnableMenuItem(hMenu, mn_SysItemId[i], MF_BYCOMMAND | MF_GRAYED);
	//}
}
Exemple #6
0
void UMASetMenuItemText(  MenuRef menu,  MenuItemIndex item, const wxString& title , wxFontEncoding encoding)
{
    wxString str = wxStripMenuCodes( title ) ;
#if TARGET_CARBON
    SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str , encoding) ) ;
#else
    Str255 ptitle ;
    wxMacStringToPascal( str , ptitle ) ;
    SetMenuItemText( menu , item , ptitle ) ;
#endif
}
static void set_about_item(void){
	Str255 aboutitem;
	StringHandle abouthandle;

	GetMenuItemText( GetMenuHandle(mApple), iAbout, aboutitem);
	abouthandle = NewString( aboutitem);
	if( abouthandle){
		StringPtr curApName = LMGetCurApName();
		long len = Munger( (Handle)abouthandle, 1, "MathLink\252", 9, curApName + 1, *curApName); 
		if( len > 0){
			**abouthandle = (unsigned char)len; 
			HLock( (Handle)abouthandle);
			SetMenuItemText( GetMenuHandle(mApple), iAbout, *abouthandle);
		}
		DisposeHandle( (Handle)abouthandle);
	}
}
void XGPopControl::ReloadItems (void)
{
	MenuHandle menu;
	int ix, len;
	char buf[256];

	if (!fControl)
		return;

	XGDraw draw(this,false);

	menu = GetMenuHandle();
	if (!menu)
		return;

#if TARGET_CARBON
	for (ix = CountMenuItems(menu); ix > 0; ix--) DeleteMenuItem(menu, ix);
#else
	for (ix = CountMItems(menu); ix > 0; ix--) DeleteMenuItem(menu, ix);
#endif

	for (ix = 0; ix < fList.GetNumStrings(); ix++) {
		fList.GetString(ix, buf);
		len = strlen(buf);
		memmove(&buf[1], buf, len);
		buf[0] = len;
		AppendMenu(menu, "\px");
		SetMenuItemText(menu, ix + 1, (unsigned char *)buf);
	}

#if TARGET_CARBON
	SetControlMaximum(fControl, CountMenuItems(menu));
#else
	SetControlMaximum(fControl, CountMItems(menu));
#endif
	SetControlValue(fControl, fValue + 1);
}
Exemple #9
0
static void Handler(void *data, int cur_item, void *user_pointer)
{
	void *item = AllocMenuItem(data);
	WSHDR *ws = AllocMenuWS(data, 128);
	
	
	for (int i = 0; i < _71_lgp_total; i++)
	{
		if (cur_item == _71_lgp[i].id)
		{
			wsprintf(ws, "%t", _71_lgp[i].str);
			break;
		}
		else
			wsprintf(ws, "%t", "Unknown");
	}
	
	
	_71 *_71 = MenuGetUserPointer(data);
	int flag = GET_FLAG();
	SetMenuItemIconArray(data, item, icons);
	SetMenuItemIcon(data, cur_item, flag);
	SetMenuItemText(data, item, ws, cur_item);
}
void fsODMenu::SetMenuItemsText(CMenu *pMenu, fsSetText *pTexts, UINT nSize, BOOL bByPos)
{
	for (UINT i = 0; i < nSize; i++)
		SetMenuItemText (pMenu, pTexts [i].pszText, pTexts [i].nIDItem, bByPos);
}
bool C4EditCursor::DoContextMenu(DWORD dwKeyState)
{
	bool fObjectSelected = !!Selection.ObjectCount();
#ifdef USE_WIN32_WINDOWS
	POINT point; GetCursorPos(&point);
	HMENU hContext = GetSubMenu(hMenu,0);
	SetMenuItemEnable( hContext, IDM_VIEWPORT_DELETE, fObjectSelected && Console.Editing);
	SetMenuItemEnable( hContext, IDM_VIEWPORT_DUPLICATE, fObjectSelected && Console.Editing);
	SetMenuItemEnable( hContext, IDM_VIEWPORT_CONTENTS, fObjectSelected && Selection.GetObject()->Contents.ObjectCount() && Console.Editing);
	SetMenuItemText(hContext,IDM_VIEWPORT_DELETE,LoadResStr("IDS_MNU_DELETE"));
	SetMenuItemText(hContext,IDM_VIEWPORT_DUPLICATE,LoadResStr("IDS_MNU_DUPLICATE"));
	SetMenuItemText(hContext,IDM_VIEWPORT_CONTENTS,LoadResStr("IDS_MNU_CONTENTS"));

	ObjselectDelItems();
	C4FindObjectAtPoint pFO(X,Y);
	C4ValueArray * atcursor; atcursor = pFO.FindMany(::Objects, ::Objects.Sectors); // needs freeing (single object ptr)
	int itemcount = atcursor->GetSize();
	if(itemcount > 0)
	{
		const int maxitems = 25; // Maximum displayed objects. if you raise it, also change note with IDM_VPORTDYN_FIRST in resource.h
		if(itemcount > maxitems) itemcount = maxitems+1;
		itemsObjselect.resize(itemcount+1); // +1 for a separator
		itemsObjselect[0].ItemId = IDM_VPORTDYN_FIRST;
		itemsObjselect[0].Object = NULL;
		AppendMenu(hContext, MF_SEPARATOR, IDM_VPORTDYN_FIRST, NULL);
		int i = 1;
		for(std::vector<ObjselItemDt>::iterator it = itemsObjselect.begin() + 1; it != itemsObjselect.end(); ++it, ++i)
		{
			C4Object * obj = (*atcursor)[i-1].getObj();
			assert(obj);
			it->ItemId = IDM_VPORTDYN_FIRST+i;
			it->Object = obj;
			AppendMenu(hContext, MF_STRING, it->ItemId, FormatString("%s #%i (%i/%i)", obj->GetName(), obj->Number, obj->GetX(), obj->GetY()).GetWideChar());
		}
		if(atcursor->GetSize() > maxitems)
		{
			AppendMenu(hContext, MF_GRAYED, IDM_VPORTDYN_FIRST+maxitems+1, L"...");
			itemsObjselect[maxitems+1].ItemId = IDM_VPORTDYN_FIRST+maxitems+1;
			itemsObjselect[maxitems+1].Object = NULL;
		}
	}
	delete atcursor;

	int32_t iItem = TrackPopupMenu(
	                  hContext,
	                  TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_NONOTIFY,
	                  point.x,point.y, 0,
	                  Console.hWindow,
	                  NULL);
	switch (iItem)
	{
	case IDM_VIEWPORT_DELETE: Delete(); break;
	case IDM_VIEWPORT_DUPLICATE: Duplicate(); break;
	case IDM_VIEWPORT_CONTENTS: GrabContents(); break;
	case 0: break;
	default:
		for(std::vector<ObjselItemDt>::iterator it = itemsObjselect.begin() + 1; it != itemsObjselect.end(); ++it)
			if(it->ItemId == iItem)
			{
				DoContextObjsel(it->Object, (dwKeyState & MK_SHIFT) == 0);
				break;
			}
		break;
	}
	ObjselectDelItems();
#else
#ifdef WITH_DEVELOPER_MODE
	gtk_widget_set_sensitive(itemDelete, fObjectSelected && Console.Editing);
	gtk_widget_set_sensitive(itemDuplicate, fObjectSelected && Console.Editing);
	gtk_widget_set_sensitive(itemGrabContents, fObjectSelected && Selection.GetObject()->Contents.ObjectCount() && Console.Editing);

	ObjselectDelItems();
	C4FindObjectAtPoint pFO(X,Y);
	C4ValueArray * atcursor; atcursor = pFO.FindMany(::Objects, ::Objects.Sectors); // needs freeing
	int itemcount = atcursor->GetSize();
	if(itemcount > 0)
	{
		itemsObjselect.resize(itemcount+1); // +1 for a separator
		itemsObjselect[0].MenuItem = gtk_separator_menu_item_new();
		itemsObjselect[0].EditCursor = this;
		gtk_menu_shell_append(GTK_MENU_SHELL(menuContext), itemsObjselect[0].MenuItem);
		int i = 0;
		for(std::vector<ObjselItemDt>::iterator it = itemsObjselect.begin() + 1; it != itemsObjselect.end(); ++it, ++i)
		{
			it->EditCursor = this;
			C4Object * obj = (*atcursor)[i].getObj();
			assert(obj);
			it->Object = obj;
			GtkWidget * wdg = gtk_menu_item_new_with_label(FormatString("%s #%i (%i/%i)", obj->GetName(), obj->Number, obj->GetX(), obj->GetY()).getData());
			it->MenuItem = wdg;
			gtk_menu_shell_append(GTK_MENU_SHELL(menuContext), wdg);
			g_signal_connect(G_OBJECT(wdg), "activate", G_CALLBACK(OnObjselect), &*it);
		}
	}
	delete atcursor;
	gtk_widget_show_all(menuContext);

	gtk_menu_popup(GTK_MENU(menuContext), NULL, NULL, NULL, NULL, 3, 0);
#endif
#endif
	return true;
}
Exemple #12
0
MenuMapOptions::MenuMapOptions(std::shared_ptr<Settings> &settings, std::shared_ptr<AcedSharedDLL::Map> &currentMap) : Menu((std::shared_ptr<AcedSharedDLL::BaseSettings>)settings) {
	SetMap(currentMap);

	SetMenuHeader(std::string("Map Options"));
	SetId(AcedSharedDLL::STATES::EDITORMAPOPTIONS);
	int widestItem = settings->GetFontWidth(GetMenuHeader());

	auto itemStoreCurrentWidth = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreCurrentWidth->SetMenuItemText(std::string("Current Width:"));

	//might need to delete this tempval char array? mmm looks to be in stack so should die when method finishs....
	std::string tempVal;
	tempVal = std::to_string(GetMap()->GetMapWidth());

	itemStoreCurrentWidth->InitMenuItemProperty(tempVal);
	itemStoreCurrentWidth->SetMenuItemTargetable(false);
	if (widestItem < settings->GetFontWidth(itemStoreCurrentWidth->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreCurrentWidth->GetMenuItemText());
	}
	AddMenuItem(itemStoreCurrentWidth);





	auto itemStoreNewWidth = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreNewWidth->InitMenuItemProperty("");
	itemStoreNewWidth->SetOptionId(AcedSharedDLL::OPTIONTYPES::WIDTHOPTION);
	itemStoreNewWidth->SetMenuItemText(std::string("New Width:"));
	if (widestItem < settings->GetFontWidth(itemStoreNewWidth->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreNewWidth->GetMenuItemText());
	}
	AddMenuItem(itemStoreNewWidth);




	auto itemStoreCurrentHeight = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreCurrentHeight->SetMenuItemText(std::string("Current Height:"));

	tempVal = std::to_string(GetMap()->GetMapHeight());

	itemStoreCurrentHeight->InitMenuItemProperty(tempVal);
	itemStoreCurrentHeight->SetMenuItemTargetable(false);
	if (widestItem < settings->GetFontWidth(itemStoreCurrentHeight->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreCurrentHeight->GetMenuItemText());
	}
	AddMenuItem(itemStoreCurrentHeight);






	auto itemStoreNewHeight = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreNewHeight->InitMenuItemProperty("");
	itemStoreNewHeight->SetOptionId(AcedSharedDLL::OPTIONTYPES::HEIGHTOPTION);
	itemStoreNewHeight->SetMenuItemText(std::string("New Height:"));
	if (widestItem < settings->GetFontWidth(itemStoreNewHeight->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreNewHeight->GetMenuItemText());
	}
	AddMenuItem(itemStoreNewHeight);




	auto itemStoreSave = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreSave->SetId(AcedSharedDLL::STATES::SAVE);
	itemStoreSave->SetMenuItemText(std::string("Save"));
	if (widestItem < settings->GetFontWidth(itemStoreSave->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreSave->GetMenuItemText());
	}
	AddMenuItem(itemStoreSave);

	auto itemStoreReturn = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreReturn->SetId(AcedSharedDLL::STATES::RETURN);
	itemStoreReturn->SetMenuItemText(std::string("Return"));
	if (widestItem < settings->GetFontWidth(itemStoreReturn->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreReturn->GetMenuItemText());
	}
	AddMenuItem(itemStoreReturn);

	widestItem += (AcedSharedDLL::Constants::TileSize() * 4);

	SetMenuX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuY(100);

	SetMenuHeaderX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuHeaderY(50 + AcedSharedDLL::Constants::TileSize());
	SetMenuHeaderHeight(50 - AcedSharedDLL::Constants::TileSize());

	int i = 0;
	int xloc = settings->GetScreenWidth() / 2;
	int yloc = 100 + AcedSharedDLL::Constants::TileSize();
	int yspacing = AcedSharedDLL::Constants::TileSize() * 2;

	auto menuSize = GetMenuItems().size();
	for (i = 0; i < menuSize; i++)
	{
		GetMenuItems()[i]->SetMenuItemX(xloc);
		GetMenuItems()[i]->SetMenuItemPropertyX(xloc + (settings->GetFontWidth(GetMenuItems()[i]->GetMenuItemText()) / 2) + (AcedSharedDLL::Constants::TileSize() * 1));
		GetMenuItems()[i]->SetMenuItemY(yloc);
		yloc = yloc + yspacing;
	}

	SetMenuWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeaderWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeight(yloc - GetMenuY());

	SetCurrentSelection();
}
Exemple #13
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
}
Exemple #14
0
MenuGameMain::MenuGameMain(std::shared_ptr<Settings> &settings) : Menu((std::shared_ptr<AcedSharedDLL::BaseSettings>)settings) {

	SetMenuHeader(std::string("Game Main Menu"));
	SetId(AcedSharedDLL::STATES::EDITORMAINMENU);
	int widestItem = settings->GetFontWidth(GetMenuHeader());

	auto itemStoreNew = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreNew->SetId(AcedSharedDLL::STATES::NEW);
	itemStoreNew->SetMenuItemText(std::string("New Map"));
	if (widestItem < settings->GetFontWidth(itemStoreNew->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreNew->GetMenuItemText());
	}
	AddMenuItem(itemStoreNew);


	auto itemStoreLoad = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreLoad->SetId(AcedSharedDLL::STATES::LOAD);
	itemStoreLoad->SetMenuItemText(std::string("Load Map"));
	if (widestItem < settings->GetFontWidth(itemStoreLoad->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreLoad->GetMenuItemText());
	}
	AddMenuItem(itemStoreLoad);

	auto itemStoreEdit = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreEdit->SetId(AcedSharedDLL::STATES::EDITORMAINMENU);
	itemStoreEdit->SetMenuItemText(std::string("Edit Mode"));
	if (widestItem < settings->GetFontWidth(itemStoreEdit->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreEdit->GetMenuItemText());
	}
	AddMenuItem(itemStoreEdit);

	auto itemStoreOptions = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreOptions->SetId(AcedSharedDLL::STATES::OPTIONS);
	itemStoreOptions->SetMenuItemText(std::string("Options"));
	if (widestItem < settings->GetFontWidth(itemStoreOptions->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreOptions->GetMenuItemText());
	}
	AddMenuItem(itemStoreOptions);


	auto itemStoreQuit = std::shared_ptr<AcedSharedDLL::MenuItem>(new AcedSharedDLL::MenuItem());
	itemStoreQuit->SetId(AcedSharedDLL::STATES::QUIT);
	itemStoreQuit->SetMenuItemText(std::string("Quit"));
	if (widestItem < settings->GetFontWidth(itemStoreQuit->GetMenuItemText())) {
		widestItem = settings->GetFontWidth(itemStoreQuit->GetMenuItemText());
	}
	AddMenuItem(itemStoreQuit);

	widestItem += (AcedSharedDLL::Constants::TileSize() * 4);

	SetMenuX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuY(100);

	SetMenuHeaderX((settings->GetScreenWidth() / 2) - (widestItem / 2) - (AcedSharedDLL::Constants::TileSize() * 4));
	SetMenuHeaderY(50 + AcedSharedDLL::Constants::TileSize());
	SetMenuHeaderHeight(50 - AcedSharedDLL::Constants::TileSize());

	int i = 0;
	int xloc = settings->GetScreenWidth() /2;
	int yloc = 100 + AcedSharedDLL::Constants::TileSize();
	int yspacing = AcedSharedDLL::Constants::TileSize()*2;

	auto menuSize = GetMenuItems().size();
	for (i = 0; i < menuSize; i++)
	{
		GetMenuItems()[i]->SetMenuItemX(xloc);
		GetMenuItems()[i]->SetMenuItemY(yloc);
		yloc = yloc + yspacing;
	}

	SetMenuWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeaderWidth(settings->GetScreenWidth() - (2 * GetMenuX()));
	SetMenuHeight(yloc - GetMenuY());


	SetCurrentSelection();
}
Exemple #15
0
/*** ADJUST MENUS ***/
OSStatus AdjustMenus( void )
{
	register		WindowRef theWin;
	short 			windowKind;
	Boolean 		isDA, isObjectWin, selection, scrapExists, undoExists, isGotoWin, isFindWin;
	EditWindowPtr	dWin = NULL;
	Str31			menuStr;
	short 			i;
	long			scrapSize;	// LR: v1.6.5
	Str255			frontWindowName, menuItemTitle;
	Boolean			namesMatch;

	theWin = FrontNonFloatingWindow();
	if( theWin )
	{
		isGotoWin = (g.gotoDlg && theWin == GetDialogWindow( g.gotoDlg ));		//LR: 1.7 - don't get window info on NULL!
		isFindWin = (g.searchDlg && theWin == GetDialogWindow( g.searchDlg ));

		windowKind = GetWindowKind( theWin );
		isDA = ( windowKind < 0 );
		isObjectWin = GetWindowKind( theWin ) == kHexEditWindowTag;
		if( isObjectWin )
		{
			dWin = (EditWindowPtr)GetWRefCon( theWin );	//LR: 1.66 - don't set unless an edit window!
			selection = dWin->endSel > dWin->startSel;
		}
		else
		{
			selection = (isGotoWin || isFindWin);
		}
	}
	else	// LR: v1.6.5 if no window is visible, then nothing is true!
	{
		isGotoWin = isFindWin = isObjectWin = isDA = selection = 0;
	}

	// LR: v1.6.5 - rewrite of scrap check
	if( isObjectWin || isFindWin || isGotoWin )
	{
#if TARGET_API_MAC_CARBON
		ScrapFlavorFlags flavorFlags;
		ScrapRef scrapRef;
		OSErr anErr;

		anErr = GetCurrentScrap( &scrapRef );
		if( !anErr )
			anErr = GetScrapFlavorFlags( scrapRef, kScrapFlavorTypeText, &flavorFlags );	// non-blocking check for scrap data
		if( !anErr )
			anErr = GetScrapFlavorSize( scrapRef, kScrapFlavorTypeText, &scrapSize );		// blocking call to get size
#else
		long offset;

		scrapSize = GetScrap( NULL, 'TEXT', &offset );
#endif
		scrapExists = scrapSize > 0;
	}
	else
		scrapExists = false;

	undoExists = (isObjectWin && gUndo.type != 0 && gUndo.theWin == dWin);	// check for NULL gUndo!
	
// LR: - enable file menu items during search, via Aaron D.
// LR:	_enableMenuItem( fileMenu, FM_New, g.searchDlg == NULL );
// LR:	_enableMenuItem( fileMenu, FM_Open, g.searchDlg == NULL );

// LR: 1.65 moved print names to string for localization
	GetIndString( menuStr, strPrint, (isObjectWin && dWin->startSel < dWin->endSel) ? 2 : 1 );

	SetMenuItemText( fileMenu, FM_Print, menuStr );

//LR 188 -- page setup should always be enabled
//	_enableMenuItem( fileMenu, FM_PageSetup, isObjectWin );	//SEL: 1.7 - enabled for carbon
	_enableMenuItem( fileMenu, FM_Print, isObjectWin );

//	HR/LR 050328 - Enable and check FM_Disassemble menu item
	_enableMenuItem( fileMenu, FM_Disassemble, isObjectWin );
	CheckMenuItem( fileMenu, FM_Disassemble, g.disassemble );

	_enableMenuItem( fileMenu, FM_OtherFork, isObjectWin );
	_enableMenuItem( fileMenu, FM_Close, isDA || isObjectWin || isFindWin || isGotoWin );	// LR: v1.6.5 rewrite via Max Horn
	_enableMenuItem( fileMenu, FM_Save, isObjectWin && dWin->dirtyFlag );
	_enableMenuItem( fileMenu, FM_SaveAs, isObjectWin );
	_enableMenuItem( fileMenu, FM_Revert, isObjectWin && dWin->refNum && dWin->dirtyFlag );

	_enableMenuItem( editMenu, 0, theWin != NULL );
	_enableMenuItem( editMenu, EM_Undo, isDA || undoExists );
	_enableMenuItem( editMenu, EM_Cut,  isDA || (selection && (!gPrefs.overwrite || (gPrefs.overwrite && !gPrefs.nonDestructive))) );
	_enableMenuItem( editMenu, EM_Copy, isDA || selection );
	_enableMenuItem( editMenu, EM_Paste, isDA || (scrapExists && (!gPrefs.overwrite || (gPrefs.overwrite && !gPrefs.nonDestructive))) );
	_enableMenuItem( editMenu, EM_Clear, isDA || selection );

	_enableMenuItem( editMenu, EM_SelectAll, isDA || isObjectWin || isFindWin || isGotoWin );

	_enableMenuItem( findMenu, 0, isObjectWin || isFindWin || isGotoWin );
/* 1.65
	_enableMenuItem( findMenu, SM_Find, isObjectWin );
	_enableMenuItem( findMenu, SM_GotoAddress, isObjectWin );
*/
	_enableMenuItem( findMenu, SM_FindForward, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) );	//LR 1.72 -- only enable w/something to search :)
	_enableMenuItem( findMenu, SM_FindBackward, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) );
	_enableMenuItem( findMenu, SM_Replace, selection || (isObjectWin && dWin->fileSize && g.searchBuffer[0]) );

	_enableMenuItem( optionsMenu, OM_NonDestructive, gPrefs.overwrite );	//LR 1.74 -- only available in overwrite mode

	CheckMenuItem( optionsMenu, OM_HiAscii, gPrefs.asciiMode );
	CheckMenuItem( optionsMenu, OM_DecimalAddr, gPrefs.decimalAddr );
	CheckMenuItem( optionsMenu, OM_Backups, gPrefs.backupFlag );
	CheckMenuItem( optionsMenu, OM_WinSize, gPrefs.constrainSize );
	CheckMenuItem( optionsMenu, OM_Overwrite, gPrefs.overwrite );
	CheckMenuItem( optionsMenu, OM_NonDestructive, !gPrefs.nonDestructive );	//LR 190 -- REVERSE (updated text, not code)
	CheckMenuItem( optionsMenu, OM_MoveOnlyPaging, gPrefs.moveOnlyPaging );	//LR 180 -- optional move only paging
	CheckMenuItem( optionsMenu, OM_Unformatted, !gPrefs.formatCopies );
	CheckMenuItem( optionsMenu, OM_VertBars, gPrefs.vertBars );
 	CheckMenuItem( optionsMenu, OM_OpenOnLaunch, gPrefs.dialogAtLaunch );	//WD_rpw 12-18-04

	// LR: v1.6.5 Lots of re-writing on handling the color scheme menu
#if !TARGET_API_MAC_CARBON
	// no color usage if not displayable!
	if( !g.colorQDFlag )
		gPrefs.useColor = false;
#endif

// LR: v1.6.5	CheckMenuItem( gColorMenu, CM_UseColor, gPrefs.useColor );	// allow turning on even if not usable
// LR: v1.6.5 Try to show status of color in new windows to help "intuitive" nature of menu
	GetIndString( menuStr, strColor, (gPrefs.useColor) ? 2 : 1 );
	SetMenuItemText( colorMenu, CM_UseColor, menuStr );

	//LR 181 -- show the current window color (or default if no windows)
	if( _cmCheckedItem )
		CheckMenuItem( colorMenu, _cmCheckedItem, false );
	_cmCheckedItem = isObjectWin ? dWin->csMenuID : gPrefs.csMenuID;
	CheckMenuItem( colorMenu, _cmCheckedItem, true );

	selection = gPrefs.useColor;	//LR 190 -- && isObjectWin && dWin->csResID > 0;
	i = CountMenuItems( colorMenu );
	do
	{
		_enableMenuItem( colorMenu, i, selection );	// LR: v1.6.5 only enable for color windows
	} while( --i > 2 );
	
	// NS: v1.6.6 checkmark front window in window menu
	if( theWin )
		GetWTitle( theWin, frontWindowName );	//LR: 1.66 - don't use NULL window!
	else
		frontWindowName[0] = 0;

	i = CountMenuItems( windowMenu );
	_enableMenuItem(windowMenu, 0, i != 0);	// dim out Window menu if no windows up.
	while( i )
	{
		GetMenuItemText( windowMenu, i, menuItemTitle );		// if you open more than one file with the same name (or edit the other fork)É
		namesMatch = EqualPStrings( frontWindowName, menuItemTitle );	// Éyou will have multiple items in the menu with the same text, and all will be checkmarked
		CheckMenuItem( windowMenu, i, namesMatch );

		i--;
	}

	return( noErr );
}