Exemplo n.º 1
0
void ConfigScroller::unregisterServer ()
{
    int exitCode = KB_ESC;
    char dllpath[512];
    *dllpath = 0;
    {
	InputDialog dlg (myScreen, "Unregister DLL Server", "Enter the DLL pathname:",
			 dllpath, 511, &mDllHist);
	dlg.run ();
	exitCode = dlg.getExitCode ();
    }
    if (exitCode != KB_ESC) {

	HINSTANCE hInst = LoadLibrary (dllpath);
	if (hInst == NULL) {
	    myScreen.sendWinErrStatusMsg ("Cannot load DLL");
	    return;
	}

	FARPROC dllEntryPoint;
	dllEntryPoint = GetProcAddress (hInst, "DllUnregisterServer");
	if (dllEntryPoint == NULL) {
	    myScreen.sendWinErrStatusMsg ("Cannot load DllUnregisterServer");
	    FreeLibrary (hInst);
	    return;
	}

	if (FAILED ((*dllEntryPoint) ()))
	    myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "The unregistration function failed."));
	else
	    myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Server unregistered!"));

	FreeLibrary (hInst);
    }
}
Exemplo n.º 2
0
InputDialogTC::InputDialogTC(InputDialog &inputDialog, unsigned int dialogId) : BasicServerCommand(SC_INPUTDIALOG_TC) {
    addStringToBuffer(inputDialog.getTitle());
    addStringToBuffer(inputDialog.getDescription());
    addUnsignedCharToBuffer(inputDialog.isMultiline() ? 1 : 0);
    addShortIntToBuffer(inputDialog.getMaxChars());
    addIntToBuffer(dialogId);
}
Exemplo n.º 3
0
  QUndoCommand* InputFileExtension::performAction(QAction *action, GLWidget *widget)
  {
    QSettings settings;
    m_widget = widget;
    QString data(action->data().toString());
    InputDialog *dialog = m_dialog[data];

    // If dialog was not called earlier, create it now
    if (!m_hasDialog[data]) {
      dialog = createInputDialog(data);
      if (!dialog) {
        // We don't know anything about this menu action.
        // If you're adding new generator, modify createInputDialog function
        qDebug() << "No dialog for " + data + "! Something went wrong!";
        return 0;
      }
      if(m_molecule)
       dialog->setMolecule(m_molecule);
      m_dialog[data] = dialog;
      m_hasDialog[data] = true;
      connect(m_dialog[data], SIGNAL(readOutput(QString)),
          this, SLOT(readOutputFile(QString)));
    }
    dialog->show();
    return 0;
  }
