Пример #1
0
/**
 * Create the window designed by wxformbuilder,
 * then add specific code editor, htanks to wxstedit
 */
CapriceIDEImpl::CapriceIDEImpl(wxWindow* parent, WXEmulator* emulator) : 
  IDE(parent),
  emulator(emulator)
{

  
   m_mainSplitter = new wxSplitterWindow((wxWindow*)this, ID_STF_MAIN_SPLITTER);
   
   wxSTEditorOptions steOptions(STE_DEFAULT_OPTIONS);
   steOptions.GetMenuManager()->SetMenuOptionType(STE_MENU_NOTEBOOK, true);
   wxSTEditorOptions::SetGlobalDefaultFileName(wxT("newfile.asm"));
   wxSTEditorOptions::SetGlobalDefaultFileExtensions(wxT("Z80 file (*.asm)|*.asm"));

   m_mainSplitter->SetMinimumPaneSize(10);

   m_steNotebook = new wxSTEditorNotebook(
       m_mainSplitter, 
       wxID_ANY, 
       wxDefaultPosition, 
       wxDefaultSize,
       wxCLIP_CHILDREN);
   m_steNotebook->CreateOptions(steOptions);
  (void)m_steNotebook->InsertEditorSplitter(-1, wxID_ANY, _T("demo.asm"), true);
  
  m_steNotebook->UpdateAllItems();
  m_mainSplitter->Initialize(m_steNotebook);

}
Пример #2
0
CodeEditor::CodeEditor(wxWindow* parent, gd::String filename_, gd::Project * game_, const gd::MainFrameWrapper & mainFrameWrapper_) :
filename(filename_),
game(game_),
mainFrameWrapper(mainFrameWrapper_)
{
	//(*Initialize(CodeEditor)
	wxFlexGridSizer* FlexGridSizer1;

	Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY"));
	FlexGridSizer1 = new wxFlexGridSizer(0, 3, 0, 0);
	textEditor = new wxSTEditor(this,ID_CUSTOM1,wxDefaultPosition,wxDefaultSize,0,_T("ID_CUSTOM1"));
	FlexGridSizer1->Add(textEditor, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
	SetSizer(FlexGridSizer1);
	MenuItem1 = new wxMenuItem((&contextMenu), ID_MENUITEM1, _("Copy"), wxEmptyString, wxITEM_NORMAL);
	MenuItem1->SetBitmap(gd::SkinHelper::GetIcon("copy", 16));
	contextMenu.Append(MenuItem1);
	MenuItem2 = new wxMenuItem((&contextMenu), ID_MENUITEM2, _("Cut"), wxEmptyString, wxITEM_NORMAL);
	MenuItem2->SetBitmap(gd::SkinHelper::GetIcon("cut", 16));
	contextMenu.Append(MenuItem2);
	MenuItem3 = new wxMenuItem((&contextMenu), ID_MENUITEM3, _("Paste"), wxEmptyString, wxITEM_NORMAL);
	MenuItem3->SetBitmap(gd::SkinHelper::GetIcon("paste", 16));
	contextMenu.Append(MenuItem3);
	contextMenu.AppendSeparator();
	MenuItem4 = new wxMenuItem((&contextMenu), ID_MENUITEM4, _("Cancel"), wxEmptyString, wxITEM_NORMAL);
	MenuItem4->SetBitmap(gd::SkinHelper::GetIcon("undo", 16));
	contextMenu.Append(MenuItem4);
	MenuItem5 = new wxMenuItem((&contextMenu), ID_MENUITEM5, _("Redo"), wxEmptyString, wxITEM_NORMAL);
	MenuItem5->SetBitmap(gd::SkinHelper::GetIcon("redo", 16));
	contextMenu.Append(MenuItem5);
	FlexGridSizer1->Fit(this);
	FlexGridSizer1->SetSizeHints(this);

	textEditor->Connect(wxEVT_RIGHT_UP,(wxObjectEventFunction)&CodeEditor::OntextEditorRightUp,0,this);
	Connect(ID_MENUITEM1,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CodeEditor::OnMenuCopySelected);
	Connect(ID_MENUITEM2,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CodeEditor::OnMenuCutSelected);
	Connect(ID_MENUITEM3,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CodeEditor::OnMenuPasteSelected);
	Connect(ID_MENUITEM4,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CodeEditor::OnMenuUndoSelected);
	Connect(ID_MENUITEM5,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CodeEditor::OnMenuRedoSelected);
	Connect(wxEVT_SIZE,(wxObjectEventFunction)&CodeEditor::OnResize);
	//*)
	Connect(ID_CUSTOM1, wxEVT_STC_UPDATEUI, (wxObjectEventFunction)&CodeEditor::UpdateTextCtrl);
	Connect(ID_CUSTOM1, wxEVT_STC_CHARADDED, (wxObjectEventFunction)&CodeEditor::OnCharAdded);

    textEditor->SetLanguage(STE_LANG_CPP);
	textEditor->LoadFile(filename);

    wxSTEditorOptions steOptions(STE_DEFAULT_OPTIONS);
    steOptions.LoadConfig(*wxConfigBase::Get());
    textEditor->CreateOptions(steOptions);
}