void C4FileSelDlg::InitElements() { UpdateSize(); CStdFont *pUseFont = &(C4GUI::GetRes()->TextFont); // main calcs bool fHasOptions = HasExtraOptions(); C4GUI::ComponentAligner caMain(GetClientRect(), 0, 0, true); C4Rect rcOptions; C4GUI::ComponentAligner caButtonArea( caMain.GetFromBottom(C4GUI_ButtonAreaHgt, 2 * C4GUI_DefButton2Wdt + 4 * C4GUI_DefButton2HSpace), C4GUI_DefButton2HSpace, (C4GUI_ButtonAreaHgt - C4GUI_ButtonHgt) / 2); if (fHasOptions) rcOptions = caMain.GetFromBottom(pUseFont->GetLineHeight() + 2 * C4GUI_DefDlgSmallIndent); C4GUI::ComponentAligner caUpperArea(caMain.GetAll(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true); // create file selection area if (iLocationCount) { C4GUI::ComponentAligner caLocations( caUpperArea.GetFromTop(C4GUI::ComboBox::GetDefaultHeight() + 2 * C4GUI_DefDlgSmallIndent), C4GUI_DefDlgIndent, C4GUI_DefDlgSmallIndent, false); StdStrBuf sText(LoadResStr("IDS_TEXT_LOCATION")); AddElement(new C4GUI::Label( sText.getData(), caLocations.GetFromLeft(pUseFont->GetTextWidth(sText.getData())), ALeft)); pLocationComboBox = new C4GUI::ComboBox(caLocations.GetAll()); pLocationComboBox->SetComboCB( new C4GUI::ComboBox_FillCallback<C4FileSelDlg>( this, &C4FileSelDlg::OnLocationComboFill, &C4FileSelDlg::OnLocationComboSelChange)); pLocationComboBox->SetText(pLocations[0].sName.getData()); } // create file selection area bool fHasPreview = HasPreviewArea(); pFileListBox = new C4GUI::ListBox( fHasPreview ? caUpperArea.GetFromLeft(caUpperArea.GetWidth() / 2) : caUpperArea.GetAll(), GetFileSelColWidth()); pFileListBox->SetSelectionChangeCallbackFn( new C4GUI::CallbackHandler<C4FileSelDlg>(this, &C4FileSelDlg::OnSelChange)); pFileListBox->SetSelectionDblClickFn(new C4GUI::CallbackHandler<C4FileSelDlg>( this, &C4FileSelDlg::OnSelDblClick)); if (fHasPreview) { caUpperArea.ExpandLeft(C4GUI_DefDlgIndent); pSelectionInfoBox = new C4GUI::TextWindow(caUpperArea.GetAll()); pSelectionInfoBox->SetDecoration(true, true, NULL, true); } // create button area C4GUI::Button *btnAbort = new C4GUI::CancelButton(caButtonArea.GetFromRight(C4GUI_DefButton2Wdt)); btnOK = new C4GUI::OKButton(caButtonArea.GetFromRight(C4GUI_DefButton2Wdt)); // add components in tab order if (pLocationComboBox) AddElement(pLocationComboBox); AddElement(pFileListBox); if (pSelectionInfoBox) AddElement(pSelectionInfoBox); if (fHasOptions) AddExtraOptions(rcOptions); AddElement(btnOK); AddElement(btnAbort); SetFocus(pFileListBox, false); // no selection yet UpdateSelection(); }