Exemplo n.º 4
0
void CMainFrame::showInput(CString title, int nCase)
{
	input.ShowWindow(SW_HIDE);
	input.SetWindowText(title);
	input.SetCase(nCase);
	input.InitView();
	input.ShowWindow(SW_SHOWNA);	
}
Exemplo n.º 5
0
//Encargado de buscar un registro y mostrarlo
void MainWindow::on_searchRecord_triggered()
{
    //toma el vector de campos
    vector<Field*> fields = this->fileRecord.getFields();
    QString str;

    //muestra una ventana para que se busque el registro a partir de su clave
    for(int i = 0; i< fields.size(); i++){
        Field* currentField = fields.at(i);
        if(currentField->isKey()){
            InputDialog* idialog = new InputDialog();
            idialog->setField(currentField);
            idialog->exec();

            if(idialog->getString().isEmpty()){
                return;
            }

            str = idialog->getString();
            delete idialog;
       }
    }

    //Obtiene un indice primario de la busqueda en el mapa de indices primarios
    PrimaryIndex* index = this->fileRecord.searchRecord(str.toStdString());

    //En caso de que no se encuentre el registro, este indice primario es nulo
    if(index == NULL){
        QMessageBox::critical(this,"Error","El registro que buscaba no se encontro");
        return;
    }else{
        //se obtiene un registro a partir del indice primario
        Record* record = this->fileRecord.getRecord(index);
        vector<string> r = record->getRecord();

        //se hace el modelo para poder mostrar el registro
        QStandardItemModel* model = new QStandardItemModel(1,1,this);

        //se hacen los encabezados de la tabla
        for(int i = 0; i < fields.size(); i++){
            model->setHorizontalHeaderItem(i,new QStandardItem(QString::fromStdString(fields[i]->getName())));
        }

        //se la fila para el registro
        for(int i = 0; i < fields.size(); i++){
            model->setItem(0,i,new QStandardItem(QString::fromStdString(r[i])));
        }

        //se elimina el registro de memoria porque esta guardado en el archivo
        delete record;

        //se asigna el modelo a la tabla del main
        ui->MWTable->setModel(model);
    }
}
Exemplo n.º 6
0
//se encarga de eliminar un registro, solamente lo marca y lo elimina de los indices primarios
//para que despues se le pase el compactar
void MainWindow::on_deleteRecord_triggered()
{
    vector<Field*> fields = this->fileRecord.getFields();
    QString str;

    for(int i = 0; i< fields.size(); i++){
        Field* currentField = fields.at(i);
        if(currentField->isKey()){
            //se le muestra una nueva ventana para pedir la llave primaria
            InputDialog* idialog = new InputDialog();
            idialog->setField(currentField);
            idialog->exec();

            if(idialog->getString().isEmpty()){
                return;
            }

            str = idialog->getString();
            delete idialog;
       }
    }

    //toma el indice primario por medio de una busqueda
    PrimaryIndex* index = this->fileRecord.searchRecord(str.toStdString());

    if(index == NULL){
        QMessageBox::critical(this,"Error","No se encontro el registro con la llave ingresada");
        return;
    }else{
        //se borra el registro de los indices primarios y se marca con un * en el archivo de registros
        if(this->fileRecord.deleteRecord(index)){
            vector<PrimaryIndex*> indexes = this->fileRecord.getIndexes();

            stringstream ss;
            for(int i = 0; i < indexes.size(); i++){
                ss<<indexes.at(i)->toString();
                if(i != indexes.size() -1){
                    ss<<'/';
                }
            }
            this->indicesFile.seekp(0,ios_base::beg);
            this->indicesFile.write(ss.str().c_str(),ss.str().length());
            this->indicesFile.flush();

            QMessageBox::information(this,"Correcto","Se ha podido eliminar el registro correctamente");
        }else{
            QMessageBox::critical(this,"Error","No se pudo eliminar el registro, no se encuentra la llave");
        }
    }
}
Exemplo n.º 7
0
void ConfigScroller::importReg ()
{
    int exitCode = KB_ESC;
    char path[512];
    *path = 0;
    {
	InputDialog dlg (myScreen, "Import Custom Commands", "Enter the pathname:",
			 path, 511, &mRegHist);
	dlg.run ();
	exitCode = dlg.getExitCode ();
    }
    if (exitCode != KB_ESC) {
	myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) importCommands (path)));
    }
}
Exemplo n.º 8
0
	QScriptValue InputDialog::constructor(QScriptContext *context, QScriptEngine *engine)
	{
		InputDialog *inputDialog = new InputDialog;
		inputDialog->setupConstructorParameters(context, engine, context->argument(0));

		QScriptValueIterator it(context->argument(0));

		while(it.hasNext())
		{
			it.next();
			
			if(it.name() == "labelText")
				inputDialog->mInputDialog->setLabelText(it.value().toString());
			else if(it.name() == "okButtonText")
				inputDialog->mInputDialog->setOkButtonText(it.value().toString());
			else if(it.name() == "cancelButtonText")
				inputDialog->mInputDialog->setCancelButtonText(it.value().toString());
			else if(it.name() == "textEchoMode")
				inputDialog->mInputDialog->setTextEchoMode(static_cast<QLineEdit::EchoMode>(it.value().toInt32()));
			else if(it.name() == "floatDecimals")
				inputDialog->mInputDialog->setDoubleDecimals(it.value().toInt32());
			else if(it.name() == "integerStep")
				inputDialog->mInputDialog->setIntStep(it.value().toInt32());
			else if(it.name() == "minimum")
				inputDialog->mMinimum = it.value();
			else if(it.name() == "maximum")
				inputDialog->mMaximum = it.value();
			else if(it.name() == "range")
			{
				inputDialog->mMinimum = it.value().property("minimum");
				inputDialog->mMaximum = it.value().property("maximum");
			}
			else if(it.name() == "inputType")
				inputDialog->mInputType = static_cast<InputType>(it.value().toInt32());
			else if(it.name() == "value")
				inputDialog->mValue = it.value();
			else if(it.name() == "items")
				inputDialog->mItems = it.value();
			else if(it.name() == "itemsEditable")
				inputDialog->mInputDialog->setComboBoxEditable(it.value().toBool());
			else if(it.name() == "onClosed")
				inputDialog->mOnClosed = it.value();
			else if(it.name() == "onValueChanged")
				inputDialog->mOnValueChanged = it.value();
		}

		return CodeClass::constructor(inputDialog, context, engine);
	}
