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:
@@ -492,6 +492,7 @@ private:
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& evt);
|
||||
void OnEraseBackground(wxEraseEvent& evt);
|
||||
void OnMenu(wxCommandEvent& evt);
|
||||
void OnListBox(wxCommandEvent& evt);
|
||||
|
||||
|
||||
// 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_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_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_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 },
|
||||
|
@@ -485,7 +485,12 @@ int ListBox::GetSelection() {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@@ -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
|
||||
@@ -237,7 +260,7 @@ bool ScintillaWX::CanPaste() {
|
||||
}
|
||||
|
||||
void ScintillaWX::CreateCallTipWindow(PRectangle) {
|
||||
ct.wCallTip = new wxWindow(wDraw.GetID(), -1);
|
||||
ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct);
|
||||
ct.wDraw = ct.wCallTip;
|
||||
}
|
||||
|
||||
@@ -385,7 +408,10 @@ void ScintillaWX::DoButtonMove(Point pt) {
|
||||
|
||||
|
||||
void ScintillaWX::DoAddChar(char ch) {
|
||||
//bool acActiveBeforeCharAdded = ac.Active();
|
||||
AddChar(ch);
|
||||
//if (acActiveBeforeCharAdded)
|
||||
// AutoCompleteChanged(ch);
|
||||
}
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
|
||||
@@ -402,6 +428,9 @@ void ScintillaWX::DoContextMenu(Point pt) {
|
||||
ContextMenu(pt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoOnListBox() {
|
||||
AutoCompleteCompleted();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@@ -126,6 +126,7 @@ public:
|
||||
|
||||
void DoCommand(int ID);
|
||||
void DoContextMenu(Point pt);
|
||||
void DoOnListBox();
|
||||
|
||||
|
||||
// helpers
|
||||
|
@@ -81,6 +81,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
|
||||
EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
|
||||
EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
|
||||
EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
|
||||
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
|
||||
|
||||
|
@@ -492,6 +492,7 @@ private:
|
||||
void OnSysColourChanged(wxSysColourChangedEvent& evt);
|
||||
void OnEraseBackground(wxEraseEvent& evt);
|
||||
void OnMenu(wxCommandEvent& evt);
|
||||
void OnListBox(wxCommandEvent& evt);
|
||||
|
||||
|
||||
// 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_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_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_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 },
|
||||
|
@@ -485,7 +485,12 @@ int ListBox::GetSelection() {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@@ -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
|
||||
@@ -237,7 +260,7 @@ bool ScintillaWX::CanPaste() {
|
||||
}
|
||||
|
||||
void ScintillaWX::CreateCallTipWindow(PRectangle) {
|
||||
ct.wCallTip = new wxWindow(wDraw.GetID(), -1);
|
||||
ct.wCallTip = new wxSTCCallTip(wDraw.GetID(), -1, &ct);
|
||||
ct.wDraw = ct.wCallTip;
|
||||
}
|
||||
|
||||
@@ -385,7 +408,10 @@ void ScintillaWX::DoButtonMove(Point pt) {
|
||||
|
||||
|
||||
void ScintillaWX::DoAddChar(char ch) {
|
||||
//bool acActiveBeforeCharAdded = ac.Active();
|
||||
AddChar(ch);
|
||||
//if (acActiveBeforeCharAdded)
|
||||
// AutoCompleteChanged(ch);
|
||||
}
|
||||
|
||||
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt) {
|
||||
@@ -402,6 +428,9 @@ void ScintillaWX::DoContextMenu(Point pt) {
|
||||
ContextMenu(pt);
|
||||
}
|
||||
|
||||
void ScintillaWX::DoOnListBox() {
|
||||
AutoCompleteCompleted();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@@ -126,6 +126,7 @@ public:
|
||||
|
||||
void DoCommand(int ID);
|
||||
void DoContextMenu(Point pt);
|
||||
void DoOnListBox();
|
||||
|
||||
|
||||
// helpers
|
||||
|
@@ -81,6 +81,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
|
||||
EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
|
||||
EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
|
||||
EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
|
||||
EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user