예제 #1
0
	bool FileDialog::onEvent(const Event &event) {
		if(event.type == Event::escape) {
			close(0);
		}
		else if(event.type == Event::button_clicked) {
			close(event.value);
		}
		else if(event.type == Event::element_selected) {
			if(event.value >= 0 && event.value < m_list_box->size()) {
				FilePath file_path = m_dir_path / FilePath((*m_list_box)[event.value].text.c_str());
				file_path = file_path.absolute();

				if(file_path.isDirectory()) {
					m_dir_path = file_path;
					updateList();
				}
				else if(file_path.isRegularFile()) {
					m_edit_box->setText(toWideString(file_path.fileName()));
				}
			}
			updateButtons();
		}
		else if(event.type == Event::text_modified) {
			auto file_name  = fromWideString(m_edit_box->text());
			m_list_box->selectEntry(m_list_box->findEntry(file_name.c_str()));
			updateButtons();
		}
		else
			return false;

		return true;
	}
예제 #2
0
	void FileDialog::updateButtons() {
		FilePath file_path = m_dir_path / FilePath(fromWideString(m_edit_box->text()));

		if(m_mode == FileDialogMode::opening_file)
			m_ok_button->enable(file_path.isRegularFile());
		else if(m_mode == FileDialogMode::saving_file)
			m_ok_button->enable(!file_path.isDirectory());
	}
예제 #3
0
	NativeString::NativeString( const char * s, Encoding encoding /*= ENCODING_NATIVE*/ )
	{
		if ( encoding == ENCODING_NATIVE )
		{
			this->assign(s);
		}
		else
		{
			fromWideString(StringUtils::utf8String2WideString(String(s)));
		}
	}
예제 #4
0
	NativeString::NativeString(const String& str, Encoding encoding ) : std::string()
	{
		if ( encoding == ENCODING_NATIVE )
		{
			this->assign(str);
		}
		else
		{
			fromWideString(StringUtils::utf8String2WideString(str));
		}
	}
예제 #5
0
	FilePath FileDialog::path() const {
		return m_dir_path / fromWideString(m_edit_box->text());
	}