LRESULT CommandDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { updateContext(); if(wID == IDOK) { TCHAR buf[256]; if((type != 0) && ((ctrlName.GetWindowTextLength() == 0) || (ctrlCommand.GetWindowTextLength()== 0))) { MessageBox(_T("Name and command must not be empty")); return 0; } #define GET_TEXT(id, var) \ GetDlgItemText(id, buf, 256); \ var = buf; GET_TEXT(IDC_NAME, name); GET_TEXT(IDC_HUB, hub); if(type != 0) { type = (ctrlOnce.GetCheck() == BST_CHECKED) ? 2 : 1; } SettingsManager::getInstance()->set(SettingsManager::OPEN_USER_CMD_HELP, IsDlgButtonChecked(IDC_USER_CMD_OPEN_HELP) == BST_CHECKED); } EndDialog(wID); return 0; }
LRESULT ADLSProperties::OnRegExpTester(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { TCHAR buf[1024]; tstring exp, text; GET_TEXT(IDC_SEARCH_STRING, exp); GET_TEXT(IDC_TEST_STRING, text); MessageBox(Text::toT(matchRegExp(Text::fromT(exp), Text::fromT(text))).c_str(), CTSTRING(REGEXP_TESTER), MB_OK); return 0; }
void RangesPage::write() { PropPage::write((HWND)*this, items); g_settings->set(SettingsManager::IP_GUARD_IS_DENY_ALL, !ctrlPolicy.GetCurSel()); if (BOOLSETTING(ENABLE_IPGUARD)) { tstring l_Guardbuf; GET_TEXT(IDC_FLYLINK_GUARD_IP, l_Guardbuf); const string l_newG = Text::fromT(l_Guardbuf); if (l_newG != m_IPGuard || m_isEnabledIPGuard == false) // Изменился текст или включили галку - прогрузимся? { try { { File fout(m_IPGuardPATH, File::WRITE, File::CREATE | File::TRUNCATE); fout.write(l_newG); } IpGuard::load(); } catch (const FileException&) { return; } } } else { IpGuard::clear(); } tstring l_Trustbuf; GET_TEXT(IDC_FLYLINK_TRUST_IP, l_Trustbuf); const string l_newT = Text::fromT(l_Trustbuf); if (l_newT != m_IPFilter) { try { File fout(m_IPFilterPATH, File::WRITE, File::CREATE | File::TRUNCATE); fout.write(l_newT); fout.close(); #ifdef PPA_INCLUDE_IPFILTER PGLoader::load(l_newT); #endif } catch (const FileException&) { return; } } // TODO - запись tstring l_ManualP2PGuard; GET_TEXT(IDC_FLYLINK_MANUAL_P2P_GUARD_IP_LIST, l_ManualP2PGuard); //const string l_new = Text::fromT(l_ManualP2PGuard); }
void CreateGameScreen::SetWidgetTexts() { _buttonStart->setCaption(GET_TEXT("ButtonStart","Gui.MainMenu.CreateGameScreen")); _buttonReturn->setCaption(GET_TEXT("ButtonReturn","Gui.MainMenu.CreateGameScreen")); _labelMaps->setCaption(GET_TEXT("LabelMapList","Gui.MainMenu.CreateGameScreen")); _labelPreview->setCaption(GET_TEXT("LabelMapPreview","Gui.MainMenu.CreateGameScreen")); _labelPlayers->setCaption(GET_TEXT("LabelPlayers","Gui.MainMenu.CreateGameScreen")); _labelSettings->setCaption(GET_TEXT("LabelSettings","Gui.MainMenu.CreateGameScreen")); _labelGameMode->setCaption(GET_TEXT("LabelGameMode","Gui.MainMenu.CreateGameScreen")); _labelStartLocMode->setCaption(GET_TEXT("LabelStartLocMode","Gui.MainMenu.CreateGameScreen")); _labelVisibilityMode->setCaption(GET_TEXT("LabelVisibilityMode","Gui.MainMenu.CreateGameScreen")); _labelResourcesMode->setCaption(GET_TEXT("LabelResourcesMode","Gui.MainMenu.CreateGameScreen")); }
C3DOTextureHandler::UnitTexture* C3DOParser::GetTexture(S3DOPiece* obj, _Primitive* p, const std::vector<unsigned char>& fileBuf) const { std::string texName; if (p->OffsetToTextureName != 0) { int unused; texName = GET_TEXT(p->OffsetToTextureName, fileBuf, unused); StringToLowerInPlace(texName); if (teamtex.find(texName) == teamtex.end()) { texName += "00"; } } else { texName = "ta_color" + IntToString(p->PaletteEntry, "%i"); } auto tex = texturehandler3DO->Get3DOTexture(texName); if (tex != nullptr) return tex; LOG_L(L_WARNING, "[%s] unknown 3DO texture \"%s\" for piece \"%s\"", __FUNCTION__, texName.c_str(), obj->name.c_str()); // assign a dummy texture (the entire atlas) return texturehandler3DO->Get3DOTexture("___dummy___"); }
LRESULT GeneralPage::onTextChanged(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { tstring buf; GET_TEXT(wID, buf); tstring old = buf; // TODO: move to Text and cleanup. if (!buf.empty()) { // Strip '$', '|', '<', '>' and ' ' from text TCHAR *b = &buf[0], *f = &buf[0], c; while ((c = *b++) != '\0') { if (c != '$' && c != '|' && (wID == IDC_DESCRIPTION || c != ' ') && ((wID != IDC_NICK && wID != IDC_DESCRIPTION && wID != IDC_SETTINGS_EMAIL) || (c != '<' && c != '>'))) *f++ = c; } *f = '\0'; } if (old != buf) { // Something changed; update window text without changing cursor pos CEdit tmp; tmp.Attach(hWndCtl); int start, end; tmp.GetSel(start, end); tmp.SetWindowText(buf.data()); if (start > 0) start--; if (end > 0) end--; tmp.SetSel(start, end); tmp.Detach(); } return TRUE; }
gboolean callback_find_timeout(char *text) { if (!g_strcmp0(text, GET_TEXT())) dwb_update_search(); g_free(text); return false; }
/* Synchronises the options data with what is held in the gui structures (the gui holds the "latest" data, so this is copied into here) This should be used when the application wants to store the settings on disk i.e save them in the configuration file or when the application wants to use the new settings with the screamer system since it will not ask the gui for this information, when the gui structures are updated (this is the only way the user can alter the configuration, apart from hand editing the configuration file) any attempt to run screamer must be done with the new configuration, so when the options are updated and ok'd they need to be synchronised with the backend options structures, so screamer can use those changes in the options */ void Options::Update(void) { #define GET_TEXT(name) gtk_entry_get_text(GTK_ENTRY(lookup_widget(OptionsWindow,name))) #define GET_NUM(name) atoi(gtk_entry_get_text(GTK_ENTRY(lookup_widget(OptionsWindow,name)))) #define GET_SPIN(name) gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lookup_widget(OptionsWindow,name))) #define GET_TOGGLE(name) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(OptionsWindow,name))) ScreamerName = GET_TEXT("ScreamerName"); ScreamerCPUNumbers = GET_NUM("ScreamerCPUNumbers"); NumberFrames = GET_SPIN("NumberFrames"); CommandDirectory = GET_TEXT("CommandDirectory"); ScreamerExecutable = GET_TEXT("ScreamerExecutable"); ScreamerConfigDir = GET_TEXT("ScreamerConfigDir"); ScreamerPriority = GET_SPIN("ScreamerPriority"); FindScreamerInterval = GET_SPIN("ScreamerInterval"); WineCmd = GET_TEXT("WineCmd"); }
Datum metaphone(PG_FUNCTION_ARGS) { int reqlen; char *str_i; size_t str_i_len; char *metaph; text *result_text; int retval; str_i = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(PG_GETARG_TEXT_P(0)))); str_i_len = strlen(str_i); /* return an empty string if we receive one */ if (!(str_i_len > 0)) PG_RETURN_TEXT_P(GET_TEXT("")); if (str_i_len > MAX_METAPHONE_STRLEN) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("argument exceeds the maximum length of %d bytes", MAX_METAPHONE_STRLEN))); if (!(str_i_len > 0)) ereport(ERROR, (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING), errmsg("argument is empty string"))); reqlen = PG_GETARG_INT32(1); if (reqlen > MAX_METAPHONE_STRLEN) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("output exceeds the maximum length of %d bytes", MAX_METAPHONE_STRLEN))); if (!(reqlen > 0)) ereport(ERROR, (errcode(ERRCODE_ZERO_LENGTH_CHARACTER_STRING), errmsg("output cannot be empty string"))); retval = _metaphone(str_i, reqlen, &metaph); if (retval == META_SUCCESS) { result_text = DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(metaph))); PG_RETURN_TEXT_P(result_text); } else { /* internal error */ elog(ERROR, "metaphone: failure"); /* * Keep the compiler quiet */ PG_RETURN_NULL(); } }
LRESULT DownloadPage::onClickedBrowseBT(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { tstring xbt; GET_TEXT(IDC_BT_MAGNET_HANDLER, xbt); if (WinUtil::browseFile(xbt, m_hWnd, false, xbt, types, defExt) == IDOK) { SetDlgItemText(IDC_BT_MAGNET_HANDLER, xbt.c_str()); } return 0; }
void ToolbarPage::BrowseForPic(int DLGITEM) { tstring x; GET_TEXT(DLGITEM, x); if (WinUtil::browseFile(x, m_hWnd, false) == IDOK) { SetDlgItemText(DLGITEM, x.c_str()); } }
/* dwb_entry_keyrelease_cb {{{*/ gboolean callback_entry_insert_text(GtkWidget* entry, char *new_text, int length, gpointer position) { const char *text = GET_TEXT(); int newlen = strlen(text) + length + 1; char buffer[newlen]; snprintf(buffer, sizeof(buffer), "%s%s", text, new_text); if (dwb.state.mode == QUICK_MARK_OPEN) return dwb_update_find_quickmark(buffer); return false; }
LRESULT CommandDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { updateContext(); if (wID == IDOK) { if (type != 0 && (ctrlName.GetWindowTextLength() == 0 || ctrlCommand.GetWindowTextLength() == 0)) { MessageBox(CTSTRING(NAME_COMMAND_EMPTY)); return 0; } GET_TEXT(IDC_NAME, name); GET_TEXT(IDC_HUB, hub); if (type != 0) { type = (ctrlOnce.GetCheck() == BST_CHECKED) ? 2 : 1; } } EndDialog(wID); return 0; }
LRESULT LimitEditDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if (wID == IDOK) { // Update search tstring buf; GET_TEXT(IDC_SPEEDLIMITDLG_EDIT, buf); m_limit = Util::toInt(buf.data()); // if (m_limit < 0) m_limit = 10; // if (m_limit > m_max) m_limit = m_max; } EndDialog(wID); return FALSE; }
S3DOPiece* C3DOParser::LoadPiece(S3DModel* model, int pos, S3DOPiece* parent, int* numobj, const std::vector<unsigned char>& fileBuf) { (*numobj)++; _3DObject me; int curOffset = pos; READ_3DOBJECT(me, fileBuf, curOffset); std::string s = GET_TEXT(me.OffsetToObjectName, fileBuf, curOffset); StringToLowerInPlace(s); S3DOPiece* piece = new S3DOPiece(); piece->name = s; piece->parent = parent; piece->offset.x = me.XFromParent * SCALE_FACTOR_3DO; piece->offset.y = me.YFromParent * SCALE_FACTOR_3DO; piece->offset.z = -me.ZFromParent * SCALE_FACTOR_3DO; piece->goffset = piece->offset + ((parent != NULL)? parent->goffset: ZeroVector); GetVertexes(&me, piece, fileBuf); GetPrimitives(piece, me.OffsetToPrimitiveArray, me.NumberOfPrimitives, ((pos == 0)? me.SelectionPrimitive: -1), fileBuf); piece->CalcNormals(); piece->SetMinMaxExtends(); piece->emitPos = ZeroVector; piece->emitDir = FwdVector; if (piece->vertexPos.size() >= 2) { piece->emitPos = piece->vertexPos[0]; piece->emitDir = piece->vertexPos[1] - piece->vertexPos[0]; } else if (piece->vertexPos.size() == 1) { piece->emitDir = piece->vertexPos[0]; } model->mins = float3::min(piece->goffset + piece->mins, model->mins); model->maxs = float3::max(piece->goffset + piece->maxs, model->maxs); piece->SetCollisionVolume(CollisionVolume("box", piece->maxs - piece->mins, (piece->maxs + piece->mins) * 0.5f)); if (me.OffsetToChildObject > 0) { piece->children.push_back(LoadPiece(model, me.OffsetToChildObject, piece, numobj, fileBuf)); } if (me.OffsetToSiblingObject > 0) { parent->children.push_back(LoadPiece(model, me.OffsetToSiblingObject, parent, numobj, fileBuf)); } return piece; }
LRESULT NetworkPage::OnEnKillfocusExternalIp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { tstring l_externalIPW; GET_TEXT(IDC_EXTERNAL_IP, l_externalIPW); const auto l_externalIP = Text::fromT(l_externalIPW); if (!l_externalIP.empty()) { boost::system::error_code ec; const auto l_ip = boost::asio::ip::address_v4::from_string(l_externalIP, ec); // TODO - убрать count и попробовать без буста - http://stackoverflow.com/questions/318236/how-do-you-validate-that-a-string-is-a-valid-ip-address-in-c? if (ec || std::count(l_externalIP.cbegin(), l_externalIP.cend(), '.') != 3) { const auto l_last_ip = SETTING(EXTERNAL_IP); ::MessageBox(NULL, Text::toT("Error IP = " + l_externalIP + ", restore last valid IP = " + l_last_ip).c_str(), _T("IP Error!"), MB_OK | MB_ICONERROR); ::SetWindowText(GetDlgItem(IDC_EXTERNAL_IP), Text::toT(SETTING(EXTERNAL_IP)).c_str()); } } return 0; }
/* entry_history_back(GList **list, GList **last) {{{ */ DwbStatus entry_history_back(GList **list, GList **last) { char *text = NULL; if (*list == NULL) return STATUS_ERROR; GList *next; if (*last == NULL) { const char *text = GET_TEXT(); if (text && *text) { for (GList *l = *list; l; l=l->next) { if (strstr(l->data, text)) { s_filterlist = g_list_prepend(s_filterlist, l->data); } } if (s_filterlist) s_filterlist = g_list_reverse(s_filterlist); } else s_filterlist = g_list_copy(*list); next = s_filterlist; s_store = g_strdup(text); } else if ((*last)->next != NULL) next = (*last)->next; else return STATUS_OK; *last = next; if (next) text = next->data; if (text && *text) { entry_set_text(text); } return STATUS_OK; } /* }}} */
gboolean callback_entry_key_release(GtkWidget* entry, GdkEventKey *e) { if (dwb.state.mode == HINT_MODE) { if (e->keyval == GDK_KEY_BackSpace) return dwb_update_hints(e); } if (dwb.state.mode == FIND_MODE) { if (dwb.misc.find_delay > 0) g_timeout_add(dwb.misc.find_delay, (GSourceFunc)callback_find_timeout, g_strdup(GET_TEXT())); else dwb_update_search(); } return false; }/*}}}*/