sis3316_flash::sis3316_flash(const TGWindow *p, UInt_t w, UInt_t h, Bool_t *b) : TGMainFrame(p, w, h) { // use hierarchical cleaning SetCleanup(kDeepCleanup); if(b){ fBSetup = b; *fBSetup = kTRUE; } // main window icon and general setup SetWindowName("SIS3316 - Flash Programmer"); SetIconPixmap("sis1.png"); fClient->GetColorByName("green", this->green); fClient->GetColorByName("red", this->red); reboot_prevent_flag = 0; // vertical frame fVert1 = new TGVerticalFrame(this, GetDefaultWidth(), GetDefaultHeight()); AddFrame(fVert1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); // VME FPGA Programming section fGrpVME = new TGGroupFrame(fVert1, "VME FPGA Programming"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpVME, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fLblVMEImg = new TGLabel(fGrpVME, "VME FPGA Image"); fGrpVME->AddFrame(fLblVMEImg, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5)); fHor1 = new TGHorizontalFrame(fGrpVME); fGrpVME->AddFrame(fHor1, new TGLayoutHints(kLHintsExpandX)); fVMEImgPath = new TGTextEntry(fHor1, "test VME Image.bin"); fHor1->AddFrame(fVMEImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fVMEImgPath->SetWidth(240); fButVMEBrowse = new TGTextButton(fHor1, "...", BTN_VME_BROWSE); fButVMEBrowse->ChangeOptions(fButVMEBrowse->GetOptions() | kFixedWidth); fButVMEBrowse->SetWidth(50); fButVMEBrowse->Associate(this); fHor1->AddFrame(fButVMEBrowse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5)); fButVMEProg = new TGTextButton(fGrpVME, "Program VME FPGA", BTN_VME_PROG); fButVMEProg->Associate(this); fGrpVME->AddFrame(fButVMEProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15)); // ADC FPGA Programming section fGrpADC = new TGGroupFrame(fVert1, "ADC FPGA Programming"); //fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 10, 5)); fVert1->AddFrame(fGrpADC, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); // ADC1 fLblADC1Img = new TGLabel(fGrpADC, "ADC FPGA Image"); fGrpADC->AddFrame(fLblADC1Img, new TGLayoutHints(kLHintsNormal, 0, 0, 10, 5)); fHorADC1 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC1, new TGLayoutHints(kLHintsExpandX)); fADC1ImgPath = new TGTextEntry(fHorADC1, "test ADC Image.bin"); fHorADC1->AddFrame(fADC1ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC1ImgPath->SetWidth(240); fButADC1Browse = new TGTextButton(fHorADC1, "...", BTN_ADC1_BROWSE); fButADC1Browse->ChangeOptions(fButADC1Browse->GetOptions() | kFixedWidth); fButADC1Browse->SetWidth(50); fButADC1Browse->Associate(this); fHorADC1->AddFrame(fButADC1Browse, new TGLayoutHints(kLHintsRight, 5, 5, 5, 5)); fButADCProg = new TGTextButton(fGrpADC, "Program ADC FPGAs", BTN_ADC_PROG); fGrpADC->AddFrame(fButADCProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15)); fButADCProg->Associate(this); #ifdef NOT_IMPLEMENTED // ADC2 fLblADC2Img = new TGLabel(fGrpADC, "ADC2 FPGA Image"); fGrpADC->AddFrame(fLblADC2Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); fHorADC2 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC2, new TGLayoutHints(kLHintsExpandX)); fADC2ImgPath = new TGTextEntry(fHorADC2, "test ADC2 Image.bin"); fHorADC2->AddFrame(fADC2ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC2ImgPath->SetWidth(187); fButADC2Browse = new TGTextButton(fHorADC2, "...", BTN_ADC2_BROWSE); fButADC2Browse->ChangeOptions(fButADC2Browse->GetOptions() | kFixedWidth); fButADC2Browse->SetWidth(50); fButADC2Browse->Associate(this); fHorADC2->AddFrame(fButADC2Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); // ADC3 fLblADC3Img = new TGLabel(fGrpADC, "ADC3 FPGA Image"); fGrpADC->AddFrame(fLblADC3Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); fHorADC3 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC3, new TGLayoutHints(kLHintsExpandX)); fADC3ImgPath = new TGTextEntry(fHorADC3, "test ADC2 Image.bin"); fHorADC3->AddFrame(fADC3ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC3ImgPath->SetWidth(187); fButADC3Browse = new TGTextButton(fHorADC3, "...", BTN_ADC3_BROWSE); fButADC3Browse->ChangeOptions(fButADC3Browse->GetOptions() | kFixedWidth); fButADC3Browse->SetWidth(50); fButADC3Browse->Associate(this); fHorADC3->AddFrame(fButADC3Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); // ADC4 fLblADC4Img = new TGLabel(fGrpADC, "ADC4 FPGA Image"); fGrpADC->AddFrame(fLblADC4Img, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0)); fHorADC4 = new TGHorizontalFrame(fGrpADC); fGrpADC->AddFrame(fHorADC4, new TGLayoutHints(kLHintsExpandX)); fADC4ImgPath = new TGTextEntry(fHorADC4, "test ADC4 Image.bin"); fHorADC4->AddFrame(fADC4ImgPath, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fADC4ImgPath->SetWidth(187); fButADC4Browse = new TGTextButton(fHorADC4, "...", BTN_ADC4_BROWSE); fButADC4Browse->ChangeOptions(fButADC4Browse->GetOptions() | kFixedWidth); fButADC4Browse->SetWidth(50); fButADC4Browse->Associate(this); fHorADC4->AddFrame(fButADC4Browse, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5)); fChkADCImgSelect = new TGCheckButton(fGrpADC, "ADC FPGAs have unique images"); fChkADCImgSelect->SetState(kButtonDown) ; // is ON ! fChkADCImgSelect->SetEnabled(kFALSE); // //fChkADCImgSelect->Associate(this); fGrpADC->AddFrame(fChkADCImgSelect); #endif //fGrpProgram = new TGGroupFrame(fVert1, "Programming"); //fVert1->AddFrame(fGrpProgram, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 10, 0, 0)); fGrpBarProg = new TGGroupFrame(fVert1, "Programming progress"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpBarProg, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fBar_prog = new TGHProgressBar(fGrpBarProg); fBar_prog->ShowPosition(kTRUE, kTRUE); fBar_prog->SetBarColor("blue"); fBar_prog->SetForegroundColor(0x000000); fGrpBarProg->AddFrame(fBar_prog, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 10)); // hints, left, right, top, bottom fGrpBarVerify = new TGGroupFrame(fVert1, "Verifying progress"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpBarVerify, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fBar_verify = new TGHProgressBar(fGrpBarVerify); fBar_verify->ShowPosition(kTRUE, kTRUE); fBar_verify->SetBarColor("blue"); fBar_verify->SetForegroundColor(0x000000); fGrpBarVerify->AddFrame(fBar_verify, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 10, 20, 20)); // hints, left, right, top, bottom fGrpReboot = new TGGroupFrame(fVert1, "Reboot"); // hints, left, right, top, bottom fVert1->AddFrame(fGrpReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 20, 5)); fButReboot = new TGTextButton(fGrpReboot, "Reboot SIS3316 FPGAs", BTN_REBOOT); fButReboot->Associate(this); fButReboot->ChangeBackground(this->green); fGrpReboot->AddFrame(fButReboot, new TGLayoutHints(kLHintsExpandX, 5, 5, 10, 15)); fLabel_reboot_note = new TGLabel(fGrpReboot,"Note: the watchdog has to be enabled -> SW80-7 ON "); fLabel_reboot_note->SetTextJustify(kTextLeft + kTextCenterX ); fLabel_reboot_note->SetMargins(0,0,0,0); fLabel_reboot_note->SetWrapLength(-1); fGrpReboot->AddFrame(fLabel_reboot_note, new TGLayoutHints(kLHintsExpandX,2,2,15,2)); // draw everything SetWMSizeHints(w, h, w, h, 1, 1); Resize(GetDefaultSize()); // resize to default size MapSubwindows(); // initially hidden #ifdef NOT_IMPLEMENTED fGrpADC->HideFrame(fHorADC2); fGrpADC->HideFrame(fHorADC3); fGrpADC->HideFrame(fHorADC4); fGrpADC->HideFrame(fLblADC2Img); fGrpADC->HideFrame(fLblADC3Img); fGrpADC->HideFrame(fLblADC4Img); #endif MapWindow(); }
bool ConfParams() { param_entry_s *pFirstParam = NULL; std::vector<char *> ParamItems; for (std::list<command_entry_s *>::iterator p=InstallInfo.command_entries.begin();p!=InstallInfo.command_entries.end(); p++) { for (std::map<std::string, param_entry_s *>::iterator p2=(*p)->parameter_entries.begin(); p2!=(*p)->parameter_entries.end();p2++) { if (!pFirstParam) pFirstParam = p2->second; ParamItems.push_back(MakeCString(p2->first)); } } if (!pFirstParam) return true; // No command entries...no need for this screen char *title = CreateText("<C></B/29>%s<!29!B>", GetTranslation("Configure parameters")); char *buttons[3] = { GetTranslation("Edit parameter"), GetTranslation("Continue"), GetTranslation("Cancel") }; ButtonBar.Clear(); ButtonBar.AddButton("TAB", "Next button"); ButtonBar.AddButton("ENTER", "Activate button"); ButtonBar.AddButton("Arrows", "Navigate menu"); ButtonBar.AddButton("A", "About"); ButtonBar.AddButton("ESC", "Exit program"); ButtonBar.Draw(); CCDKButtonBox ButtonBox(CDKScreen, CENTER, GetDefaultHeight()-1, 1, GetDefaultWidth(), 0, 1, 3, buttons, 3); ButtonBox.SetBgColor(5); CCDKScroll ScrollList(CDKScreen, getbegx(ButtonBox.GetBBox()->win), 2, getbegy(ButtonBox.GetBBox()->win)-1, GetDefaultWidth()/2, RIGHT, title, &ParamItems[0], ParamItems.size()); ScrollList.SetBgColor(5); ScrollList.Bind('a', ShowAboutK); const int defh = 3; CCDKSWindow DescWindow(CDKScreen, (getbegx(ScrollList.GetScroll()->win) + getmaxx(ScrollList.GetScroll()->win))-1, 2, getmaxy(ScrollList.GetScroll()->win)-defh-1, (GetDefaultWidth()/2)+1, CreateText("<C></B/29>%s<!29!B>", GetTranslation("Description")), 30); DescWindow.SetBgColor(5); DescWindow.AddText(GetTranslation(pFirstParam->description)); CCDKSWindow DefWindow(CDKScreen, (getbegx(ScrollList.GetScroll()->win) + getmaxx(ScrollList.GetScroll()->win))-1, getmaxy(DescWindow.GetSWin()->win), defh, (GetDefaultWidth()/2)+1, NULL, 4); DefWindow.SetBgColor(5); const char *str = pFirstParam->defaultval.c_str(); if (pFirstParam->param_type == PTYPE_BOOL) { if (!strcmp(str, "true")) str = GetTranslation("Enabled"); else str = GetTranslation("Disabled"); } DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Default"), str), false); DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Current"), str), false); setCDKScrollLLChar(ScrollList.GetScroll(), ACS_LTEE); setCDKScrollLRChar(ScrollList.GetScroll(), ACS_BTEE); setCDKScrollURChar(ScrollList.GetScroll(), ACS_TTEE); setCDKSwindowULChar(DescWindow.GetSWin(), ACS_TTEE); setCDKSwindowLLChar(DescWindow.GetSWin(), ACS_LTEE); setCDKSwindowLRChar(DescWindow.GetSWin(), ACS_RTEE); setCDKSwindowURChar(DefWindow.GetSWin(), ACS_RTEE); setCDKSwindowLRChar(DefWindow.GetSWin(), ACS_RTEE); setCDKButtonboxULChar(ButtonBox.GetBBox(), ACS_LTEE); setCDKButtonboxURChar(ButtonBox.GetBBox(), ACS_RTEE); ButtonBox.Draw(); DescWindow.Draw(); DefWindow.Draw(); void *Data[4] = { &DescWindow, &DefWindow, &ScrollList, &ParamItems }; setCDKScrollPreProcess(ScrollList.GetScroll(), ScrollParamMenuK, &Data); ScrollList.Bind(KEY_TAB, SwitchButtonK, ButtonBox.GetBBox()); bool success = false; while(1) { int selection = ScrollList.Activate(); if (ScrollList.ExitType() == vNORMAL) { if (ButtonBox.GetCurrent() == 1) { success = true; break; } else if (ButtonBox.GetCurrent() == 2) { success = false; break; } param_entry_s *pParam = GetParamByName(ParamItems[selection]); if (pParam->param_type == PTYPE_DIR) { CFileDialog filedialog(GetFirstValidDir(pParam->value), CreateText("<C>%s", GetTranslation("Select a directory")), true, false); if (filedialog.Activate()) pParam->value = filedialog.Result(); filedialog.Destroy(); refreshCDKScreen(CDKScreen); } else if (pParam->param_type == PTYPE_STRING) { CCDKEntry entry(CDKScreen, CENTER, CENTER, GetTranslation("Please enter new value"), "", 40, 0, 256); entry.SetBgColor(26); entry.SetValue(pParam->value); const char *newval = entry.Activate(); if ((entry.ExitType() == vNORMAL) && newval) pParam->value = newval; // Restore screen entry.Destroy(); refreshCDKScreen(CDKScreen); } else { std::vector<char *> chitems; int cur = 0; if (pParam->param_type == PTYPE_BOOL) { chitems.push_back(GetTranslation("Disable")); chitems.push_back(GetTranslation("Enable")); cur = (pParam->value == "true") ? 1 : 0; } else { int i = 0; for (std::list<std::string>::iterator it=pParam->options.begin(); it!=pParam->options.end();it++, i++) { chitems.push_back(GetTranslation(MakeCString(*it))); if (*it == pParam->value) cur = i; } } CCDKScroll chScrollList(CDKScreen, CENTER, CENTER, 6, 30, RIGHT, GetTranslation("Please choose new value"), &chitems[0], chitems.size()); chScrollList.SetBgColor(26); chScrollList.SetCurrent(cur); int chsel = chScrollList.Activate(); if (chScrollList.ExitType() == vNORMAL) { if (pParam->param_type == PTYPE_BOOL) { if (!strcmp(chitems[chsel], GetTranslation("Enable"))) pParam->value = "true"; else pParam->value = "false"; } else pParam->value = chitems[chsel]; } chScrollList.Destroy(); refreshCDKScreen(CDKScreen); } DefWindow.Clear(); DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Default"), GetParamDefault(pParam)), false); DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Current"), GetParamValue(pParam)), false); } else { success = false; break; } } return success; }
//______________________________________________________________________________ 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); }
bool CFileDialog::Activate() { char *buttons[] = { GetTranslation("Open directory"), GetTranslation("Select directory"), GetTranslation("Cancel") }; char label[] = "Dir: "; char curdir[1024]; ButtonBar.Push(); ButtonBar.AddButton("TAB", "Next button"); ButtonBar.AddButton("ENTER", "Activate button"); ButtonBar.AddButton("Arrows", "Navigate menu"); ButtonBar.AddButton("C", "Create directory"); ButtonBar.AddButton("A", "About"); ButtonBar.AddButton("ESC", "Cancel"); ButtonBar.Draw(); if (!getcwd(curdir, sizeof(curdir))) throwerror(true, "Could not read current directory"); if (chdir(m_szStartDir.c_str()) != 0) throwerror(true, "Could not open directory '%s'", m_szStartDir.c_str()); if (!ReadDir(m_szStartDir)) throwerror(true, "Could not read directory '%s'", m_szStartDir.c_str()); CCDKButtonBox ButtonBox(CDKScreen, CENTER, GetDefaultHeight(), 1, GetDefaultWidth(), 0, 1, 3, buttons, 3); ButtonBox.SetBgColor(5); if (!m_pCurDirWin && !m_pFileList) { m_pCurDirWin = new CCDKSWindow(CDKScreen, CENTER, getbegy(ButtonBox.GetBBox()->win)-2, 2, GetDefaultWidth()+1, NULL, 1); m_pCurDirWin->SetBgColor(5); if (!m_pFileList) { m_pFileList = new CCDKAlphaList(CDKScreen, CENTER, 2, getbegy(m_pCurDirWin->GetSWin()->win)-1, GetDefaultWidth()+1, const_cast<char*>(m_szTitle.c_str()), label, &m_DirItems[0], m_DirItems.size()); m_pFileList->SetBgColor(5); setCDKEntryPreProcess(m_pFileList->GetAList()->entryField, CreateDirCB, this); //m_pFileList->GetAList()->entryField->dispType = vVIEWONLY; // HACK: Disable backspace } setCDKAlphalistLLChar(m_pFileList->GetAList(), ACS_LTEE); setCDKAlphalistLRChar(m_pFileList->GetAList(), ACS_RTEE); setCDKLabelLLChar(m_pCurDirWin->GetSWin(), ACS_LTEE); setCDKLabelLRChar(m_pCurDirWin->GetSWin(), ACS_RTEE); setCDKButtonboxULChar(ButtonBox.GetBBox(), ACS_LTEE); setCDKButtonboxURChar(ButtonBox.GetBBox(), ACS_RTEE); } m_pFileList->Draw(); m_pCurDirWin->Draw(); ButtonBox.Draw(); m_pFileList->Bind(KEY_TAB, SwitchButtonK, ButtonBox.GetBBox()); // Pas TAB through ButtonBox m_szDestDir = m_szStartDir; UpdateCurDirText(); while(true) { // HACK: Give textbox content setCDKEntryValue(m_pFileList->GetAList()->entryField, chtype2Char(m_pFileList->GetAList()->scrollField->item[m_pFileList->GetAList()->scrollField->currentItem])); char *selection = m_pFileList->Activate(); if ((m_pFileList->ExitType() != vNORMAL) || (ButtonBox.GetCurrent() == 2)) break; if (!selection || !selection[0]) continue; if (ButtonBox.GetCurrent() == 1) { if (m_bAskWAccess && !WriteAccess(m_szDestDir)) { char *dbuttons[2] = { GetTranslation("Continue as root"), GetTranslation("Choose another directory") }; CCDKDialog Diag(CDKScreen, CENTER, CENTER, GetTranslation("You don't have write permissions for this directory.\n" "The files can be extracted as the root user,\n" "but you'll need to enter the root password for this later."), dbuttons, 2); Diag.SetBgColor(26); int sel = Diag.Activate(); Diag.Destroy(); refreshCDKScreen(CDKScreen); if (sel) continue; } break; } if (!FileExists(selection)) { if (YesNoBox(GetTranslation("Directory does not exist\nDo you want to create it?"))) { if (mkdir(selection, (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH)) != 0) { WarningBox("%s\n%.75s\n%.75s", GetTranslation("Could not create directory"), selection, strerror(errno)); continue; } } else continue; } UpdateFileList(selection); } bool success = ((m_pFileList->ExitType() != vESCAPE_HIT) && (ButtonBox.GetCurrent() == 1)); ButtonBar.Pop(); if (m_bRestoreDir) chdir(curdir); // Return back to original directory return success; }