本文整理汇总了C++中AlertWindow::getTextEditorContents方法的典型用法代码示例。如果您正苦于以下问题:C++ AlertWindow::getTextEditorContents方法的具体用法?C++ AlertWindow::getTextEditorContents怎么用?C++ AlertWindow::getTextEditorContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AlertWindow
的用法示例。
在下文中一共展示了AlertWindow::getTextEditorContents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNewFile
void createNewFile (Project::Item parent)
{
for (;;)
{
AlertWindow aw (TRANS ("Create new Component class"),
TRANS ("Please enter the name for the new class"),
AlertWindow::NoIcon, nullptr);
aw.addTextEditor (getClassNameFieldName(), String::empty, String::empty, false);
aw.addButton (TRANS ("Create Files"), 1, KeyPress (KeyPress::returnKey));
aw.addButton (TRANS ("Cancel"), 0, KeyPress (KeyPress::escapeKey));
if (aw.runModalLoop() == 0)
break;
const String className (aw.getTextEditorContents (getClassNameFieldName()).trim());
if (className == CodeHelpers::makeValidIdentifier (className, false, true, false))
{
const File newFile (askUserToChooseNewFile (className + ".h", "*.h;*.cpp", parent));
if (newFile != File::nonexistent)
createFiles (parent, className, newFile);
break;
}
}
}
示例2: renameGroup
void CtrlrLuaMethodEditor::renameGroup(ValueTree parentGroup)
{
AlertWindow w ("Rename group", "", AlertWindow::QuestionIcon, this);
w.addTextEditor("name", parentGroup.getProperty (Ids::name).toString());
w.addButton ("OK", 1, KeyPress(KeyPress::returnKey));
w.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey));
if (w.runModalLoop())
{
parentGroup.setProperty (Ids::name, w.getTextEditorContents("name"), nullptr);
updateRootItem();
}
saveSettings(); // save settings
}
示例3: popupMenuClickOnTab
void EdoTabs::popupMenuClickOnTab (const int tabIndex, const String &tabName)
{
PopupMenu menu;
menu.addItem (1, T("Rename tab"));
menu.addItem (2, T("Close tab"));
const int ret = menu.show();
if (ret == 1)
{
AlertWindow alert (T("New tab name"), T("Set the new tab name"), AlertWindow::InfoIcon);
alert.addTextEditor (T("edoTabName"), tabName, T("New tab name"), false);
alert.addButton (T("OK"), 1, KeyPress (KeyPress::returnKey));
alert.addButton (T("Cancel"), 2);
const int ret = alert.runModalLoop();
if (ret == 2)
{
return;
}
else
{
const String newName = alert.getTextEditorContents(EDO_COMPONENT_NAME);
Component *edoComponent = dynamic_cast<Component*>(getTabContentComponent (tabIndex));
if (edoComponent!=0)
{
edoComponent->setName (newName);
}
setTabName (tabIndex, newName);
}
}
if (ret == 2)
{
removeTab (tabIndex);
}
}
示例4: buttonClicked
//===============================================================================
void CabbageFileButton::buttonClicked (Button* button)
{
if (mode == "file")
{
const String lastKnownDirectory = owner->getLastOpenedDirectory();
FileChooser fc ("Choose File", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getParentDirectory() : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser());
if (fc.browseForFileToOpen())
{
owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult()));
CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult()));
//owner->refreshComboBoxContents();
}
owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName());
}
else if (mode == "save")
{
const String lastKnownDirectory = owner->getLastOpenedDirectory();
FileChooser fc ("Choose File", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getParentDirectory() : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser());
if (fc.browseForFileToSave(true))
{
owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult()));
CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult()));
//owner->refreshComboBoxContents();
}
owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName());
owner->refreshComboListBoxContents();
startTimer(500);
}
else if (mode == "directory")
{
const String lastKnownDirectory = owner->getLastOpenedDirectory();
FileChooser fc ("Open Directory", lastKnownDirectory.isEmpty() ? File (getCsdFile()).getChildFile (getFilename()) : File (lastKnownDirectory), "", CabbageUtilities::shouldUseNativeBrowser());
if (fc.browseForDirectory())
{
owner->sendChannelStringDataToCsound (getChannel(), returnValidPath (fc.getResult()));
CabbageWidgetData::setStringProp (widgetData, CabbageIdentifierIds::file, returnValidPath (fc.getResult()));
}
owner->setLastOpenedDirectory (fc.getResult().getParentDirectory().getFullPathName());
}
else if (mode == "snapshot")
{
String newFileName;
if (owner->isAudioUnit())
newFileName = File(getCsdFile()).withFileExtension(".snaps").getFullPathName();
else
newFileName = owner->createNewGenericNameForPresetFile();
owner->sendChannelStringDataToCsound (getChannel(), newFileName);
owner->savePluginStateToFile (File (newFileName));
owner->refreshComboListBoxContents();
}
else if (mode == "named snapshot")
{
String newFileName;
if (owner->isAudioUnit())
newFileName = File(getCsdFile()).withFileExtension(".snaps").getFullPathName();
else
newFileName = owner->createNewGenericNameForPresetFile();
#if JUCE_MODAL_LOOPS_PERMITTED
String presetname;
AlertWindow w ("Preset",
"Set preset name (warning, will overwrite previous preset of same name)",
AlertWindow::NoIcon);
w.setLookAndFeel(&getLookAndFeel());
w.setSize(100, 100);
w.addTextEditor ("text", "enter name here", "");
w.addButton ("OK", 1, KeyPress (KeyPress::returnKey, 0, 0));
w.addButton ("Cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));
if (w.runModalLoop() != 0) // is they picked 'ok'
{
presetname = w.getTextEditorContents ("text");
}
#endif
owner->sendChannelStringDataToCsound (getChannel(), newFileName);
owner->savePluginStateToFile (File (newFileName), presetname);
owner->refreshComboListBoxContents();
}
owner->getProcessor().updateHostDisplay();
}
示例5: showWindow
void showWindow (Component& button, DialogType type)
{
if (type >= plainAlertWindow && type <= questionAlertWindow)
{
AlertWindow::AlertIconType icon = AlertWindow::NoIcon;
switch (type)
{
case warningAlertWindow: icon = AlertWindow::WarningIcon; break;
case infoAlertWindow: icon = AlertWindow::InfoIcon; break;
case questionAlertWindow: icon = AlertWindow::QuestionIcon; break;
default: break;
}
AlertWindow::showMessageBoxAsync (icon,
"This is an AlertWindow",
"And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
"ok");
}
else if (type == okCancelAlertWindow)
{
AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
"This is an ok/cancel AlertWindow",
"And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
String::empty,
String::empty,
0,
ModalCallbackFunction::forComponent (alertBoxResultChosen, this));
}
else if (type == calloutBoxWindow)
{
ColourSelector* colourSelector = new ColourSelector();
colourSelector->setName ("background");
colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));
colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
colourSelector->setSize (300, 400);
CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr);
}
else if (type == extraComponentsAlertWindow)
{
#if JUCE_MODAL_LOOPS_PERMITTED
AlertWindow w ("AlertWindow demo..",
"This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.",
AlertWindow::QuestionIcon);
w.addTextEditor ("text", "enter some text here", "text field:");
const char* options[] = { "option 1", "option 2", "option 3", "option 4", nullptr };
w.addComboBox ("option", StringArray (options), "some options");
w.addButton ("ok", 1, KeyPress (KeyPress::returnKey, 0, 0));
w.addButton ("cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));
if (w.runModalLoop() != 0) // is they picked 'ok'
{
// this is the item they chose in the drop-down list..
const int optionIndexChosen = w.getComboBoxComponent ("option")->getSelectedItemIndex();
(void) optionIndexChosen; // (just avoids a compiler warning about unused variables)
// this is the text they entered..
String text = w.getTextEditorContents ("text");
}
#endif
}
else if (type == progressWindow)
{
// This will launch our ThreadWithProgressWindow in a modal state. (Our subclass
// will take care of deleting the object when the task has finished)
(new DemoBackgroundThread())->launchThread();
}
else if (type >= loadChooser && type <= saveChooser)
{
#if JUCE_MODAL_LOOPS_PERMITTED
const bool useNativeVersion = nativeButton.getToggleState();
if (type == loadChooser)
{
FileChooser fc ("Choose a file to open...",
File::getCurrentWorkingDirectory(),
"*",
useNativeVersion);
if (fc.browseForMultipleFilesToOpen())
{
String chosen;
for (int i = 0; i < fc.getResults().size(); ++i)
chosen << fc.getResults().getReference(i).getFullPathName() << "\n";
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
"File Chooser...",
"You picked: " + chosen);
}
}
else if (type == loadWithPreviewChooser)
{
ImagePreviewComponent imagePreview;
imagePreview.setSize (200, 200);
//.........这里部分代码省略.........