示例#1
0
std::string rconsole2utf8(const std::string& encoded)
{
   boost::regex utf8("\x02\xFF\xFE(.*?)(\x03\xFF\xFE|\\')");

   std::string output;
   std::string::const_iterator pos = encoded.begin();
   boost::smatch m;
   while (pos != encoded.end() && boost::regex_search(pos, encoded.end(), m, utf8))
   {
      if (pos < m[0].first)
         output.append(string_utils::systemToUtf8(std::string(pos, m[0].first)));
      output.append(m[1].first, m[1].second);
      pos = m[0].second;
   }
   if (pos != encoded.end())
      output.append(string_utils::systemToUtf8(std::string(pos, encoded.end())));

   return output;
}
示例#2
0
// Helper function to create an NPN String Identifier from a v8 string.
NPIdentifier getStringIdentifier(v8::Handle<v8::String> str)
{
    const int kStackBufferSize = 100;

    int bufferLength = str->Utf8Length() + 1;
    if (bufferLength <= kStackBufferSize) {
        // Use local stack buffer to avoid heap allocations for small strings. Here we should only use the stack space for
        // stackBuffer when it's used, not when we use the heap.
        //
        // WriteUtf8 is guaranteed to generate a null-terminated string because bufferLength is constructed to be one greater
        // than the string length.
        char stackBuffer[kStackBufferSize];
        str->WriteUtf8(stackBuffer, bufferLength);
        return _NPN_GetStringIdentifier(stackBuffer);
    }

    v8::String::Utf8Value utf8(str);
    return _NPN_GetStringIdentifier(*utf8);
}
示例#3
0
void CheatEditorWindow::reloadList() {
  list->clear();
  list->setSortingEnabled(false);

  if(SNES::cartridge.loaded()) {
    for(unsigned n = 0; n < SNES::cheat.count(); n++) {
      QTreeWidgetItem *item = new QTreeWidgetItem(list);
      item->setData(0, Qt::UserRole, QVariant(n));
      char slot[16];
      sprintf(slot, "%3u", n + 1);
      item->setText(0, utf8() << slot);
      updateItem(item);
    }
  }

  list->setSortingEnabled(true);
  list->header()->setSortIndicatorShown(false);
  syncUi();
}
示例#4
0
void session::open(string_t const& file_name, int flags)
{
	// close previous session
	close();

	if ( !flags )
	{
		flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE;
	}

	int const r = sqlite3_open_v2(utf8(file_name).c_str(), &impl_, flags, 0);
	if ( r != SQLITE_OK )
	{
		string_t const msg( last_error_msg(impl_) );
		int const err = ::sqlite3_errcode(impl_);
		close(); // session should be closed anyway
		throw exception(err, msg);
	}
}
示例#5
0
  for_each(VisualPhysicsActor* actor, actors) {
    if (QFileInfo(actor->path()).exists()) {
      use_ae_desc_list = true;

      AliasHandle file_alias;
      Boolean is_directory = false;

      err = FSNewAliasFromPath(NULL, utf8(actor->path()).c_str(), 0,  &file_alias, &is_directory);

      HLock((Handle) file_alias);

      AECreateDesc(typeAlias, (Ptr) (*file_alias),
                   GetHandleSize((Handle) file_alias), &file_list_element);
      HUnlock((Handle) file_alias);

      AEPutDesc(&file_list, 0, &file_list_element);
    }

  }