Exemplo n.º 9
0
void CMainFrame::OnControlPrint(WPARAM wParam, LPARAM lParam)
{
	struct tInfo{
		CPoint sPoint;
		CPoint ePoint;
		int color;
	};
	//接收成功
	if(wParam == 1){
		tInfo *nMessage = (tInfo *)lParam;
		Draw draw;
		switch(input.GetCase())
		{
			case 1: draw.DDALineDraw(nMessage->sPoint, nMessage->ePoint, nMessage->color, this); break;
			case 2: draw.MiddlePointLineDraw(nMessage->sPoint, nMessage->ePoint, nMessage->color, this); break;
			case 3: draw.BresenhamLineDraw(nMessage->sPoint, nMessage->ePoint, nMessage->color, this); break;
			case 4: draw.MiddleCircleDraw(nMessage->sPoint, nMessage->ePoint.x, nMessage->color, this); break;
			case 5: draw.BresenhamCircleDraw(nMessage->sPoint, nMessage->ePoint.x, nMessage->color, this); break;
			case 6: draw.MiddleEllipseDraw(nMessage->sPoint, nMessage->ePoint.x, nMessage->ePoint.y, nMessage->color, this); break;
			default: break;
		}
	}else{
		this->MessageBox("接收失败");
	}
}
Exemplo n.º 10
0
int FTPWindow::CreateFile(FileObject * parent) {
	InputDialog id;

	int res = id.Create(m_hwnd, TEXT("Creating file"), TEXT("Please enter the name of the new file:"), TEXT("New file"));
	if (res != 1)
		return 0;

    const TCHAR * newName = id.GetValue();

    // Check if there is already an existing file of the same name
    int childcount = parent->GetChildCount();
    char *newFileName_CP = SU::TCharToCP(newName, CP_ACP);

	for(int i = 0; i < childcount; i++) {

	    const char *currentFileName = parent->GetChild(i)->GetName();
		if (!strcmp(currentFileName, newFileName_CP)) {

            res = ::MessageBox(m_hwnd, TEXT("A file/directory by the same name already exists. Do you want to create a new blank file ?"), TEXT("Creating file"), MB_YESNO);
            if (res == IDNO) {
                return 0;
            }
            else {
                break;
            }
        }
	}


	char path[MAX_PATH];
	res = PU::ConcatLocalToExternal(parent->GetPath(), newName, path, MAX_PATH);
	if (res == -1)
		return -1;

	res = m_ftpSession->MkFile(path);
	if (res == -1)
		return -1;

	m_ftpSession->GetDirectory(parent->GetPath());

	return 0;
}
Exemplo n.º 11
0
int FTPWindow::CreateDirectory(FileObject * parent) {
	InputDialog id;

	int res = id.Create(m_hwnd, TEXT("Creating directory"), TEXT("Please enter the name of the new directory:"), TEXT("New directory"));
	if (res != 1)
		return 0;

	const TCHAR * newName = id.GetValue();
	char path[MAX_PATH];
	res = PU::ConcatLocalToExternal(parent->GetPath(), newName, path, MAX_PATH);
	if (res == -1)
		return -1;

	res = m_ftpSession->MkDir(path);
	if (res == -1)
		return -1;

	m_ftpSession->GetDirectory(parent->GetPath());

	return 0;
}
Exemplo n.º 12
0
int FTPWindow::Rename(FileObject * fo) {
	InputDialog id;

	int res = id.Create(m_hwnd, TEXT("Renaming"), TEXT("Please enter the new name:"), fo->GetLocalName());
	if (res != 1)
		return 0;

	const TCHAR * newName = id.GetValue();
	char path[MAX_PATH];
	res = PU::ConcatLocalToExternal(fo->GetParent()->GetPath(), newName, path, MAX_PATH);
	if (res == -1)
		return -1;

	res = m_ftpSession->Rename(fo->GetPath(), path);
	if (res == -1)
		return -1;

	m_ftpSession->GetDirectory(fo->GetParent()->GetPath());

	return 0;
}
Exemplo n.º 13
0
void ImageIndexEditor::addNode()
{
 //CatalogTreeNode* selectedNode = _index->getSelectedNode();
 CatalogTreeNode* selectedNode = _index->getSelectedNode();
 if (selectedNode == NULL)
 {
//  JOptionPane.showMessageDialog(this, tr("selectAddNode"),
//                                      tr("info"), JOptionPane.INFORMATION_MESSAGE);
     QMessageBox::information(this, tr("Information"), tr("Select a node where you want to add a child node."));
    }
  else
 {
#if 1
        QString name = JOptionPane::showInputDialog(this, tr("Please enter a name for the node you want to add."),
                                      tr("Question"), JOptionPane::QUESTION_MESSAGE);
        if (name != NULL) {
            if(!_index->insertNodeIntoModel(name, selectedNode)) {
                JOptionPane::showMessageDialog(this,
                                    tr("The name \"%1}\" is a duplicate. Node names\nin the path to the root must be unique.").arg(name),
                                    tr("error"), JOptionPane::ERROR_MESSAGE);
            }
        }
#else
        QString name;
        InputDialog* dlg = new InputDialog(tr("Please enter a name for the node you want to add."),name);
        if(dlg->exec() == QDialog::Accepted)
        {
         name = dlg->value();
        }
        if(name == "")
        {
         if(!_index->insertNodeIntoModel(name, selectedNode))
         {
             QMessageBox::critical(this, tr("Error"), tr("The name \"%1}\" is a duplicate. Node names\n                                                        in the path to the root must be unique.").arg(name));
         }
        }
#endif
 }
 //invalidate();
}
Exemplo n.º 14
0
LRESULT FTPWindow::MessageProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {
	bool doDefaultProc = false;
	LRESULT result = 0;

	switch(uMsg) {
		case WM_SETFOCUS: {
			//Why restore focus here? This window should never be able to get focus in the first place
			HWND hPrev = (HWND)wParam;
			if (hPrev != NULL)
				::SetFocus(hPrev);
			break; }
		case WM_ERASEBKGND: {
			HDC hDC = (HDC) wParam;
			RECT rectClient;
			GetClientRect(m_hwnd, &rectClient);
			FillRect(hDC, &rectClient, m_backgroundBrush);
			result = TRUE;
			break; }
		case WM_SETCURSOR: {
			if (m_splitter.OnSetCursor()) {
				return TRUE;
			}
			return FALSE;
			break; }
		case WM_CAPTURECHANGED: {
			m_splitter.OnCaptureChanged((HWND)lParam);
			break; }
		case WM_LBUTTONDOWN: {
			m_splitter.OnButtonDown();
			break; }
		case WM_LBUTTONUP: {
			m_splitter.OnButtonUp();
			m_ftpSettings->SetSplitRatio(m_splitter.GetRatio());
			break; }
		case WM_MOUSEMOVE: {
			if (wParam & MK_LBUTTON) {
				m_splitter.OnMouseMove();
			}
			break; }
		case WM_COMMAND: {
			switch(LOWORD(wParam)) {
				case IDM_POPUP_QUEUE_ABORT: {
					if (m_cancelOperation && m_cancelOperation->GetRunning()) {
						m_ftpSession->AbortTransfer();
					}
					m_cancelOperation = NULL;
					result = TRUE;
					break; }
				case IDM_POPUP_QUEUE_CANCEL: {
					if (m_cancelOperation && !m_cancelOperation->GetRunning()) {
						m_ftpSession->CancelOperation(m_cancelOperation);
					}
					m_cancelOperation = NULL;
					result = TRUE;
					break; }
				case IDM_POPUP_LINKTYPE: {
					m_currentSelection->SetDir(!m_currentSelection->isDir());
					m_currentSelection->GetParent()->Sort();
					m_treeview.UpdateFileObject(m_currentSelection);
					result = TRUE;
					break; }
				case IDB_BUTTON_TOOLBAR_CONNECT: {
					//Called by chevron popup: disconnect (ie no popup)
					//disconnect();
					result = TRUE;
					break;}

                case IDB_BUTTON_TOOLBAR_OPENDIR: {

                    // Show the dialog to get input directory name from the user.
                    InputDialog id;
                    int res = id.Create(m_hwnd, TEXT("Open Directory"), TEXT("Enter directory name:"), TEXT(""));
                    if (res != 1) {
                        return 0;
                    }

                    // Read the input directory name.
                    const TCHAR *dirName    = id.GetValue();
                    char *dirNameCP         = SU::TCharToCP(dirName, CP_ACP);

                    m_ftpSession->GetDirectoryHierarchy(dirNameCP);
                    break;
                }

				case IDM_POPUP_DOWNLOADFILE:
				case IDB_BUTTON_TOOLBAR_DOWNLOAD: {
					SHORT state = GetKeyState(VK_CONTROL);
					if (!(state & 0x8000)) {
						m_ftpSession->DownloadFileCache(m_currentSelection->GetPath());
						result = TRUE;
						break;
					}
					//else fallthrough
					}
				case IDM_POPUP_DLDTOLOCATION: {
					TCHAR target[MAX_PATH];
					lstrcpy(target, m_currentSelection->GetLocalName());
					int res = PU::GetSaveFilename(target, MAX_PATH, m_hwnd);
					if (res == 0) {
						m_ftpSession->DownloadFile(m_currentSelection->GetPath(), target, false);
					}
					result = TRUE;
					break; }
				case IDM_POPUP_UPLOADFILE:
				case IDB_BUTTON_TOOLBAR_UPLOAD: {
					//upload(TRUE, TRUE);		//upload to cached folder is present, else upload to last selected folder
					//m_ftpSession->UploadFile();
					TCHAR source[MAX_PATH];
					BOOL doUpload = FALSE;
					SHORT state = GetKeyState(VK_CONTROL);
					if ((state & 0x8000) && LOWORD(wParam) == IDB_BUTTON_TOOLBAR_UPLOAD) {
						source[0] = 0;
						int res = PU::GetOpenFilename(source, MAX_PATH, m_hParent);
						if (res == 0)
							doUpload = TRUE;
					} else {
						doUpload = ::SendMessage(m_hNpp, NPPM_GETFULLCURRENTPATH, (WPARAM)MAX_PATH, (LPARAM)source);
					}
					if (doUpload == TRUE) {
						if (m_currentSelection->isDir()) {
							m_ftpSession->UploadFile(source, m_currentSelection->GetPath(), true);
						} else {
							m_ftpSession->UploadFile(source, m_currentSelection->GetParent()->GetPath(), true);
						}
					}
					result = TRUE;
					break;}
				case IDM_POPUP_UPLOADOTHERFILE: {
					TCHAR source[MAX_PATH];
					source[0] = 0;
					int res = PU::GetOpenFilename(source, MAX_PATH, m_hwnd);
					if (res == 0) {
						m_ftpSession->UploadFile(source, m_currentSelection->GetPath(), true);
					}
					result = TRUE;
					break; }
				case IDM_POPUP_REFRESHDIR:
				case IDB_BUTTON_TOOLBAR_REFRESH: {
					m_ftpSession->GetDirectory(m_currentSelection->GetPath());
					result = TRUE;
					break; }
				case IDB_BUTTON_TOOLBAR_ABORT: {
					m_ftpSession->AbortTransfer();
					result = TRUE;
					break; }
				case IDB_BUTTON_TOOLBAR_RAWCMD: {
					//rawCommand();
					result = TRUE;
					break; }
				case IDB_BUTTON_TOOLBAR_SETTINGS: {
					//Should be handled by dropdown
					result = TRUE;
					break; }
				case IDB_BUTTON_TOOLBAR_MESSAGES: {
					m_outputShown = !m_outputWindow.IsVisible();
					m_outputWindow.Show(m_outputShown);
					result = TRUE;
					break; }
				case IDM_POPUP_NEWDIR: {
					this->CreateDirectory(m_currentSelection);
					result = TRUE;
					break; }
				case IDM_POPUP_DELETEDIR: {
					this->DeleteDirectory(m_currentSelection);
					result = TRUE;
					break; }
				case IDM_POPUP_NEWFILE: {
					this->CreateFile(m_currentSelection);
					result = TRUE;
					break; }
				case IDM_POPUP_DELETEFILE: {
					this->DeleteFile(m_currentSelection);
					result = TRUE;
					break; }
				case IDM_POPUP_RENAMEFILE:
				case IDM_POPUP_RENAMEDIR: {
					this->Rename(m_currentSelection);
					result = TRUE;
					break; }
				case IDM_POPUP_SETTINGSGENERAL: {
					m_settingsDialog.Create(m_hwnd, m_ftpSettings);
					result = TRUE;
					break; }
				case IDM_POPUP_SETTINGSPROFILE: {
					m_profilesDialog.Create(m_hwnd, this, m_vProfiles, m_ftpSettings->GetGlobalCache());
					result = TRUE;
					break; }
				default: {
					unsigned int value = LOWORD(wParam);
					if (!m_busy && value >= IDM_POPUP_PROFILE_FIRST && value <= IDM_POPUP_PROFILE_MAX) {
						FTPProfile * profile = m_vProfiles->at(value - IDM_POPUP_PROFILE_FIRST);
						int ret = m_ftpSession->StartSession(profile);
						if (ret == -1) {
							OutErr("[NppFTP] Cannot start FTP session");
							result = TRUE;
							break;
						}
						m_ftpSession->Connect();
						result = TRUE;
					} else {
						doDefaultProc = true;
					}
					break; }
			}
			break; }
		case WM_NOTIFY: {
			NMHDR nmh = (NMHDR) *((NMHDR*)lParam);
			if (nmh.hwndFrom == m_toolbar.GetHWND()) {
				switch(nmh.code) {
					case TBN_DROPDOWN: {
						NMTOOLBAR * pnmtb = (NMTOOLBAR*)lParam;
						switch(pnmtb->iItem) {
							case IDB_BUTTON_TOOLBAR_CONNECT: {
								if (m_ftpSession->IsConnected()) {	//only call disconnect routine to disconnect, else pick profile
									m_ftpSession->TerminateSession();
									return TBDDRET_DEFAULT;
								}
								result = m_toolbar.DoDropDown(IDB_BUTTON_TOOLBAR_CONNECT);
								break; }
							case IDB_BUTTON_TOOLBAR_SETTINGS: {
								result = m_toolbar.DoDropDown(IDB_BUTTON_TOOLBAR_SETTINGS);
								break; }
							default: {
								result = TBDDRET_NODEFAULT;
								break; }
						}
						break; }
					default: {
						doDefaultProc = true;
						break; }
				}
			} else if (nmh.hwndFrom == m_hNpp) {
				return DockableWindow::MessageProc(uMsg, wParam, lParam);
			} else if (nmh.hwndFrom == m_treeview.GetHWND()) {
				switch(nmh.code) {
					case TVN_SELCHANGED: {
						const NM_TREEVIEW & nmt = (NM_TREEVIEW) *(NM_TREEVIEW*)lParam;
						m_currentSelection = m_treeview.GetItemFileObject(nmt.itemNew.hItem);
						SetToolbarState();
						result = TRUE;
						break; }
					case TVN_ITEMEXPANDING: {
						const NM_TREEVIEW & nmt = (NM_TREEVIEW) *(NM_TREEVIEW*)lParam;
						int res = m_treeview.OnExpanding(&nmt);
						if (res == TRUE) {
							FileObject * fo = (FileObject*) nmt.itemNew.lParam;
							m_ftpSession->GetDirectory(fo->GetPath());
						}
						return res;
						break; }
					case TVN_GETDISPINFO: {
						TV_DISPINFO * ptvdi = (TV_DISPINFO*)lParam;
						m_treeview.GetDispInfo(ptvdi);
						result = TRUE;
						break; }
					case NM_RCLICK:
					case NM_DBLCLK:
					case NM_CLICK: {
						HTREEITEM res = m_treeview.OnClick();
						if (res) {
							m_currentSelection = m_treeview.GetItemFileObject(res);
							SetToolbarState();
							if (nmh.code == (UINT)NM_DBLCLK) {
								OnItemActivation();
								result = TRUE;
							}
						}
						break; }
					case NM_RETURN: {
						OnItemActivation();
						result = TRUE;	//handle message
						break; }
					case TVN_SELCHANGING: {
						result = FALSE;
						break; }
					case TVN_BEGINDRAG: {
						result = FALSE;
/*
						if (m_currentDropObject != NULL) {	//currently only one queued DnD op is supported
							result = FALSE;
							break;
						}
						NMTREEVIEW * pnmtv = (NMTREEVIEW*)lParam;
						HTREEITEM hti = pnmtv->itemNew.hItem;
						FileObject * fo = m_treeview.GetItemFileObject(hti);
						if (fo != NULL) {
							m_currentDropObject = fo;
							m_dndWindow.Create(m_hwnd);
							::PostMessage(m_dndWindow.GetHWND(), WM_DND, 0, 0);
							result = TRUE;
						}
*/
						break; }
					default: {
						doDefaultProc = true;
						break; }
				}
			} else if (nmh.hwndFrom == m_rebar.GetHWND()) {
				switch(nmh.code) {
					case RBN_CHEVRONPUSHED: {
						NMREBARCHEVRON * lpnm = (NMREBARCHEVRON*) lParam;
						POINT pt;
						pt.x = lpnm->rc.left;//right;
						pt.y = lpnm->rc.bottom;
						ClientToScreen(m_rebar.GetHWND(), &pt);
						m_toolbar.DoPopop(pt);
						result = TRUE;
						break; }
					default: {
						doDefaultProc = true;
						break; }
				}
			} else {
				switch(nmh.code) {
					case TTN_GETDISPINFO: {
						LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT) lParam;
						lpttt->hinst = NULL;
						lpttt->lpszText = (TCHAR*)m_toolbar.GetTooltip(lpttt->hdr.idFrom);
						result = TRUE;
						break; }
					default: {
						doDefaultProc = true;
						break; }
				}
			}
			break; }
		case WM_CONTEXTMENU: {
			HWND hWinContext = (HWND)wParam;
			HMENU hContext = NULL;

			POINT menuPos;
			menuPos.x = GET_X_LPARAM(lParam);
			menuPos.y = GET_Y_LPARAM(lParam);
			bool fromKeyboard = (menuPos.x == -1 && menuPos.y == -1);
			if (fromKeyboard) {	//keyboard activation
				DWORD pos = GetMessagePos();
				menuPos.x = GET_X_LPARAM(pos);
				menuPos.y = GET_Y_LPARAM(pos);

			}

			if (hWinContext == m_treeview.GetHWND()) {
				if (!m_currentSelection) {
					result = FALSE;
					break;
				}

				if (fromKeyboard) {
					RECT treerect;
					bool res = m_treeview.GetObjectItemRect(m_currentSelection, &treerect);
					if (res) {
						menuPos.x = treerect.left;
						menuPos.y = treerect.bottom;
						::ClientToScreen(m_treeview.GetHWND(), &menuPos);
					}
				}

				SHORT state = GetKeyState(VK_SHIFT);
				if ((state & 0x8000) && m_currentSelection->isLink() && !fromKeyboard) {
					hContext = m_popupLink;
				} else if (m_currentSelection->isDir()) {
					hContext = m_popupDir;
				} else {
					hContext = m_popupFile;
				}
			} else if (hWinContext == m_queueWindow.GetHWND()) {
				QueueOperation * op = m_queueWindow.GetSelectedQueueOperation();
				if (!op) {
					result = FALSE;
					break;
				}

				m_cancelOperation = op;
				bool run = op->GetRunning();

				if (fromKeyboard) {
					RECT queuerect;
					bool res = m_queueWindow.GetSelectedQueueRect(&queuerect);
					if (res) {
						menuPos.x = queuerect.left;
						menuPos.y = queuerect.bottom;
						::ClientToScreen(m_queueWindow.GetHWND(), &menuPos);
					}
				}

				if (run) {
					hContext = m_popupQueueActive;
				} else {
					hContext = m_popupQueueHold;
				}
			}

			if (!hContext) {
				result = FALSE;
				break;
			}

			::TrackPopupMenu(hContext, TPM_LEFTALIGN, menuPos.x, menuPos.y, 0, m_hwnd, NULL);
			result = TRUE;
			break; }
		case WM_OUTPUTSHOWN: {
			if (wParam == TRUE) {
				m_outputShown = true;
				m_toolbar.SetChecked(IDB_BUTTON_TOOLBAR_MESSAGES, TRUE);
				m_ftpSettings->SetOutputShown(true);
			} else {
				m_outputShown = false;
				m_toolbar.SetChecked(IDB_BUTTON_TOOLBAR_MESSAGES, FALSE);
				m_ftpSettings->SetOutputShown(false);
			}
			break; }
		case NotifyMessageStart:
		case NotifyMessageEnd: {
			bool isStart = (uMsg == (UINT)NotifyMessageStart);
			int code = (int)wParam;
			QueueOperation * queueOp = (QueueOperation*)lParam;
			void * notifyData = queueOp->GetNotifyData();
			int res = OnEvent(queueOp, code, notifyData, isStart);
			if (res != 1)	//if res == 1, then queueop becomes invalid
				queueOp->AckNotification();
			return TRUE;
			break;}
		case NotifyMessageAdd: {
			QueueOperation * queueOp = (QueueOperation*)lParam;
			m_queueWindow.PushQueueItem(queueOp);
			queueOp->AckNotification();
			return TRUE;
			break; }
		case NotifyMessageRemove: {
			QueueOperation * queueOp = (QueueOperation*)lParam;
			m_queueWindow.RemoveQueueItem(queueOp);
			queueOp->AckNotification();
			return TRUE;
			break; }
		case NotifyMessageProgress: {
			QueueOperation * queueOp = (QueueOperation*)lParam;
			m_queueWindow.ProgressQueueItem(queueOp);
			queueOp->AckNotification();
			break; }
		default:
			doDefaultProc = true;
			break;
	}

	if (doDefaultProc)
		result = DockableWindow::MessageProc(uMsg, wParam, lParam);

	return result;
}
Exemplo n.º 15
0
CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	input.Create(IDD_DIALOG1,this);
}
Exemplo n.º 16
0
void InputTag::emitData()
{
	KILE_DEBUG() << "InputTag::emitData() " << m_ki->getName();

	InputDialog *dlg = new InputDialog(m_data.text, m_options, m_history, m_hint, m_alter, m_ki, m_parent, "input_dialog");
	if (dlg->exec()) {
		if((!dlg->tag().isEmpty()) && hasHistory()) {
			addToHistory(dlg->tag());
		}

		TagData td(m_data);

		td.tagBegin.replace("%R",dlg->tag());
		td.tagEnd.replace("%R",dlg->tag());

		QString alt = dlg->useAlternative() ? "*" : "";
		td.tagBegin.replace("%A", alt);
		td.tagEnd.replace("%A", alt);

		if(dlg->useLabel()) {
			td.tagEnd += dlg->label();
			td.dy++;
		}

		if(dlg->usedSelection()) {
			m_ki->clearSelection();
		}

		// if a filename was given for a \input- or \include-command,
		// the cursor is moved out of the braces
		if ( (m_options & (KileAction::ShowBrowseButton | KileAction::FromLabelList | KileAction::FromBibItemList)) && !dlg->tag().isEmpty() ) {
			td.dx += dlg->tag().length() + 1;
		}

		// insert tag
		emit(triggered(td));
		// refresh document structure and project tree when a file was inserted
		if(dlg->useAddProjectFile()) {
			m_ki->docManager()->projectAddFile(QFileInfo(m_ki->getCompileName()).absolutePath() + '/' + dlg->tag());
		}
	}
	delete dlg;
}
Exemplo n.º 17
0
int input(int wi, int h, QWidget *w, int argc, QStringList args)
{
    int i, type = 0;
    QString title, label, filename;
    bool edit=false, full=true;

    for(i=0; i < argc; i++)
    {
        if(args[i] == "-s")
        {
            type = 0;
        }

        if(args[i] == "-l")
        {
            type = 1;
        }

        if(args[i] == "-b")
        {
            type = 2;
        }

        if(args[i] == "-p")
        {
            type = 3;
        }

        if(args[i] == "-t")
        {
            title = args[i+1];
        }

        if(args[i] == "-L")
        {
            label = args[i+1];
        }

        if(args[i] == "-F")
        {
            if(args[i+1][0] != '-')
            {
                filename = args[i+1];
            }
        }

        if(args[i] =="-E")
        {
            edit = true;
        }

        if(args[i] == "-g")
        {
            full = false;
        }
    }
    InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w);
    if(full)
    {
        w->setCaption(title);
        QPEApplication::showWidget( w );
    }
    if( id->exec() == 1)
    {
        printf("%s\n", id->getString().latin1());
        return 0;
    }
    else
    {
        return -1;
    }
}
Exemplo n.º 18
0
void ImageIndexEditor::renameNode() {
    CatalogTreeNode* selectedNode = _index->getSelectedNode();
    if (selectedNode == NULL)
    {
        JOptionPane::showMessageDialog(this, tr("Please enter a name for the node."), tr("Info"), JOptionPane::INFORMATION_MESSAGE);
    }
    else
    {
#if 1
     QString name = JOptionPane::showInputDialog(this, tr("Please enter a new name for the node."), selectedNode->getUserObject());
     if (name != NULL)
     {
      if (!_index->nodeChange(selectedNode, name)){
          JOptionPane::showMessageDialog(this, tr("The name \"%1\" is a duplicate. Node names\nin the path to the root must be unique.").arg(name),tr("error"), JOptionPane::ERROR_MESSAGE);
      }
     }
#else
       QString name;
       InputDialog* dlg = new InputDialog(tr("Please enter a new name for the node."),name);
       if(dlg->exec() == QDialog::Accepted)
       {
        name = dlg->value();
       }
       if(name == "")
       {
        if(!_index->insertNodeIntoModel(name, selectedNode))
        {
            QMessageBox::critical(this, tr("Error"), tr("The name \"%1\" is a duplicate. Node names\nin the path to the root must be unique.").arg(name));
        }
#endif
    }
//    invalidate();
}

void ImageIndexEditor::deleteNode() {
    CatalogTreeNode* selectedNode = _index->getSelectedNode();
    if (selectedNode == NULL)
    {
//        JOptionPane.showMessageDialog(this, tr("selectDeleteNode"),
//                                      tr("info"), JOptionPane.INFORMATION_MESSAGE);
        QMessageBox::information(this, tr("Info"), tr("Select the node you want to delete."));
    }
    else
    {
        int numNodes = countSubNodes(selectedNode);
        int numIcons = countIcons(selectedNode);
//        int response = JOptionPane.showConfirmDialog(this, java.text.MessageFormat.format(
//                                tr("confirmDeleteNode"), new Object[]
//                                    {(String)selectedNode.getUserObject(), Integer.valueOf(numNodes), Integer.valueOf(numIcons)}),
//                                    tr("question"), JOptionPane.YES_NO_OPTION,
//                                                    JOptionPane.QUESTION_MESSAGE);
//        if (response == JOptionPane.YES_OPTION) {
//            _index.removeNodeFromModel(selectedNode);
//        }
        switch(QMessageBox::question(this, tr("Question"), tr("Delete node, %1, its %2 subnodes, and all %3 image indices?").arg(selectedNode->getUserObject().toString()).arg(numNodes).arg(numIcons)))
        {
        case QMessageBox::Yes:
            _index->removeNodeFromModel(selectedNode);
        default:
            break;
        }
    }
}
Exemplo n.º 19
0
void ConfigScroller::exportReg ()
{
    int exitCode = KB_ESC;
    char path[512];
    *path = 0;
    {
	InputDialog dlg (myScreen, "Export Custom Commands", "Enter the pathname:",
			 path, 511, &mRegHist);
	dlg.run ();
	exitCode = dlg.getExitCode ();
    }
    if (exitCode != KB_ESC) {

	if (_access (path, 0) == 0)
	    if (myScreen.ask ("Confirm File Replace", "Overwrite the existing file?") == 0)
		return;

	FILE *file = fopen (path, "w");
	if (file == NULL) {
	    myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Could not create file."));
	    return;
	}

	for (int i = 0; i < 2; i++) {
	    int st, fn;
	    if (i == 0) {
		st = 'A';
		fn = 'Z';
	    }
	    else if (i == 1) {
		st = '0';
		fn = '9';
	    }

	    for (char c = st; c <= fn; c++) {
		try {
		    // Open registry key
		    RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Commands", KEY_READ);

		    char valname[2];
		    valname[0] = c;
		    valname[1] = '\0';
		    // try to read the current value
		    char *value = 0;
		    DWORD type;
		    try {
			value = k.queryValue (valname, type);
			if (type == REG_SZ  &&  value != 0  &&  value[0] != '\0') {
			    fprintf (file, "%c,%s\n", c, value);
			}
			delete [] value;
		    }
		    catch (const std::exception&) {
		    }
		}
		catch (const std::exception&) {
		}
	    }
	}
	fclose (file);
	myScreen.sendEvent (Event(EV_STATUS_MSG, (DWORD) "Commands exported."));
    }
}
Exemplo n.º 20
0
//Encargado de insertar un nuevo registro al archivo
void MainWindow::on_insertRecord_triggered()
{    
    //verifica que existan campos en el archivo
    if(this->fileRecord.fieldsSize() == 0){
        QMessageBox::warning(this,"Error","No tiene campos en el archivo, por favor ingrese un campo para continuar");
        return;
    }

    //Validar que cuando se ingrese la llave, esta sea unica
    vector<string> record;
    vector<Field*> tmpfields = this->fileRecord.getFields();

    for(int i = 0; i < tmpfields.size(); i++){
        Field* currentField = tmpfields[i];

        InputDialog* idialog = new InputDialog();
        idialog->setField(currentField);
        idialog->exec();

        QString text = idialog->getString();

        record.push_back(text.toStdString());
        delete idialog;
    }

    //verifica que la cantidad de ingresos sea igual a la cantidad de campos
    if(record.size() != tmpfields.size()){
        QMessageBox::critical(this,"Error","Error en la cantidad de campos que lleno");
        return;
    }

    //crea un nuevo registro
    Record* newRecord =  new Record(tmpfields,record);

    //verficica que la llave primaria no exista
    if(this->fileRecord.addRecord(newRecord)){
        //Obtiene un vector de indices principales
        vector<PrimaryIndex*> indexes = this->fileRecord.getIndexes();

        //genera como un toString para los indicies
        stringstream ss;
        for(int i = 0; i < indexes.size(); i++){
            ss<<indexes.at(i)->toString();
            if(i != indexes.size() -1){
                ss<<'/';
            }
        }

        //guarda los indices primarios en el archivo
        this->indicesFile.seekp(0,ios_base::beg);
        this->indicesFile.write(ss.str().c_str(),ss.str().length());
        this->indicesFile.flush();

        QMessageBox::information(this,"Correcto","Se ingreso correctamente el nuevo registro");
        delete newRecord;
        //lo borra de memoria, pero ya esta guardado en el archivo
    }else{
        //borra el nuevo registro porque no sirvio de nada
        QMessageBox::critical(this,"Error","Hubo un error al insertar el nuevo registro");
        delete newRecord;
    }
}