Change she::FileDialog::show() argument from DisplayHandle to Display

This is because we could make use of Display member functions inside the
FileDialog::show() implementation.
This commit is contained in:
David Capello 2015-05-28 16:13:07 -03:00
parent 2a5c93e333
commit 7826e38382
3 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,7 @@ std::string show_file_selector(const std::string& title,
dlg->addFilter("*." + tok, tok + " files (*." + tok + ")");
dlg->addFilter("*.*", "All files (*.*)");
if (dlg->show(she::instance()->defaultDisplay()->nativeHandle()))
if (dlg->show(she::instance()->defaultDisplay()))
res = dlg->getFileName();
dlg->dispose();

View File

@ -8,11 +8,10 @@
#define SHE_NATIVE_DIALOGS_H_INCLUDED
#pragma once
#include "she/display_handle.h"
#include <string>
namespace she {
class Display;
class FileDialog {
public:
@ -25,7 +24,7 @@ namespace she {
virtual void addFilter(const std::string& extension, const std::string& description) = 0;
virtual std::string getFileName() = 0;
virtual void setFileName(const std::string& filename) = 0;
virtual bool show(DisplayHandle parent) = 0;
virtual bool show(Display* parent) = 0;
};
class NativeDialogs {

View File

@ -12,6 +12,7 @@
#include "base/path.h"
#include "base/string.h"
#include "she/display.h"
#include "she/error.h"
#include <windows.h>
@ -68,13 +69,13 @@ public:
m_initialDir = base::from_utf8(base::get_file_path(filename));
}
bool show(DisplayHandle parent) override {
bool show(Display* parent) override {
std::wstring filtersWStr = getFiltersForGetOpenFileName();
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = (HWND)parent;
ofn.hwndOwner = (HWND)parent->nativeHandle();
ofn.hInstance = GetModuleHandle(NULL);
ofn.lpstrFilter = filtersWStr.c_str();
ofn.nFilterIndex = m_defFilter;