示例#6
0
PerformanceStatsHUD::PerformanceStatsHUD()
: show_HUD_(false) {
  if (!HUD_resources_are_loaded_) {
    QString resource_path = FileManager::getResourcePath();
    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(utf8(resource_path + "/OgreCore.zip"),
                                                                   "Zip", "Bootstrap");
    Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
    HUD_resources_are_loaded_ = true;
  }

  debug_overlay_ = Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay");
  avg_FPS_ = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
  curr_FPS_ = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
  best_FPS_ = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
  worst_FPS_ = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
  memory_use_in_bytes = Ogre::OverlayManager::getSingleton().getOverlayElement("Core/NumTris");

  assert(QObject::connect(BumpTopApp::singleton(), SIGNAL(onRender()),  // NOLINT
                          this, SLOT(renderTick())));  // NOLINT
}
示例#7
0
void freqtable::load(const QString& file)
{
    QFile io(file);
    if (!io.open(QIODevice::ReadOnly))
        throw std::runtime_error(utf8("open frequence table failed: _1", file));

    QTextStream stream(&io);
    stream.setCodec("UTF-8");
    while (!stream.atEnd())
    {
        const auto& line  = stream.readLine();
        const auto& words = line.split("\t");
        if (words.size() != 2)
            throw std::runtime_error("unexpected frequency table data");

        const auto& word = words[0];
        const auto& freq = words[1].toLongLong();
        table_[word] = freq;
    }
}
示例#8
0
//updates system state text at bottom-right of main window statusbar
void Utility::updateSystemState() {
  string text;

  if(cartridge.loaded() == false) {
    text = "No cartridge loaded";
  } else if(application.power == false) {
    text = "Power off";
  } else if(application.pause == true || application.autopause == true) {
    text = "Paused";
  } else if(ppu.status.frames_updated == true) {
    ppu.status.frames_updated = false;
    text << (int)ppu.status.frames_executed;
    text << " fps";
  } else {
    //nothing to update
    return;
  }

  winMain->systemState->setText(utf8() << text);
}
示例#9
0
void PopupButton::draw(NVGcontext* ctx) {
    if (!mEnabled && mPushed)
        mPushed = false;

    mPopup->setVisible(mPushed);
    Button::draw(ctx);

    auto icon = utf8(ENTYPO_ICON_CHEVRON_SMALL_RIGHT);
    NVGcolor textColor = mTextColor.w() == 0 ? mTheme->mTextColor : mTextColor;
    nvgFontSize(ctx, mTheme->mButtonFontSize * 1.5f);
    nvgFontFace(ctx, "icons");
    nvgFillColor(ctx, mEnabled ? textColor : mTheme->mDisabledTextColor);
    nvgTextAlign(ctx, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);

    float iw = nvgTextBounds(ctx, 0, 0, icon.data(), nullptr, nullptr);
    Vector2f iconPos(
        mPos.x() + mSize.x() - iw - 8, mPos.y() + mSize.y() * 0.5f -1);

    nvgText(ctx, iconPos.x(), iconPos.y(), icon.data(), nullptr);
}
示例#10
0
void PrefChanged(const char* aPref, void* aClosure)
{
  if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
    nsAdoptingString value = Preferences::GetString(aPref);
    StaticMutexAutoLock lock(sMutex);
    if (value.IsEmpty()) {
      sVolumeScale = 1.0;
    } else {
      NS_ConvertUTF16toUTF8 utf8(value);
      sVolumeScale = std::max<double>(0, PR_strtod(utf8.get(), nullptr));
    }
  } else if (strcmp(aPref, PREF_CUBEB_LATENCY) == 0) {
    // Arbitrary default stream latency of 100ms.  The higher this
    // value, the longer stream volume changes will take to become
    // audible.
    sCubebLatencyPrefSet = Preferences::HasUserValue(aPref);
    uint32_t value = Preferences::GetUint(aPref, CUBEB_NORMAL_LATENCY_MS);
    StaticMutexAutoLock lock(sMutex);
    sCubebLatency = std::min<uint32_t>(std::max<uint32_t>(value, 1), 1000);
  }
}
示例#11
0
//true means filename can be loaded directly
//false means it cannot (eg this is a folder and we are attempting to load a ROM)
bool DiskBrowser::currentFilename(string &filename) {
  bool loadable = false;
  QModelIndex item = view->currentIndex();
  filename = model->filePath(item).toUtf8().constData();

  if(browseMode != Folder) {
    if(model->isDir(item) == true) {
      QDir directory(utf8() << filename);
      directory.setNameFilters(QStringList() << "*.sfc");
      QStringList list = directory.entryList(QDir::Files | QDir::NoDotAndDotDot);
      if(list.count() == 1) {
        filename << "/" << list[0].toUtf8().constData();
        loadable = true;
      }
    } else {
      loadable = true;
    }
  }

  return loadable;
}
static int PrefChanged(const char* aPref, void* aClosure)
{
  if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
    nsAdoptingString value = Preferences::GetString(aPref);
    MutexAutoLock lock(*gAudioPrefsLock);
    if (value.IsEmpty()) {
      gVolumeScale = 1.0;
    } else {
      NS_ConvertUTF16toUTF8 utf8(value);
      gVolumeScale = std::max<double>(0, PR_strtod(utf8.get(), nullptr));
    }
  } else if (strcmp(aPref, PREF_CUBEB_LATENCY) == 0) {
    // Arbitrary default stream latency of 100ms.  The higher this
    // value, the longer stream volume changes will take to become
    // audible.
    uint32_t value = Preferences::GetUint(aPref, 100);
    MutexAutoLock lock(*gAudioPrefsLock);
    gCubebLatency = std::min<uint32_t>(std::max<uint32_t>(value, 20), 1000);
  }
  return 0;
}
示例#13
0
void PopupButton::draw (NVGcontext * ctx)
{
   if (!mEnabled && mPushed)
      mPushed = false;
   mPopup->setVisible (mPushed);
   Button::draw (ctx);
   if (mChevronIcon)
   {
      auto icon = utf8 (mChevronIcon);
      NVGcolor textColor =
         mTextColor.a == 0 ? mTheme->mTextColor : mTextColor;
      nvgFontSize (ctx, (mFontSize < 0 ? mTheme->mButtonFontSize : mFontSize) * 1.5f);
      nvgFontFace (ctx, "icons");
      nvgFillColor (ctx, mEnabled ? textColor : mTheme->mDisabledTextColor);
      nvgTextAlign (ctx, NVG_ALIGN_LEFT | NVG_ALIGN_MIDDLE);
      float iw = nvgTextBounds (ctx, 0, 0, icon.data(), nullptr, nullptr);
      vec2 iconPos (mPos.x + mSize.x - iw - 8,
                        mPos.y + mSize.y * 0.5f - 1);
      nvgText (ctx, iconPos.x, iconPos.y, icon.data(), nullptr);
   }
}
static QString RunApp(const QString &execPath, const QString &execParam, const QString &execPipeIn="") {
    QString outPipePath = Xapi::TmpFilePath("pipeOut");

    QProcess app;
    app.setStandardInputFile(execPipeIn);
    app.setStandardOutputFile(outPipePath);
    app.setStandardErrorFile(outPipePath);
    app.start(execPath + " " + execParam);
    app.waitForFinished();

    if (QProcess::NormalExit != app.exitStatus())
        qDebug()<<app.error()<<app.errorString()<<app.state();

    QFile locale(outPipePath);
    if (!locale.open(QIODevice::ReadOnly)) {
        qDebug()<<"Open output pipe Fialed!"<<outPipePath;
        return "";
    }
    QTextStream localets(&locale);

    QString outUtf8PipePath = Xapi::TmpFilePath("utf8pipeOut");
    QFile utf8(outUtf8PipePath);
    if (!utf8.open(QIODevice::WriteOnly)) {
        qDebug()<<"Open utf8 output pipe Fialed!"<<outUtf8PipePath;
        return "";
    }
    QTextStream utf8ts(&utf8);
    utf8ts.setCodec("utf8");
    utf8ts<<localets.readAll();
    locale.close();
    utf8.close();

    utf8.open(QIODevice::ReadOnly);
    QString ret = QString(utf8.readAll());
    utf8.close();

    locale.remove();
    utf8.remove();
    return ret;
}
示例#15
0
void HexEditor::update() {
    string output;
    char temp[256];
    unsigned offset = hexOffset;

    for(unsigned y = 0; y < 16; y++) {
        if(offset >= hexSize) break;
        sprintf(temp, "%.6x", offset & 0xffffff);
        output << "<font color='#606060'>" << temp << "</font>&nbsp;&nbsp;";

        for(unsigned x = 0; x < 16; x++) {
            if(offset >= hexSize) break;
            sprintf(temp, "%.2x", reader(offset++));
            output << "<font color='" << ((x & 1) ? "#000080" : "#0000ff") << "'>" << temp << "</font>";
            if(x != 15) output << "&nbsp;";
        }

        if(y != 15) output << "<br>";
    }

    setHtml(utf8() << output);
}
示例#16
0
int main() {
	int retval;
	test_batch_runner *runner = test_batch_runner_new();

	constructor(runner);
	accessors(runner);
	node_check(runner);
	iterator(runner);
	iterator_delete(runner);
	create_tree(runner);
	hierarchy(runner);
	parser(runner);
	render_html(runner);
	utf8(runner);
	test_cplusplus(runner);

	test_print_summary(runner);
	retval =  test_ok(runner) ? 0 : 1;
	free(runner);

	return retval;
}
示例#17
0
 static void construct(PyObject* obj, boost::python::converter::rvalue_from_python_stage1_data* data)
 {
     if(PyString_Check(obj)) {
         const char* value = PyString_AsString(obj);
         //MY_CHECK(value,translate("Received null string pointer from Python"));
         void* storage = ((boost::python::converter::rvalue_from_python_storage<std::string>*)data)->storage.bytes;
         new (storage) std::string(value);
         data->convertible = storage;
     }
     else if(PyUnicode_Check(obj)) {
         boost::python::handle<> utf8(boost::python::allow_null(PyUnicode_AsUTF8String(obj)));
         //MY_CHECK(utf8,translate("Could not convert Python unicode object to UTF8 string"));
         void* storage = ((boost::python::converter::rvalue_from_python_storage<std::string>*)data)->storage.bytes;
         const char* utf8v = PyString_AsString(utf8.get());
         //MY_CHECK(utf8v,translate("Received null string from utf8 string"));
         new (storage) std::string(utf8v);
         data->convertible = storage;
     }
     else {
         throw std::logic_error("Unexpected type for string conversion");
     }
 }
