void CObjectSelectTool::EndTool() { // TODO: 在此添加控件通知处理程序代码 if ( mSelectionBuffer ) { delete mSelectionBuffer; mSelectionBuffer = NULL; } GetEditor()->unRegisterEditorListener( this ); if(mLastSelectedEntity) mLastSelectedEntity->getParentSceneNode()->showBoundingBox(false); if ( m_iCurrentPageId ) { m_pObjectCtrl->RemovePage(m_iCurrentPageId); } mAxisGizmo.DestroyGizmo(); }
void PreciseScaleCmd::Execute () { float x = 0.0, y = 0.0; Editor* ed = GetEditor(); if (_dialog == nil) { _dialog = new ScaleDialog(); } ed->InsertDialog(_dialog); bool accepted = _dialog->Accept(); ed->RemoveDialog(_dialog); if (accepted) { _dialog->GetValues(x, y); if (x != 0.0 && y != 0.0) { ScaleCmd* scaleCmd = new ScaleCmd(ed, x, y); scaleCmd->Execute(); scaleCmd->Log(); } } }
void PreciseRotateCmd::Execute () { float angle = 0.0; Editor* ed = GetEditor(); if (_dialog == nil) { _dialog = new RotateDialog(); } ed->InsertDialog(_dialog); bool accepted = _dialog->Accept(); ed->RemoveDialog(_dialog); if (accepted) { _dialog->GetValue(angle); if (angle != 0.0) { RotateCmd* rotateCmd = new RotateCmd(ed, angle); rotateCmd->Execute(); rotateCmd->Log(); } } }
//------------------------------------------------------------ void SnipWiz::OnMenuPaste(wxCommandEvent& e) { wxUnusedVar(e); IEditor* editor = GetEditor(); if(!editor) return; if(m_clipboard.IsEmpty()) return; // otherwise insert text wxString output = FormatOutput(editor, m_clipboard); wxString selection = editor->GetSelection(); int curPos = editor->GetCurrentPosition() - selection.Len(); // get caret position long cursorPos = output.Find(REAL_CARET_STR); if(cursorPos != wxNOT_FOUND) output.Remove(cursorPos, wxStrlen(REAL_CARET_STR)); editor->ReplaceSelection(output); // set caret if(cursorPos != wxNOT_FOUND) editor->SetCaretAt(curPos + cursorPos); else editor->SetCaretAt(curPos + output.Len()); }
void wxSTEditorNotebook::UpdateItems(wxMenu *menu, wxMenuBar *menuBar, wxToolBar *toolBar) { if (!menu && !menuBar && !toolBar) return; bool has_pages = GetPageCount() > 0; bool can_save_all = CanSaveAll(); bool editor_page = GetEditor() != NULL; STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_SAVE_ALL, can_save_all); if (menu) { wxMenuItem *gotoMenuItem = menu->FindItem(ID_STN_MENU_GOTO); if (gotoMenuItem) UpdateGotoCloseMenu(gotoMenuItem->GetSubMenu(), ID_STN_GOTO_PAGE_START); wxMenuItem *closeMenuItem = menu->FindItem(ID_STN_MENU_CLOSE); if (closeMenuItem) UpdateGotoCloseMenu(closeMenuItem->GetSubMenu(), ID_STN_CLOSE_PAGE_START); } if (menuBar) { wxMenuItem *gotoMenuItem = menuBar->FindItem(ID_STN_MENU_GOTO); if (gotoMenuItem) UpdateGotoCloseMenu(gotoMenuItem->GetSubMenu(), ID_STN_GOTO_PAGE_START); wxMenuItem *closeMenuItem = menuBar->FindItem(ID_STN_MENU_CLOSE); if (closeMenuItem) UpdateGotoCloseMenu(closeMenuItem->GetSubMenu(), ID_STN_CLOSE_PAGE_START); } STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_WIN_PREVIOUS, has_pages); // && (GetSelection() > 0)); STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_WIN_NEXT, has_pages); // && (GetSelection()+1 < (int)GetPageCount())); STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_MENU_GOTO, has_pages); STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_CLOSE_PAGE, editor_page); STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_CLOSE_ALL, has_pages); STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_CLOSE_ALL_OTHERS, has_pages); STE_MM::DoEnableItem(menu, menuBar, toolBar, ID_STN_MENU_CLOSE, has_pages); }
void NewCompCmd::Execute () { Editor* ed = GetEditor(); Component* orig = ed->GetComponent(); Component* comp = prototype_->Copy(); CompNameVar* compNameVar = (CompNameVar*) ed->GetState("CompNameVar"); ModifStatusVar* modifVar = (ModifStatusVar*)ed->GetState("ModifStatusVar"); if (OnlyOneEditorOf(orig) && !ReadyToClose(ed)) { return; } if (compNameVar != nil) compNameVar->SetComponent(comp); if (modifVar != nil) modifVar->SetComponent(comp); ed->SetComponent(comp); ed->Update(); if (orig != nil && unidraw->FindAny(orig) == nil) { Component* root = orig->GetRoot(); delete root; } }
void editor_renz_shutdown(Tcl_Interp *interp, editor_result *result, int seq_num){ EDITOR_RECORD *er; ed_renz_res *data = result->data; out_canvas_e *output = result->output; char cmd[1024]; int ed_id, seq_id; /* need to deregister sequence */ editor_deregister(seq_num, ed_renz_callback, (editor_result *)result); ed_delete_cursor(seq_num, output->cursor->id, 0); seq_id = GetEdenId (seq_num); ed_id = GetEdIdFromSeqId (seq_id); er = GetEditor (ed_id); er->graphical = 0; if (er->text == 0) { delete_editor (ed_id); } sprintf(cmd, "DeleteREnzPlot %s %s\n", data->frame, data->re_win); if (TCL_ERROR == Tcl_Eval(interp, cmd)) { verror(ERR_WARN, "restriction enzymes", "shutdown %s\n", interp->result); } ed_renz_shutdown(data->r_enzyme, data->num_enzymes, data->match, data->canvas, data->world, data->zoom); free(data->text_colour); free(data->tick->colour); free(data->cursor.colour); free(data->ruler->tick.t.colour); free(data->ruler->colour); xfree(result->data); /* xfree(result->input); */ xfree(result->output); xfree(result); }
void EntityEx::Create( const String& entityName, const String& meshName, const String& mtlName ) { mpSceneMgr = GetEditor()->GetSceneManager(); // create main model msEntityName = entityName; mpSceneNode = mpSceneMgr->getRootSceneNode()->createChildSceneNode(); mpEntity = mpSceneMgr->createEntity( msEntityName, meshName ); mpEntity->setUserAny( Ogre::Any(this) ); mbVisible = false; mpTipNode = static_cast<SceneNode*>(mpSceneNode->createChild()); msBillboardName = entityName + "bbinfo"; mpTipBoard = mpSceneMgr->createBillboardSet(msBillboardName); Billboard* pTip = mpTipBoard->createBillboard(Vector3(0, 50, 0)); pTip->setDimensions( 20.0f, 20.0f ); if ( mtlName != "NULL" ) { mpEntity->setMaterialName(mtlName); mpTipBoard->setMaterialName(mtlName); } }
void PreciseMoveCmd::Execute () { float dx = 0.0, dy = 0.0; Editor* ed = GetEditor(); if (_dialog == nil) { _dialog = new MoveDialog(); } ed->InsertDialog(_dialog); boolean accepted = _dialog->Accept(); ed->RemoveDialog(_dialog); if (accepted) { _dialog->GetValues(dx, dy); if (dx != 0.0 || dy != 0.0) { MoveCmd* moveCmd = new MoveCmd(ed, dx, dy); moveCmd->Execute(); moveCmd->Log(); } } }
void SaveCompCmd::Execute () { Editor* ed = GetEditor(); ModifStatusVar* modifVar = (ModifStatusVar*)ed->GetState("ModifStatusVar"); CompNameVar* compNameVar = (CompNameVar*) ed->GetState("CompNameVar"); const char* name = (compNameVar == nil) ? nil : compNameVar->GetName(); if (name == nil) { SaveCompAsCmd saveCompAs(ed); saveCompAs.Execute(); } else if (modifVar == nil || modifVar->GetModifStatus()) { Catalog* catalog = unidraw->GetCatalog(); Component* comp; if (catalog->Retrieve(name, comp) && catalog->Save(comp, name)) { if (modifVar != nil) modifVar->SetModifStatus(false); unidraw->ClearHistory(comp); } else { char title[CHARBUFSIZE]; const char* reason = !Writable(comp) ? "(File not writable.)" : ""; sprintf(title, "Couldn't save! %s", reason); char subtitle[CHARBUFSIZE]; const char* domain = unidraw->GetCatalog()->GetAttribute("domain"); domain = (domain == nil) ? "component" : domain; sprintf(subtitle, "Save this %s as:", domain); Style* s = new Style(Session::instance()->style()); s->attribute("caption", title); s->attribute("subcaption", subtitle); s->attribute("open", "Save"); /* BUG: style s is never used!!!! */ SaveCompAsCmd saveCompAs(ed); saveCompAs.Execute(); } } }
void CommandDrawHeightmap::Execute() { LandscapeEditorHeightmap* editor = GetEditor(); if (editor == NULL) { SetState(STATE_INVALID); return; } Heightmap* heightmap; editor->GetHeightmap(&heightmap); if (redoFilename == "") { redoFilename = SaveHeightmap(heightmap, "_" + GetRandomString(10)); } else { heightmap->Load(redoFilename); editor->UpdateHeightmap(heightmap); } }
void wxSTEditorFrame::OnNotebookPageChanged(wxNotebookEvent &WXUNUSED(event)) { wxSTEditor *editor = GetEditor(); wxString title; wxSTEditorMenuManager *steMM = GetOptions().GetMenuManager(); if (editor) { title = MakeTitle(editor); if ( steMM && !steMM->HasEnabledEditorItems()) steMM->EnableEditorItems(true, NULL, GetMenuBar(), GetToolBar()); } else { title = m_titleBase; if (steMM && steMM->HasEnabledEditorItems()) steMM->EnableEditorItems(false, NULL, GetMenuBar(), GetToolBar()); } SetTitle(title); }
// ------------------------------------------------------------ void SpellCheck::OnCheck(wxCommandEvent& e) { IEditor* editor = GetEditor(); if(!editor) return; wxString text = editor->GetEditorText(); text += wxT(" "); // prevents indicator flickering at end of file if(m_pEngine != NULL) { if(GetCheckContinuous()) // switch continuous search off if running SetCheckContinuous(false); // if we don't have a dictionary yet, open settings if(!m_pEngine->GetDictionary()) { OnSettings(e); return; } switch(editor->GetLexerId()) { case 3: { // wxSCI_LEX_CPP if(m_mgr->IsWorkspaceOpen()) { m_pEngine->CheckCppSpelling(text); if(!m_checkContinuous) { editor->ClearUserIndicators(); } } } break; case 1: { // wxSCI_LEX_NULL m_pEngine->CheckSpelling(text); if(!m_checkContinuous) { editor->ClearUserIndicators(); } } break; } } }
void QuitCmd::Execute () { Editor* ed = GetEditor(); if (ReadyToClose(ed)) { Component* comp = ed->GetComponent(); if (comp == nil) { unidraw->Close(ed); } else { unidraw->CloseDependents(comp->GetRoot()); } Iterator i; for (;;) { unidraw->First(i); if (unidraw->Done(i)) { break; } ed = unidraw->GetEditor(i); if (ReadyToClose(ed)) { comp = ed->GetComponent(); if (comp == nil) { unidraw->Close(ed); } else { unidraw->CloseDependents(comp->GetRoot()); } } else { return; } } unidraw->Quit(); } }
void GroupCmd::Execute () { Clipboard* cb = GetClipboard(); if (cb == nil) { SetClipboard(cb = new Clipboard); Editor* ed = GetEditor(); Selection* s = ed->GetSelection(); if (s->Number() > 1) { Iterator i; GraphicView* views = ed->GetViewer()->GetGraphicView(); s->Sort(views); for (s->First(i); !s->Done(i); s->Next(i)) { s->GetView(i)->Interpret(this); } } } else { Clipboard* oldcb = cb; SetClipboard(cb = new Clipboard); Iterator i; for (oldcb->First(i); !oldcb->Done(i); oldcb->Next(i)) { oldcb->GetComp(i)->Interpret(this); } delete oldcb; } if (!cb->IsEmpty()) { if (_group == nil) { SetGroup(new GraphicComps); } _group->Interpret(this); _executed = true; } }
void CNpcTestTool::OnMouseMove(UINT nFlags, CPoint point) { switch (mState) { case E_NPC_BORN: { Ogre::TerrainGroup::RayResult rayResult = GetEditor()->TerrainHitTest( point ); if (rayResult.hit) { mpNpc->setPosition(rayResult.position); } } break; case E_NPC_IDLE: { //Ogre::TerrainGroup::RayResult rayResult = GetEditor()->TerrainHitTest( point ); //if (rayResult.hit) //{ // mpNpc->setGoalDirection(rayResult.position); //} } break; } }
void CRenderDialog::OnRButtonUp(UINT nFlags, CPoint point) { GetEditor()->OnRButtonUp(nFlags,point); CDialog::OnRButtonUp(nFlags, point); }
BOOL CRenderDialog::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { GetEditor()->OnMouseWheel( nFlags, zDelta, pt); return CDialog::OnMouseWheel( nFlags, zDelta, pt); }
void CRenderDialog::OnMouseMove(UINT nFlags, CPoint point) { CDialog::OnMouseMove(nFlags, point); GetEditor()->OnMouseMove(nFlags,point); }
void CRenderDialog::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { CDialog::OnKeyUp(nChar, nRepCnt, nFlags); GetEditor()->OnKeyUp(nChar,nRepCnt,nFlags); }
HTMLTextAreaElement::GetTextEditor() { return GetEditor(); }
MenuItem* FrameKit::MakeFrameMenu() { LayoutKit& lk = *LayoutKit::instance(); WidgetKit& kit = *WidgetKit::instance(); MenuItem *mbi = kit.menubar_item(kit.label("Frame")); mbi->menu(kit.pulldown()); MoveFrameCmd::default_instance (new MoveFrameCmd(new ControlInfo("Move Forward","^F",""), +1)); MakeMenu(mbi, MoveFrameCmd::default_instance(), "Move Forward "); MakeMenu(mbi, new MoveFrameCmd(new ControlInfo("Move Backward","^B",""), -1), "Move Backward "); MakeMenu(mbi, new FrameBeginCmd(new ControlInfo("Goto First Frame")), "Goto First Frame"); MakeMenu(mbi, new FrameEndCmd(new ControlInfo("Goto Last Frame")), "Goto Last Frame "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new CreateMoveFrameCmd(new ControlInfo("New Forward","F","F")), "New Forward "); MakeMenu(mbi, new CreateMoveFrameCmd(new ControlInfo("New Backward","B","B"), false), "New Backward "); MakeMenu(mbi, new CopyMoveFrameCmd(new ControlInfo("Copy Forward","X","X")), "Copy Forward "); MakeMenu(mbi, new CopyMoveFrameCmd(new ControlInfo("Copy Backward","Y","Y"), false), "Copy Backward "); MakeMenu(mbi, new DeleteFrameCmd(new ControlInfo("Delete","D","D")), "Delete "); mbi->menu()->append_item(kit.menu_item_separator()); MakeMenu(mbi, new ShowOtherFrameCmd(new ControlInfo("Show Prev Frame","",""), -1), "Show Prev Frame"); MakeMenu(mbi, new ShowOtherFrameCmd(new ControlInfo("Hide Prev Frame","",""), 0), "Hide Prev Frame"); MenuItem* menu_item; menu_item = kit.menu_item(kit.label("Enable Looping")); menu_item->action (new ActionCallback(MoveFrameCmd) (MoveFrameCmd::default_instance(), &MoveFrameCmd::set_wraparound)); mbi->menu()->append_item(menu_item); menu_item = kit.menu_item(kit.label("Disable Looping")); menu_item->action (new ActionCallback(MoveFrameCmd) (MoveFrameCmd::default_instance(), &MoveFrameCmd::clr_wraparound)); mbi->menu()->append_item(menu_item); #if 0 MakeMenu(mbi, new AutoNewFrameCmd(new ControlInfo("Toggle Auto New Frame", "","")), "Toggle Auto New Frame"); #else menu_item = kit.check_menu_item(kit.label("Auto New Frame")); menu_item->state()->set(TelltaleState::is_chosen, ((FrameEditor*)GetEditor())->AutoNewFrame()); ((FrameEditor*)GetEditor())->_autonewframe_tts = menu_item->state(); AutoNewFrameCmd::default_instance(new AutoNewFrameCmd(GetEditor())); menu_item->action (new ActionCallback(AutoNewFrameCmd) (AutoNewFrameCmd::default_instance(), &AutoNewFrameCmd::Execute)); mbi->menu()->append_item(menu_item); #endif return mbi; }
int ed_renz_reg (Tcl_Interp *interp, int seq_id, out_canvas_e *output, char *frame, char *names_win, char *re_win, char *inlist, int num_items, int start, int end, int text_offset, char *text_fill, tick_s *tick, int yoffset, ruler_s *ruler, cursor_s cursor) { editor_result *result; RENZYMES *r_enzyme; SELECTION *selection; EDITOR_RECORD *er; ed_renz_res *data; int id, ed_id, group_id, member_id; int seq_num, seq_type; seq_reg_cursor_notify cn; int line_width; char **sel = NULL; int num_sel; if (NULL == (result = (editor_result *)xmalloc(sizeof(editor_result)))) return -1; if (NULL == (data = (ed_renz_res *)xmalloc(sizeof(ed_renz_res)))) return -1; seq_num = GetEdenNum(seq_id); /* get position of the sequence in registration list */ seq_type = GetEdenType (seq_num); result->data = data; result->seq_id[HORIZONTAL] = seq_id; result->seq_id[VERTICAL] = -1; id = get_editor_reg_id(); result->id = id; result->output = (void *)output; result->pr_func = ed_nip_renz_print_func; result->op_func = ed_renz_callback; result->txt_func = ed_nip_renz_text_func; /* data structure */ strcpy(data->re_win, re_win); strcpy(data->frame, frame); strcpy(data->names_win, names_win); data->tick = tick; data->ruler = ruler; data->cursor = cursor; /* cursor_s */ data->sequence_len = GetEdenLength (seq_num); data->sequence_type = seq_type; /* create list of windows in the restriction enzyme display */ if (NULL == (data->win_list = (win **)xmalloc(MAX_NUM_WINS * sizeof(win*)))) return -1; data->num_wins = 0; addWindow(data->win_list, &data->num_wins, data->re_win, 'b', id); addWindow(data->win_list, &data->num_wins, data->ruler->window, 'x', id); addWindow(data->win_list, &data->num_wins, data->names_win, 'y', id); if (NULL == (data->canvas = (CanvasPtr *)xmalloc(sizeof(CanvasPtr)))) return -1; if (NULL == (data->world= (WorldPtr *)xmalloc(sizeof(WorldPtr)))) return -1; if (NULL == (data->world->visible = (d_box *)xmalloc(sizeof(d_box)))) return -1; if (NULL == (data->world->total = (d_box *)xmalloc(sizeof(d_box)))) return -1; initCanvas(interp, data->canvas, data->re_win); createZoom(&data->zoom); /* create selecing Renzyme name array */ if (Tcl_SplitList(interp, inlist, &num_sel, &sel) != TCL_OK) return -1; r_enzyme = get_selected_renzyme ( num_sel, sel); data->r_enzyme = r_enzyme; data->num_enzymes = num_sel; /* num_items = num_sel ? */; data->tick = tick; data->yoffset = yoffset; data->text_offset = text_offset; data->text_colour = strdup(text_fill); /*data->seq_id = seq_num;*/ data->seq_id = seq_id; data->match = NULL; data->num_match = 0; selection = init_selection (); data->sel = selection; line_width = get_default_int(interp, nip_defs, w("NIP.CURSOR.LINE_WIDTH")); /* private=0: share cursor for every plot */ output->cursor = editor_create_cursor(seq_num, 0, NULL, line_width, 1, HORIZONTAL); output->cursor_visible = 0; ed_id = GetEdIdFromSeqId (seq_id); member_id = GetMemberIdFromSeqId (seq_id); group_id = GetGroupIdFromSeqId (seq_id); er = GetEditor (ed_id); er->graphical = 1; output->cursor->frame_name = NULL; output->cursor->posy = member_id; set_editor_cursor (ed_id, output->cursor); /* move cursor to start position if this is our own cursor */ if (output->cursor->refs == 1) { output->cursor->abspos = start; output->cursor->posy = 1; } editor_register(seq_num, ed_renz_callback, (void *)result, SEQ_PLOT_TEMP, id); ed_renz_replot (interp, output, result, data); /* if above returns -1, may want to * to editor_renz_shutdown(interp, result, seq_num); ? */ cn.job = SEQ_CURSOR_NOTIFY; cn.cursor = output->cursor; cn.cursor->job = CURSOR_MOVE; cn.selection = selection; editor_notify(seq_num, (editor_reg_data *)&cn); return id; }
void CRenderDialog::OnCancel() { GetEditor()->SetEditTool(NULL); }
void CRenderDialog::OnDestroy() { GetEditor()->Destroy(); CDialog::OnDestroy(); }
boolean GraphExportCmd::Export (const char* pathname) { Editor* editor = GetEditor(); Selection* s = editor->GetSelection(); GraphIdrawComp* real_top = (GraphIdrawComp*)editor->GetComponent(); boolean ok = false; char* old_format = NULL; boolean empty = s->IsEmpty(); GraphIdrawComp* false_top = new GraphIdrawComp(); Iterator i; empty ? real_top->First(i) : s->First(i); while (empty ? !real_top->Done(i) : !s->Done(i)) { if (chooser_->idraw_format() || chooser_->postscript_format()) { OverlayComp* oc = empty ? new OverlayComp(real_top->GetComp(i)->GetGraphic()->Copy()) : new OverlayComp(s->GetView(i)->GetGraphicComp()->GetGraphic()->Copy()); false_top->Append(oc); } else { OverlayComp* oc = empty ? (OverlayComp*)real_top->GetComp(i)->Copy() : (OverlayComp*)s->GetView(i)->GetGraphicComp()->Copy(); false_top->Append(oc); } empty ? real_top->Next(i) : s->Next(i); } OverlayPS* ovpsv; if (chooser_->idraw_format() || chooser_->postscript_format()) ovpsv = (OverlayPS*) false_top->Create(POSTSCRIPT_VIEW); else { ovpsv = (OverlayPS*) false_top->Create(SCRIPT_VIEW); if(strcmp(chooser_->format(), "dot")==0) { old_format = OverlayScript::format() ? strnew(OverlayScript::format()) : NULL; OverlayScript::format("dot"); } } if (ovpsv != nil) { filebuf fbuf; char* tmpfilename; if (chooser_->to_printer()) { tmpfilename = tmpnam(nil); false_top->SetPathName(tmpfilename); ok = fbuf.open(tmpfilename, output) != 0; } else { ok = fbuf.open(pathname, output) != 0; } if (ok) { ostream out(&fbuf); false_top->Attach(ovpsv); ovpsv->SetCommand(this); if (!chooser_->idraw_format() && !chooser_->postscript_format()) ((GraphIdrawScript*)ovpsv)->SetByPathnameFlag(chooser_->by_pathname_flag()); ovpsv->Update(); ok = ovpsv->Emit(out); fbuf.close(); if (chooser_->to_printer()) { char cmd[CHARBUFSIZE]; if (strstr(pathname, "%s")) { char buf[CHARBUFSIZE]; sprintf(buf, pathname, tmpfilename); sprintf(cmd, "(%s;rm %s)&", buf, tmpfilename); } else sprintf(cmd, "(%s %s;rm %s)&", pathname, tmpfilename, tmpfilename); ok = system(cmd) == 0; } } delete ovpsv; } delete false_top; if (old_format) { OverlayScript::format(old_format); delete old_format; } return ok; }
bool TextComposition::HasEditor() const { nsCOMPtr<nsIEditor> editor = GetEditor(); return !!editor; }
void GraphExportCmd::Execute () { Editor* ed = GetEditor(); Style* style; boolean reset_caption = false; if (chooser_ == nil) { style = new Style(Session::instance()->style()); style->attribute("subcaption", "Export selected graphics to file:"); style->attribute("open", "Export"); const char *formats_svg[] = {"EPS", "idraw EPS", "drawtool", "SVG"}; const char *formats_nosvg[] = {"EPS", "idraw EPS", "drawtool", "dot"}; const char *svg_arg = unidraw->GetCatalog()->GetAttribute("svgexport"); const boolean svg_flag = svg_arg && strcmp(svg_arg, "true")==0; const char **formats = svg_flag ? formats_svg : formats_nosvg; int nformats = (svg_flag ? sizeof(formats_svg) : sizeof(formats_nosvg)) / sizeof(char*); const char *commands_svg[] = {"ghostview %s", "idraw %s", "drawtool %s", "firefox %s"}; const char *commands_nosvg[] = {"ghostview %s", "idraw %s", "drawtool %s", "dot %s"}; const char **commands = svg_flag ? commands_svg : commands_nosvg; chooser_ = new ExportChooser(".", WidgetKit::instance(), style, formats, nformats, commands, nil, true); Resource::ref(chooser_); } else { style = chooser_->style(); } boolean again; while (again = chooser_->post_for(ed->GetWindow())) { const String* str = chooser_->selected(); if (str != nil) { NullTerminatedString ns(*str); const char* name = ns.string(); style->attribute("caption", " " ); chooser_->twindow()->repair(); chooser_->twindow()->display()->sync(); Catalog* catalog = unidraw->GetCatalog(); boolean ok = true; if (!chooser_->to_printer() && catalog->Exists(name) && catalog->Writable(name)) { char buf[CHARBUFSIZE]; sprintf(buf, "\"%s\" already exists,", name); GConfirmDialog* dialog = new GConfirmDialog(buf, "Overwrite?"); Resource::ref(dialog); ok = dialog->post_for(ed->GetWindow()); Resource::unref(dialog); } if (ok) { ed->GetWindow()->cursor(hourglass); chooser_->twindow()->cursor(hourglass); if (Export(ns.string())) { again = false; break; } style->attribute("caption", "Export failed!" ); reset_caption = true; ed->GetWindow()->cursor(arrow); chooser_->twindow()->cursor(arrow); } } } chooser_->unmap(); if (reset_caption) { style->attribute("caption", " " ); } if (!again) ed->GetWindow()->cursor(arrow); return; }
////NSIFRAME NS_IMETHODIMP nsTextControlFrame::AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType) { nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent()); NS_ASSERTION(txtCtrl, "Content not a text control element"); nsISelectionController* selCon = txtCtrl->GetSelectionController(); const PRBool needEditor = nsGkAtoms::maxlength == aAttribute || nsGkAtoms::readonly == aAttribute || nsGkAtoms::disabled == aAttribute || nsGkAtoms::spellcheck == aAttribute; nsCOMPtr<nsIEditor> editor; if (needEditor) { GetEditor(getter_AddRefs(editor)); } if ((needEditor && !editor) || !selCon) return nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);; nsresult rv = NS_OK; if (nsGkAtoms::maxlength == aAttribute) { PRInt32 maxLength; PRBool maxDefined = GetMaxLength(&maxLength); nsCOMPtr<nsIPlaintextEditor> textEditor = do_QueryInterface(editor); if (textEditor) { if (maxDefined) { // set the maxLength attribute textEditor->SetMaxTextLength(maxLength); // if maxLength>docLength, we need to truncate the doc content } else { // unset the maxLength attribute textEditor->SetMaxTextLength(-1); } } rv = NS_OK; // don't propagate the error } else if (nsGkAtoms::readonly == aAttribute) { PRUint32 flags; editor->GetFlags(&flags); if (AttributeExists(nsGkAtoms::readonly)) { // set readonly flags |= nsIPlaintextEditor::eEditorReadonlyMask; if (nsContentUtils::IsFocusedContent(mContent)) selCon->SetCaretEnabled(PR_FALSE); } else { // unset readonly flags &= ~(nsIPlaintextEditor::eEditorReadonlyMask); if (!(flags & nsIPlaintextEditor::eEditorDisabledMask) && nsContentUtils::IsFocusedContent(mContent)) selCon->SetCaretEnabled(PR_TRUE); } editor->SetFlags(flags); } else if (nsGkAtoms::disabled == aAttribute) { PRUint32 flags; editor->GetFlags(&flags); if (AttributeExists(nsGkAtoms::disabled)) { // set disabled flags |= nsIPlaintextEditor::eEditorDisabledMask; selCon->SetDisplaySelection(nsISelectionController::SELECTION_OFF); if (nsContentUtils::IsFocusedContent(mContent)) selCon->SetCaretEnabled(PR_FALSE); } else { // unset disabled flags &= ~(nsIPlaintextEditor::eEditorDisabledMask); selCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN); if (nsContentUtils::IsFocusedContent(mContent)) { selCon->SetCaretEnabled(PR_TRUE); } } editor->SetFlags(flags); } else if (!mUseEditor && nsGkAtoms::value == aAttribute) { UpdateValueDisplay(PR_TRUE); } // Allow the base class to handle common attributes supported // by all form elements... else { rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType); } return rv; }
void CommandDrawCustomColors::Cancel() { LandscapeEditorCustomColors* editor = GetEditor(); if (editor && undoImage) editor->RestoreState(undoImage); }