MRESULT EXPENTRY MimeDlgProc(HWND hwndDlg,ULONG msg,MPARAM mp1,MPARAM mp2) { HPOINTER hptrOrig, hptrWait; static int num_entries; static int entry; static FILE *in; static Container *list; static MimeSet *mimes; UserData *ud; char buffer[1024]; int i; switch(msg) { case WM_INITDLG: hptrWait = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ); hptrOrig = WinQueryPointer( HWND_DESKTOP ); WinSetPointer( HWND_DESKTOP, hptrWait ); WinSendMsg(WinWindowFromID(hwndDlg,MIME_NAME),EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXT), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXE), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0)); mimes = (MimeSet*)mp2; list = new Container(); list->initialise(hwndDlg,MIME_CONT); num_entries = mimes->getSetNum(); for (i=0; i<num_entries; i++) { sprintf(buffer,"%s: %s",mimes->getName(i),mimes->getExtensions(i)); // message("%d/%d %s is %s",i,num_entries,mimes->getName(i),mimes->getExtensions(i)); list->insert(buffer,(UserData*)NULL,8888L,8888L); } WinFocusChange(HWND_DESKTOP,WinWindowFromID(hwndDlg,MIME_CONT),0); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(mimes->getSetNum()-1)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(mimes->getSetNum()-1)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(mimes->getSetNum()-1)); list->setItemFocus(list->getLastInsert()); WinSetPointer( HWND_DESKTOP, hptrOrig ); entry = -1; break; case WM_HELP: showHelpWindow(HELP_MIMES); break; case WM_CLOSE: mimes->reload(); delete list; return WinDefDlgProc(hwndDlg,msg,mp1,mp2); case WM_USER: list->arrange(); break; case WM_CONTROL: switch(SHORT2FROMMP(mp1)) { case CN_HELP: WinSendMsg(hwndDlg,WM_HELP,0,0); break; // sent every time emphasis of an object is changed, so if // change from A to B, get deselect on A, and select on B case CN_EMPHASIS: { PNOTIFYRECORDEMPHASIS nre = (PNOTIFYRECORDEMPHASIS)mp2; ud = (UserData*)nre->pRecord; if (ud != NULL) { char *buffer = new char[4096]; strcpy(buffer,ud->getName()); char *ptr = buffer+strlen(buffer)-1; while (ptr>buffer && *ptr!='.') ptr--; if (*ptr == '.') { int index = mimes->find(ptr); if (index > -1) { entry = index; WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(index)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(index)); WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(index)); } } delete[] buffer; } } break; case EN_CHANGE: { if (SHORT1FROMMP(mp1) == MIME_EXE) { ud = list->findSelectedRecord(NULL); static int lastindex = 0; if (ud && entry != -1) { if (lastindex == entry) { char *buffer = new char[4096]; WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer); mimes->setCommand(entry,buffer); delete[] buffer; } lastindex = entry; } } } break; } break; case WM_COMMAND: switch( SHORT1FROMMP( mp1 ) ) { case IDM_DELETE: // message("delete"); break; case DID_OK: // all OK, close dialog, return if (entry != -1) { WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer); mimes->setCommand(entry,buffer); } mimes->save(); delete list; WinDismissDlg( hwndDlg, TRUE); return (MRESULT) TRUE; case DID_CANCEL: mimes->reload(); delete list; WinDismissDlg( hwndDlg, TRUE); return (MRESULT) FALSE; } break; default: return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } return (MRESULT) TRUE; }
DataWindow::DataWindow(Information *info, int ind) { index = ind; xindex = STARTING_XPIN_INDEX; yindex = STARTING_YPIN_INDEX; ui = new Ui::DataWindow; ui->setupUi(this); widgetState = WIDGET_OPENED; widgetOpenAnimation = new QPropertyAnimation(ui->actionsContainerWidget, "maximumWidth", this); widgetOpenAnimation->setDuration(WIDGET_ANIMATION_TIME); widgetOpenAnimation->setEasingCurve(QEasingCurve::OutCubic); widgetCloseAnimation = new QPropertyAnimation(ui->actionsContainerWidget, "maximumWidth", this); widgetCloseAnimation->setDuration(WIDGET_ANIMATION_TIME); widgetCloseAnimation->setEasingCurve(QEasingCurve::OutCubic); windowOpenAnimation = new QPropertyAnimation(this, "geometry", this); windowOpenAnimation->setDuration(WIDGET_ANIMATION_TIME); windowOpenAnimation->setEasingCurve(QEasingCurve::OutCubic); windowCloseAnimation = new QPropertyAnimation(this, "geometry", this); windowCloseAnimation->setDuration(WIDGET_ANIMATION_TIME); windowCloseAnimation->setEasingCurve(QEasingCurve::OutCubic); openAnimation = new QParallelAnimationGroup(this); openAnimation->addAnimation(widgetOpenAnimation); openAnimation->addAnimation(windowOpenAnimation); connect(openAnimation, SIGNAL(finished()), this, SLOT(animationFinished())); closeAnimation = new QParallelAnimationGroup(this); closeAnimation->addAnimation(widgetCloseAnimation); closeAnimation->addAnimation(windowCloseAnimation); connect(closeAnimation, SIGNAL(finished()), this, SLOT(animationFinished())); connect(ui->retractionButton, SIGNAL(released()), this, SLOT(startAnimation())); setWindowTitle(tr("Data fill window: data") + QString::number(ind+1)); information = info; selectorSide = COLUMN_SELECTION; dataTable = new DataTable(info, STARTING_ROW_COUNT, STARTING_COLUMN_COUNT, ROW_HEIGHT, COLUMN_WIDTH); columnSelector = new ColumnSelectorWidget(STARTING_COLUMN_COUNT, STARTING_XPIN_INDEX, STARTING_YPIN_INDEX, STARTING_SELECTOR_INDEX); columnActionsWidget = new ColumnActionsWidget(dataTable, info, STARTING_COLUMN_COUNT); rowSelector = new RowSelectorWidget(STARTING_ROW_COUNT); rowActionsWidget = new RowActionsWidget(STARTING_ROW_COUNT); QHBoxLayout *columnSelectorLayout = new QHBoxLayout(); columnSelectorLayout->setMargin(0); columnSelectorLayout->setSpacing(0); columnSelectorSpacer = new QWidget(); columnSelector->setFixedHeight(COLUMN_SELECTOR_HEIGHT); columnSelectorLayout->addWidget(columnSelectorSpacer); columnSelectorLayout->addWidget(columnSelector); columnSelectorLayout->addStretch(); ui->tableLayout->addLayout(columnSelectorLayout); QVBoxLayout *rowSelectorLayout = new QVBoxLayout(); rowSelectorLayout->setMargin(0); rowSelectorLayout->setSpacing(0); rowSelectorSpacer = new QWidget(); rowSelector->setFixedWidth(ROW_SELECTOR_WIDTH); rowSelectorLayout->addWidget(rowSelectorSpacer); rowSelectorLayout->addWidget(rowSelector); rowSelectorLayout->addStretch(); QHBoxLayout *secondLayout = new QHBoxLayout(); secondLayout->setMargin(0); secondLayout->setSpacing(0); secondLayout->addLayout(rowSelectorLayout); secondLayout->addWidget(dataTable); ui->tableLayout->addLayout(secondLayout); ui->tableLayout->addStretch(); updateSelectorsSize(); connect(dataTable, SIGNAL(newPosCorrections()), this, SLOT(updateSelectorsSize())); connect(dataTable, SIGNAL(newColumnCount(int)), this, SLOT(updateSelectorsSize())); connect(dataTable, SIGNAL(newRowCount(int)), this, SLOT(updateSelectorsSize())); columnSelector->updateSelectorsPos(); rowSelector->updateSelectorsPos(); ui->actionsLayout->addWidget(columnActionsWidget); ui->actionsLayout->addWidget(rowActionsWidget); rowActionsWidget->hide(); csvHandler = new CSVhandler(this); connect(csvHandler, SIGNAL(dataFromCSV(QList<QStringList>)), dataTable, SLOT(addData(QList<QStringList>))); connect(ui->open, SIGNAL(released()), this, SLOT(openData())); connect(ui->save, SIGNAL(released()), this, SLOT(saveData())); connect(columnSelector, SIGNAL(newSelectorPos(bool,int)), columnActionsWidget, SLOT(setSelectorPos(bool,int))); connect(columnSelector, SIGNAL(askForSelector()), rowSelector, SLOT(askedForSelector())); connect(columnSelector, SIGNAL(askForSelector()), this, SLOT(selectorInColumnSelection())); connect(columnSelector, SIGNAL(newSelectorPos(bool,int)), this, SLOT(selectorPosChanged(bool,int))); connect(columnSelector, SIGNAL(newXIndex(int)), this, SLOT(dataChanged())); connect(columnSelector, SIGNAL(newYIndex(int)), this, SLOT(dataChanged())); connect(rowSelector, SIGNAL(askForSelector()), this, SLOT(selectorInRowSelection())); connect(rowSelector, SIGNAL(askForSelector()), columnSelector, SLOT(askedForSelector())); connect(rowSelector, SIGNAL(newIndex(bool,int)), this, SLOT(selectorPosChanged(bool,int))); connect(rowSelector, SIGNAL(newIndex(bool,int)), rowActionsWidget, SLOT(setSelectorPos(bool,int))); connect(rowActionsWidget, SIGNAL(insertRowClicked(int)), dataTable, SLOT(insertRow(int))); connect(rowActionsWidget, SIGNAL(removeRowClicked(int)), dataTable, SLOT(removeRow(int))); connect(columnActionsWidget, SIGNAL(insertColumnClicked(int)), dataTable, SLOT(insertColumn(int))); connect(columnActionsWidget, SIGNAL(removeColumnClicked(int)), dataTable, SLOT(removeColumn(int))); connect(dataTable, SIGNAL(newColumnCount(int)), columnSelector, SLOT(setColumnCount(int))); connect(dataTable, SIGNAL(newColumnCount(int)), columnActionsWidget, SLOT(setColumnCount(int))); connect(dataTable, SIGNAL(newRowCount(int)), rowSelector, SLOT(setRowCount(int))); connect(dataTable, SIGNAL(newRowCount(int)), rowActionsWidget, SLOT(setRowCount(int))); connect(dataTable, SIGNAL(valEdited(int,int)), this, SLOT(cellValChanged(int,int))); connect(dataTable, SIGNAL(newColumnName(int)), this, SLOT(columnNameChanged(int))); connect(dataTable, SIGNAL(columnMoved(int,int,int)), this, SLOT(columnMoved(int,int,int))); connect(ui->cartesian, SIGNAL(toggled(bool)), columnSelector, SLOT(setCoordinateSystem(bool))); connect(ui->cartesian, SIGNAL(toggled(bool)), this, SLOT(remakeDataList())); //connect to row actions widget connect(ui->addModel, SIGNAL(released()), this, SLOT(addModel())); connect(ui->polar, SIGNAL(toggled(bool)), this, SLOT(coordinateSystemChanged(bool))); connect(ui->help, SIGNAL(released()), this, SIGNAL(showHelpWindow())); }