示例#1
0
//__________________________________________________________________
_HYRect _HYPullDown::_SuggestDimensions (void)
{
    _HYRect res = {25,100,25,100,HY_COMPONENT_NO_SCROLL};

    if (theMenu) {
        long            naturalWidth = 0;
        PangoLayout *   fontMeasurer = nil;
        for (long k=0; k<widgetList.lLength; k+=2) {
            GtkWidget * dropWidget = GTK_WIDGET (widgetList(k));
            if (!fontMeasurer) {
                fontMeasurer = pango_layout_new (gtk_widget_get_pango_context (dropWidget));
            }

            pango_layout_set_text(fontMeasurer,GetMenuItem(k/2)->sData ,GetMenuItem(k/2)->sLength);
            PangoRectangle extents,
                           log_ext;
            pango_layout_get_pixel_extents (fontMeasurer,&extents,nil);
            if (extents.width > naturalWidth) {
                naturalWidth = extents.width;
            }
        }
        if (fontMeasurer) {
            g_object_unref (fontMeasurer);
        }

        res.right = res.left = naturalWidth+25;
    }

    return res;
}
示例#2
0
/**
*返回鼠标指向的菜单在menu中是第多少项
*/
int SelectShellIndex(XlibMenu * menu, int x, int y, int* offseth)
{
    FcitxSkin *sc = &menu->owner->skin;
    int i;
    int winheight = sc->skinMenu.marginTop;
    int fontheight;
    int marginLeft = sc->skinMenu.marginLeft;
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;

    if (x < marginLeft)
        return -1;

    fontheight = FontHeight(menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU) {
            if (y > winheight + 1 && y < winheight + 6 + fontheight - 1) {
                if (offseth)
                    *offseth = winheight;
                return i;
            }
            winheight = winheight + 6 + fontheight;
        } else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE)
            winheight += 5;
    }
    return -1;
}
示例#3
0
/*
* 显示菜单上面的文字信息,只需要指定窗口,窗口宽度,需要显示文字的上边界,字体,显示的字符串和是否选择(选择后反色)
* 其他都固定,如背景和文字反色不反色的颜色,反色框和字的位置等
*/
void DisplayText(XlibMenu * menu, int shellindex, int line_y, int fontHeight)
{
    FcitxSkin *sc = &menu->owner->skin;
    int marginLeft = sc->skinMenu.marginLeft;
    int marginRight = sc->skinMenu.marginRight;
    cairo_t *  cr;
    cr = cairo_create(menu->menu_cs);
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    SetFontContext(cr, menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);

    if (GetMenuItem(menu->menushell, shellindex)->isselect == 0) {
        fcitx_cairo_set_color(cr, &sc->skinFont.menuFontColor[MENU_INACTIVE]);

        OutputStringWithContext(cr, dpi, GetMenuItem(menu->menushell, shellindex)->tipstr, 15 + marginLeft , line_y);
    } else {
        cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
        fcitx_cairo_set_color(cr, &sc->skinMenu.activeColor);
        cairo_rectangle(cr, marginLeft , line_y, menu->width - marginRight - marginLeft, fontHeight + 4);
        cairo_fill(cr);

        fcitx_cairo_set_color(cr, &sc->skinFont.menuFontColor[MENU_ACTIVE]);
        OutputStringWithContext(cr, dpi, GetMenuItem(menu->menushell, shellindex)->tipstr , 15 + marginLeft , line_y);
    }
    ResetFontContext();
    cairo_destroy(cr);
}
示例#4
0
void GetMenuSize(XlibMenu * menu)
{
    int i = 0;
    int winheight = 0;
    int fontheight = 0;
    int menuwidth = 0;
    FcitxSkin *sc = &menu->owner->skin;
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    winheight = sc->skinMenu.marginTop + sc->skinMenu.marginBottom;//菜单头和尾都空8个pixel
    fontheight = FontHeight(menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU)
            winheight += 6 + fontheight;
        else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE)
            winheight += 5;

        int width = StringWidth(GetMenuItem(menu->menushell, i)->tipstr, menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
        if (width > menuwidth)
            menuwidth = width;
    }
    menu->height = winheight;
    menu->width = menuwidth + sc->skinMenu.marginLeft + sc->skinMenu.marginRight + 15 + 20;
}
示例#5
0
//根据Menu内容来绘制菜单内容
void DrawXlibMenu(XlibMenu * menu)
{
    FcitxSkin *sc = &menu->owner->skin;
    FcitxClassicUI *classicui = menu->owner;
    Display* dpy = classicui->dpy;
    GC gc = XCreateGC(dpy, menu->menuWindow, 0, NULL);
    int i = 0;
    int fontheight;
    int iPosY = 0;
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    fontheight = FontHeight(menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
    SkinImage *background = LoadImage(sc, sc->skinMenu.backImg, false);

    GetMenuSize(menu);
    EnlargeCairoSurface(&menu->menu_cs, menu->width, menu->height);

    if (background) {
        cairo_t* cr = cairo_create(menu->menu_cs);
        DrawResizableBackground(cr, background->image, menu->height, menu->width,
                                sc->skinMenu.marginLeft,
                                sc->skinMenu.marginTop,
                                sc->skinMenu.marginRight,
                                sc->skinMenu.marginBottom,
                                sc->skinMenu.fillV,
                                sc->skinMenu.fillH
                            );

        cairo_destroy(cr);
    }

    iPosY = sc->skinMenu.marginTop;
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU) {
            DisplayText(menu, i, iPosY, fontheight);
            if (menu->menushell->mark == i)
                MenuMark(menu, iPosY, i);

            if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU)
                DrawArrow(menu, iPosY);
            iPosY = iPosY + 6 + fontheight;
        } else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE) {
            DrawDivLine(menu, iPosY);
            iPosY += 5;
        }
    }
    XResizeWindow(dpy, menu->menuWindow, menu->width, menu->height);
    _CAIRO_SETSIZE(menu->menu_x_cs, menu->width, menu->height);
    cairo_t* c = cairo_create(menu->menu_x_cs);
    cairo_set_operator(c, CAIRO_OPERATOR_SOURCE);
    cairo_set_source_surface(c, menu->menu_cs, 0, 0);
    cairo_rectangle(c, 0, 0, menu->width, menu->height);
    cairo_clip(c);
    cairo_paint(c);
    cairo_destroy(c);
    cairo_surface_flush(menu->menu_x_cs);
    XFreeGC(dpy, gc);
}
示例#6
0
void CMenu::ItemChanged( int a_iItemCode, int a_iValue, CMenuItem* a_poMenuItem )
{
	debug( "CMenu::ItemChanged( %d, %d )\n", a_iItemCode, a_iValue );
	
	switch ( a_iItemCode )
	{
		case MENU_NUM_PLAYERS:
			g_oState.m_iNumPlayers = a_iValue;
			break;

		case MENU_TEAM_MODE:
		{
			g_oState.m_enTeamMode = (SState::TTeamModeEnum) a_iValue;
			CMenuItem* poItem;
			poItem = GetMenuItem( MENU_TEAM_SIZE );
			if ( poItem ) poItem->SetEnabled( SState::Team_CUSTOM==g_oState.m_enTeamMode );
			poItem = GetMenuItem( MENU_TEAM_MULTISELECT );
			if ( poItem ) poItem->SetEnabled( SState::Team_CUSTOM==g_oState.m_enTeamMode );
			break;
		}

		case MENU_TEAM_SIZE:
			g_oState.m_iTeamSize = a_iValue;
			break;

		case MENU_TEAM_MULTISELECT:
			g_oState.m_bTeamMultiselect = a_iValue;
			break;

		case MENU_MUSIC_VOLUME:
			g_oState.m_iMusicVolume = a_iValue;
			Audio->SetMusicVolume( a_iValue );
			break;
			
		case MENU_SOUND_VOLUME:
			g_oState.m_iSoundVolume = a_iValue;
			break;
			
		case MENU_ROUND_LENGTH:
			g_oState.m_iRoundLength = a_iValue;
			break;
			
		case MENU_GAME_SPEED:
			g_oState.m_iGameSpeed = a_iValue;
			break;
			
		case MENU_TOTAL_HIT_POINTS:
			g_oState.m_iHitPoints = a_iValue;
			break;
		
		case MENU_LANGUAGE:
			g_oState.SetLanguage( g_ppcLanguageCodes[ a_iValue ] );
			Clear();
			Draw();
			break;
	} // end of switch a_iItemCode
}
示例#7
0
void Screen_Base::BasicMenuHandleHeldFunc(int fingerindex, float x, float y)
{
    if( fingerindex == -1 )
        return;

    for( int i=m_MenuItemsNeeded-1; i>=0; i-- )
    {
        if( GetMenuItem(i) )
        {
            GetMenuItem(i)->ReleaseOnNoCollision( fingerindex, x, y );
        }
    }
}
示例#8
0
void PauseMenu::DoGameOver()
{
	state = GAME_OVER;

	auto global = Global::GetInstance();
	black = Ptr<Sprite>::New();
	black->SetTexture(global->texBlack);
	black->SetPosition(Vector3f(192, 224, 10));
	black->SetAlpha(0);
	black->AddTween(Ptr<FadeTo>::New(0.75f, FADE_TIME, Tweener::EASE_OUT).Get());
	AddChild(black.Get());

	title = Ptr<PauseMenuItem>::New(PauseMenuItem::GAME_OVER);
	title->SetPosition(Vector3f(-140, 440, 5));
	title->SetAlpha(0);
	title->AddTween(Ptr<MoveBy>::New(Vector3f(140, -235, 0), FADE_TIME, Tweener::EASE_OUT).Get());
	title->AddTween(Ptr<FadeTo>::New(1.0f, FADE_TIME, Tweener::EASE_OUT).Get());
	AddChild(title.Get());

	AddMenuItem(Ptr<PauseMenuItem>::New(PauseMenuItem::CONTINUE).Get());
	AddMenuItem(Ptr<PauseMenuItem>::New(PauseMenuItem::RETURN_TO_TITLE).Get());
	AddMenuItem(Ptr<PauseMenuItem>::New(PauseMenuItem::SAVE_REPLAY).Get());
	AddMenuItem(Ptr<PauseMenuItem>::New(PauseMenuItem::RETRY).Get());

	for (int i = 0; i < GetItemCount(); i++)
	{
		auto menuItem = GetMenuItem(i);
		menuItem->SetPosition(Vector3f(-140, 440, 5));
		menuItem->SetAlpha(0);
		menuItem->AddTween(Ptr<MoveBy>::New(Vector3f(150, -285 - 32 * i, 0), FADE_TIME, Tweener::EASE_OUT).Get());
		menuItem->AddTween(Ptr<FadeTo>::New(1.0f, FADE_TIME, Tweener::EASE_OUT).Get());
	}

	EventSystem::GetInstance()->RegisterKeyDownListener(this);
}
示例#9
0
//*************************************************************
//
//  SaveMruInReg()
//
//  Purpose:
//              Save MRU in the registry
//
//  Parameters:
//      LPMRUMENU lpMruMenu -      pointer on MRUMENU
//      LPSTR lpszKey  -           Points to a null-terminated string
//                                      specifying  the name of a key that
//                                      this function opens or creates.
//
//  Return: (BOOL)
//      TRUE  - Function run successfully
//      FALSE - Function don't run successfully
//
//
//  Comments:
//      Win32 function designed for Windows NT and Windows 95
//      See RegCreateKeyEx API for more info on lpszKey
//
//  History:    Date       Author       Comment
//              09/24/94   G. Vollant   Created
//
//*************************************************************
BOOL SaveMruInReg( LPMRUMENU lpMruMenu, LPSTR lpszKey )
{
    LPSTR lpTxt;
    WORD i;
    HKEY hCurKey;
    DWORD dwDisp;

    lpTxt = ( LPSTR )GlobalAllocPtr( GHND, lpMruMenu->wMaxSizeLruItem + 20 );
    if ( lpTxt == NULL )
        return FALSE;

    RegCreateKeyEx( HKEY_CURRENT_USER, lpszKey, 0, NULL,
                    REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hCurKey, &dwDisp );

    for ( i = 0; i < lpMruMenu->wNbLruMenu; i++ )
    {
        char szEntry[16];
        wsprintf( szEntry, "File%lu", ( DWORD )i + 1 );
        if ( !GetMenuItem( lpMruMenu, i, FALSE, lpTxt, lpMruMenu->wMaxSizeLruItem + 10 ) )
            *lpTxt = '\0';
        RegSetValueEx( hCurKey, szEntry, 0, REG_SZ, ( unsigned char* )lpTxt, lstrlen( lpTxt ) );
    }
    RegCloseKey( hCurKey );
    GlobalFreePtr( lpTxt );
    return TRUE;
}
示例#10
0
文件: MRU.CPP 项目: hkaiser/TRiAS
//*************************************************************
//
//  SaveMruInIni()
//
//  Purpose:
//              Save MRU in a private .INI
//
//  Parameters:
//      LPMRUMENU lpMruMenu -      pointer on MRUMENU
//      LPSTR lpszSection  -       Points to a null-terminated string containing
//                                      the name of the section 
//      LPSTR lpszFile -           Points to a null-terminated string that names 
//                                      the initialization file. 
//
//  Return: (bool)
//      true  - Function run successfully
//      false - Function don't run successfully
//
//
//  Comments:
//      See WritePrivateProfileString API for more info on lpszSection and lpszFile
//
//  History:    Date       Author       Comment
//              09/24/94   G. Vollant   Created
//
//*************************************************************
bool SaveMruInIni(LPMRUMENU lpMruMenu,LPCSTR lpszSection,LPCSTR lpszFile)
{
LPSTR lpTxt;
WORD i;

	lpTxt = new char [lpMruMenu->wMaxSizeLruItem + 20];
	if (lpTxt == NULL) return false;

	for (i = 0; i < lpMruMenu->wNbLruMenu; i++) {
	char szEntry[16];                         

		wsprintf (szEntry,"File%lu", (DWORD)i+1);

	char *pOut = lpTxt;
	
		if (!GetMenuItem(lpMruMenu,i,false,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
			pOut = NULL;
		WritePrivateProfileString(lpszSection,szEntry,pOut,lpszFile);
	}
	delete lpTxt;

	WritePrivateProfileString(NULL,NULL,NULL,lpszFile); // flush cache 

return true;
}
示例#11
0
void PauseMenu::DoResume()
{
	if (black)
		black->AddTween(Ptr<FadeOut>::New(FADE_TIME, Tweener::EASE_OUT).Get());

	black = nullptr;

	title->AddTween(Ptr<MoveTo>::New(Vector3f(-140, 440, 5), FADE_TIME, Tweener::EASE_OUT).Get());
	title->AddTween(Ptr<FadeOut>::New(FADE_TIME, Tweener::EASE_OUT).Get());

	title = nullptr;

	for (int i = 0; i < GetItemCount(); i++)
	{
		auto menuItem = GetMenuItem(i);

		menuItem->AddTween(Ptr<MoveTo>::New(Vector3f(-140, 440, 5), FADE_TIME, Tweener::EASE_OUT).Get());
		menuItem->AddTween(Ptr<FadeOut>::New(FADE_TIME, Tweener::EASE_OUT).Get());
	}

	ClearItems();

	((GameScene*)Game::GetInstance()->GetScene().Get())->GetSTGLayer()->Resume();
	((GameScene*)Game::GetInstance()->GetScene().Get())->GetSTGParticleLayer()->Resume();

	EventSystem::GetInstance()->UnRegisterKeyDownListener(this);
}
示例#12
0
文件: MRU.CPP 项目: hkaiser/TRiAS
//*************************************************************
//
//  SaveMruInReg()
//
//  Purpose:
//              Save MRU in the registry
//
//  Parameters:
//      LPMRUMENU lpMruMenu -      pointer on MRUMENU
//      LPSTR lpszKey  -           Points to a null-terminated string 
//                                      specifying  the name of a key that 
//                                      this function opens or creates.
//
//  Return: (bool)
//      true  - Function run successfully
//      false - Function don't run successfully
//
//
//  Comments:
//      Win32 function designed for Windows NT and Windows 95
//      See RegCreateKeyEx API for more info on lpszKey
//
//  History:    Date       Author       Comment
//              09/24/94   G. Vollant   Created
//
//*************************************************************
bool SaveMruInReg (LPMRUMENU lpMruMenu, LPCSTR lpszKey)
{
	ASSERT(lpMruMenu);
	ASSERT(lpszKey);
	if (NULL == lpMruMenu || NULL == lpMruMenu) return false;

LPSTR lpTxt;
WORD i;
HKEY hCurKey;
DWORD dwDisp;

	lpTxt = new char [lpMruMenu->wMaxSizeLruItem + 20];
	if (lpTxt == NULL) return false;

	RegCreateKeyEx (HKEY_CURRENT_USER, lpszKey, 0, NULL,
			REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
			NULL, &hCurKey, &dwDisp);

	for (i = 0; i < lpMruMenu->wNbLruMenu; i++) {
	char szEntry[16];

		wsprintf(szEntry, "File%lu", (DWORD)i+1);
		if (!GetMenuItem(lpMruMenu,i,false,lpTxt,lpMruMenu->wMaxSizeLruItem + 10)) {
			RegDeleteKey (hCurKey, szEntry);
			break;
		} else
			RegSetValueEx (hCurKey, szEntry, 0, REG_SZ, (CONST BYTE *)lpTxt, lstrlen(lpTxt));
	}
	RegCloseKey(hCurKey);
	delete lpTxt;
	
return true;
}
示例#13
0
BOOL DoMru(HWND hWnd,WORD wId)
{
	char szFileName[128];
	OFSTRUCT of;
	BOOL fExist;

	GetMenuItem(g_qeglobals.d_lpMruMenu, wId, TRUE, szFileName, sizeof(szFileName));

	// Test if the file exists.

	fExist = OpenFile(szFileName ,&of,OF_EXIST) != HFILE_ERROR;

	if (fExist) {

		// Place the file on the top of MRU.
		AddNewItem(g_qeglobals.d_lpMruMenu,(LPSTR)szFileName);

		// Now perform opening this file !!!
		Map_LoadFile (szFileName);	
	}
	else
		// Remove the file on MRU.
		DelMenuItem(g_qeglobals.d_lpMruMenu,wId,TRUE);

	// Refresh the File menu.
	PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(hWnd),0),
			ID_FILE_EXIT);

	return fExist;
}
示例#14
0
void ClearSelectFlag(XlibMenu * menu)
{
    int i;
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        GetMenuItem(menu->menushell, i)->isselect = 0;
    }
}
示例#15
0
//*************************************************************
//
//  SaveMruInReg()
//
//  Purpose:
//              Save MRU in the registry
//
//  Parameters:
//      LPMRUMENU lpMruMenu -      pointer on MRUMENU
//      LPSTR lpszKey  -           Points to a null-terminated string 
//                                      specifying  the name of a key that 
//                                      this function opens or creates.
//
//  Return: (BOOL)
//      true  - Function run successfully
//      false - Function don't run successfully
//
//
//  Comments:
//      Win32 function designed for Windows NT and Windows 95
//      See RegCreateKeyEx API for more info on lpszKey
//
//  History:    Date       Author       Comment
//              09/24/94   G. Vollant   Created
//
//*************************************************************
BOOL SaveMruInReg (LPMRUMENU lpMruMenu, LPCSTR lpszKey)
{
HKEY hCurKey;
DWORD dwDisp;

	RegCreateKeyEx (HKEY_CURRENT_USER, lpszKey, 0, NULL,
			REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
			NULL, &hCurKey, &dwDisp);

	for (WORD i = 0; i < lpMruMenu->wNbLruMenu; i++) {
	char szEntry[16];
	BOOL fRO;
	string str;

		wsprintf(szEntry, "File%lu", (DWORD)i+1);
		if (!GetMenuItem(lpMruMenu,i,false,str,fRO) || 0 == str.length()) {
			RegDeleteValue (hCurKey, szEntry);
//			break;
		} else {
			str += fRO ? ",1" : ",0";
			RegSetValueEx (hCurKey, szEntry, 0, REG_SZ, (const BYTE *)str.c_str(), str.length());
		}
	}
	RegCloseKey(hCurKey);

	lpMruMenu -> fEmpty = true;		// nicht mehr dirty
	
return true;
}
示例#16
0
文件: MenuWindow.c 项目: ezc/fcitx
boolean MenuWindowEventHandler(void *arg, XEvent* event)
{
    XlibMenu* menu = (XlibMenu*) arg;
    FcitxXlibWindow* window = arg;
    FcitxClassicUI* classicui = window->owner;
    if (event->xany.window == window->wId) {
        switch (event->type) {
        case Expose:
            FcitxXlibWindowPaint(&menu->parent);
            break;
        case LeaveNotify: {
            int x = event->xcrossing.x_root;
            int y = event->xcrossing.y_root;

            if (!IsMouseInOtherMenu(menu, x, y)) {
                CloseAllSubMenuWindow(menu);
            }
        }
        break;
        case MotionNotify: {
            int offseth = 0;
            int i = SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth);
            boolean flag = ReverseColor(menu, i);
            FcitxMenuItem *item = GetMenuItem(menu->menushell, i);
            if (!flag) {
                XlibMenuShow(menu);
                if (item && item->type == MENUTYPE_SUBMENU && item->subMenu) {
                    XlibMenu* subxlibmenu = (XlibMenu*) item->subMenu->uipriv[classicui->isfallback];
                    CloseOtherSubMenuWindow(menu, subxlibmenu);
                    XlibMenuMoveSubMenu(subxlibmenu, menu, offseth);
                    XlibMenuShow(subxlibmenu);
                }
            }
            if (item == NULL)
                CloseOtherSubMenuWindow(menu, NULL);
        }
        break;
        case ButtonPress: {
            switch (event->xbutton.button) {
            case Button1: {
                int offseth;
                int i = SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth);
                if (menu->menushell->MenuAction) {
                    if (menu->menushell->MenuAction(menu->menushell, i))
                        CloseAllMenuWindow(classicui);
                }
            }
            break;
            case Button3:
                CloseAllMenuWindow(classicui);
                break;
            }
        }
        break;
        }
        return true;
    }
    return false;
}
示例#17
0
void CWinMenu::OnLButtonDown(UINT nFlags, CPoint point) 
{
	BOOL bCmdArea = FALSE;
	LPMITEMINFO	pmi = GetMenuItem( &point, &bCmdArea );

	// Check with toolbar
	if (	pmi != NULL && pmi->toolbar != NULL && 
			pmi->toolbar->OnLButtonDown( nFlags, &point ) ) 
	{	m_tbclick = pmi; pmi = NULL; RedrawWindow(); }
	else m_tbclick = NULL;

	// Clear if not in command area
	if ( !bCmdArea ) pmi = NULL;

	// Process if object clicked
	if ( pmi != NULL && *pmi->name != NULL )
	{
		if ( pmi->cursor != NULL )
		{
			m_menuitem = pmi;
			SetCapture();
			SetCursor( pmi->cursor );
		} // end if

		// Let the parent window handle it if any
		else if ( m_hParentMenu != NULL )
		{
			// Do they expect us to toggle the flag?
			if ( pmi->cmd == 0 && pmi->b != NULL )
				*pmi->b = !(*pmi->b);

			// Let the parent send the command
			::PostMessage( m_hParentMenu, WM_MENUCMD, (WPARAM)pmi->cmd, (LPARAM)m_hWndMsgTarget );

		} // end else if

		// Ignore clicks on sub menu
		else if ( pmi->cmd == MAXDWORD );

		// Send message if there is a target
		else if ( pmi->cmd != 0 && m_hWndMsgTarget != NULL && IsWindow( m_hWndMsgTarget ) )
		{
			::PostMessage( m_hWndMsgTarget, WM_COMMAND, pmi->cmd, NULL );
//			DestroyWindow();

			// Destroy if needed
			if ( !m_bAutoDestroy ) UnselectMenu();
			else PostMessage( WM_CLOSE, 0, 0L );

		} // end if

//		else DestroyWindow();

	} // end if
	
	CWnd::OnLButtonDown(nFlags, point);
}
void PDocument::ResetModified(void)
{
	bool locked = Lock();
	BMenuItem *saveItem = GetMenuItem(P_MENU_FILE_SAVE);
	if ((saveItem) && (entryRef != NULL))
		saveItem->SetEnabled(false);
	modified=false;
	if (locked)
		Unlock();
}
BOOL CXTPShortcutListBox::EnableMenuItem(int iItem, BOOL bEnabled)
{
    CONTENT_ITEM* pCI = GetMenuItem(iItem);
    if (pCI != NULL)
    {
        pCI->m_bEnabled = bEnabled;
        return TRUE;
    }
    return FALSE;
}
示例#20
0
文件: MenuWindow.c 项目: ezc/fcitx
boolean ReverseColor(XlibMenu * menu, int shellIndex)
{
    boolean flag = false;
    int i;

    int last = -1;

    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->isselect)
            last = i;

        GetMenuItem(menu->menushell, i)->isselect = 0;
    }
    if (shellIndex == last)
        flag = true;
    if (shellIndex >= 0 && shellIndex < utarray_len(&menu->menushell->shell))
        GetMenuItem(menu->menushell, shellIndex)->isselect = 1;
    return flag;
}
示例#21
0
文件: MenuWindow.c 项目: ezc/fcitx
/*
* 显示菜单上面的文字信息,只需要指定窗口,窗口宽度,需要显示文字的上边界,字体,显示的字符串和是否选择(选择后反色)
* 其他都固定,如背景和文字反色不反色的颜色,反色框和字的位置等
*/
void XlibMenuPaintText(XlibMenu * menu, cairo_t* c, FcitxCairoTextContext* ctc, int shellindex, int line_y, int fontHeight)
{
    FcitxXlibWindow* window = (FcitxXlibWindow*) menu;
    FcitxClassicUI* classicui = window->owner;
    FcitxSkin *sc = &classicui->skin;

    cairo_save(c);
    if (GetMenuItem(menu->menushell, shellindex)->isselect == 0) {
        FcitxCairoTextContextOutputString(ctc, GetMenuItem(menu->menushell, shellindex)->tipstr, 15 , line_y, &sc->skinFont.menuFontColor[MENU_INACTIVE]);
    } else {
        cairo_set_operator(c, CAIRO_OPERATOR_OVER);
        fcitx_cairo_set_color(c, &sc->skinMenu.activeColor);
        cairo_rectangle(c, 0 , line_y, window->contentWidth, fontHeight + 4);
        cairo_fill(c);

        FcitxCairoTextContextOutputString(ctc, GetMenuItem(menu->menushell, shellindex)->tipstr, 15 , line_y, &sc->skinFont.menuFontColor[MENU_ACTIVE]);
    }
    cairo_restore(c);
}
示例#22
0
void PauseMenu::ConfirmCanceled()
{
	title->AddTween(Ptr<FadeTo>::New(1.0f, 20, Tweener::EASE_OUT).Get());
	for (int i = 0; i < GetItemCount(); i++)
	{
		auto menuItem = GetMenuItem(i);
		menuItem->AddTween(Ptr<FadeTo>::New(1.0f, 20, Tweener::EASE_OUT).Get());
	}

	Resume();

	EventSystem::GetInstance()->RegisterKeyDownListener(this);
}
示例#23
0
void Screen_Pause::Draw()
{
    Screen_Base::Draw();

    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->Create( 1, 1, 0, 1, 0, 1, Justify_Left|Justify_Top );
    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->SetPosition( 0, 1, 0 );
    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->SetTint( ColorByte(0,0,0,240) );
    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->Draw( &g_pGame->m_OrthoMatrix );

    FontDefinition* pFont = g_pGame->m_pSystemFont;
    int scrw = (int)g_pGame->m_GameWidth;
    int scrh = (int)g_pGame->m_GameHeight;
    float fontheight = 30;
    unsigned char justify = Justify_CenterX|Justify_CenterY;

    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->SetTint( ColorByte(0,150,0,255) );

    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->Create( 1, 0.2f, 0, 1, 0, 1, Justify_CenterX|Justify_CenterY );
    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->SetPosition( 0.5f, 0.8f, 0 );
    g_pGame->m_pResources->m_pSprites[SL_WhiteSquareResizable]->Draw( &g_pGame->m_OrthoMatrix );
    //if( g_pGame->m_GBGameType == GBType_Options )
    //{
    //    RenderTextQuick( pFont, fontheight*4, 0.5f*scrw, 0.8f*scrh, justify, "OPTIONS" );        
    //}
    //else
    {
        RenderTextQuick( pFont, fontheight*4, 0.5f*scrw, 0.8f*scrh, justify, "PAUSE" );        
    }

    int i=0;
    for( i=0; i<m_MenuItemsNeeded; i++ )
    {
        if( GetMenuItem(i) )
        {
            GetMenuItem(i)->Draw( &g_pGame->m_OrthoMatrixGameSize );
        }
    }
}
BOOL CXTPShortcutListBox::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    if (m_hCursor != NULL)
    {
        CONTENT_ITEM* pCI = GetMenuItem(m_nPrevIndex);
        if (pCI && pCI->m_bEnabled)
        {
            SetCursor(m_hCursor);
            return TRUE;
        }
    }

    return CListBox::OnSetCursor(pWnd, nHitTest, message);
}
示例#25
0
void PauseMenu::Clear()
{
	title->MarkDestroy();
	black->MarkDestroy();
	for (int i = 0; i < GetItemCount(); i++)
	{
		auto menuItem = GetMenuItem(i);
		menuItem->MarkDestroy();
	}
	ClearItems();
	title = nullptr;
	black = nullptr;
	EventSystem::GetInstance()->UnRegisterKeyDownListener(this);
}
void CXTPShortcutListBox::OnLButtonUp(UINT nFlags, CPoint point)
{
    CListBox::OnLButtonUp(nFlags, point);
    RedrawItem(point);

    CONTENT_ITEM* pCI = GetMenuItem(GetCurSel());
    if (pCI && !pCI->m_bEnabled)
        return;

    CWnd* pWndOwner = GetOwner();
    ASSERT(pWndOwner);

    if (pWndOwner) pWndOwner->SendMessage(WM_XTP_SHORTCUTLBOX_NOTIFY,
                                              (LPARAM)GetCurSel(), (WPARAM)GetDlgCtrlID());
}
示例#27
0
int Screen_Base::GetMenuButtonHeldCount()
{
    int count = 0;

    for( int i=0; i<m_MenuItemsNeeded; i++ )
    {
        if( GetMenuItem(i) && GetMenuItemType(i) == MIT_Button )
        {
            if( GetMenuButton(i)->GetState() == MBS_HeldDown )
                count++;
        }
    }

    return count;
}
示例#28
0
文件: MenuWindow.c 项目: ezc/fcitx
/**
*返回鼠标指向的菜单在menu中是第多少项
*/
int SelectShellIndex(XlibMenu * menu, int x, int y, int* offseth)
{
    FcitxXlibWindow* window = (FcitxXlibWindow*) menu;
    int i;
    int contentX = window->contentX;
    int contentY = window->contentY;

    if (x < contentX)
        return -1;

    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU) {
            if (y > contentY + 1 && y < contentY + 6 + menu->fontheight - 1) {
                if (offseth)
                    *offseth = contentY;
                return i;
            }
            contentY = contentY + 6 + menu->fontheight;
        } else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE) {
            contentY += 5;
        }
    }
    return -1;
}
示例#29
0
void SetupMenu() // Set up menu
{
	uint8 i;

	while(1)
	{
	  i = GetMenuItem("TERMINAL SETUP","WiFi Setup","ESPUSB Fudge","Scan WiFi","Test Wifi","Exit");

  	if(i==1) SetupWIFI();

		if(i==2) // Open USB in CDC Mode passthough to ESP-01
    {
      SerialPurge(WIFI_UART);
      CLS();
      LCDWriteStrAt(0,4, "  USB <-> ESP01 ");
      LCDWriteStrAt(0,6, "   PROGRAMMIING   ");
      LCDWriteStrAt(0,10,"  PRESS KEY TO ");
      LCDWriteStrAt(0,12,"    CONTINUE    ");
      
      PORTSetPinsDigitalIn(IOPORT_C,  BIT_2 );
      PPSUnLock;					// Unlock PPS (Peripheral Pin Select) to allow PIN Mapping
      PPSOutput(4,RPC2,NULL); 
      PPSLock;						// lock PPS
      ESP_PGM(0);
      WIFI_PWR(1);
      i = WaitEvent(9999);
      CLS();
      WIFI_PWR(0);
      ESP_PGM(1);
  		DelayMs(500);
      WIFI_PWR(1);
      LCDWriteStrAt(0,4, "  USB <-> ESP01 ");
      LCDWriteStrAt(0,6, "   PASSTHROUGH   ");
      LCDWriteStrAt(0,10,"  POWER OFF TO ");
      LCDWriteStrAt(0,12,"     RESUME     ");
      while(1);
    }

		if(i==4) 
    {		
      if(CheckWIFI()) LCDInform("SUCCESS","Connection OK");
    }

		if(i==3) {	LCDInform("WARNING","Not Implemented");	}

		if(i==0 ||i==5) return;
	}
}
示例#30
0
文件: MenuWindow.c 项目: ezc/fcitx
void XlibMenuPaintMark(XlibMenu * menu, cairo_t* cr, int y, int i)
{
    FcitxXlibWindow* window = (FcitxXlibWindow*) menu;
    FcitxSkin* sc = &window->owner->skin;
    double size = (sc->skinFont.menuFontSize * 0.7) / 2;
    cairo_save(cr);
    if (GetMenuItem(menu->menushell, i)->isselect == 0) {
        fcitx_cairo_set_color(cr, &sc->skinFont.menuFontColor[MENU_INACTIVE]);
    } else {
        fcitx_cairo_set_color(cr, &sc->skinFont.menuFontColor[MENU_ACTIVE]);
    }
    cairo_translate(cr, 7, y + (sc->skinFont.menuFontSize / 2.0));
    cairo_arc(cr, 0, 0, size , 0., 2 * M_PI);
    cairo_fill(cr);
    cairo_restore(cr);
}