예제 #1
0
파일: Menu.c 프로젝트: tobynet/clcl
/*
 * menu_create - メニューの作成
 */
HMENU menu_create(const HWND hWnd, MENU_INFO *menu_info, const int menu_cnt,
				  DATA_INFO *history_di, DATA_INFO *regist_di)
{
	HMENU hMenu;
	HDC hdc;
	HFONT hFont, hRetFont;
	int id = 0;

	// メニュー作成
	if ((hMenu = CreatePopupMenu()) == NULL) {
		return NULL;
	}
	menu_item_info = menu_create_info(menu_info, menu_cnt, history_di, regist_di, &id, &menu_item_cnt);

	if ((hdc = GetDC(hWnd)) == NULL) {
		DestroyMenu(hMenu);
		return NULL;
	}
	// フォント設定
	hFont = menu_create_font();
	hRetFont = SelectObject(hdc, hFont);
	// メニューに項目を設定
	menu_set_item(hdc, hMenu, menu_item_info, menu_item_cnt);
	SelectObject(hdc, hRetFont);
	DeleteObject(hFont);
	ReleaseDC(hWnd, hdc);
	return hMenu;
}
예제 #2
0
파일: Menu.c 프로젝트: tobynet/clcl
/*
 * menu_set_item - メニューに項目を設定
 */
static BOOL menu_set_item(const HDC hdc, const HMENU hMenu, MENU_ITEM_INFO *mii, const int cnt)
{
	HMENU hPopupMenu;
	SIZE size;
	int height = 0;
	int item_height;
	int menu_flag;
	int i;

	// メニュー項目の追加
	for (i = 0; i < cnt; i++) {
		// メニューの高さを取得
		if ((mii + i)->flag & MF_SEPARATOR) {
			item_height = option.menu_separator_height;
		} else if ((mii + i)->flag & MF_OWNERDRAW) {
			if ((mii + i)->text != NULL && GetTextExtentPoint32(hdc,
				(mii + i)->text, lstrlen((mii + i)->text), &size) == TRUE) {
				(mii + i)->text_x = size.cx;
				(mii + i)->text_y = size.cy;
			}
			if ((mii + i)->hkey != NULL && GetTextExtentPoint32(hdc,
				(mii + i)->hkey, lstrlen((mii + i)->hkey), &size) == TRUE) {
				(mii + i)->text_x += size.cx;
			}
			item_height = menu_get_item_size(mii + i, NULL);
		} else {
			item_height = GetSystemMetrics(SM_CYMENU);
		}
		// 折り返し設定
		menu_flag = 0;
		height += item_height;
		if (option.menu_break == 1 && height >= GetSystemMetrics(SM_CYSCREEN)) {
			height = item_height;
			menu_flag = MF_MENUBARBREAK;
		}

		if ((mii + i)->flag & MF_POPUP) {
			hPopupMenu = CreatePopupMenu();
			menu_set_item(hdc, hPopupMenu, (mii + i)->mii, (mii + i)->mii_cnt);
			// メニュー項目の追加
			AppendMenu(hMenu, (mii + i)->flag | menu_flag, (UINT)hPopupMenu, (mii + i)->item);
		} else {
			// メニュー項目の追加
			AppendMenu(hMenu, (mii + i)->flag | menu_flag, (mii + i)->id, (mii + i)->item);
		}
	}
	return TRUE;
}
예제 #3
0
void benchmark(void)
{
    unsigned long i;
    int row, col;

    menu_settings_t* mset   = &_menu_settings;
    menu_items_t   * mitems = &_menu_items;
    int menu_selected;

    /* Init timer stuff. */
    sc_tmr_start();

    menu_reset_settings(mset);
    menu_reset_items(mitems);
    menu_set_title(mset, "Saturn Memory Benchmark");

    menu_set_item(mitems, 0/*id*/, "Start Benchmarking    ", 0/*tag*/);
    menu_set_item(mitems, 1/*id*/, "Init DRAM             ", 1/*tag*/);
    menu_set_item(mitems, 2/*id*/, "Select test pattern   ", 2/*tag*/);
    menu_set_item(mitems, 3/*id*/, "Hexedit on error      ", 3/*tag*/);

    menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 7/*h*/, 1/*cols*/);
    menu_set_erase_on_exit(mset, 0);
    menu_set_callback_redraw(mset, display_bench_settings);

    menu_selected = 0;
    do
    {
        menu_selected = menu_start(mitems, mset, menu_selected/*selected_tag*/);
        if(mset->exit_code == MENU_EXIT_CANCEL)
        {
            return;
        }

        switch(menu_selected)
        {
        default:
        case(0):
            break;

        case(1):
            menu_clear_display(mset);
            my_RB_CartRAM_init(0/*CS0*/);
            bench_display_clear();
            break;

        case(2):
            test_pattern = (test_pattern+1)%PATTERN_CNT;
            break;

        case(3):
            hexedit_on_error = hexedit_on_error ? 0 : 1;
            break;
        }
    } while(menu_selected != 0);

    /* User requested benchmark start, so clear settings menu. */
    menu_clear_display(mset);


    /* Execute benchmarks. */
    bench_display_clear();
    row = 5, col = 2;
    for(i = 0; i < nBenches; i++)
    {
        unsigned short color;

        conio_printf(2, 4, COLOR_GREEN, "[%3d%%]Benchmarking \"%s\" ...", (100*i)/nBenches, benches[i].name);

        /* Perform bench. */
        benches[i].function(benches + i);

        /* Display some data in order to keep user waiting ... */
        display_bench_result(i);

        color = benches[i].status ? COLOR_YELLOW : COLOR_RED;
        conio_printf(col+ 0, row, color, "%s", benches[i].name);
        if(col==2)
        {
            col = 9;
        }
        else if(col==9)
        {
            col = 16;
        }
        else if(col==16)
        {
            col = 23;
        }
        else if(col==23)
        {
            col = 30;
        }
        else
        {
            col = 2;
            row++;
        }

        if(row >= BENCH_RESULT_STARTROW)
        {
            bench_display_clear();
            row = 5;
            col = 2;
        }
    }

prompt_start();//TMP?
    /* Display benchmark results. */
    bench_display_clear();

    menu_reset_settings(mset);
    menu_reset_items(mitems);
    menu_set_title(mset, "Benchmark Results");

    menu_set_pos(mset, -1/*x0*/, MENU_TOP_ROW/*y0*/, 30/*w*/, 12/*h*/, 1/*cols*/);
    menu_set_erase_on_exit(mset, 1);

    menu_set_features(mset, MENU_FEATURES_TEXTCENTER);
    menu_set_callback_getstr(mset, get_bench_name);
    menu_set_callback_redraw(mset, display_bench_result);

    menu_selected = 0;
    menu_selected = menu_list_start(NULL/*Items Array*/, nBenches, mset, menu_selected, NULL/*selection*/);
}