예제 #1
0
void FindReplaceDlg::findPrev(HWND hParent, BOOL isVolatile)
{
	if (isCreated() || (isVolatile == TRUE))
	{
		BOOL storeDir = _whichDirection;

		_hParentHandle	= hParent;
		_whichDirection = DIR_UP;
		onFind(isVolatile);
		_whichDirection = storeDir;
	}
}
예제 #2
0
void ABoxDlg::onModify( wxCommandEvent& event ) {
  if( m_SelectedStub != wxNOT_FOUND ) {
    iONode stub = (iONode)m_Stubs->GetItemData(m_SelectedStub);
    iONode cmd = NodeOp.inst( wDataReq.name(), NULL, ELEMENT_NODE );
    wDataReq.setcmd( cmd, wDataReq.abox_modifylink );
    iONode clone = (iONode)NodeOp.base.clone(stub);
    NodeOp.setStr(clone, "text", m_ResultText->GetValue().mb_str(wxConvUTF8) );
    NodeOp.setStr(clone, "note", m_ResultNote->GetValue().mb_str(wxConvUTF8) );
    NodeOp.addChild(cmd, clone);
    wxGetApp().sendToRocrail( cmd );
    cmd->base.del(cmd);

    onFind(event);
  }
}
예제 #3
0
void ABoxDlg::onDelete( wxCommandEvent& event ) {
  if( m_SelectedStub != wxNOT_FOUND ) {
    int action = wxMessageDialog( this, wxGetApp().getMsg("removewarning"), _T("Rocrail"), wxYES_NO | wxICON_EXCLAMATION ).ShowModal();
    if( action == wxID_NO )
      return;
    iONode stub = (iONode)m_Stubs->GetItemData(m_SelectedStub);
    iONode cmd = NodeOp.inst( wDataReq.name(), NULL, ELEMENT_NODE );
    wDataReq.setcmd( cmd, wDataReq.abox_deletelink );
    NodeOp.addChild(cmd, (iONode)NodeOp.base.clone(stub));
    wxGetApp().sendToRocrail( cmd );
    cmd->base.del(cmd);

    onFind(event);
  }
}
예제 #4
0
void ABoxDlg::onBmpFind( wxMouseEvent& event ) {
  wxCommandEvent cmdEvent;
  onFind(cmdEvent);
}
예제 #5
0
void ABoxDlg::onAdd( wxCommandEvent& event ) {
  if( m_Filename->GetValue().IsEmpty() || m_Text->GetValue().IsEmpty() || m_Category->GetValue().IsEmpty() ) {
    // Upload criteria missing.
    int action = wxMessageDialog( this, wxGetApp().getMsg("missingcriteria"), _T("Rocrail"), wxOK | wxICON_EXCLAMATION ).ShowModal();
    return;
  }
  if( StrOp.startsWithi(m_Filename->GetValue().mb_str(wxConvUTF8), "http"))
    m_Link->SetValue(true);

  wABox.setlink(m_Ini, m_Link->IsChecked()?True:False);

  iONode cmd = NodeOp.inst( wDataReq.name(), NULL, ELEMENT_NODE );
  wDataReq.setcmd( cmd, wDataReq.abox_addlink );
  wDataReq.setlink( cmd, m_Link->IsChecked()?True:False);

  iONode direntry = NodeOp.inst(wDirEntry.name(), cmd, ELEMENT_NODE );
  NodeOp.addChild(cmd, direntry);
  iONode fileentry = NodeOp.inst(wFileEntry.name(), cmd, ELEMENT_NODE );
  NodeOp.addChild(direntry, fileentry);

  wFileEntry.setfname( fileentry, m_Filename->GetValue().mb_str(wxConvUTF8) );

  // save the file path in case it must be uploaded
  m_AddedUID[0] = '\0';
  if( !m_Link->IsChecked() ) {
    StrOp.copy( m_AddedFilename, wFileEntry.getfname(fileentry) );
    EnableDlg(false);
  }
  else
    m_AddedFilename[0] = '\0';

  wFileEntry.settext( fileentry, m_Text->GetValue().mb_str(wxConvUTF8) );
  wFileEntry.setcategory( fileentry, m_Category->GetValue().mb_str(wxConvUTF8) );
  if( !StrOp.startsWithi(wFileEntry.getfname(fileentry), "http"))
    wFileEntry.setsize(fileentry, FileOp.fileSize(wFileEntry.getfname(fileentry)));

  if( !StrOp.startsWithi(wFileEntry.getfname(fileentry), "http")) {
    char   dateStr[20];
    long aTime = FileOp.fileTime( wFileEntry.getfname(fileentry) );
    strftime( dateStr, sizeof(dateStr), "%Y%m%d", localtime(&aTime) );
    wFileEntry.setfiledate(fileentry, dateStr);
    strftime( dateStr, sizeof(dateStr), "%H%M%S", localtime(&aTime) );
    wFileEntry.setfiletime(fileentry, dateStr);
  }

  char* s = NodeOp.base.toString(cmd);
  TraceOp.trc( "aboxdlg", TRCLEVEL_INFO, __LINE__, 9999, "add: %s", s );
  StrOp.free(s);

  wxGetApp().sendToRocrail( cmd );
  cmd->base.del(cmd);

  m_FindText->SetValue(m_Text->GetValue());

  m_Filename->SetValue(wxT(""));
  m_Text->SetValue(wxT(""));
  m_Category->SetValue(wxT(""));

  onFind(event);

  cmd = NodeOp.inst( wDataReq.name(), NULL, ELEMENT_NODE );
  wDataReq.setcmd( cmd, wDataReq.abox_getcategories );
  wxGetApp().sendToRocrail( cmd );
  cmd->base.del(cmd);
}
예제 #6
0
INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message) 
	{
        case WM_INITDIALOG :
		{
			initDialog();
			goToCenter();
			return TRUE;
		}
		case WM_ACTIVATE :
        {
			UINT	posBeg;
			UINT	posEnd;

			::SendMessage(_hParentHandle, HEXM_GETSEL, (WPARAM)&posBeg, (LPARAM)&posEnd);
			::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_IN_SEL), ((posBeg == posEnd)?FALSE:TRUE));

			/* change language */
			NLChangeDialog(_hInst, _nppData._nppHandle, _hSelf, _T("FindReplace"));

            break;
        }
		case WM_COMMAND : 
		{
			switch (LOWORD(wParam))
			{
				case IDOK :
                {
					onFind(FALSE);
					return TRUE;
                }
				case IDC_REPLACE:
                {
					onReplace();
					break;
                }
				case IDC_COUNT :
				{
					processAll(COUNT);
					break;
                }
				case IDC_REPLACEALL :
                {
					HWND	hSci = getCurrentHScintilla();
					ScintillaMsg(hSci, SCI_BEGINUNDOACTION);
					processAll(REPLACE_ALL);
					ScintillaMsg(hSci, SCI_ENDUNDOACTION);
					return TRUE;
                }
				case IDC_COMBO_DATATYPE:
				{
					if (HIWORD(wParam) == CBN_SELCHANGE)
						changeCoding();
					break;
				}
				case IDC_CHECK_TRANSPARENT :
				{
					setTrans();
					break;
				}
				case IDC_RADIO_DIRUP :
				case IDC_RADIO_DIRDOWN :
				{
					_whichDirection = isChecked(IDC_RADIO_DIRDOWN);
					return TRUE;
				}
				case IDC_CHECK_MATCHCASE :
				{
					_isMatchCase = isChecked(IDC_CHECK_MATCHCASE);
					return TRUE;
				}
				case IDC_CHECK_WRAP :
				{
					_isWrap = isChecked(IDC_CHECK_WRAP);
					return TRUE;
				}
				case IDC_CHECK_IN_SEL :
				{
					_isInSel = isChecked(IDC_CHECK_IN_SEL);
					return TRUE;
				}
				case IDCANCEL :
				{
					display(FALSE);
					::SetFocus(_hParentHandle);
					break;
				}
				default :
					break;
			}
			break;
		}
		case WM_NOTIFY:
		{
			NMHDR	nmhdr = *((LPNMHDR)lParam);

			if ((nmhdr.idFrom == IDC_SWITCH) && (nmhdr.code == TCN_SELCHANGE))
			{
				_findReplace = TabCtrl_GetCurSel(::GetDlgItem(_hSelf, IDC_SWITCH));
				updateDialog();
			}
			break;
		}
		case WM_HSCROLL :
		{
			if ((HWND)lParam == ::GetDlgItem(_hSelf, IDC_SLIDER_PERCENTAGE))
			{
				setTrans();
			}
			return TRUE;
		}
	}
	return FALSE;
}
예제 #7
0
void FindReplaceDlg::onReplace(void)
{
	HWND	hSciSrc	= getCurrentHScintilla();
	INT		lenSrc  = ScintillaMsg(hSciSrc, SCI_GETLENGTH);
	lenSrc; //avoid compiler warning  C4189
	INT		lenStr	= 0;
	INT		offset	= 0;
	INT		length  = 0;
	INT		posBeg  = 0;
	INT		posEnd  = 0;
	eError	isRep	= E_OK;

	_pFindCombo->getText(&_find);
	_pReplaceCombo->getText(&_replace);

	/* get selection and correct anchor and cursor position */
	::SendMessage(_hParentHandle, HEXM_GETSEL, (WPARAM)&posBeg, (LPARAM)&posEnd);
	if (posEnd < posBeg) {
		UINT posTmp = posBeg;
		posBeg = posEnd;
		posEnd = posTmp;
	}

	/* copy data into scintilla handle (encoded if necessary) and select string */
	offset = posBeg;
	length = posEnd - posBeg;
	lenStr = length;
	if (LittleEndianChange(_hSCI, hSciSrc, &offset, &length) == TRUE)
	{
		LPSTR	text	= (LPSTR)new CHAR[lenStr+1];

		if (text != NULL)
		{
			/* get selection and compare if it is equal to expected text */
			ScintillaMsg(_hSCI, SCI_SETSELECTIONSTART, posBeg - offset, 0);
			ScintillaMsg(_hSCI, SCI_SETSELECTIONEND, posEnd - offset, 0);
    		ScintillaMsg(_hSCI, SCI_GETSELTEXT, 0, (LPARAM)text);

			/* make difference between match case modes */
    		if (((_isMatchCase == TRUE) && (memcmp(text, _find.text, lenStr) == 0)) ||
				((_isMatchCase == FALSE) && (_stricmp(text, _find.text) == 0)))
    		{
    			ScintillaMsg(_hSCI, SCI_TARGETFROMSELECTION);
    			ScintillaMsg(_hSCI, SCI_REPLACETARGET, _replace.length, (LPARAM)&_replace.text);
    			isRep = replaceLittleToBig(hSciSrc, _hSCI, posBeg - offset, posBeg, lenStr, _replace.length);
    			if (isRep == E_OK)
    			{
    				::SendMessage(_hParentHandle, HEXM_SETPOS, 0, posBeg + _replace.length);
    				_pFindCombo->addText(_find);
    				_pReplaceCombo->addText(_replace);
    			}
    		}

    		if (isRep == E_OK) {
    			onFind(FALSE);
    		} else {
    			LITTLE_REPLACE_ERROR;
    		}

    		delete [] text;
		}
   		CleanScintillaBuf(_hSCI);
	}
}