long Editor :: MenuCommand(wCommandMsg m) { Document *top = (Document*)TopMdiDocument(); short lp; Document *doc; // SET FOREGROUND COLOR if (m.usCmd() >= O_FGCOLOR && m.usCmd() < O_BGCOLOR) { fgc = carr[m.usCmd() - O_FGCOLOR]; wColor oldc; for (DocList()->First() ; (doc = (Document*)(DocList()->Current())) != 0 ; DocList()->Next()) oldc= doc->mle->SetForeground(fgc); for (lp=0 ; lp < 16 && carr[lp] != oldc; lp++) ; menu->UnCheckItem(lp + O_FGCOLOR); menu->CheckItem(m.usCmd()); } // SET BACKGROUND COLOR if (m.usCmd() >= O_BGCOLOR && m.usCmd() < O_BGCOLOR + 18) { bgc = carr[m.usCmd() - O_BGCOLOR]; wColor oldc; for (DocList()->First() ; (doc = (Document*)(DocList()->Current())) != 0 ; DocList()->Next()) oldc= doc->mle->SetBackground(bgc); for (lp=0 ; lp < 16 && carr[lp] != oldc; lp++) ; menu->UnCheckItem(lp + O_BGCOLOR); menu->CheckItem(m.usCmd()); } // SET FONT if (m.usCmd() == O_FONT) Fonts(); switch (m.usCmd()) { case F_NEW: new Document(this); break; case F_OPEN: Open(); break; case F_SAVE: top->Save(); break; case F_SAVEAS: top->SaveAs(); break; case F_CLOSE: if (top->Close(wMessage())) delete top; break; case F_QUIT: if (top) { if (CloseAll()) PostMessage(wMessage(WM_QUIT, 0, 0)); } break; case E_UNDO: top->mle->Undo(); break; case E_CUT: top->mle->CutSelection(); break; case E_COPY: top->mle->CopySelection(); break; case E_PASTE: top->mle->PasteSelection(); break; case E_CLEAR: top->mle->ClearSelection(); break; case E_FIND: { ushort found = TRUE; SearchDlg s(this, EDIT_SEARCH, &search, &replace, &cs); switch(s.GetResult()) { case ID_CANCEL: return FALSE; case ID_SEARCH: { //top->mle->DisableUpdate(); found = top->mle->Search(search, PosFirst, PosLast, MlSelectMatch | (cs ? MlCaseSensitive : 0)); break; } case ID_REPLACE: top->mle->DisableUpdate(); found = top->mle->SearchReplace(search, replace, PosFirst, PosLast, (cs ? MlCaseSensitive : 0)); break; case ID_REPLACEALL: top->mle->DisableUpdate(); found = TRUE; top->mle->SearchReplace(search, replace, PosFirst, PosLast, MlChangeAll | (cs ? MlCaseSensitive : 0)); break; } top->mle->EnableUpdate(); if (!found) { wMessageBox mb(this, "Search string not found", "Search", MbIconAsterisk | MbOk); } } break; case E_SELECTALL: top->mle->SetSelection(wRange(0, top->mle->GetNumChars())); break; case O_TABSTOPS: { ushort tmp; TabStops ts(this, &tab); if ((tmp = ts.GetResult()) != 0) { tab = tmp; if (top) { Document *doc; for (DocList()->First() ; (doc=(Document*)(DocList()->Current())) != 0 ; DocList()->Next()) doc->mle->SetTabStop(tmp); } } } break; case O_WWRAP: { wwrap = !wwrap; for (DocList()->First() ; (doc = (Document*)(DocList()->Current())) != 0 ; DocList()->Next()) (doc->mle->SetWrap(wwrap)); menu->ToggleCheckItem(O_WWRAP); } break; default: return FALSE; } return FALSE; }