/** * Return a string with the object information (only the header) */ QString UAVObject::toStringBrief() { QString sout; sout.append( QString("%1 (ID: %2, InstID: %3, NumBytes: %4, SInst: %5)\n") .arg(getName()) .arg(getObjID()) .arg(getInstID()) .arg(getNumBytes()) .arg(isSingleInstance()) ); return sout; }
int ScreensaverApp::run() { int retVal=0; switch (iScreensaverMode) { case SS_MODE_PREVIEW: // PreviewWindow ......... { RECT rcPos; GetClientRect(parentHwnd, &rcPos); vecDisplays[0]->Window.setStyles(0,0); vecDisplays[0]->Window.setParentHandle(parentHwnd); vecDisplays[0]->Window.setPosition(rcPos); vecDisplays[0]->Window.setScreensaverMode(iScreensaverMode); if (vecDisplays[0]->Window.createWindow()) retVal=vecDisplays[0]->Window.MessageLoop(); } break; case SS_MODE_PASSWORD: // Password is changing (only for old Win95/98ME)...... { HINSTANCE mpr = LoadLibrary( "MPR.dll"); typedef DWORD (FAR PASCAL *PWCHGPROC)( LPCTSTR, HWND, DWORD, LPVOID ); if( mpr ) { PWCHGPROC pwd = (PWCHGPROC)GetProcAddress( mpr, "PwdChangePasswordA" ); if( pwd ) pwd( TEXT("SCRSAVE"), parentHwnd, 0, NULL ); FreeLibrary( mpr ); } } break; case SS_MODE_SAVER: // the full screen Screensaver is running........ { if (!isSingleInstance()) return retVal; if (CRegistry::MatrixShow[REGISTRY_CLONE]) { for (unsigned int x=0;x<vecDisplays.size();x++) { vecDisplays[x]->Window.setScreensaverMode(iScreensaverMode); vecDisplays[x]->Window.createWindow(); } } else { RECT rcAll; SetRect(&rcAll,0,0,0,0); for (unsigned int x=0;x<vecDisplays.size();x++) { RECT tmp=vecDisplays[x]->rcMonitor; tmp.bottom+=tmp.top; // convert from x/y, w,h to x1/y1, x2/y2 tmp.right+=tmp.left; if (tmp.left<rcAll.left) rcAll.left=tmp.left; if (tmp.top<rcAll.top) rcAll.top=tmp.top; if (tmp.right>rcAll.right) rcAll.right=tmp.right; if (tmp.bottom>rcAll.bottom) rcAll.bottom=tmp.bottom; } rcAll.bottom-=rcAll.top; rcAll.right-=rcAll.left; vecDisplays[0]->Window.setPosition(rcAll); vecDisplays[0]->Window.setScreensaverMode(iScreensaverMode); vecDisplays[0]->Window.createWindow(); } } retVal=vecDisplays[0]->Window.MessageLoop(); break; case SS_MODE_CONFIG: // the configDlg will be shown... retVal=DialogBox(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_DIALOG),parentHwnd,DialogProc); if (retVal==-1) retVal=GetLastError(); break; default: return MessageBox(NULL,"No Screensaver-Mode Found","Screensaver",MB_OK); } return retVal; }
EmulApp::EmulApp(int & argc, char ** argv) : QApplication(argc, argv, true), fsmPrintFunctor(0), debug(false), initializing(true), nLinesInLog(0), nLinesInLogMax(1000), fsmRunning(false), fsmServerProc(0), soundServerProc(0), soundTrigShm(0), sndThr(0), lastSndEvt(0) { if (!isSingleInstance()) { QMessageBox::critical(0, "FSM Emulator - Error", "Another copy of this program is already running!"); std::exit(1); } if (singleton) { QMessageBox::critical(0, "FSM Emulator - Invariant Violation", "Only 1 instance of EmulApp allowed per application!"); std::exit(1); } singleton = this; setApplicationName("FSMEmulator"); try { if (!::init) ::init = new Init; loadSettings(); installEventFilter(this); // filter our own events mainwin = new MainWindow; defaultLogColor = mainwin->textEdit()->textColor(); Log() << "Application started"; mainwin->installEventFilter(this); mainwin->textEdit()->installEventFilter(this); mainwin->setWindowTitle("FSM Emulator v." VersionSTR); mainwin->resize(600, 300); int delta = 0; #ifdef Q_WS_X11 delta += 22; // this is a rough guesstimate to correct for window frame size being unknown on X11 #endif mainwin->move(0,mainwin->frameSize().height()+delta); mainwin->show(); // do sound trig shm stuff.. RTOS::ShmStatus shmStatus; soundTrigShm = reinterpret_cast<FSMExtTrigShm *>(RTOS::shmAttach(FSM_EXT_TRIG_SHM_NAME, FSM_EXT_TRIG_SHM_SIZE, &shmStatus, true)); if (!soundTrigShm) { throw FatalException(QString("Cannot create shm to ") + FSM_EXT_TRIG_SHM_NAME + " reason was: " + RTOS::statusString(shmStatus)); } soundTrigShm->magic = FSM_EXT_TRIG_SHM_MAGIC; soundTrigShm->function = &EmulApp::soundTrigFunc; soundTrigShm->valid = 1; killProcs("FSMServer"); killProcs("SoundServer"); startFSM(); startFSMServer(); startSoundServer(); pfv = new ProcFileViewer(0); pfv->resize(516, 621); pfv->hide(); /// construct the moduleparmviewer.. mpv = new QWidget(0); mpv->setWindowTitle("FSM Emulator - Module Parameter Viewer"); QGridLayout *l = new QGridLayout(mpv); QScrollArea *qsa = new QScrollArea(mpv); mp = new ModuleParmView(qsa); qsa->setWidget(mp); qsa->setWidgetResizable(true); l->addWidget(new QLabel("Modify FSM module parameters here, note that applying the parameters <B><font color=red>*will*</b></font> force an FSM restart!", mpv), 0, 0, 1, 3); l->addWidget(qsa, 1, 0, 1, 3); applyParamsBut = new QPushButton("Apply", mpv); applyParamsBut->setEnabled(false); revertParamsBut = new QPushButton("Revert", mpv); revertParamsBut->setEnabled(false); l->addWidget(applyParamsBut, 2, 0, 1, 1, Qt::AlignLeft); l->addWidget(revertParamsBut, 2, 1, 1, 1, Qt::AlignLeft); l->addWidget(new QWidget(mpv), 2, 2, 1, 1); connect(applyParamsBut, SIGNAL(clicked()), this, SLOT(applyModParams())); connect(revertParamsBut, SIGNAL(clicked()), this, SLOT(revertModParams())); connect(mp, SIGNAL(changed()), this, SLOT(modParamsChanged())); // construct the control window controlwin = new ControlWin(0); controlwin->show(); setupAppIcon(); buildAppMenus(); initializing = false; Log() << "Application initialized"; QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); timer->setSingleShot(false); timer->start(247); // update status bar every 247ms.. i like this non-round-numbre.. ;) } catch (const Exception & e) { Error() << e.what() << "\n"; QMessageBox::critical(0, "FSM Emulator - Exception Caught", e.what()); postEvent(mainwin, new QCloseEvent()); } }