// CEX32ADoc 명령 void CEX32ADoc::OnModify() { // TODO: 여기에 명령 처리기 코드를 추가합니다. CTextDialog dlg; dlg.m_strText = m_strText; if (dlg.DoModal() == IDOK) { m_strText = dlg.m_strText; UpdateAllViews(NULL); // Trigger CX32AView::OnDraw UpdateAllItems(NULL); // Trigger CX32AItem::OnDraw SetModifiedFlag(); } }
void CSketcherView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC aDC(this); // Create a device context OnPrepareDC(&aDC); // Get origin adjusted aDC.DPtoLP(&point); // Convert point to logical coordinatesm_FirstPoint = point; // Record the cursor position if(m_MoveMode) { // In moving mode, so drop the element m_MoveMode = false; // Kill move mode m_pSelected = nullptr; // De-select the element GetDocument()->UpdateAllViews(0); // Redraw all the views GetDocument()->SetModifiedFlag(); return; } CSketcherDoc* pDoc = GetDocument();// Get a document pointer if(pDoc->GetElementType() == TEXT) { CTextDialog aDlg; if(aDlg.DoModal() == IDOK) { // Exit OK so create a text element CSize textExtent = aDC.GetTextExtent(aDlg.m_TextString); CRect rect(point, textExtent); //Create enclosing rectangle CText* pTextElement = new CText( aDlg.m_TextString, rect, pDoc->GetElementColor()); // Add the element to the document pDoc->AddElement(pTextElement); // Get all views updated pDoc->UpdateAllViews(nullptr, 0, pTextElement); } return; } m_FirstPoint = point; // Record the cursor position SetCapture(); // Capture subsequent mouse messages }
QString CTextDialog::getText(const QString &caption, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, QWidget *parent, const char *name ) { #ifdef DEBUG qDebug("static CTextDialog::getText()"); #endif CTextDialog *dlg = new CTextDialog(parent, name, true); dlg->textLabel->setText(label); dlg->Text->setText(text); dlg->setCaption(caption); dlg->Text->setEchoMode(mode); bool ok_ = false; QString result; ok_ = dlg->exec() == QDialog::Accepted; if (ok) *ok = ok_; if ( ok_ ) result = dlg->Text->text(); delete dlg; return result; }