⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scintillawx.cpp

📁 robocup rcssserver 运行防真机器人足球比赛所用的服务器端
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    bool modified = false;    int vertEnd = nMax;    if (!verticalScrollBarVisible)        vertEnd = 0;    // Check the vertical scrollbar    if (sci->m_vScrollBar == NULL) {  // Use built-in scrollbar        int  sbMax    = sci->GetScrollRange(wxVERTICAL);        int  sbThumb  = sci->GetScrollThumb(wxVERTICAL);        int  sbPos    = sci->GetScrollPos(wxVERTICAL);        if (sbMax != vertEnd || sbThumb != nPage) {            sci->SetScrollbar(wxVERTICAL, sbPos, nPage, vertEnd+1);            modified = true;        }    }    else { // otherwise use the one that's been given to us        int  sbMax    = sci->m_vScrollBar->GetRange();        int  sbPage   = sci->m_vScrollBar->GetPageSize();        int  sbPos    = sci->m_vScrollBar->GetThumbPosition();        if (sbMax != vertEnd || sbPage != nPage) {            sci->m_vScrollBar->SetScrollbar(sbPos, nPage, vertEnd+1, nPage);            modified = true;        }    }    // Check the horizontal scrollbar    PRectangle rcText = GetTextRectangle();    int horizEnd = scrollWidth;    if (horizEnd < 0)        horizEnd = 0;    if (!horizontalScrollBarVisible || (wrapState != eWrapNone))        horizEnd = 0;    int pageWidth = rcText.Width();    if (sci->m_hScrollBar == NULL) {  // Use built-in scrollbar        int sbMax    = sci->GetScrollRange(wxHORIZONTAL);        int sbThumb  = sci->GetScrollThumb(wxHORIZONTAL);        int sbPos    = sci->GetScrollPos(wxHORIZONTAL);        if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) {            sci->SetScrollbar(wxHORIZONTAL, sbPos, pageWidth, horizEnd);            modified = true;            if (scrollWidth < pageWidth) {                HorizontalScrollTo(0);            }        }    }    else { // otherwise use the one that's been given to us        int sbMax    = sci->m_hScrollBar->GetRange();        int sbThumb  = sci->m_hScrollBar->GetPageSize();        int sbPos    = sci->m_hScrollBar->GetThumbPosition();        if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) {            sci->m_hScrollBar->SetScrollbar(sbPos, pageWidth, horizEnd, pageWidth);            modified = true;            if (scrollWidth < pageWidth) {                HorizontalScrollTo(0);            }        }    }    return modified;}void ScintillaWX::NotifyChange() {    sci->NotifyChange();}void ScintillaWX::NotifyParent(SCNotification scn) {    sci->NotifyParent(&scn);}// This method is overloaded from ScintillaBase in order to prevent the// AutoComplete window from being destroyed when it gets the focus.  There is// a side effect that the AutoComp will also not be destroyed when switching// to another window, but I think that is okay.void ScintillaWX::CancelModes() {    if (! focusEvent)        AutoCompleteCancel();    ct.CallTipCancel();    Editor::CancelModes();}void ScintillaWX::Copy() {    if (currentPos != anchor) {        SelectionText st;        CopySelectionRange(&st);        CopyToClipboard(st);    }}void ScintillaWX::Paste() {    pdoc->BeginUndoAction();    ClearSelection();#if wxUSE_DATAOBJ    wxTextDataObject data;    wxString textString;    wxWX2MBbuf buf;    int   len  = 0;    bool  rectangular = false;    if (wxTheClipboard->Open()) {        wxTheClipboard->UsePrimarySelection(false);        wxCustomDataObject selData(wxDF_PRIVATE);        bool gotRectData = wxTheClipboard->GetData(selData);        if (gotRectData && selData.GetSize()>1) {            const char* rectBuf = (const char*)selData.GetData();            rectangular = rectBuf[0] == (char)1;            len = selData.GetDataSize()-1;            char* buffer = new char[len];            memcpy (buffer, rectBuf+1, len);            textString = sci2wx(buffer, len);            delete buffer;        } else {            bool gotData = wxTheClipboard->GetData(data);            if (gotData) {                textString = wxTextBuffer::Translate (data.GetText(),                                                      wxConvertEOLMode(pdoc->eolMode));            }        }        data.SetText(wxEmptyString); // free the data object content        wxTheClipboard->Close();    }    buf = (wxWX2MBbuf)wx2sci(textString);    len  = strlen(buf);    int newPos = 0;    if (rectangular) {        int newLine = pdoc->LineFromPosition (currentPos) + wxCountLines (buf, pdoc->eolMode);        int newCol = pdoc->GetColumn(currentPos);        PasteRectangular (currentPos, buf, len);        newPos = pdoc->FindColumn (newLine, newCol);    } else {        pdoc->InsertString (currentPos, buf, len);        newPos = currentPos + len;    }    SetEmptySelection (newPos);#endif // wxUSE_DATAOBJ    pdoc->EndUndoAction();    NotifyChange();    Redraw();}void ScintillaWX::CopyToClipboard (const SelectionText& st) {#if wxUSE_CLIPBOARD    if (wxTheClipboard->Open()) {        wxTheClipboard->UsePrimarySelection (false);        wxString text = wxTextBuffer::Translate (sci2wx(st.s, st.len-1));        // composite object will hold "plain text" for pasting in other programs and a custom        // object for local use that remembers what kind of selection was made (stream or        // rectangular).        wxDataObjectComposite* obj = new wxDataObjectComposite();        wxCustomDataObject* rectData = new wxCustomDataObject (wxDF_PRIVATE);        char* buffer = new char[st.len+1];        buffer[0] = (st.rectangular)? (char)1 : (char)0;        memcpy (buffer+1, st.s, st.len);        rectData->SetData (st.len+1, buffer);        delete buffer;        obj->Add (rectData, true);        obj->Add (new wxTextDataObject (text));        wxTheClipboard->SetData (obj);        wxTheClipboard->Close();    }#else    wxUnusedVar(st);#endif // wxUSE_CLIPBOARD}bool ScintillaWX::CanPaste() {#if wxUSE_CLIPBOARD    bool canPaste = false;    bool didOpen;    if (Editor::CanPaste()) {        didOpen = !wxTheClipboard->IsOpened();        if ( didOpen )            wxTheClipboard->Open();        if (wxTheClipboard->IsOpened()) {            wxTheClipboard->UsePrimarySelection(false);            canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);            if (didOpen)                wxTheClipboard->Close();        }    }    return canPaste;#else    return false;#endif // wxUSE_CLIPBOARD}void ScintillaWX::CreateCallTipWindow(PRectangle) {    if (! ct.wCallTip.Created() ) {        ct.wCallTip = new wxSCICallTip(sci, &ct, this);        ct.wDraw = ct.wCallTip;    }}void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {    if (!label[0])        ((wxMenu*)popup.GetID())->AppendSeparator();    else        ((wxMenu*)popup.GetID())->Append(cmd, wxGetTranslation(sci2wx(label)));    if (!enabled)        ((wxMenu*)popup.GetID())->Enable(cmd, enabled);}// This is called by the Editor base class whenever something is selectedvoid ScintillaWX::ClaimSelection() {#if 0    // Until wxGTK is able to support using both the primary selection and the    // clipboard at the same time I think it causes more problems than it is    // worth to implement this method.  Selecting text should not clear the    // clipboard.  --Robin#ifdef __WXGTK__    // Put the selected text in the PRIMARY selection    if (currentPos != anchor) {        SelectionText st;        CopySelectionRange(&st);        if (wxTheClipboard->Open()) {            wxTheClipboard->UsePrimarySelection(true);            wxString text = sci2wx(st.s, st.len);            wxTheClipboard->SetData(new wxTextDataObject(text));            wxTheClipboard->UsePrimarySelection(false);            wxTheClipboard->Close();        }    }#endif#endif}void ScintillaWX::UpdateSystemCaret() {#ifdef __WXMSW__    if (hasFocus) {        if (HasCaretSizeChanged()) {            DestroySystemCaret();            CreateSystemCaret();        }        Point pos = LocationFromPosition(currentPos);#if wxCHECK_VERSION(2, 5, 0)        ::SetCaretPos(pos.x, pos.y);#endif    }#endif}bool ScintillaWX::HasCaretSizeChanged() {#ifdef __WXMSW__#if !wxCHECK_VERSION(2, 5, 0)    return false;#else    if (( (0 != vs.caretWidth) && (sysCaretWidth != vs.caretWidth) )        || (0 != vs.lineHeight) && (sysCaretHeight != vs.lineHeight)) {        return true;    }#endif#endif    return false;}bool ScintillaWX::CreateSystemCaret() {#ifdef __WXMSW__#if !wxCHECK_VERSION(2, 5, 0)    return false;#else    sysCaretWidth = vs.caretWidth;    if (0 == sysCaretWidth) {        sysCaretWidth = 1;    }    sysCaretHeight = vs.lineHeight;    int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) * sysCaretHeight;    char *bits = new char[bitmapSize];    memset(bits, 0, bitmapSize);    sysCaretBitmap = ::CreateBitmap(sysCaretWidth, sysCaretHeight, 1,                                    1, reinterpret_cast<BYTE *>(bits));    delete [] bits;    BOOL retval = ::CreateCaret(GetHwndOf(sci), sysCaretBitmap,                                sysCaretWidth, sysCaretHeight);    ::ShowCaret(GetHwndOf(sci));    return retval != 0;#endif#else    return false;#endif}bool ScintillaWX::DestroySystemCaret() {#ifdef __WXMSW__#if !wxCHECK_VERSION(2, 5, 0)    return false;#else    ::HideCaret(GetHwndOf(sci));    BOOL retval = ::DestroyCaret();    if (sysCaretBitmap) {        ::DeleteObject(sysCaretBitmap);        sysCaretBitmap = 0;    }    return retval != 0;#endif#else    return false;#endif}//----------------------------------------------------------------------long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {    return 0;}long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) {      switch (iMessage) {      case SCI_CALLTIPSHOW: {          // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx          // because of the little tweak that needs done below for wxGTK.          // When updating new versions double check that this is still          // needed, and that any new code there is copied here too.          Point pt = LocationFromPosition(wParam);          char* defn = reinterpret_cast<char *>(lParam);          AutoCompleteCancel();          pt.y += vs.lineHeight;          PRectangle rc = ct.CallTipStart(currentPos, pt,                                          defn,                                          vs.styles[STYLE_DEFAULT].fontName,                                          vs.styles[STYLE_DEFAULT].sizeZoomed,                                          CodePage(),                                          vs.styles[STYLE_DEFAULT].characterSet,                                          wMain);          // If the call-tip window would be out of the client          // space, adjust so it displays above the text.          PRectangle rcClient = GetClientRectangle();          if (rc.bottom > rcClient.bottom) {#ifdef __WXGTK__              int offset = int(vs.lineHeight * 1.25)  + rc.Height();#else              int offset = vs.lineHeight + rc.Height();#endif              rc.top -= offset;              rc.bottom -= offset;          }          // Now display the window.          CreateCallTipWindow(rc);          ct.wCallTip.SetPositionRelative(rc, wMain);          ct.wCallTip.Show();          break;      }/*? TODO#ifdef SCI_LEXER      case SCI_LOADLEXERLIBRARY:            LexerManager::GetInstance()->Load((const char*)lParam);            break;#endif ?*/      default:          return ScintillaBase::WndProc(iMessage, wParam, lParam);      }      return 0;}//----------------------------------------------------------------------// Event delegatesvoid ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {    paintState = painting;    Surface* surfaceWindow = Surface::Allocate();    surfaceWindow->Init(dc, wMain.GetID());    rcPaint = PRectangleFromwxRect(rect);    PRectangle rcClient = GetClientRectangle();    paintingAllText = rcPaint.Contains(rcClient);    ClipChildren(*dc, rcPaint);    Paint(surfaceWindow, rcPaint);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -