KVFileDialog::KVFileDialog(const TGWindow *p, const TGWindow *main, EKVFileDialogMode dlg_type, TGFileInfo *file_info) : TGTransientFrame(p, main, 10, 10, kVerticalFrame) { // Create a file selection dialog. Depending on the dlg_type it can be // used for opening or saving a file or selecting a directory. fDlgMode=dlg_type; SetCleanup(kDeepCleanup); Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()"); DontCallClose(); int i; if (!p && !main) { MakeZombie(); return; } if (!file_info) { Error("KVFileDialog", "file_info argument not set"); fFileInfo = &gInfo; if (fFileInfo->fIniDir) { delete [] fFileInfo->fIniDir; fFileInfo->fIniDir = 0; } if (fFileInfo->fFilename) { delete [] fFileInfo->fFilename; fFileInfo->fFilename = 0; } fFileInfo->fFileTypeIdx = 0; } else fFileInfo = file_info; if (!fFileInfo->fFileTypes) fFileInfo->fFileTypes = gDefTypes; if (!fFileInfo->fIniDir) fFileInfo->fIniDir = StrDup("."); TGHorizontalFrame *fHtop = new TGHorizontalFrame(this, 10, 10); //--- top toolbar elements TGLabel *fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave) ? "S&ave in:" : "&Look in:")); fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB); fTreeLB->Associate(this); fPcdup = fClient->GetPicture("tb_uplevel.xpm"); fPnewf = fClient->GetPicture("tb_newfolder.xpm"); fPlist = fClient->GetPicture("tb_list.xpm"); fPdetails = fClient->GetPicture("tb_details.xpm"); if (!(fPcdup && fPnewf && fPlist && fPdetails)) Error("KVFileDialog", "missing toolbar pixmap(s).\n"); fCdup = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP); fNewf = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER); fList = new TGPictureButton(fHtop, fPlist, kIDF_LIST); fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS); fCdup->SetStyle(gClient->GetStyle()); fNewf->SetStyle(gClient->GetStyle()); fList->SetStyle(gClient->GetStyle()); fDetails->SetStyle(gClient->GetStyle()); fCdup->SetToolTipText("Up One Level"); fNewf->SetToolTipText("Create New Folder"); fList->SetToolTipText("List"); fDetails->SetToolTipText("Details"); fCdup->Associate(this); fNewf->Associate(this); fList->Associate(this); fDetails->Associate(this); fList->AllowStayDown(kTRUE); fDetails->AllowStayDown(kTRUE); fTreeLB->Resize(200, fTreeLB->GetDefaultHeight()); fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)); fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2)); fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2)); fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2)); fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2)); fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2)); if (dlg_type == kKVFDSave) { fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB); fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected"); } else { fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB); fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed"); fCheckB->Connect("Toggled(Bool_t)","TGFileInfo",fFileInfo,"SetMultipleSelection(Bool_t)"); } fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); fCheckB->SetOn(fFileInfo->fMultipleSelection); AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1)); //--- file view fFv = new TGListView(this, 400, 161); fFc = new TGFileContainer(fFv->GetViewPort(), 10, 10, kHorizontalFrame, fgWhitePixel); fFc->Associate(this); fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel); fFv->SetContainer(fFc); fFv->SetViewMode(kLVList); fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time TGTextButton** buttons = fFv->GetHeaderButtons(); if (buttons) { buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)"); buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)"); buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)"); buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)"); buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)"); buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)"); } fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx+1]); fFc->Sort(kSortByName); fFc->ChangeDirectory(fFileInfo->fIniDir); fFc->SetMultipleSelection(fFileInfo->fMultipleSelection); fTreeLB->Update(fFc->GetDirectory()); fList->SetState(kButtonEngaged); AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1)); if (dlg_type == kKVFDOpen) { fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"SetMultipleSelection(Bool_t)"); fCheckB->Connect("Toggled(Bool_t)","TGFileContainer",fFc,"UnSelectAll()"); } //--- file name and types TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 10, 10); TGVerticalFrame *fVf = new TGVerticalFrame(fHf, 10, 10); TGHorizontalFrame *fHfname = new TGHorizontalFrame(fVf, 10, 10); TGLabel *fLfname = new TGLabel(fHfname, new TGHotString("File &name:")); fTbfname = new TGTextBuffer(1034); fName = new TGTextEntry(fHfname, fTbfname); fName->Resize(230, fName->GetDefaultHeight()); fName->Associate(this); fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)); fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2)); fVf->AddFrame(fHfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX)); TGHorizontalFrame *fHftype = new TGHorizontalFrame(fVf, 10, 10); TGLabel *fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:")); fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB); fTypes->Associate(this); fTypes->Resize(230, fName->GetDefaultHeight()); TString s; for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) { s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i+1]); fTypes->AddEntry(s.Data(), i); } fTypes->Select(fFileInfo->fFileTypeIdx); // Show all items in combobox without scrollbar //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize(); //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight); if (fFileInfo->fFilename && fFileInfo->fFilename[0]) fTbfname->AddText(0, fFileInfo->fFilename); else fTbfname->Clear(); fTypes->GetListBox()->Resize(230, 120); fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)); fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2)); fVf->AddFrame(fHftype, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX)); fHf->AddFrame(fVf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY | kLHintsExpandX)); //--- Open/Save and Cancel buttons TGVerticalFrame *fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth); fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave) ? "&Save" : "&Open"), kIDF_OK); fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL); fOk->Associate(this); fCancel->Associate(this); fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2)); fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2)); UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20; fVbf->Resize(width + 20, fVbf->GetDefaultHeight()); fHf->AddFrame(fVbf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY)); AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1)); SetEditDisabled(kEditDisable); MapSubwindows(); TGDimension size = GetDefaultSize(); Resize(size); //---- position relative to the parent's window CenterOnParent(); //---- make the message box non-resizable SetWMSize(size.fWidth, size.fHeight); SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1); const char *wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type==kKVFDOpen) ? "Open" : "Choose directory..."); SetWindowName(wname); SetIconName(wname); SetClassHints("FileDialog", "FileDialog"); SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize | kMWMDecorMinimize | kMWMDecorMenu, kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize | kMWMFuncMinimize, kMWMInputModeless); MapWindow(); fFc->DisplayDirectory(); fClient->WaitFor(this); }
//______________________________________________________________________________ ButtonWindow::ButtonWindow() : TGMainFrame(gClient->GetRoot(), 600, 500) { // Main test window. SetWindowName("CaLib Control Panel"); // --------------------------------------------------------------------------------- TGGroupFrame* config_frame = new TGGroupFrame(this, "Calibration and set configuration", kHorizontalFrame); config_frame->SetTitlePos(TGGroupFrame::kLeft); TGVerticalFrame* ver_frame_1 = new TGVerticalFrame(config_frame); // calibration selection fCBox_Calibration = new TGComboBox(ver_frame_1, "Choose calibration"); fCBox_Calibration->Resize(260, 25); ver_frame_1->AddFrame(fCBox_Calibration, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0)); // fill calibrations gCalibrations = TCMySQLManager::GetManager()->GetAllCalibrations(); for (Int_t i = 0; i < gCalibrations->GetSize(); i++) { TObjString* s = (TObjString*) gCalibrations->At(i); fCBox_Calibration->AddEntry(s->GetString().Data(), i); } fCBox_Calibration->Connect("Selected(Int_t)", "ButtonWindow", this, "EnableModuleSelection(Int_t)"); // calibration module selection fCBox_Module = new TGComboBox(ver_frame_1, "Choose calibration module"); fCBox_Module->Resize(260, 25); ver_frame_1->AddFrame(fCBox_Module, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0)); // fill modules for (Int_t i = 0; i < gCaLibModules->GetSize(); i++) { TCCalib* cmod = (TCCalib*) gCaLibModules->At(i); fCBox_Module->AddEntry(cmod->GetTitle(), i); } fCBox_Module->Connect("Selected(Int_t)", "ButtonWindow", this, "ReadRunsets(Int_t)"); config_frame->AddFrame(ver_frame_1, new TGLayoutHints(kLHintsFillX)); TGVerticalFrame* ver_frame_2 = new TGVerticalFrame(config_frame); // runset selection fLB_RunSet = new TGListBox(ver_frame_2); fLB_RunSet->SetMultipleSelections(kTRUE); fLB_RunSet->Resize(120, 60); ver_frame_2->AddFrame(fLB_RunSet, new TGLayoutHints(kLHintsLeft | kLHintsExpandY | kLHintsExpandX, 5, 0, 10, 0)); config_frame->AddFrame(ver_frame_2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); AddFrame(config_frame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); // --------------------------------------------------------------------------------- // control buttons TGGroupFrame* control_frame = new TGGroupFrame(this, "Calibration control", kHorizontalFrame); control_frame->SetTitlePos(TGGroupFrame::kLeft); fTB_Init = new TGTextButton(control_frame, "Start module"); ResizeFrame(fTB_Init); fTB_Init->Connect("Clicked()", "ButtonWindow", this, "StartModule()"); control_frame->AddFrame(fTB_Init, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); fTB_Write = new TGTextButton(control_frame, "Write to DB"); ResizeFrame(fTB_Write); fTB_Write->Connect("Clicked()", "ButtonWindow", this, "DoWrite()"); control_frame->AddFrame(fTB_Write, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); fTB_Print = new TGTextButton(control_frame, "Print values"); ResizeFrame(fTB_Print); fTB_Print->Connect("Clicked()", "ButtonWindow", this, "Print()"); control_frame->AddFrame(fTB_Print, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); fTB_PrintChanges = new TGTextButton(control_frame, "Print changes"); ResizeFrame(fTB_PrintChanges); fTB_PrintChanges->Connect("Clicked()", "ButtonWindow", this, "PrintChanges()"); control_frame->AddFrame(fTB_PrintChanges, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); fTB_Quit = new TGTextButton(control_frame, "Quit"); ResizeFrame(fTB_Quit); fTB_Quit->Connect("Clicked()", "ButtonWindow", this, "Quit()"); control_frame->AddFrame(fTB_Quit, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); AddFrame(control_frame, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 5)); // --------------------------------------------------------------------------------- TGHorizontalFrame* nav_main_frame = new TGHorizontalFrame(this); // manual navigation TGGroupFrame* nav_man_frame = new TGGroupFrame(nav_main_frame, "Manual navigation", kHorizontalFrame); nav_man_frame->SetTitlePos(TGGroupFrame::kLeft); fTB_Prev = new TGTextButton(nav_man_frame, "Previous"); ResizeFrame(fTB_Prev); fTB_Prev->SetToolTipText("Go to previous element", 200); fTB_Prev->Connect("Clicked()", "ButtonWindow", this, "DoPrev()"); nav_man_frame->AddFrame(fTB_Prev, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0)); fTB_Next = new TGTextButton(nav_man_frame, " Next "); ResizeFrame(fTB_Next); fTB_Next->SetToolTipText("Go to next element", 200); fTB_Next->Connect("Clicked()", "ButtonWindow", this, "DoNext()"); nav_man_frame->AddFrame(fTB_Next, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0)); fTB_Ignore = new TGTextButton(nav_man_frame, " Ignore "); ResizeFrame(fTB_Ignore); fTB_Ignore->SetToolTipText("Go to next element and ignore current one", 200); fTB_Ignore->Connect("Clicked()", "ButtonWindow", this, "DoIgnore()"); nav_man_frame->AddFrame(fTB_Ignore, new TGLayoutHints(kLHintsLeft, 0, 20, 10, 0)); fTB_Goto = new TGTextButton(nav_man_frame, "Go to"); ResizeFrame(fTB_Goto); fTB_Goto->SetToolTipText("Go to specified element", 200); fTB_Goto->Connect("Released()", "ButtonWindow", this, "Goto()"); nav_man_frame->AddFrame(fTB_Goto, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0)); fNE_Elem = new TGNumberEntry(nav_man_frame, 0, 3, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0, 719); ResizeFrame(fNE_Elem); nav_man_frame->AddFrame(fNE_Elem, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0)); nav_main_frame->AddFrame(nav_man_frame, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); // automatic navigation TGGroupFrame* nav_auto_frame = new TGGroupFrame(nav_main_frame, "Automatic navigation", kHorizontalFrame); nav_auto_frame->SetTitlePos(TGGroupFrame::kLeft); fNE_Delay = new TGNumberEntry(nav_auto_frame, 0.1, 3, -1, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0.01, 5); ResizeFrame(fNE_Delay); nav_auto_frame->AddFrame(fNE_Delay, new TGLayoutHints(kLHintsLeft, 0, 5, 10, 0)); fTB_DoAll = new TGTextButton(nav_auto_frame, "Start"); ResizeFrame(fTB_DoAll); fTB_DoAll->SetToolTipText("Process automatically", 200); fTB_DoAll->Connect("Clicked()", "ButtonWindow", this, "DoAll()"); nav_auto_frame->AddFrame(fTB_DoAll, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0)); fTB_Stop = new TGTextButton(nav_auto_frame, "Stop"); ResizeFrame(fTB_Stop); fTB_Stop->SetToolTipText("Stop processing", 200); fTB_Stop->Connect("Clicked()", "ButtonWindow", this, "Stop()"); nav_auto_frame->AddFrame(fTB_Stop, new TGLayoutHints(kLHintsLeft, 0, 0, 10, 0)); nav_main_frame->AddFrame(nav_auto_frame, new TGLayoutHints(kLHintsLeft, 5, 0, 0, 0)); AddFrame(nav_main_frame, new TGLayoutHints(kLHintsExpandX, 5, 5, 0, 5)); // window configuration Connect("CloseWindow()", "ButtonWindow", this, "Quit()"); DontCallClose(); // Map all subwindows of main frame MapSubwindows(); // Initialize the layout algorithm Resize(GetDefaultSize()); // show window MapRaised(); // move window Move(gClient->GetDisplayWidth() - GetDefaultWidth(), gClient->GetDisplayHeight() - GetDefaultHeight() - 30); }