示例#18
0
//when device combobox item is changed, object list needs to be repopulated
void InputSettingsWindow::reloadList() {
  list->clear();
  list->setSortingEnabled(false);
  listItem.reset();

  int index = device->currentIndex();
  if(index < deviceItem.size()) {
    InputGroup &group = *deviceItem[index];
    for(unsigned i = 0; i < group.size(); i++) {
      QTreeWidgetItem *item = new QTreeWidgetItem(list);
      item->setText(0, utf8() << (int)(1000000 + i));
      item->setText(1, group[i]->name);
      item->setText(2, (const char*)group[i]->id);
      listItem.add(item);
    }
  }

  list->setSortingEnabled(true);
  list->sortByColumn(0, Qt::AscendingOrder);  //set default sorting on list change, overriding user setting
  list->resizeColumnToContents(1);  //shrink name column
  syncUi();
}
TEST_F(DictGroupTest, TaiwanPhraseGroupTest) {
  const DictGroupPtr dictGroup(new DictGroup(
      list<DictPtr>{CreateDictForPhrases(), CreateTaiwanPhraseDict()}));
  {
    const auto& entry = dictGroup->Dict::MatchPrefix(utf8("鼠标"));
    EXPECT_EQ(utf8("鼠標"), entry.Get()->GetDefault());
  }
  {
    const auto& entry = dictGroup->Dict::MatchPrefix(utf8("克罗地亚"));
    EXPECT_EQ(utf8("克羅埃西亞"), entry.Get()->GetDefault());
  }
  {
    const auto& matches = dictGroup->Dict::MatchAllPrefixes(utf8("鼠标"));
    EXPECT_EQ(1, matches.size());
    EXPECT_EQ(utf8("鼠標"), matches[0]->GetDefault());
  }
}
示例#20
0
Vector2i Button::preferredSize(NVGcontext *ctx) const {
    nvgFontFace(ctx, "sans-bold");
    float tw = nvgTextBounds(ctx, 0,0, mCaption.c_str(), nullptr, nullptr);
    int fontSize = mFontSize == -1 ? mTheme->mButtonFontSize : mFontSize;
    float iw = 0.0f, ih = fontSize;
    nvgFontSize(ctx, fontSize);

    if (mIcon) {
        if (nvgIsFontIcon(mIcon)) {
            ih *= 1.5f;
            nvgFontFace(ctx, "icons");
            nvgFontSize(ctx, ih);
            iw = nvgTextBounds(ctx, 0, 0, utf8(mIcon).data(), nullptr, nullptr)
                + mSize.y() * 0.15f;
        } else {
            int w, h;
            ih *= 0.9f;
            nvgImageSize(ctx, mIcon, &w, &h);
            iw = w * ih / h;
        }
    }
    return Vector2i((int)(tw + iw) + 20, fontSize + 10);
}
/** Set value of the DOM element. Sets value for elements recognized by get_ctl_type() function. 
 * \param[in] el \b const dom::element&, The element.
 * \param[in] v \b const json::value&, The value.
 **/
  inline void set_value(dom::element& el, const json::value& v )
  {
    switch(get_ctl_type(el))
    {
      case CTL_UNKNOWN:         break;
      case CTL_EDIT:
      case CTL_DECIMAL:
      case CTL_CURRENCY:
      case CTL_PASSWORD:
      case CTL_NUMERIC: 
      case CTL_PROGRESS:        
      case CTL_SLIDER:          
      case CTL_SELECT_SINGLE:   
      case CTL_SELECT_MULTIPLE: 
      case CTL_DD_SELECT:       
      case CTL_TEXTAREA:
      case CTL_DATE:
      case CTL_CALENDAR:
      case CTL_HIDDEN:
      default:
        el.set_value(v);
        break;
      // special cases:
      case CTL_BUTTON:          break;
      case CTL_CHECKBOX:        set_checkbox_bits(el,v); break;
      case CTL_RADIO:           set_radio_index(el,v);  break;
      case CTL_HTMLAREA:        
       {
          aux::w2utf utf8(static_cast<const wchar_t*>(v.get( L"" ))); 
          el.set_html( utf8, utf8.length() );
          //el.update();
        } break;
      case CTL_NO:
        assert(false);
        break;
    }
  }
