Пример #1
0
/** Show a window menu. */
void ShowWindowMenu(ClientNode *np, int x, int y, char keyboard)
{
   Menu *menu = CreateWindowMenu(np);
   InitializeMenu(menu);
   ShowMenu(menu, RunWindowCommand, x, y, keyboard);
   DestroyMenu(menu);
}
Пример #2
0
void ResetMenu()
{
	u8 last_item;
	last_item = game.item;
	InitializeMenu(game.menu);
	game.item = last_item;
}
// Window Controls
WindowRef windowInitialize(GLWindow *glw)
{
    OSStatus err;
    
    if(glw == NULL)
    {
	err = -1;
	return NULL;
    }

#if __APPLE_CC__
    err = CreateNibReference(CFSTR("main"), &glw->nibRef);
    err = SetMenuBarFromNib(glw->nibRef, CFSTR("MenuBar"));
    err = CreateWindowFromNib(glw->nibRef, CFSTR("MainWindow"), &glw->pWin);
    err = CreateWindowFromNib(glw->nibRef, CFSTR("Window"), &glw->supportWindow); 
#else
    err = CreateNewWindow(kDocumentWindowClass, 
			  kWindowStandardDocumentAttributes | 
			  kWindowStandardHandlerAttribute,
			  &winRect, 
			  &glw->pWin);
    InitializeMenu();
#endif
    ShowWindow(glw->supportWindow);
    ShowWindow(glw->pWin);
    // Set our rectangle
    GetWindowPortBounds(glw->pWin, &glw->winRect);
    return glw->pWin;
}
Пример #4
0
void* FcitxUnikeyCreate(FcitxInstance* instance)
{
    FcitxUnikey* unikey = (FcitxUnikey*) fcitx_utils_malloc0(sizeof(FcitxUnikey));

    if (!LoadUnikeyConfig(&unikey->config))
    {
        free(unikey);
        return NULL;
    }
    unikey->owner = instance;
    unikey->preeditstr = new std::string;
    union {
        short s;
        unsigned char b[2];
    } endian;
    endian.s = 0x1234;
    if (endian.b[0] == 0x12)
        unikey->conv = iconv_open("utf-8", "ucs-4be");
    else
        unikey->conv = iconv_open("utf-8", "ucs-4le");

    FcitxIMIFace iface;
    memset(&iface, 0, sizeof(FcitxIMIFace));
    iface.Init = FcitxUnikeyInit;
    iface.ResetIM = FcitxUnikeyReset;
    iface.DoInput = FcitxUnikeyDoInput;
    iface.ReloadConfig = ReloadConfigFcitxUnikey;
    iface.Save = FcitxUnikeySave;

    FcitxInstanceRegisterIMv2(
        instance,
        unikey,
        "unikey",
        _("Unikey"),
        "unikey",
        iface,
        1,
        "vi"
    );

    UnikeySetup();

    InitializeBar(unikey);
    InitializeMenu(unikey);

    ConfigUnikey(unikey);

    FcitxIMEventHook hk;
    hk.arg = unikey;
    hk.func = FcitxUnikeyResetUI;

    FcitxInstanceRegisterResetInputHook(instance, hk);

    return unikey;
}
Пример #5
0
SQLiteViewer::SQLiteViewer(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	m_ptrTableNamesModel = NULL;
	m_ptrQuerySetModel = NULL;

	InitializeActions();
	InitializeMenu();
	InitializeControls();
}
Пример #6
0
/** Get the size of a window menu. */
void GetWindowMenuSize(ClientNode *np, int *width, int *height)
{

   Menu *menu;

   client = np;
   menu = CreateWindowMenu();
   InitializeMenu(menu);
   *width = menu->width;
   *height = menu->height;
   DestroyMenu(menu);

}
Пример #7
0
/** Show a window menu. */
void ShowWindowMenu(ClientNode *np, int x, int y)
{

   Menu *menu;

   client = np;
   menu = CreateWindowMenu();

   InitializeMenu(menu);

   ShowMenu(menu, RunWindowCommand, x, y);

   DestroyMenu(menu);

}
Пример #8
0
/** Prepare a root menu to be shown. */
void PatchRootMenu(Menu *menu) {

   MenuItem *item;

   for(item = menu->items; item; item = item->next) {
      if(item->submenu) {
         PatchRootMenu(item->submenu);
      }
      if(item->action.type == MA_DESKTOP) {
         item->submenu = CreateDesktopMenu(1 << currentDesktop);
         InitializeMenu(item->submenu);
      }
   }

}
Пример #9
0
void* FcitxUnikeyCreate(FcitxInstance* instance)
{
    FcitxUnikey* unikey = (FcitxUnikey*) fcitx_utils_malloc0(sizeof(FcitxUnikey));

    if (!LoadUnikeyConfig(&unikey->config))
    {
        free(unikey);
        return NULL;
    }
    unikey->owner = instance;
    unikey->preeditstr = new std::string;

    FcitxIMIFace iface;
    memset(&iface, 0, sizeof(FcitxIMIFace));
    iface.Init = FcitxUnikeyInit;
    iface.ResetIM = FcitxUnikeyReset;
    iface.DoInput = FcitxUnikeyDoInput;
    iface.ReloadConfig = ReloadConfigFcitxUnikey;
    iface.Save = FcitxUnikeySave;

    FcitxInstanceRegisterIMv2(
        instance,
        unikey,
        "unikey",
        _("Unikey"),
        "unikey",
        iface,
        1,
        "vi"
    );

    UnikeySetup();

    InitializeBar(unikey);
    InitializeMenu(unikey);

    ConfigUnikey(unikey);

    FcitxIMEventHook hk;
    hk.arg = unikey;
    hk.func = FcitxUnikeyResetUI;

    FcitxInstanceRegisterResetInputHook(instance, hk);

    return unikey;
}
Пример #10
0
/** State - Initialize title */
void StateTitle()
{
	// Hide working screen (0)
	SetPage8(1);
	SetScreenColor(0, 0, COLOR8_BLACK);
	ClearScreen8(COLOR8_BLACK);

	// Build title
	DrawText(50, 32,       "PONGLYPH", COLOR8_RED);
	DrawText(52, 32 + 256, "PONGLYPH", COLOR8_CYAN);
	DrawText(150, 64,       "PHENIX 2011", COLOR8_GRAY);
	DrawText(150, 64 + 256, "PHENIX 2011", COLOR8_GRAY);

	InitializeMenu(0);
	game.pressed = 0;
	game.page = 0;
	game.state = StateMainMenu;
}
Пример #11
0
/** Startup root menus. */
void StartupRootMenu() {

   int x, y;
   int found;

   for(x = 0; x < ROOT_MENU_COUNT; x++) {
      if(rootMenu[x]) {
         found = 0;
         for(y = 0; y < x; y++) {
            if(rootMenu[y] == rootMenu[x]) {
               found = 1;
               break;
            }
         }
         if(!found) {
            InitializeMenu(rootMenu[x]);
         }
      }
   }

}
Пример #12
0
/** Show the menu associated with a task list item. */
void ShowClientList(TaskBarType *bar, TaskEntry *tp)
{
   Menu *menu;
   MenuItem *item;
   ClientEntry *cp;

   const ScreenType *sp;
   int x, y;
   Window w;

   if(settings.groupTasks) {

      menu = Allocate(sizeof(Menu));
      menu->itemHeight = 0;
      menu->items = NULL;
      menu->label = NULL;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Close"));
      item->action.type = MA_CLOSE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Minimize"));
      item->action.type = MA_MINIMIZE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_NORMAL);
      item->name = CopyString(_("Restore"));
      item->action.type = MA_RESTORE | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      item = CreateMenuItem(MENU_ITEM_SUBMENU);
      item->name = CopyString(_("Send To"));
      item->action.type = MA_SENDTO_MENU | MA_GROUP_MASK;
      item->action.context = tp;
      item->next = menu->items;
      menu->items = item;

      /* Load the separator and group actions. */
      item = CreateMenuItem(MENU_ITEM_SEPARATOR);
      item->next = menu->items;
      menu->items = item;

      /* Load the clients into the menu. */
      for(cp = tp->clients; cp; cp = cp->next) {
         if(!ShouldFocus(cp->client, 0)) {
            continue;
         }
         item = CreateMenuItem(MENU_ITEM_NORMAL);
         if(cp->client->state.status & STAT_MINIMIZED) {
            size_t len = 0;
            if(cp->client->name) {
               len = strlen(cp->client->name);
            }
            item->name = Allocate(len + 3);
            item->name[0] = '[';
            memcpy(&item->name[1], cp->client->name, len);
            item->name[len + 1] = ']';
            item->name[len + 2] = 0;
         } else {
            item->name = CopyString(cp->client->name);
         }
         item->icon = cp->client->icon ? cp->client->icon : GetDefaultIcon();
         item->action.type = MA_EXECUTE;
         item->action.context = cp->client;
         item->next = menu->items;
         menu->items = item;
      }
   } else {
      /* Not grouping clients. */
      menu = CreateWindowMenu(tp->clients->client);
   }

   /* Initialize and position the menu. */
   InitializeMenu(menu);
   sp = GetCurrentScreen(bar->cp->screenx, bar->cp->screeny);
   GetMousePosition(&x, &y, &w);
   if(bar->layout == LAYOUT_HORIZONTAL) {
      if(bar->cp->screeny + bar->cp->height / 2 < sp->y + sp->height / 2) {
         /* Bottom of the screen: menus go up. */
         y = bar->cp->screeny + bar->cp->height;
      } else {
         /* Top of the screen: menus go down. */
         y = bar->cp->screeny - menu->height;
      }
      x -= menu->width / 2;
      x = Max(x, sp->x);
   } else {
      if(bar->cp->screenx + bar->cp->width / 2 < sp->x + sp->width / 2) {
         /* Left side: menus go right. */
         x = bar->cp->screenx + bar->cp->width;
      } else {
         /* Right side: menus go left. */
         x = bar->cp->screenx - menu->width;
      }
      y -= menu->height / 2;
      y = Max(y, sp->y);
   }

   ShowMenu(menu, RunTaskBarCommand, x, y, 0);

   DestroyMenu(menu);

}
Пример #13
0
/** State - Process main menu */
void StateMainMenu()
{
	u8 keyLine, i;

	SetPage8(game.page);
	game.page = 1 - game.page;
	game.yOffset = 256 * game.page;

	// Handle activation
	keyLine = GetKeyMatrixLine(8);
	if((keyLine & KEY_SPACE) == 0
	|| Joytrig(1) != 0
	|| Joytrig(2) != 0)
	{
		if(g_Menus[game.menu].items[game.item].action != 0)
			g_Menus[game.menu].items[game.item].action(ACTION_SET, g_Menus[game.menu].items[game.item].value);
		if((g_Menus[game.menu].items[game.item].nextIdx & 0x80) == 0)
			InitializeMenu(g_Menus[game.menu].items[game.item].nextIdx);
		return;
	}

	if((keyLine & KEY_RIGHT) == 0)
	{
		if(g_Menus[game.menu].items[game.item].action != 0)
			g_Menus[game.menu].items[game.item].action(ACTION_INC, g_Menus[game.menu].items[game.item].value);
	}
	else if((keyLine & KEY_LEFT) == 0)
	{
		if(g_Menus[game.menu].items[game.item].action != 0)
			g_Menus[game.menu].items[game.item].action(ACTION_DEC, g_Menus[game.menu].items[game.item].value);
	}

	// Handle navigation
	if(game.pressed > 16)
		game.pressed = 0;
	if(((keyLine & KEY_UP) == 0) && (game.item > 0))
	{
		if(game.pressed == 0)
		{
			i = game.item;
			while(i > 0)
			{
				i--;
				if(g_Menus[game.menu].items[i].nextIdx != ITEM_DUMMY)
				{
					game.item = i;
					break;
				}
			}			
		}
		game.pressed++;
	}
	else if(((keyLine & KEY_DOWN) == 0) && (game.item < g_Menus[game.menu].itemNum - 1))
	{
		if(game.pressed == 0)
		{
			i = game.item;
			while(i < g_Menus[game.menu].itemNum)
			{
				i++;
				if(g_Menus[game.menu].items[i].nextIdx != ITEM_DUMMY)
				{
					game.item = i;
					break;
				}
			}
		}
		game.pressed++;
	}
	else
		game.pressed = 0;

	// Render
	FillVRAM(MENU_X, MENU_Y + TITLE_SPACE + game.yOffset, 8, LINE_SPACE * g_Menus[game.menu].itemNum, COLOR8_BLACK);
	DrawText(MENU_X, MENU_Y + TITLE_SPACE + game.yOffset + (LINE_SPACE * game.item), "@", COLOR8_WHITE);
	WaitRetrace();
}
Пример #14
0
DLLExport BOOL WINAPI PoorMansTypeToolProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
	// set up some local variables, use these until OK is pressed and then
	// copy in to global data
	static short	lastV = 0;
	static short	lastH = 0;
	static int32	lastXFactor = 4;
	static BOOL		lastGaussianBlurData = FALSE;
	static bool		lastAllLayerData = FALSE;
	static BOOL		lastDiffLayerData = FALSE;
	static int16	lastLayerIndex = 0;
	RECT			imageRect;
	int				item, cmd;
	short			numberErr = 0;
	int32			x = 0;
	static int		lastItem = 0;
	static GPtr		globals = NULL;		  /* need to be static */

	switch  (wMsg)
	{

		case  WM_INITDIALOG:

			/* set up globals	*/

			globals = (GPtr) lParam;

			CenterDialog(hDlg);
			
			lastV = gPointV;
			lastH = gPointH;
			lastXFactor = gXFactor;
			lastGaussianBlurData = gGaussianBlurData;
			lastAllLayerData = gViewAllLayerData;
			lastLayerIndex = gViewLayerIndex;

			GetProxyItemRect(hDlg, &gProxyRect);
			CalcProxyScaleFactor(&gDocDesc->bounds, &gProxyRect, &gScaleFactor);
			UpdateProxyView(globals);

			StuffNumber(hDlg, kDVertical,(int32)lastV);
			StuffNumber(hDlg, kDHorizontal,(int32)lastH);

			InitializeMenu(globals, hDlg, kDSize);
			SetSizePopUpMenu(hDlg, lastXFactor);

			InitializeMenu(globals, hDlg, kDLayersPopUp);
			SendMessage(GetDlgItem(hDlg, kDLayersPopUp), CB_SETCURSEL, 0, 0);

			InitializeMenu(globals, hDlg, kDDocPopUp);
			SendMessage(GetDlgItem(hDlg, kDDocPopUp), CB_SETCURSEL, 0, 0);

			SetCheckBoxState(hDlg, kDAllLayers, lastAllLayerData);

			SetCheckBoxState(hDlg, kDGaussianBlurData, lastGaussianBlurData);

			ShowHideItem(hDlg, kDWarningText, false);

			SelectTextItem(hDlg, kDVertical);

			/* drop into PAINT missing break is intentional */
		case WM_PAINT:
			ShowOutputBuffer(globals, hDlg);	 // Draw Proxy Item
			return FALSE;
			break;

		case  WM_COMMAND:
	  		item = COMMANDID (wParam);              // WIN32 Change
			cmd = HIWORD (wParam);

			switch  (item)
			{
				case kDVertical:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == EN_KILLFOCUS)
							lastItem = kDVertical; // validate will get this
						else if (cmd == EN_CHANGE)
						{
							numberErr = FetchNumber(hDlg,
													kDVertical,
													gDocDesc->bounds.top,
													gDocDesc->bounds.bottom,
													&x);
							if (numberErr == noErr && x != gPointV)
							{ // different number, update
								gPointV = (short)x;

								// Do Filtering operation
								UpdateProxyView(globals);

								// Invalidate Proxy Item
								GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
								ScreenToClient (hDlg, (LPPOINT)&imageRect);
								ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
								InvalidateRect (hDlg, &imageRect, FALSE);
							}
						}
					}
					break;

				case kDHorizontal:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == EN_KILLFOCUS)
							lastItem = kDHorizontal; // validate will get this
						else if (cmd == EN_CHANGE)
						{
							numberErr = FetchNumber(hDlg,
													kDHorizontal,
													gDocDesc->bounds.left,
													gDocDesc->bounds.right,
													&x);
							if (numberErr == noErr && x != gPointH)
							{ // different number, update
								gPointH = (short)x;

								// Do Filtering operation
								UpdateProxyView(globals);

								// Invalidate Proxy Item
								GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
								ScreenToClient (hDlg, (LPPOINT)&imageRect);
								ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
								InvalidateRect (hDlg, &imageRect, FALSE);
							}
						}
					}
					break;

				case kDSize:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == CBN_SELENDOK)
						{
							gXFactor = GetSizePopUpMenu(hDlg);
							// Do Filtering operation
							UpdateProxyView(globals);
			
							// Invalidate Proxy Item
							GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
							ScreenToClient (hDlg, (LPPOINT)&imageRect);
							ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
							InvalidateRect (hDlg, &imageRect, FALSE);
							return FALSE;
						}
					}
					break;

				case kDGaussianBlurData:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == BN_CLICKED)
						{	
							gGaussianBlurData = !gGaussianBlurData;
							SetCheckBoxState (hDlg, kDGaussianBlurData, gGaussianBlurData);
							
							// Do Filtering operation
							UpdateProxyView(globals);
			
							// Invalidate Proxy Item
							GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
							ScreenToClient (hDlg, (LPPOINT)&imageRect);
							ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
							InvalidateRect (hDlg, &imageRect, FALSE);
							return FALSE;
						}
					}
					break;

				case kDAllLayers:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == BN_CLICKED)
						{	
							gViewAllLayerData = !gViewAllLayerData;
							SetCheckBoxState (hDlg, kDAllLayers, gViewAllLayerData);
							ShowHideItem(hDlg, kDWarningText, gViewAllLayerData);
							
							// Do Filtering operation
							UpdateProxyView(globals);
			
							// Invalidate Proxy Item
							GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
							ScreenToClient (hDlg, (LPPOINT)&imageRect);
							ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
							InvalidateRect (hDlg, &imageRect, FALSE);
							return FALSE;
						}
					}
					break;
				
				case kDLayersPopUp:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == CBN_SELENDOK)
						{
							HWND hWnd = GetDlgItem(hDlg, kDLayersPopUp);
							if (hWnd == NULL) break;
							gViewLayerIndex = (int16)SendMessage(hWnd, CB_GETCURSEL, 0, 0);

							if (gViewLayerIndex == 0)
							{
								SetCheckBoxState(hDlg, kDAllLayers, gViewAllLayerData);
								PIEnableControl(hDlg, kDAllLayers);
							}
							else
							{
								gViewAllLayerData = false;
								SetCheckBoxState(hDlg, kDAllLayers, false);
								PIDisableControl(hDlg, kDAllLayers);
							}

							// Do Filtering operation
							UpdateProxyView(globals);
			
							// Invalidate Proxy Item
							GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
							ScreenToClient (hDlg, (LPPOINT)&imageRect);
							ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
							InvalidateRect (hDlg, &imageRect, FALSE);
							return FALSE;
						}
					}
					break;

				case kDDocPopUp:
					if (Validate(globals, hDlg, &lastItem))
					{
						if (cmd == CBN_SELENDOK)
						{
							HWND hWnd = GetDlgItem(hDlg, kDDocPopUp);
							if (hWnd == NULL) break;

							int16 docIndex = (int16)SendMessage(hWnd, CB_GETCURSEL, 0, 0);
							
							// point the global doc desc at the selected doc desc
							gDocDesc = gDocInfo;
							while (docIndex-- > 0 && gDocDesc != NULL)
								gDocDesc = gDocDesc->next;

							gViewLayerIndex = 0;
							gViewAllLayerData = 0;

							SetCheckBoxState(hDlg, kDAllLayers, gViewAllLayerData);
							PIEnableControl(hDlg, kDAllLayers);

							InitializeMenu(globals, hDlg, kDLayersPopUp);
							SendMessage(GetDlgItem(hDlg, kDLayersPopUp), CB_SETCURSEL, 0, 0);

							// reset the proxy stuff to use the new doc desc
							ReleaseProxyMemory(globals);
							GetProxyItemRect(hDlg, &gProxyRect);
							CalcProxyScaleFactor(&gDocDesc->bounds, &gProxyRect, &gScaleFactor);

							UpdateProxyView(globals);
			
							// Invalidate Proxy Item
							GetWindowRect(GetDlgItem(hDlg, kDProxyItem), &imageRect);
							ScreenToClient (hDlg, (LPPOINT)&imageRect);
							ScreenToClient (hDlg, (LPPOINT)&(imageRect.right));
							InvalidateRect (hDlg, &imageRect, FALSE);
							return FALSE;
						}
					}
					break;

				case OK:
					if (cmd == BN_CLICKED)
					{
						lastItem = kDVertical; // force validate
						if (Validate(globals, hDlg, &lastItem))
						{
							lastItem = kDHorizontal;
							if (Validate(globals, hDlg, &lastItem))
							{
								EndDialog(hDlg, item); 
								return TRUE;
							}
						}
					}
					else 
					{
						(void) Validate(globals, hDlg, &lastItem);
					}
					break;
				case CANCEL:
					if (cmd == BN_CLICKED)
					{
						gPointV = lastV;
						gPointH = lastH;
						gXFactor = lastXFactor;
						gGaussianBlurData = lastGaussianBlurData;
						gViewAllLayerData = lastAllLayerData;
						gViewLayerIndex = lastLayerIndex;
						gResult = userCanceledErr;
						EndDialog(hDlg, item);          // WIN32 change
						return TRUE;
					}
					// don't ever validate during cancel
					break;
				default:
					break;
			} // switch (item)
			break; // case WM_COMMAND
		default:
			return FALSE;
			break;
		} // switch

	return  TRUE;
}