Вобщем, почти разобрался сам:
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/textctrl.h>
#include <wx/dnd.h>
#include <wx/filename.h>
#define MAIN_WINDOW_ID 1000
class DnDFile : public wxFileDropTarget{
private:
wxTextCtrl *TargetTextCtrl;
public:
DnDFile(wxTextCtrl *target) {TargetTextCtrl = target; }
virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames);
};
bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString &filenames)
{
wxFileName file(filenames[0]);
if(file.GetExt() == "txt") TargetTextCtrl->LoadFile(filenames[0]);
return true;
}
//-----------------------------------------
class MainWindow : public wxFrame{
private:
wxTextCtrl *text_ctrl;
public:
MainWindow(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, long style, const wxString &name);
virtual ~MainWindow();
};
MainWindow::MainWindow(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, long style, const wxString &name)
: wxFrame(parent,id, title, pos, size, style, name)
{
text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
text_ctrl->SetDropTarget(new DnDFile(text_ctrl));
}
//-----------------------------------------
MainWindow::~MainWindow()
{
//-----------------------------------------
class Application : public wxApp{
public:
bool OnInit();
};
IMPLEMENT_APP(Application)
bool Application::OnInit()
{
MainWindow *main_window = new MainWindow(NULL, MAIN_WINDOW_ID, wxT("test"),
wxPoint(100,100), wxSize(640,480),
wxDEFAULT_FRAME_STYLE, "test");
main_window->Show();
return true;
}
правда компилируется только под windows, под линуксом ругается на 9 строку: "expected class-name before '{' token", или что-то в этом роде. Подозреваю, что это как-то связано с подключением инклюдов... вобщем буду разбираться дальше...