示例#22
0
HRESULT ScriptShape(
  /*__in*/     HDC hdc,
  /*__inout*/  SCRIPT_CACHE *psc,
  /*__in*/     const WCHAR *pwcChars,
  /*__in*/     int cChars,
  /*__in*/     int cMaxGlyphs,
  /*__inout*/  SCRIPT_ANALYSIS *psa,
  /*__out*/    WORD *pwOutGlyphs,
  /*__out*/    WORD *pwLogClust,
  /*__out*/    SCRIPT_VISATTR *psva,
  /*__out*/    int *pcGlyphs)
{
	if (cMaxGlyphs < cChars)
		return E_OUTOFMEMORY;

	// TODO-Linux: make this more accurate.
	psva->uJustification = 2;
	psva->fClusterStart = 1;
	psva->fDiacritic = 0;
	psva->fZeroWidth = 0;
	psva->fReserved = 0;
	psva->fShapeReserved = 0;

	UnicodeString8 utf8(pwcChars, cChars);
	PangoCharsToGlyph(psc, utf8.c_str(), utf8.size(), cMaxGlyphs, reinterpret_cast<PangoGlyphString**>(pwOutGlyphs), pcGlyphs);

	for(int i = 0; i < cChars; ++i)
	{
		if (psa->fRTL)
			pwLogClust[i] = cChars - i + 1;
		else
			pwLogClust[i] = i;
	}

	return S_OK;
}
示例#23
0
FSEventsWatcher::FSEventsWatcher(QString path) {
  CFStringRef path_to_watch = CFStringCreateWithCString(kCFAllocatorDefault,
                                                        utf8(path).c_str(),
                                                        kCFStringEncodingUTF8);
  CFArrayRef paths_to_watch = CFArrayCreate(NULL, (const void **)&path_to_watch, 1, NULL);

  context_ = new FSEventStreamContext;
  context_->version = 0;
  context_->info = static_cast<void*>(this);
  context_->retain = NULL;
  context_->release = NULL;
  context_->copyDescription = NULL;

  stream_ = FSEventStreamCreate(kCFAllocatorDefault,
                                &FSEventsCallback,
                                context_,
                                paths_to_watch,
                                kFSEventStreamEventIdSinceNow, /* Or a previous event ID */
                                1.0, /* latency in seconds */
                                kFSEventStreamCreateFlagNone);

  FSEventStreamScheduleWithRunLoop(stream_, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
  FSEventStreamStart(stream_);
}
示例#24
0
文件: strings.hpp 项目: go4and/lib
 std::string operator()(const std::wstring & input) const
 {
     return utf8(input);
 }
示例#25
0
void HtmlViewerWindow::show(const char *title, const char *htmlData) {
  document->setHtml(utf8() << htmlData);
  setWindowTitle(title);
  QbWindow::show();
}
示例#26
0
void xhn::wpath_node::search(const wchar_t* path)
{
	path_name = path;
	transform(path_name.begin(), path_name.end(), path_name.begin(), FWCharFormat());
    wstring search_path = path_name;
#if defined(_WIN32) || defined(_WIN64)
	if (search_path.size() && search_path[search_path.size() - 1] != L'\\') {
		search_path += L'\\';
	}
#elif defined(__APPLE__)
    if (search_path.size() && search_path[search_path.size() - 1] != L'/') {
		search_path += L'/';
	}
#else
#    error
#endif
#if defined(_WIN32) || defined(_WIN64)
	wstring tmp = search_path +  L"*";

	struct _wfinddata_t fd;
	long h = _wfindfirst(tmp.c_str(), &fd);
	int ret = 0;
	while (h != -1L && !ret)
	{
		if (StrCmpW(fd.name, L".") != 0 && StrCmpW(fd.name, L"..") != 0)
		{
			wpath_node_ptr child;
#ifdef USE_SMART_PTR
            child = VNEW wpath_node;
#else
            child = GC_ALLOC(wpath_node);
#endif
			child->search((search_path + fd.name).c_str());
			if (fd.attrib == 0x10) {
			    child->is_folder = true;
			}
			child->next = children;
			children = child;
		}
		ret = _wfindnext(h, &fd);
	}
	_findclose(h);
#elif defined(__APPLE__)
    Utf8 utf8(search_path.c_str());
    vector<string> subFolders;
    vector<string> paths;
    GetPaths(((string)utf8).c_str(), subFolders, paths);
    {
        vector<string>::iterator iter = subFolders.begin();
        vector<string>::iterator end = subFolders.end();
        for (; iter != end; iter++) {
            string& subFolder = *iter;
            Unicode uc16(subFolder.c_str());
            wpath_node_ptr child;
#ifdef USE_SMART_PTR
            child = VNEW wpath_node;
#else
            child = GC_ALLOC(wpath_node);
#endif
            child->search(((wstring)uc16).c_str());
            child->is_folder = true;
            child->next = children;
			children = child;
        }
    }
    {
        vector<string>::iterator iter = paths.begin();
        vector<string>::iterator end = paths.end();
        for (; iter != end; iter++) {
            string& path = *iter;
            Unicode uc16(path.c_str());
            wpath_node_ptr child;
#ifdef USE_SMART_PTR
            child = VNEW wpath_node;
#else
            child = GC_ALLOC(wpath_node);
#endif
            child->path_name = uc16;
            child->is_folder = false;
            child->next = children;
			children = child;
        }
    }
#else
#    error
#endif
}
示例#27
0
static nsresult
rdf_BlockingWrite(nsIOutputStream* stream, const nsAString& s)
{
    NS_ConvertUTF16toUTF8 utf8(s);
    return rdf_BlockingWrite(stream, utf8.get(), utf8.Length());
}
示例#28
0
bool InputManager::on_input(SDL_Event *e) {

	// top level input handler
	switch (e->type) {

	case SDL_KEYUP: {
		SDL_Keycode code = reinterpret_cast<SDL_KeyboardEvent *>(e)->keysym.sym;
		Event ev = sdl_key(code, SDL_GetModState());
		this->set_state(ev, false);
		break;
	} // case SDL_KEYUP

	case SDL_KEYDOWN: {
		SDL_Keycode code = reinterpret_cast<SDL_KeyboardEvent *>(e)->keysym.sym;
		this->set_state(sdl_key(code, SDL_GetModState()), true);
		break;
	} // case SDL_KEYDOWN

	case SDL_TEXTINPUT: {
		this->trigger(utf8(e->text.text));
		break;
	} // case SDL_TEXTINPUT

	case SDL_MOUSEBUTTONUP: {
		this->set_relative(false);
		Event ev = sdl_mouse(e->button.button, SDL_GetModState());
		this->set_state(ev, false);
		break;
	} // case SDL_MOUSEBUTTONUP

	case SDL_MOUSEBUTTONDOWN: {

		// TODO: set which buttons
		if (e->button.button == 2) {
			this->set_relative(true);
		}
		Event ev = sdl_mouse(e->button.button, SDL_GetModState());
		this->set_state(ev, true);
		break;
	} // case SDL_MOUSEBUTTONDOWN

	case SDL_MOUSEMOTION: {
		if (this->relative_mode) {
			this->set_motion(e->motion.xrel, e->motion.yrel);
		}
		else {
			this->set_mouse(e->button.x, e->button.y);
		}

		// must occur after setting mouse position
		Event ev(event_class::MOUSE_MOTION, 0, this->get_mod());
		this->trigger(ev);
		break;
	} // case SDL_MOUSEMOTION

	case SDL_MOUSEWHEEL: {
		Event ev = sdl_wheel(e->wheel.y, SDL_GetModState());
		this->trigger(ev);
		break;
	} // case SDL_MOUSEWHEEL

	} // switch (e->type)

	return true;
}
示例#29
0
void object::test<2>()
{
	exception ex_copy(ex);
	ensure_equals("code copy", ex_copy.code(), 2343);
	ensure_equals("what copy", ex_copy.what(), utf8(L"exception message"));
}
示例#30
0
void object::test<1>()
{
	ensure_equals("code", ex.code(), 2343);
	ensure_equals("what", ex.what(), utf8(L"exception message"));
}