bool dhUserPrefs::create_window(void){ DWORD screen_width; DWORD screen_height; CString window_name; if(!register_window_class()){ return false; } if(m_app_name != NULL) { window_name.Format("%s : User Preferences",m_app_name); } else { window_name = "User Preferences"; } screen_width=GetSystemMetrics(SM_CXSCREEN); screen_height=GetSystemMetrics(SM_CYSCREEN); m_window = CreateWindowEx(WS_EX_APPWINDOW|WS_EX_DLGMODALFRAME, user_pref_wnd_class_name, window_name, WS_CAPTION|WS_VISIBLE, (screen_width - window_width)/2, (screen_height - window_height)/2, window_width, window_height, NULL, //WindowParent NULL, //Menu GetModuleHandle(NULL), //Instance NULL); //lpParam add_widgets(); return true; }
/** * @brief Creates a list dialogue with OK and Cancel buttons, with a fixed message, * as well as a small extra area for the list to react to item selected events. * * @param title Title of the dialogue. * @param items Items in the list (should be all malloced, automatically freed). * @param nitems Number of items. * @param extrawidth Width of area to add for select_call callback. * @param minheight Minimum height for the window. * @param add_widgets This function is called with the new window as an argument * allowing for initial population of the extra area. * @param select_call (optional) This function is called when a new item in the list * is selected, receiving the window's id and the selected widgets name as * arguments. * @param msg string with text to display. */ int dialogue_listPanelRaw( const char* title, char **items, int nitems, int extrawidth, int minheight, void (*add_widgets) (unsigned int wid, int x, int y, int w, int h), void (*select_call) (unsigned int wid, char* wgtname, int x, int y, int w, int h), const char *msg ) { int i; int w, h, winw, winh; glFont* font; unsigned int wid; int list_width, list_height; int text_height, text_width; int done; if (input_dialogue.input_wid) return -1; font = dialogue_getSize( title, msg, &text_width, &text_height ); /* Calculate size stuff. */ list_width = 0; list_height = 0; for (i=0; i<nitems; i++) { list_width = MAX( list_width, gl_printWidthRaw( &gl_defFont, items[i] ) ); list_height += gl_defFont.h + 5; } list_height += 100; if (list_height > 500) h = (list_height*8)/10; else h = MAX( 300, list_height ); h = MIN( (SCREEN_H*2)/3, h ); w = MAX( list_width + 60, 200 ); winw = w + extrawidth; winh = MAX( h, minheight ); h = winh; /* Create the window. */ wid = window_create( title, -1, -1, winw, winh ); window_setData( wid, &done ); window_addText( wid, 20, -40, w-40, text_height, 0, "txtMsg", font, &cDConsole, msg ); window_setAccept( wid, dialogue_listClose ); window_setCancel( wid, dialogue_listCancel ); if(add_widgets) add_widgets(wid, w, 0, winw, winh); if(select_call) { input_dialogue.x = w; input_dialogue.y = 0; input_dialogue.w = winw; input_dialogue.h = winh; input_dialogue.item_select_cb = select_call; } /* Create the list. */ window_addList( wid, 20, -40-text_height-20, w-40, h - (40+text_height+20) - (20+30+20), "lstDialogue", items, nitems, 0, select_call_wrapper ); /* Create the buttons. */ window_addButton( wid, -20, 20, 60, 30, "btnOK", "OK", dialogue_listClose ); window_addButton( wid, -20-60-20, 20, 60, 30, "btnCancel", "Cancel", dialogue_listCancel ); dialogue_open++; toolkit_loop( &done ); /* cleanup */ input_dialogue.x = 0; input_dialogue.y = 0; input_dialogue.w = 0; input_dialogue.h = 0; input_dialogue.item_select_cb = NULL; return dialogue_listSelected; }
int ux500_ab8500_machine_codec_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; int ret; pr_debug("%s Enter.\n", __func__); ret = snd_soc_jack_new(codec, "AB8500 Hs Status", SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | SND_JACK_HEADSET | SND_JACK_LINEOUT | SND_JACK_MECHANICAL | SND_JACK_VIDEOOUT, &jack); if (ret < 0) { pr_err("%s: ERROR: Failed to create Jack (ret = %d)!\n", __func__, ret); return ret; } /* Add controls */ snd_ctl_add(codec->card->snd_card, snd_ctl_new1( &mclk_input_control, codec)); snd_ctl_add(codec->card->snd_card, snd_ctl_new1( &anc_status_control, codec)); snd_ctl_add(codec->card->snd_card, snd_ctl_new1( &mic1a_regulator_control, codec)); snd_ctl_add(codec->card->snd_card, snd_ctl_new1( &mic1b_regulator_control, codec)); snd_ctl_add(codec->card->snd_card, snd_ctl_new1( &mic2_regulator_control, codec)); /* Get references to clock-nodes */ clk_ptr_sysclk = NULL; clk_ptr_ulpclk = NULL; clk_ptr_intclk = NULL; clk_ptr_audioclk = NULL; clk_ptr_gpio1 = NULL; clk_ptr_sysclk = clk_get(codec->dev, "sysclk"); if (IS_ERR(clk_ptr_sysclk)) { pr_err("ERROR: clk_get failed (ret = %d)!", -EFAULT); return -EFAULT; } clk_ptr_ulpclk = clk_get(codec->dev, "ulpclk"); if (IS_ERR(clk_ptr_sysclk)) { pr_err("ERROR: clk_get failed (ret = %d)!", -EFAULT); return -EFAULT; } clk_ptr_intclk = clk_get(codec->dev, "intclk"); if (IS_ERR(clk_ptr_audioclk)) { pr_err("ERROR: clk_get failed (ret = %d)!", -EFAULT); return -EFAULT; } clk_ptr_audioclk = clk_get(codec->dev, "audioclk"); if (IS_ERR(clk_ptr_audioclk)) { pr_err("ERROR: clk_get failed (ret = %d)!", -EFAULT); return -EFAULT; } clk_ptr_gpio1 = clk_get_sys("gpio.1", NULL); if (IS_ERR(clk_ptr_gpio1)) { pr_err("ERROR: clk_get_sys(gpio.1) failed (ret = %d)!", -EFAULT); return -EFAULT; } /* Set intclk default parent to ulpclk */ ret = clk_set_parent(clk_ptr_intclk, clk_ptr_ulpclk); if (ret) { pr_err("%s: ERROR: Setting intclk parent to ulpclk failed (ret = %d)!", __func__, ret); return -EFAULT; } master_clock_sel = 1; ab8500_power_count = 0; reg_claim[REGULATOR_AMIC1] = 0; reg_claim[REGULATOR_AMIC2] = 0; /* Add DAPM-widgets */ ret = add_widgets(codec); if (ret < 0) { pr_err("%s: Failed add widgets (%d).\n", __func__, ret); return ret; } return 0; }