Exemple #1
0
void TimeEdit::OnKeyDown(wxKeyEvent &event) {
    int kc = event.GetKeyCode();

    // Needs to be done here to trump user-defined hotkeys
    int key = event.GetUnicodeKey();
    if (event.CmdDown()) {
        if (key == 'C' || key == 'X')
            CopyTime();
        else if (key == 'V')
            PasteTime();
        else
            event.Skip();
        return;
    }

    // Shift-Insert would paste the stuff anyway
    // but no one updates the private "time" variable.
    if (event.ShiftDown() && kc == WXK_INSERT) {
        PasteTime();
        return;
    }

    if (byFrame || insert) {
        event.Skip();
        return;
    }
    // Overwrite mode stuff

    // On OS X backspace is reported as delete
#ifdef __APPLE__
    if (kc == WXK_DELETE)
        kc = WXK_BACK;
#endif

    // Back just moves cursor back one without deleting
    if (kc == WXK_BACK) {
        long start = GetInsertionPoint();
        if (start > 0)
            SetInsertionPoint(start - 1);
    }
    // Delete just does nothing
    else if (kc != WXK_DELETE)
        event.Skip();
}
void  Browser::SendToArea( QString t , int modus )
{
QString tu = PasteTime();
QString text;
    if (modus == 1) {
    text = QString("Query Log =start=>\n%1\n<=end=").arg(t); 
    } else {
    text = QString("On %1:").arg(tu);   
    }
    
forums->append(text);
forums->setReadOnly(true);
forums->toPlainText();
forums->setAutoFormatting(QTextEdit::AutoAll);
forums->setLineWrapMode(QTextEdit::NoWrap);
}
void TimeEdit::OnKeyDown(wxKeyEvent &event) {
	int key = event.GetKeyCode();
	if (event.CmdDown()) {
		if (key == 'C' || key == 'X')
			CopyTime();
		else if (key == 'V')
			PasteTime();
		else
			event.Skip();
		return;
	}

	// Shift-Insert would paste the stuff anyway
	// but no one updates the private "time" variable.
	if (event.ShiftDown() && key == WXK_INSERT) {
		PasteTime();
		return;
	}

	// Translate numpad presses to normal numbers
	if (key >= WXK_NUMPAD0 && key <= WXK_NUMPAD9)
		key += '0' - WXK_NUMPAD0;

	// If overwriting is disabled, we're in frame mode, or it's a key we
	// don't care about just let the standard processing happen
	event.Skip();
	if (byFrame) return;
	if (insert) return;
	if ((key < '0' || key > '9') && key != WXK_BACK && key != WXK_DELETE && key != ';' && key != '.') return;

	event.Skip(false);

	long start = GetInsertionPoint();
	wxString text = GetValue();

	// Delete does nothing
	if (key == WXK_DELETE) return;
	// Back just moves cursor back one without deleting
	if (key == WXK_BACK) {
		if (start > 0)
			SetInsertionPoint(start - 1);
		return;
	}
	// Cursor is at the end so do nothing
	if (start >= (long)text.size()) return;

	// If the cursor is at punctuation, move it forward to the next digit
	if (text[start] == ':' || text[start] == '.')
		++start;

	// : and . hop over punctuation but never insert anything
	if (key == ';' || key == '.') {
		SetInsertionPoint(start);
		return;
	}

	// Overwrite the digit
	time = text.Left(start) + (char)key + text.Mid(start + 1);
	SetValue(time.GetASSFormated());
	SetInsertionPoint(start + 1);
}