More STC fixes. Calltips and AutoComplete work now.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7314 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2000-04-29 05:17:21 +00:00
parent 91c93b48e9
commit 6e96414894
10 changed files with 90 additions and 6 deletions

View File

@@ -492,6 +492,7 @@ private:
void OnSysColourChanged(wxSysColourChangedEvent& evt); void OnSysColourChanged(wxSysColourChangedEvent& evt);
void OnEraseBackground(wxEraseEvent& evt); void OnEraseBackground(wxEraseEvent& evt);
void OnMenu(wxCommandEvent& evt); void OnMenu(wxCommandEvent& evt);
void OnListBox(wxCommandEvent& evt);
// Turn notifications from Scintilla into events // Turn notifications from Scintilla into events
@@ -612,7 +613,7 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
#define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_CMDKEY(id, fn) { wxEVT_STC_CMDKEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_KEY(id, fn) { wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },

View File

@@ -485,7 +485,12 @@ int ListBox::GetSelection() {
} }
int ListBox::Find(const char *prefix) { int ListBox::Find(const char *prefix) {
return ((wxListBox*)id)->FindString(prefix); for (int x=0; x < ((wxListBox*)id)->Number(); x++) {
wxString text = ((wxListBox*)id)->GetString(x);
if (text.StartsWith(prefix))
return x;
}
return -1;
} }
void ListBox::GetValue(int n, char *value, int len) { void ListBox::GetValue(int n, char *value, int len) {

View File

@@ -62,6 +62,29 @@ void wxSTCDropTarget::OnLeave() {
} }
class wxSTCCallTip : public wxWindow {
public:
wxSTCCallTip(wxWindow* parent, int ID, CallTip* ct)
: wxWindow(parent, ID)
{
m_ct = ct;
}
void OnPaint(wxPaintEvent& evt) {
wxPaintDC dc(this);
Surface surfaceWindow;
surfaceWindow.Init(&dc);
m_ct->PaintCT(&surfaceWindow);
surfaceWindow.Release();
}
CallTip* m_ct;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxSTCCallTip, wxWindow)
EVT_PAINT(wxSTCCallTip::OnPaint)
END_EVENT_TABLE()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Constructor/Destructor // Constructor/Destructor
@@ -237,7 +260,7 @@ bool ScintillaWX::CanPaste() {
} }
void ScintillaWX::CreateCallTipWindow(PRectangle) { void ScintillaWX::CreateCallTipWindow(PRectangle) {
ct.wCallTip = new wxWindow(wDraw.GetID(), -1); ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct);
ct.wDraw = ct.wCallTip; ct.wDraw = ct.wCallTip;
} }
@@ -385,7 +408,10 @@ void ScintillaWX::DoButtonMove(Point pt) {
void ScintillaWX::DoAddChar(char ch) { void ScintillaWX::DoAddChar(char ch) {
//bool acActiveBeforeCharAdded = ac.Active();
AddChar(ch); AddChar(ch);
//if (acActiveBeforeCharAdded)
// AutoCompleteChanged(ch);
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
@@ -402,6 +428,9 @@ void ScintillaWX::DoContextMenu(Point pt) {
ContextMenu(pt); ContextMenu(pt);
} }
void ScintillaWX::DoOnListBox() {
AutoCompleteCompleted();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -126,6 +126,7 @@ public:
void DoCommand(int ID); void DoCommand(int ID);
void DoContextMenu(Point pt); void DoContextMenu(Point pt);
void DoOnListBox();
// helpers // helpers

View File

@@ -81,6 +81,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu) EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -1452,6 +1453,11 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
} }
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
m_swx->DoOnListBox();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Turn notifications from Scintilla into events // Turn notifications from Scintilla into events

View File

@@ -492,6 +492,7 @@ private:
void OnSysColourChanged(wxSysColourChangedEvent& evt); void OnSysColourChanged(wxSysColourChangedEvent& evt);
void OnEraseBackground(wxEraseEvent& evt); void OnEraseBackground(wxEraseEvent& evt);
void OnMenu(wxCommandEvent& evt); void OnMenu(wxCommandEvent& evt);
void OnListBox(wxCommandEvent& evt);
// Turn notifications from Scintilla into events // Turn notifications from Scintilla into events
@@ -612,7 +613,7 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
#define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_CMDKEY(id, fn) { wxEVT_STC_CMDKEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_KEY(id, fn) { wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },
#define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, #define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL },

View File

@@ -485,7 +485,12 @@ int ListBox::GetSelection() {
} }
int ListBox::Find(const char *prefix) { int ListBox::Find(const char *prefix) {
return ((wxListBox*)id)->FindString(prefix); for (int x=0; x < ((wxListBox*)id)->Number(); x++) {
wxString text = ((wxListBox*)id)->GetString(x);
if (text.StartsWith(prefix))
return x;
}
return -1;
} }
void ListBox::GetValue(int n, char *value, int len) { void ListBox::GetValue(int n, char *value, int len) {

View File

@@ -62,6 +62,29 @@ void wxSTCDropTarget::OnLeave() {
} }
class wxSTCCallTip : public wxWindow {
public:
wxSTCCallTip(wxWindow* parent, int ID, CallTip* ct)
: wxWindow(parent, ID)
{
m_ct = ct;
}
void OnPaint(wxPaintEvent& evt) {
wxPaintDC dc(this);
Surface surfaceWindow;
surfaceWindow.Init(&dc);
m_ct->PaintCT(&surfaceWindow);
surfaceWindow.Release();
}
CallTip* m_ct;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxSTCCallTip, wxWindow)
EVT_PAINT(wxSTCCallTip::OnPaint)
END_EVENT_TABLE()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Constructor/Destructor // Constructor/Destructor
@@ -237,7 +260,7 @@ bool ScintillaWX::CanPaste() {
} }
void ScintillaWX::CreateCallTipWindow(PRectangle) { void ScintillaWX::CreateCallTipWindow(PRectangle) {
ct.wCallTip = new wxWindow(wDraw.GetID(), -1); ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct);
ct.wDraw = ct.wCallTip; ct.wDraw = ct.wCallTip;
} }
@@ -385,7 +408,10 @@ void ScintillaWX::DoButtonMove(Point pt) {
void ScintillaWX::DoAddChar(char ch) { void ScintillaWX::DoAddChar(char ch) {
//bool acActiveBeforeCharAdded = ac.Active();
AddChar(ch); AddChar(ch);
//if (acActiveBeforeCharAdded)
// AutoCompleteChanged(ch);
} }
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) { int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
@@ -402,6 +428,9 @@ void ScintillaWX::DoContextMenu(Point pt) {
ContextMenu(pt); ContextMenu(pt);
} }
void ScintillaWX::DoOnListBox() {
AutoCompleteCompleted();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@@ -126,6 +126,7 @@ public:
void DoCommand(int ID); void DoCommand(int ID);
void DoContextMenu(Point pt); void DoContextMenu(Point pt);
void DoOnListBox();
// helpers // helpers

View File

@@ -81,6 +81,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu) EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -1452,6 +1453,11 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
} }
void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
m_swx->DoOnListBox();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Turn notifications from Scintilla into events // Turn notifications from Scintilla into events