C4GameOptionsList::OptionDropdown::OptionDropdown(class C4GameOptionsList *pForDlg, const char *szCaption, bool fReadOnly) : Option(pForDlg) { CStdFont &rUseFont = ::GraphicsResource.TextFont; // get size of caption label bool fTabular = pForDlg->IsTabular(); int32_t iCaptWidth, iCaptHeight; if (fTabular) { // tabular layout: Caption label width by largest caption rUseFont.GetTextExtent(LoadResStr("IDS_NET_RUNTIMEJOIN"), iCaptWidth, iCaptHeight, true); iCaptWidth = iCaptWidth * 5 / 4; } else { rUseFont.GetTextExtent(szCaption, iCaptWidth, iCaptHeight, true); } // calc total height for component int iHorizontalMargin = 1; int iVerticalMargin = 1; int iComboMargin = 5; int iSelComboHgt = C4GUI::ComboBox::GetDefaultHeight(); SetBounds(C4Rect(0, 0, pForDlg->GetItemWidth(), (!fTabular) * (iCaptHeight + iVerticalMargin*2) + iVerticalMargin*2 + iSelComboHgt)); C4GUI::ComponentAligner ca(GetContainedClientRect(), iHorizontalMargin, iVerticalMargin); // create subcomponents AddElement(pCaption = new C4GUI::Label(FormatString("%s:", szCaption).getData(), fTabular ? ca.GetFromLeft(iCaptWidth, iCaptHeight) : ca.GetFromTop(iCaptHeight), ALeft)); ca.ExpandLeft(-iComboMargin); AddElement(pPrimarySubcomponent = pDropdownList = new C4GUI::ComboBox(ca.GetAll())); pDropdownList->SetReadOnly(fReadOnly); pDropdownList->SetComboCB(new C4GUI::ComboBox_FillCallback<C4GameOptionsList::OptionDropdown>(this, &C4GameOptionsList::OptionDropdown::OnDropdownFill, &C4GameOptionsList::OptionDropdown::OnDropdownSelChange)); // final init InitOption(pForDlg); }
int main(int argc, char **argv){ int im_exit = 0; FILE *IN; int file_open = 0; OPT option; InitOption(&option); GetOption(&option,argc-1,argv+1); if(option.help == 1){ PrintHelp(); im_exit++; } if(option.check == 1){ PrintOption(option); im_exit++; } if(im_exit > 0){ exit(0); } if(strlen(option.file) > 0){ IN = fopen(option.file,"r"); file_open++; }else{ IN = stdin; } prnit_ngram2int(IN,option); if(file_open > 0){ fclose(IN); } return(0); }
C4GameOptionsList::OptionDropdown::OptionDropdown(class C4GameOptionsList *pForDlg, const char *szCaption, bool fReadOnly) : Option(pForDlg), fReadOnly(fReadOnly) { bool fIsPreGame = pForDlg->IsPreGame(); CStdFont &rUseFont = fIsPreGame ? C4Startup::Get()->Graphics.BookFont : ::GraphicsResource.TextFont; uint32_t dwFontClr = fIsPreGame ? C4StartupFontClr : 0xffffffff; // get size of caption label bool fTabular = pForDlg->IsTabular(); int32_t iCaptWidth, iCaptHeight; if (fTabular) { // tabular layout: Caption label width by largest caption on runtime; fixed 1/3rd on startup rUseFont.GetTextExtent(LoadResStr("IDS_NET_RUNTIMEJOIN"), iCaptWidth, iCaptHeight, true); if (pForDlg->IsPreGame()) { iCaptWidth = pForDlg->GetItemWidth() * 1 / 3; } else { iCaptWidth = iCaptWidth * 5 / 4; } } else { rUseFont.GetTextExtent(szCaption, iCaptWidth, iCaptHeight, true); } // calc total height for component int iHorizontalMargin = 1; int iVerticalMargin = 1; int iComboMargin = 5; int iSelComboHgt = C4GUI::ComboBox::GetDefaultHeight(); SetBounds(C4Rect(0, 0, pForDlg->GetItemWidth(), (!fTabular) * (iCaptHeight + iVerticalMargin*2) + iVerticalMargin*2 + iSelComboHgt)); C4GUI::ComponentAligner ca(GetContainedClientRect(), iHorizontalMargin, iVerticalMargin); // create subcomponents AddElement(pCaption = new C4GUI::Label(FormatString("%s:", szCaption).getData(), fTabular ? ca.GetFromLeft(iCaptWidth, iCaptHeight) : ca.GetFromTop(iCaptHeight), ALeft, dwFontClr, &rUseFont, false, false)); ca.ExpandLeft(-iComboMargin); AddElement(pPrimarySubcomponent = pDropdownList = new C4GUI::ComboBox(ca.GetAll())); pDropdownList->SetReadOnly(fReadOnly); pDropdownList->SetComboCB(new C4GUI::ComboBox_FillCallback<C4GameOptionsList::OptionDropdown>(this, &C4GameOptionsList::OptionDropdown::OnDropdownFill, &C4GameOptionsList::OptionDropdown::OnDropdownSelChange)); if (fIsPreGame) { pDropdownList->SetColors(C4StartupFontClr, C4StartupEditBGColor, C4StartupEditBorderColor); pDropdownList->SetFont(&rUseFont); pDropdownList->SetDecoration(&(C4Startup::Get()->Graphics.fctContext)); } // final init InitOption(pForDlg); }
BOOL CDlgCustomMCFunction::OnInitDialog() { CDialog::OnInitDialog(); m.Info.bSubDlgOpen = true; f.UpdateButtonState(); // init button m_btnOK.SetIcon(IDI_SAVE);; m_btnOK.SetAlign(CButtonST::ST_ALIGN_VERT);; m_btnOK.SetFlat(FALSE); m_btnCancel.SetIcon(IDI_CANCEL); m_btnCancel.SetAlign(CButtonST::ST_ALIGN_VERT); m_btnCancel.SetFlat(FALSE); // InitOption(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
int main(int argc, char **argv){ //def and init OPT option; int im_ext = 0; FILE *IN; int file_open = 0; InitOption(&option); //opt analysis GetOption(argc-1,argv+1,&option); if(option.check > 0){ PrintOption(option); im_ext++; } if(option.help > 0){ help(); im_ext++; } if(im_ext > 0){ exit(0); } if(strlen(option.file) > 0){ if((IN = fopen(option.file,"rw")) == NULL){perror("fopen()\n"); exit(0);} file_open = 1; }else{ IN = stdin; } //core func data_read_print_ngram_from_fp(IN,option); //file closer if(file_open > 1){ fclose(IN); } return(0); }
int main(int argc, char *argv[]) { int ret = 1; g_main_window=NULL; /* for UpdateMenuLink (check "first call") */ g_quality_dialog = NULL; /* for UpdateMenuLink (check "first call") */ bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset( PACKAGE, "UTF-8" ); textdomain(PACKAGE); gtk_set_locale(); // Set gtk resource file. SetGtkResourceFile(); gtk_init(&argc, &argv); #ifdef USE_LIB_GLADE // Initialize the glade library. glade_init(); #endif // Parse options. InitOption(argc, argv); // Set the directory name for storing keytext files. SetKeyTextDir(PACKAGE_DATA_DIR); #ifndef USE_LIB_GLADE // Set the directory name for storing xpm files. SetPixmapDir(PACKAGE_DATA_DIR); #endif // Load fontset. //g_main_font = LoadFontSet(); g_main_font = NULL; // Initialize signal control level. InitSignal(); // Load the glade and keytext file. if( LoadResources() ) { // Initialize databases. InitDataBase(g_model_name); // Initialize printint type table. InitPrintingType(); // Create main dialog, and realize it. g_main_window = CreateMainWindow(); gtk_widget_realize(UI_DIALOG(g_main_window)->window); // Create dialogs. CreateDialogs(); // Connect signal handlers. ConnectSignalHandlers(); // Update widgets. DisableSignal(); UpdateWidgets(UI_DIALOG(g_main_window)->window, NULL); EnableSignal(); // Set window title. snprintf(g_window_title, sizeof(g_window_title), "Canon %s", GetDispModelName()); //Ver.2.90(s) gtk_window_set_title( GTK_WINDOW(UI_DIALOG(g_main_window)->window), g_window_title); // Show widgets depend on model. ShowModelDependWidgets(g_main_window); gtk_widget_show(UI_DIALOG(g_main_window)->window); gtk_main(); ret = 0; // Dispose dialogs. DisposeDialogs(); // Dispose main dialog. DisposeDialog(UI_DIALOG(g_main_window)); // Free databases. FreeDataBase(); // Free resources. FreeResources(); } // Free Gdk resource. if( g_main_font ) gdk_font_unref(g_main_font); // Free option strings. FreeOption(); return ret; }