]> git.saurik.com Git - wxWidgets.git/blobdiff - src/stc/stc.cpp.in
set device origin when drawing on a frame in order to not overwrite the menu/toolbar...
[wxWidgets.git] / src / stc / stc.cpp.in
index 4cc177306fdeb4d35c55fb4386947b63d120edd8..a859ec1a47e8a2a97f2987770cc25193c92e7a73 100644 (file)
@@ -150,8 +150,11 @@ void wxStyledTextCtrl::Create(wxWindow *parent,
                                    long style,
                                    const wxString& name)
 {
+#ifdef __WXMAC__
+    style |= wxVSCROLL | wxHSCROLL;
+#endif
     wxControl::Create(parent, id, pos, size,
-              style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
+              style | wxWANTS_CHARS | wxCLIP_CHILDREN,
               wxDefaultValidator, name);
 
 #ifdef LINK_LEXERS
@@ -349,20 +352,19 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
     if (file.IsOpened())
     {
         wxString contents;
-#if wxUSE_UNICODE
-        wxMemoryBuffer buffer;
-#else
-        wxString buffer;
-#endif
         off_t len = file.Length();
         if (len > 0)
         {
-            void *bufptr = buffer.GetWriteBuf(len);
-            success = (file.Read(bufptr, len) == len);
-            buffer.UngetWriteBuf(len);
 #if wxUSE_UNICODE
-            contents = wxString(buffer, *wxConvCurrent);
+            wxMemoryBuffer buffer(len+1);
+            success = (file.Read(buffer.GetData(), len) == len);
+           if (success) {
+                ((char*)buffer.GetData())[len] = 0;
+                contents = wxString(buffer, *wxConvCurrent, len);
+            }
 #else
+            wxString buffer;
+            success = (file.Read(wxStringBuffer(buffer, len), len) == len);
             contents = buffer;
 #endif
         }
@@ -393,6 +395,14 @@ bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
 #endif
 
 
+void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
+    m_swx->SetUseAntiAliasing(useAA);
+}
+
+bool wxStyledTextCtrl::GetUseAntiAliasing() {
+    return m_swx->GetUseAntiAliasing();
+}
+
 //----------------------------------------------------------------------
 // Event handlers
 
@@ -458,6 +468,14 @@ void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
     wxPoint pt = evt.GetPosition();
     ScreenToClient(&pt.x, &pt.y);
+    /*
+      Show context menu at event point if it's within the window,
+      or at caret location if not
+    */
+    wxHitTest ht = this->HitTest(pt);
+    if (ht != wxHT_WINDOW_INSIDE) {
+        pt = this->PointFromPosition(this->GetCurrentPos());
+    }
     m_swx->DoContextMenu(Point(pt.x, pt.y));
 }
 
@@ -485,7 +503,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
 //     printf("OnChar key:%%d  consumed:%%d  ctrl:%%d  alt:%%d  skip:%%d\n",
 //            key, m_lastKeyDownConsumed, ctrl, alt, skip);
 
-    if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) &&
+    if ( (key <= WXK_START || key > WXK_COMMAND) &&
          !m_lastKeyDownConsumed && !skip) {
         m_swx->DoAddChar(key);
         return;
@@ -511,13 +529,15 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
 }
 
 
-void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) {
+void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
     m_swx->DoLoseFocus();
+    evt.Skip();
 }
 
 
-void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) {
+void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
     m_swx->DoGainFocus();
+    evt.Skip();
 }
 
 
@@ -542,6 +562,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
 }
 
 
+void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
+    m_swx->DoOnIdle(evt);
+}
+
+
 //----------------------------------------------------------------------
 // Turn notifications from Scintilla into events