NS_IMETHODIMP DeleteCommand::IsCommandEnabled(const char* aCommandName, nsISupports* aCommandRefCon, bool* aIsEnabled) { if (NS_WARN_IF(!aIsEnabled)) { return NS_ERROR_INVALID_ARG; } *aIsEnabled = false; nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { return NS_OK; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); // We can generally delete whenever the selection is editable. However, // cmd_delete doesn't make sense if the selection is collapsed because it's // directionless, which is the same condition under which we can't cut. *aIsEnabled = textEditor->IsSelectionEditable(); if (!nsCRT::strcmp("cmd_delete", aCommandName) && *aIsEnabled) { nsresult rv = textEditor->CanDelete(aIsEnabled); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } } return NS_OK; }
//------------------------------------------------------------------------------ void PreferencesDialog::textEditorEscapeKeyPressed(TextEditor &editor) { if(editor.getName() == "oscPortEditor") editor.setText(currentPort, false); else if(editor.getName() == "oscMulticastEditor") editor.setText(currentMulticast, false); }
NS_IMETHODIMP InsertPlaintextCommand::DoCommandParams(const char* aCommandName, nsICommandParams* aParams, nsISupports* aCommandRefCon) { if (NS_WARN_IF(!aParams)) { return NS_ERROR_INVALID_ARG; } nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (NS_WARN_IF(!editor)) { return NS_ERROR_FAILURE; } // Get text to insert from command params nsAutoString text; nsresult rv = aParams->AsCommandParams()->GetString(STATE_DATA, text); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); // XXX InsertTextAsAction() is not same as OnInputText(). However, other // commands to insert line break or paragraph separator use OnInput*(). // According to the semantics of those methods, using *AsAction() is // better, however, this may not cause two or more placeholder // transactions to the top transaction since its name may not be // nsGkAtoms::TypingTxnName. rv = textEditor->InsertTextAsAction(text); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to insert the text"); return NS_OK; }
NS_IMETHODIMP SelectionMoveCommands::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) { nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (NS_WARN_IF(!editor)) { return NS_ERROR_FAILURE; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); RefPtr<Document> doc = textEditor->GetDocument(); if (doc) { // Most of the commands below (possibly all of them) need layout to // be up to date. doc->FlushPendingNotifications(FlushType::Layout); } nsCOMPtr<nsISelectionController> selectionController = textEditor->GetSelectionController(); if (NS_WARN_IF(!selectionController)) { return NS_ERROR_FAILURE; } // scroll commands for (size_t i = 0; i < mozilla::ArrayLength(scrollCommands); i++) { const ScrollCommand& cmd = scrollCommands[i]; if (!nsCRT::strcmp(aCommandName, cmd.reverseScroll)) { return (selectionController->*(cmd.scroll))(false); } else if (!nsCRT::strcmp(aCommandName, cmd.forwardScroll)) { return (selectionController->*(cmd.scroll))(true); } } // caret movement/selection commands for (size_t i = 0; i < mozilla::ArrayLength(moveCommands); i++) { const MoveCommand& cmd = moveCommands[i]; if (!nsCRT::strcmp(aCommandName, cmd.reverseMove)) { return (selectionController->*(cmd.move))(false, false); } else if (!nsCRT::strcmp(aCommandName, cmd.forwardMove)) { return (selectionController->*(cmd.move))(true, false); } else if (!nsCRT::strcmp(aCommandName, cmd.reverseSelect)) { return (selectionController->*(cmd.move))(false, true); } else if (!nsCRT::strcmp(aCommandName, cmd.forwardSelect)) { return (selectionController->*(cmd.move))(true, true); } } // physical-direction movement/selection for (size_t i = 0; i < mozilla::ArrayLength(physicalCommands); i++) { const PhysicalCommand& cmd = physicalCommands[i]; if (!nsCRT::strcmp(aCommandName, cmd.move)) { return selectionController->PhysicalMove(cmd.direction, cmd.amount, false); } else if (!nsCRT::strcmp(aCommandName, cmd.select)) { return selectionController->PhysicalMove(cmd.direction, cmd.amount, true); } } return NS_ERROR_FAILURE; }
string CreatureEditor::edit(vector<string> args) { if(args.size() < 2) { return "What do you want to edit?"; } string editNoun = args[1]; toLower(&editNoun); if(editNoun == STR_NAME) { return set(args); } else if(editNoun == STR_DESCRIPTION || editNoun == STR_DESC) { TextEditor ed; creature->description = ed.edit("Editing Description For Creature:"+creature->getPrimaryName(),creature->description); clearWindows(); resetWindows(); return ""; } else { return "I don't know how to edit that"; } }
EditorTab::EditorTab(WebFile* file, QWidget* parent) : QSplitter(parent) { m_options = OptionStore::getInstance(); m_listmodel =new QStringListModel; m_documentList = new QList<QTextDocument*>; TextEditor* textedit = new TextEditor(this);//qobject_cast<TextEditor*>(m_editor->widget()); if(file) connect(textedit,SIGNAL(textChanged()),file,SLOT(hasBeenModified())); p = new PhpHighLighter(textedit->document()); connect(m_options,SIGNAL(fontChanged(QFont)),textedit,SLOT(setCurrentFont(QFont))); textedit->setCurrentFont(m_options->font()); m_leftcolumn = new QSplitter(Qt::Vertical,this); ProjectFilesBrowser* tmpBrowser=new ProjectFilesBrowser(); m_view = new FancyWidget(tmpBrowser); m_leftcolumn->addWidget(m_view->widget()); addWidget(m_leftcolumn); setStretchFactor(0,1); addEditor(textedit); setStretchFactor(1,3); }
MenuWindow::MenuWindow(AmobaApplication &app, int x, int y) : Window (x, y), _app(app) { StaticText *text = new StaticText(170, 50, 100,30, "Amöba"); widgets.push_back(text); ClickButton *kilepesGomb = new ClickButton([&]() { kilepesClicked(); }, 40, 320, 100, 35); widgets.push_back(kilepesGomb); StaticText *exit = new StaticText(70, 330, 40, 20, "EXIT"); widgets.push_back(exit); ClickButton *jatekGomb = new ClickButton([&]() { jatekClicked(); }, 260, 320, 100, 35); widgets.push_back(jatekGomb); StaticText *kek = new StaticText(40, 180, 100, 35, "Kék játékos:"); widgets.push_back(kek); TextEditor *ed = new TextEditor(40, 200, 100, 35, _app.players[0]); ed->addValueChangeListener([&](ValueChangedEvent event) { textEditorChanged(event); }); widgets.push_back(ed); StaticText *play = new StaticText(290, 330, 40, 20, "PLAY"); widgets.push_back(play); StaticText *piros = new StaticText(260, 180, 100, 35, "Piros játékos:"); widgets.push_back(piros); TextEditor *ed2 = new TextEditor(260, 200, 100, 35, _app.players[1]); ed2->addValueChangeListener([&](ValueChangedEvent event) { textEditorChanged2(event); }); widgets.push_back(ed2); }
void IDLabel::showExtended(const QPoint &p) {//, bool alreadyAdjusted, RegisterLabel *v) { /* QPoint p2 = p; if (!alreadyAdjusted) p2 = mapToParent(p); if (v == NULL) v = this;*/ /* if (m_parent->m_extended->m_orig == this || m_parent->m_extended->m_orig == v) { m_parent->m_extended->move(p2); return; }*/ QString alias = getRegisterText(m_register, true); QString regName = ((m_register >= 32) ? QString("<b>%1</b>").arg(alias) : QString("<b>r%1</b> (%2)").arg(QString::number(m_register), alias)); QString mText = QString( "<span style=\"font-size: 12;\">%1</span>" "<pre>").arg(regName); if (m_value == 0) mText += QString("Value = 0"); else { QString one = getNoInBase(m_value, 16), // two = getNoInBase(m_value, 2), three = getNoInBase(m_value, -10), four = getNoInBase(m_value, 10); mText += QString( "Hex: %1<br>" // "Binary: %2<br>" "Decimal: %2") .arg(one, /*two, */three); if (three != four) mText += QString("<br>UDecimal: %1").arg(four); } // Display the line which is responsible for setting // the value currently in this register. TextEditor *active = NULL; if (m_lastModified != NULL && m_lastModified->isValid() && m_lastModified->getTextBlock() != NULL && (active = m_parent->m_parent->m_gui->getActiveProgram()) != NULL) { mText += QString("<br>" "(Set by line <i>%1</i>)").arg(1 + active->lineNumber(*m_lastModified->getTextBlock())); } mText += QString("</pre>"); /* QString(""); ("Last modifed by<br>line: <b>%1</b>").arg(QString("N/A"));*/ //"<ul style=\"list-style: none;\">" /*"<li "STYLE_LEFT">Hex</li><li "STYLE_RIGHT">%2</li>" "<li "STYLE_LEFT">Binary</li><li "STYLE_RIGHT">%3</li>" "<li "STYLE_LEFT">Decimal</li><li "STYLE_RIGHT">%4</li>" "<li "STYLE_LEFT">Unsigned</li><li "STYLE_RIGHT">%5</li>"*/ //"</ul>" m_parent->showExtended(p, mText, this); }
NS_IMETHODIMP PasteTransferableCommand::GetCommandStateParams(const char* aCommandName, nsICommandParams* aParams, nsISupports* aCommandRefCon) { nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (NS_WARN_IF(!editor)) { return NS_ERROR_FAILURE; } nsCOMPtr<nsISupports> supports = aParams->AsCommandParams()->GetISupports("transferable"); if (NS_WARN_IF(!supports)) { return NS_ERROR_FAILURE; } nsCOMPtr<nsITransferable> trans; trans = do_QueryInterface(supports); if (NS_WARN_IF(!trans)) { return NS_ERROR_FAILURE; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); return aParams->AsCommandParams()->SetBool( STATE_ENABLED, textEditor->CanPasteTransferable(trans)); }
NS_IMETHODIMP SelectAllCommand::IsCommandEnabled(const char* aCommandName, nsISupports* aCommandRefCon, bool* aIsEnabled) { NS_ENSURE_ARG_POINTER(aIsEnabled); nsresult rv = NS_OK; // You can always select all, unless the selection is editable, // and the editable region is empty! *aIsEnabled = true; nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { return NS_OK; } // You can select all if there is an editor which is non-empty TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); bool isEmpty = false; rv = textEditor->IsEmpty(&isEmpty); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } *aIsEnabled = !isEmpty; return NS_OK; }
void AddFilmWindow::ShowEditor( CutLabel* editDataIn, const QString& title ) { TextEditor* editor = new TextEditor( this ); editor->SetDataSource( editDataIn ); editor->SetDataReceiver( editDataIn ); editor->SetTitle( title ); editor->show(); }
void ProjucerLookAndFeel::fillTextEditorBackground (Graphics& g, int width, int height, TextEditor& textEditor) { g.setColour (textEditor.findColour (TextEditor::backgroundColourId)); g.fillRect (0, 0, width, height); g.setColour (textEditor.findColour (TextEditor::outlineColourId)); g.drawHorizontalLine (height - 1, 0.0f, static_cast<float> (width)); }
QString editHtml(const QString& s, const QString& title) { TextEditor editor; editor.setWindowTitle(title); editor.setHtml(s); editor.exec(); return editor.toHtml(); }
//============================================================================== void OldSchoolLookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor) { if (textEditor.isEnabled()) { g.setColour (textEditor.findColour (TextEditor::outlineColourId)); g.drawRect (0, 0, width, height); } }
QString editPlainText(const QString& s, const QString& title) { TextEditor editor; editor.setWindowTitle(title); editor.setPlainText(s); editor.exec(); return editor.toPlainText(); }
void HadronLabel::textEditorReturnKeyPressed(TextEditor& editor) { if (use_modal_editor_) { setText(editor.getText(), true); editor.exitModalState(0); } else { Label::textEditorReturnKeyPressed(editor); } }
NS_IMETHODIMP CopyCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) { nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { return NS_ERROR_FAILURE; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); return textEditor->Copy(); }
void FindAndReplaceDialog::resized() { label1->setBounds (8, 8, 56, 24); textEditor1->setBounds (72, 8, 336, 24); label2->setBounds (8, 40, 56, 24); textEditor2->setBounds (72, 40, 336, 24); textButton1->setBounds (8, 72, 80, 24); textButton2->setBounds (88, 72, 80, 24); textButton3->setBounds (168, 72, 96, 24); textButton4->setBounds (264, 72, 64, 24); textButton5->setBounds (328, 72, 80, 24); }
NS_IMETHODIMP InsertLineBreakCommand::DoCommand(const char* aCommandName, nsISupports* aCommandRefCon) { nsCOMPtr<nsIPlaintextEditor> editor = do_QueryInterface(aCommandRefCon); if (NS_WARN_IF(!editor)) { return NS_ERROR_NOT_IMPLEMENTED; } TextEditor* textEditor = static_cast<TextEditor*>(editor.get()); return textEditor->TypedText(EmptyString(), TextEditor::eTypedBR); }
void DragLabel::mouseUp(const MouseEvent& e) { // By showing the editor here (instead of letting the base class do it // for us) we can get a pointer to the editor and make sure that users // can't enter anything except 1..5 digits. this->showEditor(); TextEditor* ed = this->getCurrentTextEditor(); if (ed) { ed->setInputRestrictions(5, "0123456789"); } Label::mouseUp(e); }
//------------------------------------------------------------------------------ void PreferencesDialog::textEditorFocusLost(TextEditor &editor) { if(editor.getName() == "oscPortEditor") { currentPort = editor.getText(); mainPanel->setSocketPort(currentPort); } else if(editor.getName() == "oscMulticastEditor") { currentMulticast = editor.getText(); mainPanel->setSocketMulticast(currentMulticast); } }
void TextEditorBase::execSyncV( FieldContainer &oFrom, ConstFieldMaskArg whichField, AspectOffsetStore &oOffsets, ConstFieldMaskArg syncMode, const UInt32 uiSyncInfo) { TextEditor *pThis = static_cast<TextEditor *>(this); pThis->execSync(static_cast<TextEditor *>(&oFrom), whichField, oOffsets, syncMode, uiSyncInfo); }
int main( int argc, char** argv ) { QApplication qApplication( argc, argv ); qApplication.setQuitOnLastWindowClosed( true ); TextEditor textEditor; textEditor.show(); // open the the specified command line files if any if( qApplication.arguments().size() > 1 ) for( int index=1; index < qApplication.arguments().size(); index++ ) textEditor.newTab( qApplication.arguments().value(index) ); return qApplication.exec(); }
NS_IMETHODIMP PasteQuotationCommand::GetCommandStateParams(const char* aCommandName, nsICommandParams* aParams, nsISupports* aCommandRefCon) { nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { return NS_OK; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); bool enabled = false; textEditor->CanPaste(nsIClipboard::kGlobalClipboard, &enabled); aParams->AsCommandParams()->SetBool(STATE_ENABLED, enabled); return NS_OK; }
NS_IMETHODIMP CopyCommand::IsCommandEnabled(const char* aCommandName, nsISupports* aCommandRefCon, bool* aIsEnabled) { if (NS_WARN_IF(!aIsEnabled)) { return NS_ERROR_INVALID_ARG; } nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { *aIsEnabled = false; return NS_OK; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); return textEditor->CanCopy(aIsEnabled); }
NS_IMETHODIMP SelectionMoveCommands::IsCommandEnabled(const char* aCommandName, nsISupports* aCommandRefCon, bool* aIsEnabled) { NS_ENSURE_ARG_POINTER(aIsEnabled); nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (!editor) { *aIsEnabled = false; return NS_OK; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); *aIsEnabled = textEditor->IsSelectionEditable(); return NS_OK; }
//------------------------------------------------------------------------------ void MappingsDialog::textEditorTextChanged(TextEditor &editor) { BypassableInstance *proc = dynamic_cast<BypassableInstance *>(pluginNode->getProcessor()); if(proc) oscManager->registerMIDIProcessor(editor.getText(), proc); }
NS_IMETHODIMP InsertPlaintextCommand::IsCommandEnabled(const char* aCommandName, nsISupports* aCommandRefCon, bool* aIsEnabled) { if (NS_WARN_IF(!aIsEnabled)) { return NS_ERROR_INVALID_ARG; } nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon); if (NS_WARN_IF(!editor)) { *aIsEnabled = false; return NS_ERROR_FAILURE; } TextEditor* textEditor = editor->AsTextEditor(); MOZ_ASSERT(textEditor); *aIsEnabled = textEditor->IsSelectionEditable(); return NS_OK; }
void NonShinyLookAndFeel::drawTextEditorOutline (Graphics& g, int width, int height, TextEditor& textEditor) { if (textEditor.isEnabled()) { if (textEditor.hasKeyboardFocus (true) && ! textEditor.isReadOnly()) { const int border = 2; g.setColour (textEditor.findColour (TextEditor::focusedOutlineColourId)); g.drawRect (0, 0, width, height, border); g.setOpacity (1.0f); const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId).withMultipliedAlpha (0.75f)); drawBevel (g, 0, 0, width, height + 2, border + 2, shadowColour, shadowColour); } else { g.setColour (textEditor.findColour (TextEditor::outlineColourId)); g.drawRect (0, 0, width, height); g.setOpacity (1.0f); const Colour shadowColour (textEditor.findColour (TextEditor::shadowColourId)); drawBevel (g, 0, 0, width, height + 2, 3, shadowColour, shadowColour); } } }
//TODOODOT : implement correct version void updateFromTransactionsQueryForRow(QueryEntry *qe, Array<int> numTransactions, int row, bool dView, bool edit) { setDetailedView(dView); setEdit(edit); resized(); this->row = row; if(qe) { // summary const int numFields = 3; for (int i=0; i<getNumChildComponents(); i++) { TextEditor *te = dynamic_cast<TextEditor*>(getChildComponent(i)); if (te && te->getName().startsWith("#")) { const int ord = te->getName().substring(1).getIntValue(); const int row = ord/numFields; const int field = ord%numFields; if (row < numTransactions.size()) { te->setText(qe->getFieldFromRow(row, field)); te->setEnabled(edit); te->setVisible(true); } else { te->setVisible(false); } } } } }