"WxWidgets"의 두 판 사이의 차이
jjuiddong
(새 문서: * 이벤트 핸들링 (Event Handling) ** bind를 통해서도 이벤트를 핸들링 할 수 있다. ** wxMemMonitor 소스에서도 이 방식을 사용하고 있다. ** http://doc...) |
|||
4번째 줄: | 4번째 줄: | ||
** wxMemMonitor 소스에서도 이 방식을 사용하고 있다. | ** wxMemMonitor 소스에서도 이 방식을 사용하고 있다. | ||
** http://docs.wxwidgets.org/trunk/overview_events.html#overview_events_bind | ** http://docs.wxwidgets.org/trunk/overview_events.html#overview_events_bind | ||
+ | * Drag and Drop | ||
+ | ** http://forums.wxwidgets.org/viewtopic.php?f=1&t=34546 | ||
+ | DragAcceptFiles(true); | ||
+ | Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MyFrame::OnDropFiles), NULL, this); | ||
+ | void MyFrame::OnDropFiles(wxDropFilesEvent& event) | ||
+ | { | ||
+ | if (event.GetNumberOfFiles() > 0) | ||
+ | { | ||
+ | wxString* dropped = event.GetFiles(); | ||
+ | wxASSERT(dropped); | ||
+ | |||
+ | wxBusyCursor busyCursor; | ||
+ | wxWindowDisabler disabler; | ||
+ | wxBusyInfo busyInfo(_("Adding files, wait please...")); | ||
+ | |||
+ | wxString name; | ||
+ | wxArrayString files; | ||
+ | for (int i = 0; i < event.GetNumberOfFiles(); i++) { | ||
+ | name = dropped[i]; | ||
+ | if (wxFileExists(name)) | ||
+ | files.push_back(name); | ||
+ | else if (wxDirExists(name)) | ||
+ | wxDir::GetAllFiles(name, &files); | ||
+ | } | ||
+ | } | ||
+ | } |
2013년 4월 30일 (화) 13:35 판
- 이벤트 핸들링 (Event Handling)
- bind를 통해서도 이벤트를 핸들링 할 수 있다.
- wxMemMonitor 소스에서도 이 방식을 사용하고 있다.
- http://docs.wxwidgets.org/trunk/overview_events.html#overview_events_bind
- Drag and Drop
DragAcceptFiles(true); Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(MyFrame::OnDropFiles), NULL, this); void MyFrame::OnDropFiles(wxDropFilesEvent& event) { if (event.GetNumberOfFiles() > 0) { wxString* dropped = event.GetFiles(); wxASSERT(dropped); wxBusyCursor busyCursor; wxWindowDisabler disabler; wxBusyInfo busyInfo(_("Adding files, wait please...")); wxString name; wxArrayString files; for (int i = 0; i < event.GetNumberOfFiles(); i++) { name = dropped[i]; if (wxFileExists(name)) files.push_back(name); else if (wxDirExists(name)) wxDir::GetAllFiles(name, &files); } } }