void TextCtrl_Float::replenish() { if(editor->hexMode) { stringbuf buffer; ostream os (&buffer); os << hex << setw(8) << setfill('0') << uppercase << *(uint32_t*)container.back(); ChangeValue(buffer.str()); } else { if(editor->accurateFloats) { ChangeValue(lexical_cast<string>(*(float*)container.back())); } else { stringbuf buffer; ostream os (&buffer); if(*(int32_t*)container.back() == 0x7F7FFFFF) os << "max"; else if(*(int32_t*)container.back() == 0x00800000) os << "min"; else os << *(float*)container.back(); ChangeValue(buffer.str()); } } if(!LinkedBoxes.empty()) for(auto it = LinkedBoxes.begin(); it != LinkedBoxes.end(); ++it) { (*it)->SetChoice(*(float*)container.back()); (*it)->EnableCtrl(true); } }
int TextCtrl_Float::SaveEdits(bool forced) { if(editor->hexMode || container.empty()) return 1; if(editedFileId != editor->loadedFileId) return 1; string value = string(GetValue().mb_str()); if(value.size() > 0) { short batchMode = 0; if(value[0] == 'b' && !BatchCheck(value, batchMode)) { editor->post(BATCHWARNING, BWTITLE, NULL); return 1; } try { float casted; if(value == "max") casted = 3.40282347e+38; else if(value == "min") casted = 1.17549435e-38; else casted = lexical_cast<float>(value); if(batchMode > 0) { for(auto &pointer: container) { ++edits; switch(batchMode) { case 1: *(float*)pointer += casted; break; case 2: *(float*)pointer -= casted; break; case 3: *(float*)pointer *= casted; break; case 4: *(float*)pointer /= casted; break; } } ChangeValue(lexical_cast<string>(*(float*)container.back())); HandleResults(*(float*)container.back()); return 0; } if(*(float*)container.back() != casted || forced) { for(auto &pointer: container) { ++edits; *(float*)pointer = casted; } HandleResults(casted); return 0; } } catch(bad_lexical_cast e) { editor->post("Please enter a valid floating point number", IETITLE, this); return 2; } } else { ChangeValue(lexical_cast<string>(*(float*)container.back())); } return 1; }
int TextCtrl_UShort::SaveEdits(bool forced) { if(editor->hexMode || container.empty()) return 1; if(editedFileId != editor->loadedFileId) return 1; string value = string(GetValue().mb_str()); if(value.size() > 0) { short batchMode = 0; if(value[0] == 'b' && !BatchCheck(value, batchMode)) { editor->post(BATCHWARNING, BWTITLE, NULL); return 1; } try { uint16_t casted = lexical_cast<uint16_t>(value); if(batchMode > 0) { for(auto &pointer: container) { ++edits; switch(batchMode) { case 1: *(uint16_t*)pointer += casted; break; case 2: *(uint16_t*)pointer -= casted; break; case 3: *(uint16_t*)pointer *= casted; break; case 4: *(uint16_t*)pointer /= casted; break; case 5: *(uint16_t*)pointer %= casted; break; } } ChangeValue(lexical_cast<string>(*(uint16_t*)container.back())); HandleResults(*(uint16_t*)container.back()); return 0; } if(*(uint16_t*)container.back() != casted || forced) { for(auto &pointer: container) { ++edits; *(uint16_t*)pointer = casted; } HandleResults(casted); return 0; } } catch(bad_lexical_cast e) { editor->post("Please enter a number from 0 to 65 535", IETITLE, this); return 2; } } else { ChangeValue(lexical_cast<string>(*(uint16_t*)container.back())); } return 1; }
bool wxSpinButton::PerformAction(const wxControlAction& action, long numArg, const wxString& strArg) { if ( action == wxACTION_SPIN_INC ) ChangeValue(+1); else if ( action == wxACTION_SPIN_DEC ) ChangeValue(-1); else return wxControl::PerformAction(action, numArg, strArg); return true; }
// 主程序 int main(int argc, char* argv[]) { // Get command line optins getoptions(argc, argv); // Load temp images to be matched IplImage* imgTemp = cvLoadImage(globalArgs.inputFiles[0]); // Get image from srcs[] which match temp image, and set ROI on it int nMatch; IplImage* imgSrc; if ((imgSrc = GetSourceImage(imgTemp, &nMatch)) == NULL) { if (globalArgs.verbosity) printf("[ERROR] Cannot match any temps. Abort.\n"); return EXIT_FAILURE; } // Calculate match area of temp image int nMatchAreaSize = MatchAreaCount(imgSrc, imgTemp); // Calculate the change value int nChangeValue = ChangeValue(nMatchAreaSize, nMatch); if (globalArgs.verbosity) { printf( "MatchValue=%d YUAN\nMatchAreaRate=%f\nChangeValue = %d YUAN\n", full_value[nMatch], MatchAreaRate(nMatchAreaSize, nMatch), nChangeValue); } printf("%d", nChangeValue); cvReleaseImage(&imgSrc); cvReleaseImage(&imgTemp); return EXIT_SUCCESS; }
void Arpege::Interface(int Num, int Value) { switch(Num) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: lastChangeValue = Num; ChangeValue( Num , Value , 0); break; case 10: lastChangeValue = CHGT_PAGE; if ( ChangePage(Value, 0) ) mxAD.PageChanged(); break; case 11: lastChangeValue = CHGT_M1; ChangeM1(Value, 0); break; case 12: lastChangeValue = CHGT_M2; ChangeM2(Value, 0); break; case 13: lastChangeValue = CHGT_M3; ChangeM3(Value, 0); break; case 32: ChangeS1S5(Value); break; case 33: ChangePAT(Value); break; } }
void wxOwnerDrawnComboBox::DoDeleteOneItem(unsigned int n) { wxCHECK_RET( IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::Delete") ); if ( GetSelection() == (int) n ) ChangeValue(wxEmptyString); GetVListBoxComboPopup()->Delete(n); }
void SetDescriptiveText(const wxString& text) { if ( GetValue() == m_descriptiveText ) { ChangeValue(wxEmptyString); } m_descriptiveText = text; }
void TextCtrl_UShort::replenish() { if(editor->hexMode) { stringbuf buffer; ostream os (&buffer); os << hex << setw(4) << setfill('0') << uppercase << *(uint16_t*)container.back(); ChangeValue(buffer.str()); } else { ChangeValue(lexical_cast<string>(*(uint16_t*)container.back())); } if(!LinkedBoxes.empty()) for(auto it = LinkedBoxes.begin(); it != LinkedBoxes.end(); ++it) { (*it)->SetChoice(*(uint16_t*)container.back()); (*it)->EnableCtrl(true); } }
void wxMoTimelineBandCtrl::SetValue( int value ) { ChangeValue(value); wxCommandEvent event( wxEVT_MO_TIMELINEBAND, m_windowId ); event.SetInt( GetValue() ); event.SetEventObject( this ); ProcessEvent(event ); }
void moTimelineRuler::SetValue( int value ) { ChangeValue(value); wxCommandEvent event( MO_EVT_DIRECTOR_TIMELINERULER, m_windowId ); event.SetInt( GetValue() ); event.SetEventObject( this ); ProcessEvent(event ); }
int TextCtrl_String::SaveEdits(bool forced) // This may crash the program. { if(container.empty()) return 1; if(editedFileId != editor->loadedFileId) return 1; string value = string(GetValue().mb_str()); if(*(string*)container.back() != value || forced) // Has been changed { // Broken, strings like "C-Bonus" are interpret as batch mode 2. /*if(value.size() > 2) { short batchMode = 0; BatchCheck(value, batchMode); if(batchMode > 0) { for(auto &pointer: container) { ++edits; string vasili = *(string*)pointer; switch(batchMode) { case 1: vasili += value; vasili = vasili.substr(0, maxSize); break; case 2: vasili = vasili.substr(0, vasili.size() - lexical_cast<int>(value)); break; } *(string*)pointer = vasili; } ChangeValue(*(string*)container.back()); HandleResults(0); return 0; } }*/ if(value.size() <= maxSize) { for(auto &pointer: container) { ++edits; *(string*)pointer = value; // replenish data field } } else { value = value.substr(0, maxSize); for(auto &pointer: container) { ++edits; *(string*)pointer = value; } ChangeValue(*(string*)container.back()); } HandleResults(0); return 0; } return 1; }
bool COptionsPage::SetText(int id, const wxString& text, bool& failure) { auto pTextCtrl = dynamic_cast<wxTextCtrl*>(FindWindow(id)); if (!pTextCtrl) { failure = true; return false; } pTextCtrl->ChangeValue(text); return true; }
bool TBSelectList::OnEvent(const TBWidgetEvent &ev) { if (ev.type == EVENT_TYPE_CLICK && ev.target->GetParent() == m_layout.GetContentRoot()) { // SetValue (EVENT_TYPE_CHANGED) might cause something to delete this (f.ex closing // the dropdown menu. We want to sent another event, so ensure we're still around. TBWidgetSafePointer this_widget(this); int index = ev.target->data.GetInt(); SetValue(index); // If we're still around, invoke the click event too. if (this_widget.Get()) { TBSelectList *target_list = this; // If the parent window is a TBMenuWindow, we will iterate up the event destination // chain to find the top TBMenuWindow and invoke the event there. // That way events in submenus will reach the caller properly, and seem like it was // invoked on the top menu. TBWindow *window = GetParentWindow(); while (TBMenuWindow *menu_win = TBSafeCast<TBMenuWindow>(window)) { target_list = menu_win->GetList(); window = menu_win->GetEventDestination()->GetParentWindow(); } // Invoke the click event on the target list TBWidgetEvent ev(EVENT_TYPE_CLICK); if (TBWidget *widget = GetItemWidget(m_value)) ev.ref_id = widget->GetID(); target_list->InvokeEvent(ev); } return true; } else if (ev.type == EVENT_TYPE_KEY_DOWN) { if (ChangeValue(ev.special_key)) return true; // Give the scroll container a chance to handle the key so it may // scroll. This matters if the list itself is focused instead of // some child view of any select item (since that would have passed // the container already) if (GetScrollContainer()->OnEvent(ev)) return true; } return false; }
void COptionsPage::SetTextFromOption(int ctrlId, int optionId, bool& failure) { if (ctrlId == -1) { failure = true; return; } auto pTextCtrl = dynamic_cast<wxTextCtrl*>(FindWindow(ctrlId)); if (!pTextCtrl) { failure = true; return; } const wxString& text = m_pOptions->GetOption(optionId); pTextCtrl->ChangeValue(text); }
void NumberTextCtrl::OnEnterText(wxCommandEvent& evt) { printf("%d\n", (int)GetInsertionPoint()); wxString text = GetValue(); wxString ntext; int p = GetInsertionPoint(); if(text.size() && text[0] == wxT('-')) ntext.Append(wxT('-')); for(size_t s = 0; s < text.size(); ++s) { if(text[s] >= '0' && text[s] <= '9') ntext.Append(text[s]); else --p; } // Check that value is in range long v; if(ntext.ToLong(&v)) { if(v < minval) v = minval; else if(v > maxval) v = maxval; ntext.clear(); ntext << v; } else { // Invalid input, set to "" ntext = wxT(""); } // Check if there was any change if(ntext != text) { // User input was invalid, change the text to the cleaned one. // ChangeValue doesn't generate events ChangeValue(ntext); SetInsertionPoint(p); } }
void wxTimeTextCtrl::OnKillFocus(wxFocusEvent& event) { wxString value = GetValue().Trim(false).Trim(true); int minutesSep = value.Find(":"); if(-1 != minutesSep) { double minutes; value.SubString(0, minutesSep).Trim(false).Trim(true).ToDouble(&minutes); value.SubString(minutesSep+1, value.Length()).Trim(false).Trim(true).ToDouble(&m_time); m_time += minutes * 60.0; } else value.Trim(false).Trim(true).ToDouble(&m_time); int nDecimalPlaces = 0; ChangeValue(wxString::Format(wxString::Format("%d:%%0%d.%df", (int)(m_time/60), nDecimalPlaces == 0 ? 2 : (nDecimalPlaces + 3), nDecimalPlaces), m_time - 60*(int)(m_time/60))); }
void CProtocolDemo::Polling() { // qDebug()<<__func__<<QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"); QMap<unsigned int ,CDemoPointNode *>::iterator iterator; for (iterator = m_PointNode.m_PointNodeMap.begin(); iterator != m_PointNode.m_PointNodeMap.end(); ++iterator) { if (ABS(GetSysAbsTime()-iterator.value()->m_nStorageMoment) >= iterator.value()->m_nPeriodicStorage) { // qDebug()<<__func__<<"AAAAAAAA"<<iterator.value()->m_nStorageMoment<<iterator.value()->m_nPeriodicStorage; iterator.value()->m_nStorageMoment = GetSysAbsTime(); for (int i = 0; i < iterator.value()->m_PointList.count(); ++i) { // qDebug()<<__func__<<"bbbbbbbbbb"<<iterator.value()->m_PointList.at(i)->m_strRTDBName; ChangeValue(iterator.value()->m_PointList.at(i)); } } } }
void Arpege::Encoder(byte Value) { switch(lastChangeValue) { case CHGT_PAGE: ChangePage(0, Value); break; case CHGT_M1: ChangeM1(0, Value); break; case CHGT_M2: ChangeM2(0, Value); break; case CHGT_M3: ChangeM3(0, Value); break; default : ChangeValue(lastChangeValue,0, Value ); break; } }
void ScreenSetTime::MenuLeft( PlayerNumber pn ) { ChangeValue( -1 ); }
void ScreenSetTime::MenuRight( const InputEventPlus &input ) { ChangeValue( +1 ); }
void wxBitmapComboBox::RecreateControl() { // // Recreate control so that WM_MEASUREITEM gets called again. // Can't use CBS_OWNERDRAWVARIABLE because it has odd // mouse-wheel behaviour. // wxString value = GetValue(); wxPoint pos = GetPosition(); wxSize size = GetSize(); size.y = GetBestSize().y; const wxArrayString strings = GetStrings(); const unsigned numItems = strings.size(); unsigned i; // Save the client data pointers before clearing the control, if any. const wxClientDataType clientDataType = GetClientDataType(); wxVector<wxClientData*> objectClientData; wxVector<void*> voidClientData; switch ( clientDataType ) { case wxClientData_None: break; case wxClientData_Object: objectClientData.reserve(numItems); for ( i = 0; i < numItems; ++i ) objectClientData.push_back(GetClientObject(i)); break; case wxClientData_Void: voidClientData.reserve(numItems); for ( i = 0; i < numItems; ++i ) voidClientData.push_back(GetClientData(i)); break; } wxComboBox::DoClear(); HWND hwnd = GetHwnd(); DissociateHandle(); ::DestroyWindow(hwnd); if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) ) return; // initialize the controls contents for ( i = 0; i < numItems; i++ ) { wxComboBox::Append(strings[i]); if ( !objectClientData.empty() ) SetClientObject(i, objectClientData[i]); else if ( !voidClientData.empty() ) SetClientData(i, voidClientData[i]); } // and make sure it has the same attributes as before if ( m_hasFont ) { // calling SetFont(m_font) would do nothing as the code would // notice that the font didn't change, so force it to believe // that it did wxFont font = m_font; m_font = wxNullFont; SetFont(font); } if ( m_hasFgCol ) { wxColour colFg = m_foregroundColour; m_foregroundColour = wxNullColour; SetForegroundColour(colFg); } if ( m_hasBgCol ) { wxColour colBg = m_backgroundColour; m_backgroundColour = wxNullColour; SetBackgroundColour(colBg); } else { SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); } ::SendMessage(GetHwnd(), CB_SETITEMHEIGHT, 0, MeasureItem(0)); // Revert the old string value if ( !HasFlag(wxCB_READONLY) ) ChangeValue(value); }
void ScreenSetTime::MenuRight( PlayerNumber pn ) { ChangeValue( +1 ); }
/* NumberTextCtrl::onChanged * Called when the value is changed *******************************************************************/ void NumberTextCtrl::onChanged(wxCommandEvent& e) { string new_value = GetValue(); // Check if valid // Can begin with '+', '++', '-' or '--', rest has to be numeric bool num = false; bool valid = true; int plus = 0; int minus = 0; int decimal = 0; for (unsigned a = 0; a < new_value.size(); a++) { // Check for number if (new_value.at(a) >= '0' && new_value.at(a) <= '9') { num = true; continue; } // Check for + if (new_value.at(a) == '+') { if (num || plus == 2 || minus > 0) { // We've had a number, '-' or 2 '+' already, invalid valid = false; break; } else plus++; } // Check for - else if (new_value.at(a) == '-') { if (num || minus == 2 || plus > 0) { // We've had a number, '+' or 2 '-' already, invalid valid = false; break; } else minus++; } // Check for . else if (new_value.at(a) == '.') { if (!num || decimal > 0) { // We've already had a decimal, or no numbers yet, invalid valid = false; break; } else decimal++; } } // If invalid revert to previous value if (!valid) { ChangeValue(last_value); SetInsertionPoint(last_point); } else { last_value = new_value; last_point = GetInsertionPoint(); e.Skip(); } }
void Test(WatchedPtr<Integer> wB) { printf("B has been set to "); ChangeValue(wB); }
/* NumberTextCtrl::setDecNumber * Sets the text control (decimal) value to [num] *******************************************************************/ void NumberTextCtrl::setDecNumber(double num) { ChangeValue(S_FMT("%1.3f", num)); }
/* NumberTextCtrl::setNumber * Sets the text control value to [num] *******************************************************************/ void NumberTextCtrl::setNumber(int num) { ChangeValue(S_FMT("%d", num)); }
void CFT_ReadDlg::DispFT() { m_RWRIST_Fz = theApp.m_pSharedMemory->RWRIST_Fz; m_RWRIST_Mx = theApp.m_pSharedMemory->RWRIST_Mx; m_RWRIST_My = theApp.m_pSharedMemory->RWRIST_My; m_LFOOT_Fz = theApp.m_pSharedMemory->LFOOT_Fz; m_LFOOT_Mx = theApp.m_pSharedMemory->LFOOT_Mx; m_LFOOT_My = theApp.m_pSharedMemory->LFOOT_My; m_LWRIST_Fz = theApp.m_pSharedMemory->LWRIST_Fz; m_LWRIST_Mx = theApp.m_pSharedMemory->LWRIST_Mx; m_LWRIST_My = theApp.m_pSharedMemory->LWRIST_My; m_RFOOT_Fz = theApp.m_pSharedMemory->RFOOT_Fz; m_RFOOT_Mx = theApp.m_pSharedMemory->RFOOT_Mx; m_RFOOT_My = theApp.m_pSharedMemory->RFOOT_My; m_NM_RFOOT_Mx = ChangeValue(theApp.m_pSharedMemory->NM_RFOOT_Mx); m_NM_RFOOT_My = ChangeValue(theApp.m_pSharedMemory->NM_RFOOT_My); m_N_RFOOT_Fz = ChangeValue(theApp.m_pSharedMemory->N_RFOOT_Fz); m_NM_LFOOT_Mx = ChangeValue(theApp.m_pSharedMemory->NM_LFOOT_Mx); m_NM_LFOOT_My = ChangeValue(theApp.m_pSharedMemory->NM_LFOOT_My); m_N_LFOOT_Fz = ChangeValue(theApp.m_pSharedMemory->N_LFOOT_Fz); m_NM_RWRIST_Mx = ChangeValue(theApp.m_pSharedMemory->NM_RWRIST_Mx); m_NM_RWRIST_My = ChangeValue(theApp.m_pSharedMemory->NM_RWRIST_My); m_N_RWRIST_Fz = ChangeValue(theApp.m_pSharedMemory->N_RWRIST_Fz); m_NM_LWRIST_Mx = ChangeValue(theApp.m_pSharedMemory->NM_LWRIST_Mx); m_NM_LWRIST_My = ChangeValue(theApp.m_pSharedMemory->NM_LWRIST_My); m_N_LWRIST_Fz = ChangeValue(theApp.m_pSharedMemory->N_LWRIST_Fz); m_Xzmp = theApp.m_pSharedMemory->Xzmp; m_Yzmp = theApp.m_pSharedMemory->Yzmp; m_RXzmp = theApp.m_pSharedMemory->RXzmp; m_RYzmp = theApp.m_pSharedMemory->RYzmp; m_LXzmp = theApp.m_pSharedMemory->LXzmp; m_LYzmp = theApp.m_pSharedMemory->LYzmp; UpdateData(FALSE); }
void ShortcutCtrl::SetKey(const wxString& binding) { m_binding = binding; const tmKey key(binding); ChangeValue(key.shortcut); }
void ScreenSetTime::MenuLeft( const InputEventPlus &input ) { ChangeValue( -1 ); }