void ProsodyDisplay::OnMenu(wxCommandEvent& event) {//=============================================== int id; int value; PHONEME_LIST *p; id = event.GetId(); p = &phlist[selected_ph]; if((id & 0xf00) == 0x100) { // selected a pitch envelope p->env = id - 0x100; } switch(id) { case 2: value = wxGetNumberFromUser(_T(""),_T("Amplitude"),_T(""),p->amp,0,40); if(value >= 0) p->amp = value; break; case 3: value = wxGetNumberFromUser(_T(""),_T("Length"),_T(""),p->length,1,500); if(value >= 0) p->length = value; break; case 4: MakeWave2(phlist,numph); break; } SelectPh(selected_ph); Refresh(); }
void Edit::OnGoto (wxCommandEvent &WXUNUSED(event)) { const int lastLine = LineFromPosition(GetLastPosition()); long line = wxGetNumberFromUser(wxT(""), wxT("Goto line:"), wxT("Goto Line"), 1, 1, 1000000, this); if(line <= lastLine) { GotoLine(line - 1); } }
void MyFrame::OnSetStatusField(wxCommandEvent& WXUNUSED(event)) { wxStatusBar *sb = GetStatusBar(); if (!sb) return; long rc = wxGetNumberFromUser ( "Configure the field index to be used by the set, push " "and pop text commands in the menu.\n" "\n" "0 corresponds to the first field, 1 to the second one " "and so on.", "Field &index:", SAMPLE_DIALOGS_TITLE, m_field, 0, sb->GetFieldsCount() - 1, NULL ); if ( rc == -1 ) return; m_field = rc; wxLogStatus("Status bar text will be set for field #%d", m_field); }
void SettingsAudioOutput::OnOutputProperties(wxCommandEvent& event) { wxTreeItemId selection = m_AudioOutput->GetSelection(); AudioItemData* data = GetObject(selection); if (data && data->type == AudioItemData::AUDIO_NODE) { int latency = data->latency; latency = wxGetNumberFromUser(_("Desired output latency"), _("Desired latency:"), _("Audio device settings"), latency, 0, 999, this); if (latency == -1) return; data->latency = latency; UpdateDevice(selection); } else if (data && data->type == AudioItemData::GROUP_NODE) { wxString current = wxString::Format(wxT("%f"), data->volume >= -120 ? data->volume : -120); current = wxGetTextFromUser(_("Please enter new volume in dB:"), _("Change audio group"), current); if (current == wxEmptyString) return; double volume; if (!current.ToDouble(&volume) || volume < -120.0 || volume > 40.0) { wxMessageBox(_("Please enter a volume between -120 and 40 dB") , _("Error"), wxOK | wxICON_ERROR, this); return; } data->volume = volume; UpdateVolume(selection, data->volume); } UpdateButtons(); }
void Edit::OnGoto(wxCommandEvent &WXUNUSED(event)) { const wxString message = wxString::Format(_("Line number : 1 - %d"), GetLineCount()); const long line_number = wxGetNumberFromUser(wxEmptyString, message, wxT("Go To Line"), 1, 1, 100, this); if (line_number > 0) { GotoLine(line_number - 1); } }
void GridFrame::OnVTable(wxCommandEvent& ) { static long s_sizeGrid = 10000; #ifdef __WXMOTIF__ // MB: wxGetNumberFromUser doesn't work properly for wxMotif wxString s; s << s_sizeGrid; s = wxGetTextFromUser( _T("Size of the table to create"), _T("Size:"), s ); s.ToLong( &s_sizeGrid ); #else s_sizeGrid = wxGetNumberFromUser(_T("Size of the table to create"), _T("Size: "), _T("wxGridDemo question"), s_sizeGrid, 0, 32000, this); #endif if ( s_sizeGrid != -1 ) { BigGridFrame* win = new BigGridFrame(s_sizeGrid); win->Show(true); } }
void CustomPolygonDialog::OnButton3Click(wxCommandEvent& event) { wxString angleStr = wxGetTextFromUser(_("Rotation angle"), _("Rotation..."), "0", this); wxString originStr = wxGetTextFromUser(_("Point around which the rotation should be made.\nPoint 0;0 is the point draw on the polygon preview."), _("Rotation..."), "0;0", this); int precision = wxGetNumberFromUser(_("Precision allow to choose the number of decimal digits of the result"), _("Precision"), _("Rotation..."), 2, 0, 10, this); if(precision == -1) return; float angleRad = -gd::String(angleStr).To<float>() * M_PI/180; sf::Vector2f origin(gd::String::FromWxString(originStr).Split(U';').at(0).To<float>(), gd::String::FromWxString(originStr).Split(U';').at(1).To<float>()); std::vector<sf::Vector2f> pointList = PhysicsBehavior::GetCoordsVectorFromString(pointsEdit->GetValue()); for(std::size_t a = 0; a < pointList.size(); a++) { sf::Vector2f pointProjOnOrigin(pointList.at(a).x - origin.x, pointList.at(a).y - origin.y); pointList.at(a).x = round((cos(angleRad) * pointProjOnOrigin.x + sin(angleRad) * pointProjOnOrigin.y) * pow(10,precision)) / pow(10,precision) + origin.x; pointList.at(a).y = round((-sin(angleRad) * pointProjOnOrigin.x + cos(angleRad) * pointProjOnOrigin.y) * pow(10,precision)) / pow(10,precision) + origin.y; } pointsEdit->SetValue(PhysicsBehavior::GetStringFromCoordsVector(pointList)); }
bool SwitchWindow::showPortSelectDialog() { int res; res = wxGetNumberFromUser(_("Select port number"), _("Port:"), _("Switches"), this->portNo, 0, Cpu::IO_PORTS_NO-1, this); if ((res >= 0) && (res < (int)Cpu::IO_PORTS_NO)) { if (res != this->portNo) { this->cpu->detachInput(this->in); this->in = this->cpu->ins[res].attach( string(GetName().mb_str()) ); if (this->in != NULL) { wxString str = wxString::Format(wxT("%d (0x%02X)"), res, res); labelPort->SetLabel(str); this->setValue(); } else { wxMessageBox(_("Port already in use!"), _("Error"), wxICON_ERROR, this); labelPort->SetLabel(_("<none>")); } } this->updateParentWindow(); return true; } return false; }
void Calendario::CrearRecordatorio(wxCommandEvent& event) { long minutos=wxGetNumberFromUser(_("Escribe los minutos"),_("Introduce los minutos"),_("Divel Calendar"),1L,1L); sleep(minutos*60*1000); wxMessageBox(_("Tiempo acabado"),_("Divel Calendar"),wxICON_INFORMATION|wxOK); }
void OnButton(wxCommandEvent &event){ wxTextAttr textattr; int i = textctrl->GetInsertionPoint(); textctrl->GetStyle(i, textattr); wxFont font = textattr.GetFont(); int id = event.GetId(); long flags = 0; if(id == ID_FONT){ font = wxGetFontFromUser(this, font); flags = wxTEXT_ATTR_FONT_FACE; }else if(id == ID_SIZE){ font.SetPointSize(wxGetNumberFromUser(_T("Size:"), _T(""), _T("Set Font Size"), font.GetPointSize())); flags = wxTEXT_ATTR_FONT_SIZE; }else if(id == ID_BOLD){ font.SetWeight(font.GetWeight() != wxFONTWEIGHT_BOLD? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); flags = wxTEXT_ATTR_FONT_WEIGHT; }else if(id == ID_ITAL){ font.SetStyle(font.GetStyle() != wxFONTSTYLE_ITALIC? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL); flags = wxTEXT_ATTR_FONT_ITALIC; }else if(id == ID_UNDR){ font.SetUnderlined(!font.GetUnderlined()); flags = wxTEXT_ATTR_FONT_UNDERLINE; }else if(id == ID_COLR){ textattr.SetTextColour(wxGetColourFromUser(this, textattr.GetTextColour())); flags = wxTEXT_ATTR_TEXT_COLOUR; }else if(id == ID_BCLR){ textattr.SetBackgroundColour(wxGetColourFromUser(this, textattr.GetBackgroundColour())); flags = wxTEXT_ATTR_BACKGROUND_COLOUR; }else if(id == ID_RTLT){ //textctrl->SetSelection(0, textctrl->GetLastPosition()); textctrl->SetRTL(!textctrl->GetRTL()); textctrl->SetFocus(); return; } long start, end; textctrl->GetSelection(&start, &end); //printf("TextAttr flags: %x\n", textattr.GetFlags()); textattr.SetFont(font); textattr.SetFlags(flags); //printf("TextAttr flags: %x\n", textattr.GetFlags()); textctrl->SetStyle(start, end, textattr); textctrl->SetFocus(); }
void CTimeBarFrame::OnPlayTypeBtnClicked(wxCommandEvent& /*event*/) { long nPlayType = wxGetNumberFromUser(_T("请输入播放类型的序号:\n0. 单次播放\n1. 循环播放\n2. 倒序播放\n3. 倒序循环播放\n4. 来回播放"), _T("PlayType"), _T("PlayType Input"), 0, -1, eNAPT_Count - 1); if (nPlayType != -1) { m_nPlayType = nPlayType; m_pPlayTypeBtn->SetLabel(wxString::Format(_T("%d"), nPlayType)); } }
void BattleRoomTab::OnAutoSpec( wxCommandEvent& /*unused*/ ) { if ( !m_battle ) return; int trigger = wxGetNumberFromUser( _( "Enter timeout before autospeccing a player in minutes" ), _( "Set Timeout" ), _T( "" ), sett().GetBattleLastAutoSpectTime() / 60, 1, 60, ( wxWindow* ) & ui().mw(), wxDefaultPosition ); if ( trigger < 0 ) trigger = 0; trigger = trigger * 60; m_autospec_mnu->Check( trigger > 0 ); sett().SetBattleLastAutoSpectTime( trigger ); }
extern "C" WXEXPORT long wxGetNumberFromUser_func(wxc_string message, wxc_string prompt, wxc_string caption, long value, long min, long max, wxWindow* parent, wxPoint* pos) { return wxGetNumberFromUser(wxstr(message), wxstr(prompt), wxstr(caption), value, min, max, parent, *pos); }
void BattleroomListCtrl::OnHandicapSelect( wxCommandEvent& /*unused*/ ) { wxLogDebugFunc( _T("") ); if( !m_sel_user ) return; long handicap = wxGetNumberFromUser( _("Please enter a value between 0 and 100"), _("Set Resource Bonus"), _T(""), m_sel_user->BattleStatus().handicap, 0, 100, (wxWindow*)&ui().mw(), wxDefaultPosition ); if ( handicap != -1 ) { ((Battle*)m_battle)->SetHandicap( *m_sel_user, handicap ); } }
void MyFrame::OnSetImageSize(wxCommandEvent& WXUNUSED(event)) { int size = wxGetNumberFromUser(wxT("Enter the size for the images to use"), wxT("Size: "), wxT("TreeCtrl sample"), m_treeCtrl->ImageSize()); if ( size == -1 ) return; m_treeCtrl->CreateImageList(size); wxGetApp().SetShowImages(true); }
void wxLuaConsole::OnMenu(wxCommandEvent& event) { switch (event.GetId()) { case wxID_NEW : { m_textCtrl->Clear(); break; } case wxID_SAVEAS : { wxString filename = wxFileSelector(wxT("Select file to save output to"), m_saveFilename.GetPath(), m_saveFilename.GetFullName(), wxT("txt"), wxT("Text files (*.txt)|*.txt|All files|*.*"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, this); if (!filename.IsEmpty()) { m_saveFilename = wxFileName(filename); m_textCtrl->SaveFile(filename); } break; } case wxID_COPY : { long from = 0, to = 0; m_textCtrl->GetSelection(&from, &to); m_textCtrl->SetSelection(-1, -1); m_textCtrl->Copy(); m_textCtrl->SetSelection(from, to); break; } case ID_WXLUACONSOLE_SCROLLBACK_LINES : { long lines = wxGetNumberFromUser(wxT("Set the number of printed lines to remember, 0 to 10000.\nSet to 0 for infinite history."), wxT("Lines : "), wxT("Set Number of Scrollback Lines"), m_max_lines, 0, 10000, this); if (lines >= 0) SetMaxLines(lines); break; } default : break; } }
void MyFrame::OnPreviewRate(wxCommandEvent &) { unsigned int currentpreviewrate = m_vidCapWin->GetPreviewRateMS(); long int previewrate; previewrate = wxGetNumberFromUser(wxT("Set minimum time between preview frames"), wxT("milliseconds"), wxT("Preview Rate"), currentpreviewrate, 0, 32000, this ); // if cancel pressed if (previewrate == -1) return; m_vidCapWin->SetPreviewRateMS(previewrate); }
void CustomPolygonDialog::OnButton4Click(wxCommandEvent& event) { int precision = wxGetNumberFromUser(_("( There may be a loss of precision beyond 8 decimal digits )"), _("Precision ( Number of decimal digits )"), _("Round..."), 2, 0, 10, this); if(precision == -1) return; std::vector<sf::Vector2f> pointList = PhysicsBehavior::GetCoordsVectorFromString(pointsEdit->GetValue()); for(std::size_t a = 0; a < pointList.size(); a++) { pointList.at(a).x = round(pointList.at(a).x * pow(10, precision)) / pow(10, precision); pointList.at(a).y = round(pointList.at(a).y * pow(10, precision)) / pow(10, precision); } pointsEdit->SetValue(PhysicsBehavior::GetStringFromCoordsVector(pointList)); }
void Histogram2D::Build(VData&data) { vec3 voxel_size = data.spacing; chunk_size.y = wxGetNumberFromUser( "Enter chunk size for the gradient", _T("Enter a number(>0):"), _T("Numeric input"), chunk_size.y, 1, 2024, 0 ); ivec3 data_size = data.GetSize(); hist_size = ivec2(1024,256); mag_scale = (float)(hist_size.y*chunk_size.y)/(float)(256*256); if(hist)delete[]hist; hist = new unsigned int[hist_size.x*hist_size.y]; memset(hist,0,hist_size.x*hist_size.y*sizeof(int)); int max_h = data_size.x*data_size.y*data_size.z/(hist_size.y*hist_size.x); if(!max_h)max_h=1; for(int i=0;i<data_size.x-1;i+=2) for(int j=0;j<data_size.y-1;j+=2) for(int k=0;k<data_size.z-1;k+=2) { unsigned int val = data.GetValue(i,j,k); ivec3 gr(-val); gr.x += data.GetValue(i+1,j,k); gr.y += data.GetValue(i,j+1,k); gr.z += data.GetValue(i,j,k+1); unsigned int tmpv = val/chunk_size.x; unsigned int grad_mag = sqrt(sqr(gr.x/voxel_size.x)+sqr(gr.y/voxel_size.y)+sqr(gr.z/voxel_size.z))/chunk_size.y; // tmpv=rand()%hist_size.x; // grad_mag=rand()%hist_size.y; if(tmpv>=0 && tmpv<hist_size.x && grad_mag<hist_size.y) { int id = tmpv+grad_mag*hist_size.x; if(rand()%max_h > hist[id]) hist[id]++; } } max_chunk = 0; unsigned int *hh = hist; for(int i=0;i<hist_size.x*hist_size.y;i++,hh++) { if(max_chunk<*hh)max_chunk=*hh; } //UpdateTexture(); need_reload_txt=1; }
void MyFrame::OnStartThreads(wxCommandEvent& WXUNUSED(event) ) { static long s_num; s_num = wxGetNumberFromUser(wxT("How many threads to start: "), wxT(""), wxT("wxThread sample"), s_num, 1, 10000, this); if ( s_num == -1 ) { s_num = 10; return; } unsigned count = unsigned(s_num), n; wxArrayThread threads; // first create them all... for ( n = 0; n < count; n++ ) { wxThread *thr = CreateThread(); // we want to show the effect of SetPriority(): the first thread will // have the lowest priority, the second - the highest, all the rest // the normal one if ( n == 0 ) thr->SetPriority(wxPRIORITY_MIN); else if ( n == 1 ) thr->SetPriority(wxPRIORITY_MAX); else thr->SetPriority(wxPRIORITY_DEFAULT); threads.Add(thr); } #if wxUSE_STATUSBAR wxString msg; msg.Printf(wxT("%d new threads created."), count); SetStatusText(msg, 1); #endif // wxUSE_STATUSBAR // ...and then start them for ( n = 0; n < count; n++ ) { threads[n]->Run(); } }
void MyFrame::OnSetMargins(wxCommandEvent& WXUNUSED(event)) { long margin = wxGetNumberFromUser ( wxT("Enter the margins to use for the listbox items."), wxT("Margin: "), wxT("HtmlLbox: Set the margins"), 0, 0, 20, this ); if ( margin != -1 ) { m_hlbox->SetMargins(margin, margin); m_hlbox->RefreshAll(); } }
void OnButton(wxCommandEvent &event){ int id = event.GetId(); long flags = 0; if(id == ID_GRTF){ wxString rtf = textctrl->GetRTF(); printf("%s\n\n", rtf.ToAscii()); output->SetValue(converter.Convert(rtf, encoder)); input->SetValue(rtf); }else if(id == ID_GVAL){ wxString text = textctrl->GetValue(); wxTextAttr style; textctrl->GetStyle(0, style); output->SetValue(converter.Convert(text, encoder, L"plaintext", &style)); input->SetValue(text); }else if(id == ID_SEPR){ printf("\n========\n\n"); }else if(id == ID_RSIZ){ #if USEEXPANDO textctrl->SetMinHeight(wxGetNumberFromUser(_T("Input Height:"), _T(""), _T("Set Input Height"), textctrl->GetMinHeight())); printf("%d\n", textctrl->GetMinSize().GetHeight()); #endif //USEEXPANDO }else if(id == ID_RTFG){ if(rtfTemp.IsEmpty()){ rtfTemp = textctrl->GetRTF(); textctrl->Clear(); }else{ textctrl->SetRTF(rtfTemp); rtfTemp.Clear(); } }else if(id == ID_SETV){ wxString v = wxGetTextFromUser(L"Text?"); textctrl->SetValue(v); }else if(id == ID_LINK){ wxString rtf(L"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Comic Sans MS;}{\\f1\\fnil\\fcharset0 MS Shell Dlg 2;}}\r\n{\\colortbl ;\\red255\\green0\\blue255;\\red0\\green255\\blue255;}\r\n{\\*\\generator Msftedit 5.41.21.2509;}\\viewkind4\\uc1\\pard\\cf1\\highlight2\\ul\\b\\i\\f0\\fs44 test 123\\cf0\\highlight0\\ulnone\\b0\\i0\\f1\\fs17\\par\\par I use {\\hl {\\hlloc http://www.digsby.com/?utm_source=aim&utm_medium=aim&utm_campaign=aimprofilelink } {\\hlfr digsby} }\\par\r\n}"); //printf("%s\n\n", rtf.ToAscii()); output->SetValue(converter.Convert(rtf, encoder)); input->SetValue(rtf); }else if(id == ID_NEW){ CreateTestWindow((ExpandoApp*)wxTheApp, L"Spawn"); } textctrl->SetFocus(); }
void ProjectionDlg::OnSetEPSG( wxCommandEvent &event ) { // 4001 - 4904 for GCS values, 2000 - 3993 or 20004 - 32766 for PCS // Get an integer int value = m_proj.GuessEPSGCode(); int minv = 2000; int maxv = 32766; value = wxGetNumberFromUser(_T(""), _("Enter EPSG code:"), _("Input"), value, minv, maxv); if (value < 0) return; OGRErr result = m_proj.importFromEPSG(value); if (result == OGRERR_FAILURE) wxMessageBox(_("Couldn't set EPSG coordinate system.")); else SetUIFromProjection(); }
bool wxExHexMode::GotoDialog() { long val; if ((val = wxGetNumberFromUser( _("Input") + wxString::Format(" 0 - %d:", m_Buffer.size() - 1), wxEmptyString, _("Enter Byte Offset"), m_Goto, // initial value 0, m_Buffer.size() - 1, m_STC)) < 0) { return false; } m_Goto = val; return wxExHexModeLine(this, val, false).Goto(); }
void BattleOptionsTab::OnRestrict( wxCommandEvent& /*unused*/ ) { if ( !m_battle ) return; wxArrayInt sel; wxArrayString names; m_allowed_list->GetSelections( sel ); for ( unsigned int i = 0; i < sel.Count(); i++ ) { wxString name = m_allowed_list->GetString( sel.Item( i ) ); name = name.AfterLast( '(' ); name = name.BeforeLast( ')' ); names.Add( name ); } for ( unsigned int i = 0; i < names.Count(); i++ ) { wxString unit = names.Item( i ); int count = wxGetNumberFromUser( _( "How many units of this type do you wish to allow?" ), wxEmptyString, _( "Unit restriction" ), 0, 0, 500000 ); if ( count >= 0 ) m_battle->RestrictUnit(STD_STRING(unit), count ); } if ( names.Count() > 0 ) m_battle->SendHostInfo( IBattle::HI_Restrictions ); }
void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) ) { long res = wxGetNumberFromUser( _T("This is some text, actually a lot of text.\n") _T("Even two rows of text."), _T("Enter a number:"), _T("Numeric input test"), 50, 0, 100, this ); wxString msg; int icon; if ( res == -1 ) { msg = _T("Invalid number entered or dialog cancelled."); icon = wxICON_HAND; } else { msg.Printf(_T("You've entered %lu"), res ); icon = wxICON_INFORMATION; } wxMessageBox(msg, _T("Numeric test result"), wxOK | icon, this); }
void ImagesPanel::RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet& img) { wxConfigBase* config=wxConfigBase::Get(); long nFeatures = HUGIN_ASS_NCONTROLPOINTS; #if wxCHECK_VERSION(2,9,4) if(wxGetKeyState(WXK_COMMAND)) #else if(wxGetKeyState(WXK_CONTROL)) #endif { nFeatures = config->Read(wxT("/MainFrame/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS); nFeatures = wxGetNumberFromUser( _("Enter maximal number of control points per image pair"), _("Points per Overlap"), _("Control point detector option"), nFeatures, 1, 10000 ); if(nFeatures<1) { return; }; config->Write(wxT("/MainFrame/nControlPoints"), nFeatures); } else { nFeatures = config->Read(wxT("/Assistant/nControlPoints"), HUGIN_ASS_NCONTROLPOINTS); }; AutoCtrlPointCreator matcher; HuginBase::CPVector cps = matcher.automatch(setting, *m_pano, img, nFeatures, this); wxString msg; wxMessageBox(wxString::Format(_("Added %lu control points"), (unsigned long) cps.size()), _("Control point detector result"),wxOK|wxICON_INFORMATION,this); PanoCommand::GlobalCmdHist::getInstance().addCommand( new PanoCommand::AddCtrlPointsCmd(*m_pano, cps) ); };
void MyFrame::OnSetItemsCount(wxCommandEvent& WXUNUSED(event)) { int numItems = wxGetNumberFromUser ( "Enter the initial number of items for " "the list and report views", "Number of items:", "wxWidgets wxListCtrl sample", m_numListItems, 0, 10000, this ); if ( numItems == -1 || numItems == m_numListItems ) return; m_numListItems = numItems; if ( m_listCtrl->HasFlag(wxLC_REPORT) && !m_listCtrl->HasFlag(wxLC_VIRTUAL) ) RecreateList(wxLC_REPORT); else if ( m_listCtrl->HasFlag(wxLC_LIST) ) RecreateList(wxLC_LIST); }
/* TextEditor::jumpToLine * Prompts the user for a line number and moves the cursor to the end * of the entered line *******************************************************************/ void TextEditor::jumpToLine() { int numlines = GetNumberOfLines(); // Prompt for line number long line = wxGetNumberFromUser( "Enter a line number to jump to", S_FMT("Line number (1-%d):", numlines), "Jump To Line", GetCurrentLine() + 1, 1, numlines, this); if (line >= 1) { // Move to line int pos = GetLineEndPosition(line - 1); SetCurrentPos(pos); SetSelection(pos, pos); EnsureCaretVisible(); SetFocus(); } }
//WARNING: event ID must match enum ddDataType!!! this event was created on view void ddTextTableItemFigure::OnGenericPopupClick(wxCommandEvent &event, hdDrawingView *view) { wxTextEntryDialog *nameDialog = NULL; ddPrecisionScaleDialog *numericDialog = NULL; wxString tmpString; int answer; int tmpprecision; long tmpvalue; hdRemoveDeleteDialog *delremDialog = NULL; switch(event.GetId()) { case MNU_DDADDCOLUMN: nameDialog = new wxTextEntryDialog(view, wxT("New column name"), wxT("Add a column")); answer = nameDialog->ShowModal(); if (answer == wxID_OK) { tmpString = nameDialog->GetValue(); getOwnerColumn()->getOwnerTable()->addColumn(view->getIdx(), new ddColumnFigure(tmpString, getOwnerColumn()->getOwnerTable())); view->notifyChanged(); } delete nameDialog; break; case MNU_DELCOLUMN: answer = wxMessageBox(wxT("Are you sure you wish to delete column ") + getText(true) + wxT("?"), wxT("Delete column?"), wxYES_NO | wxNO_DEFAULT, view); if (answer == wxYES) { getOwnerColumn()->getOwnerTable()->removeColumn(view->getIdx(), getOwnerColumn()); view->notifyChanged(); } break; case MNU_AUTONAMCOLUMN: getOwnerColumn()->activateGenFkName(); getOwnerColumn()->getFkSource()->syncAutoFkName(); view->notifyChanged(); break; case MNU_RENAMECOLUMN: nameDialog = new wxTextEntryDialog(view, wxT("New column name"), wxT("Rename Column"), getText()); nameDialog->ShowModal(); if(getOwnerColumn()->isGeneratedForeignKey()) //after a manual user column rename, deactivated automatic generation of fk name. getOwnerColumn()->deactivateGenFkName(); setText(nameDialog->GetValue()); delete nameDialog; view->notifyChanged(); break; case MNU_NOTNULL: if(getOwnerColumn()->isNotNull()) getOwnerColumn()->setColumnOption(null); else getOwnerColumn()->setColumnOption(notnull); view->notifyChanged(); break; case MNU_PKEY: if(getOwnerColumn()->isPrimaryKey()) { getOwnerColumn()->disablePrimaryKey(); } else { getOwnerColumn()->enablePrimaryKey(); getOwnerColumn()->setColumnOption(notnull); } view->notifyChanged(); break; case MNU_UKEY: getOwnerColumn()->toggleColumnKind(uk, view); view->notifyChanged(); break; case MNU_TYPESERIAL: setDataType(dt_serial); //Should use setDataType always to set this value to allow fk to work flawlessly recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); view->notifyChanged(); break; case MNU_TYPEBOOLEAN: setDataType(dt_boolean); recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); view->notifyChanged(); break; case MNU_TYPEINTEGER: setDataType(dt_integer); recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); view->notifyChanged(); break; case MNU_TYPEMONEY: setDataType(dt_money); recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); view->notifyChanged(); break; case MNU_TYPEVARCHAR: setDataType(dt_varchar); tmpprecision = wxGetNumberFromUser(_("Varchar size"), _("Size for varchar datatype"), _("Varchar size"), getPrecision(), 0, 255, view); if (tmpprecision >= 0) { setPrecision(tmpprecision); setScale(-1); } recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); view->notifyChanged(); break; case MNU_TYPEOTHER: answer = wxGetSingleChoiceIndex(wxT("New column datatype"), wxT("Column Datatypes"), dataTypes(), view); if(answer >= 0) { view->notifyChanged(); if(answer == dt_varchar || answer == dt_bit || answer == dt_char || answer == dt_interval || answer == dt_varbit) { tmpprecision = wxGetNumberFromUser(_("datatype size"), _("Size for datatype"), _("size"), getPrecision(), 0, 255, view); if (tmpprecision >= 0) { setPrecision(tmpprecision); setScale(-1); } recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); } if(answer == dt_numeric) { numericDialog = new ddPrecisionScaleDialog( view, NumToStr((long)getPrecision()), NumToStr((long)getScale())); numericDialog->ShowModal(); numericDialog->GetValue1().ToLong(&tmpvalue); setPrecision(tmpvalue); numericDialog->GetValue2().ToLong(&tmpvalue); setScale(tmpvalue); delete numericDialog; recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); } setDataType( (ddDataType) answer ); recalculateDisplayBox(); getOwnerColumn()->displayBoxUpdate(); getOwnerColumn()->getOwnerTable()->updateTableSize(); } break; case MNU_TYPEPKEY_CONSTRAINTNAME: tmpString = wxGetTextFromUser(wxT("New name of primary key:"), getOwnerColumn()->getOwnerTable()->getPkConstraintName(), getOwnerColumn()->getOwnerTable()->getPkConstraintName(), view); if(tmpString.length() > 0) { getOwnerColumn()->getOwnerTable()->setPkConstraintName(tmpString); view->notifyChanged(); } break; case MNU_TYPEUKEY_CONSTRAINTNAME: answer = wxGetSingleChoiceIndex(wxT("Select Unique Key constraint to edit name"), wxT("Select Unique Constraint to edit name:"), getOwnerColumn()->getOwnerTable()->getUkConstraintsNames(), view); if(answer >= 0) { tmpString = wxGetTextFromUser(wxT("Change name of Unique Key constraint:"), getOwnerColumn()->getOwnerTable()->getUkConstraintsNames().Item(answer), getOwnerColumn()->getOwnerTable()->getUkConstraintsNames().Item(answer), view); if(tmpString.length() > 0) { getOwnerColumn()->getOwnerTable()->getUkConstraintsNames().Item(answer) = tmpString; view->notifyChanged(); } } break; case MNU_DELTABLE: delremDialog = new hdRemoveDeleteDialog(wxT("Are you sure you wish to delete table ") + getOwnerColumn()->getOwnerTable()->getTableName() + wxT("?"), wxT("Delete table?"), view); answer = delremDialog->ShowModal(); ddTableFigure *table = getOwnerColumn()->getOwnerTable(); if (answer == DD_DELETE) { ddDrawingEditor *editor = (ddDrawingEditor *) view->editor(); //Unselect table at all diagrams editor->removeFromAllSelections(table); //Drop foreign keys with this table as origin or destination table->processDeleteAlert(view->getDrawing()); //Drop table editor->deleteModelFigure(table); editor->getDesign()->refreshBrowser(); view->notifyChanged(); } else if(answer == DD_REMOVE) { ddDrawingEditor *editor = (ddDrawingEditor *) view->editor(); editor->getExistingDiagram(view->getIdx())->removeFromSelection(table); editor->getExistingDiagram(view->getIdx())->remove(table); view->notifyChanged(); } delete delremDialog; break; } }