Ejemplo n.º 1
0
bool nnMoreInfo::handlerMouseButtonDown(nnPoint &logPoint, int _color, IExtHandler *hook)
{
    bool  res = false;
    lastPos = logPoint;
    color = _color;
    if (parent)
    {
        IManager *manager = parent->getManager();
        if (manager)
        {
            InnObj *obj = manager->getObj(lastPos.x, lastPos.y);
            if (obj != nullptr)
            {
                std::string  str = obj->toString();
                info.clear();
                info.push_back(str);
                show();
                if (hook)
                    hook->doHandler(action_redraw);
                res = true;
            }
            else
            {
                lastPos.set(-1, -1);
                hide();
            }
        }
    }
    return res;
}
Ejemplo n.º 2
0
void CMakeHelpTab::CreateHelpPage(const wxString& content, const wxString& subject)
{
    wxString text = content;
    text.Replace("<br />", "\n");
    text.Replace("&lt;" , "<");
    text.Replace("&gt;" , ">");
    text.Replace("\r", "");
    text.Replace("\n\n", "\n");
    text.Replace("::\n", "\n\n");
    IManager* manager = ::clGetManager();
    
    // Write the content of the help into a temporary file
    wxFileName fnTemp = wxFileName::CreateTempFileName("cmake");
    wxFileName fnCMakeHelpFile = fnTemp;
    fnCMakeHelpFile.SetFullName("CMakeHelp.cmake");
    
    if(!FileUtils::WriteFileContent(fnCMakeHelpFile, text)) return;
    
    if(manager->OpenFile(fnCMakeHelpFile.GetFullPath())) {
        IEditor* activeEditor = manager->GetActiveEditor();
        if(activeEditor && activeEditor->GetFileName().GetFullPath() == fnCMakeHelpFile.GetFullPath()) {
            activeEditor->GetCtrl()->SetEditable(true);
            activeEditor->ReloadFile();
            activeEditor->GetCtrl()->SetFirstVisibleLine(0);
            activeEditor->GetCtrl()->SetEditable(false);
        }
    }
}
void wxCodeCompletionBoxManager::InsertSelectionTemplateFunction(const wxString& selection)
{
    IManager* manager = ::clGetManager();
    IEditor* editor = manager->GetActiveEditor();
    if(editor) {
        wxStyledTextCtrl* ctrl = editor->GetCtrl();
        // Default behviour: remove the partial text from teh editor and replace it
        // with the selection
        int start = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
        int end = ctrl->GetCurrentPos();
        ctrl->SetSelection(start, end);

        wxString entryText = selection;
        if(entryText.Find("(") != wxNOT_FOUND) {
            // a function like
            wxString textToInsert = entryText.BeforeFirst('(');
            textToInsert << "<>()";
            ctrl->ReplaceSelection(textToInsert);
            // Place the caret between the angle brackets
            int caretPos = start + textToInsert.Len() - 3;
            ctrl->SetCurrentPos(caretPos);
            ctrl->SetSelection(caretPos, caretPos);

        } else {
            ctrl->ReplaceSelection(entryText);
        }
    }
}
Ejemplo n.º 4
0
IManager * Kernel::Manager (string name)
{
	for (ManagerList::iterator it = _managers.begin(); it != _managers.end(); ++it) {
		IManager *m = *it ;
		if (name == m->Name()) return m ;
	}
	return NULL ;
}
Ejemplo n.º 5
0
	/// Remove self from the object hierarchy
	void RemoveFromHierarchy()
	{
		IManager *manager;
		// make sure RTTI information checks that this component is truly
		// of type IManager, some bug is preventing this from working?
		// manager = dynamic_cast<IManager *>(toolBox->CreateComponent(
		manager = static_cast<IManager *>(m_ToolBox->CreateComponent(&m_hierManTypeName, 0));
		assert(manager != NULL);
		manager->DeleteObject(this);
	}
Ejemplo n.º 6
0
void CMakeHelpTab::OnInsert(wxCommandEvent& event)
{
    IManager* manager = m_plugin->GetManager();
    wxASSERT(manager);
    IEditor* editor = manager->GetActiveEditor();

    // No active editor
    if(!editor) return;

    // Insert value
    editor->InsertText(editor->GetCurrentPosition(), m_listBoxList->GetString(event.GetInt()));
}
Ejemplo n.º 7
0
void wxCodeCompletionBoxManager::InsertSelection(const wxString& selection)
{
    IManager* manager = ::clGetManager();
    IEditor* editor = manager->GetActiveEditor();
    if(editor) {
        wxStyledTextCtrl* ctrl = editor->GetSTC();
        // Default behviour: remove the partial text from teh editor and replace it
        // with the selection
        int start = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
        int end = ctrl->GetCurrentPos();
        ctrl->SetSelection(start, end);

        wxString entryText = selection;
        if(entryText.Find("(") != wxNOT_FOUND) {
            // a function like
            wxString textToInsert = entryText.BeforeFirst('(');

            // Build the function signature
            wxString funcSig = entryText.AfterFirst('(');
            funcSig = funcSig.BeforeLast(')');
            funcSig.Trim().Trim(false);

            CL_DEBUG("Inserting selection: %s", textToInsert);
            CL_DEBUG("Signature is: %s", funcSig);

            textToInsert << "()";
            ctrl->ReplaceSelection(textToInsert);
            if(!funcSig.IsEmpty()) {
                // Place the caret between the parenthesis
                int caretPos = start + textToInsert.Len() - 1;
                ctrl->SetCurrentPos(caretPos);
                ctrl->SetSelection(caretPos, caretPos);

                // trigger a code complete for function calltip.
                // We do this by simply mimicing the user action of going to the menubar:
                // Edit->Display Function Calltip
                wxCommandEvent event(wxEVT_MENU, XRCID("function_call_tip"));
                wxTheApp->GetTopWindow()->GetEventHandler()->AddPendingEvent(event);
            }
        } else {
            ctrl->ReplaceSelection(entryText);
        }
    }
}
Ejemplo n.º 8
0
bool nnView::draw(void)
{
    bool res = false;
    int x, y;
    nnPoint map = {0};
    if (parent)
    {
        IManager *manager = parent->getManager();
        IViewGlue * glue = parent->getView();
        if (glue != nullptr)
        {
            nnObjManager & mn = *dynamic_cast<nnObjManager*>(manager);
            nnPoint off = glue->getOffsetView();
            nnPoint map = glue->getMap();
            InnObj *obj;
            res = true;
            map += off;
            for (y = off.y; y < map.y; y++)
            {
                for (x = off.x; x < map.x; x++)
                {
                    obj = manager->getObj(x, y);
                    if (obj)
                    {
                        res &= drawObj(obj, x, y, glue);
                    }
                    else
                    {
                        res &= drawBkg(x, y, glue);
                    }
                }
            }
        }
        if (res)
        {
            drawPower(glue);
        }
    }
    return res;
}
Ejemplo n.º 9
0
int IhmCommunicationThread::SendFrame(IFrame &frame)
{
  char sztmp[255];
  sprintf(sztmp,"IHM: Data Hex: ");
  for (int a=0;a<frame.taille-1;a++)
    sprintf(sztmp,"%s 0x%02X", sztmp, frame.data[a]);
  DOMOASTER_DEBUG << sztmp;

	int sender = (int) frame.sender;

  IManager *nm = _kernel->Manager ("nodes");

	INode *pNode = nm->GetNode (sender) ;
	if (pNode == NULL) {
		DOMOASTER_DEBUG << "SendFrame : node " << sender << " UNKNOWN";
		return 0 ;
	}

  std::stringstream ihm;
	ihm << PARAM_STR("ihm_address") << ":" << PARAM_STR("ihm_port");

	std::stringstream path;
	path << PARAM_STR("ihm_base") << PARAM_STR("ihm_datas_post");

  memset(sztmp, 0, sizeof(sztmp));
  for (int a=0;a<frame.taille-1;a++)
    sprintf(sztmp,"%s0x%02X", sztmp, frame.data[a]);

  stringstream buf;
  buf << "sender=" << sender << "&value=" << sztmp << "\r\n" ;

  WebBrowser browser(ihm.str());
  browser.doPost(path.str(), buf.str());

	return 1;
}
Ejemplo n.º 10
0
void WorkspacePane::CreateGUIControls()
{
    wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
    SetSizer(mainSizer);

// add notebook for tabs
#ifdef __WXOSX__
    long style = (kNotebook_Default | kNotebook_AllowDnD | kNotebook_LeftTabs);
#else
    long style = (kNotebook_Default | kNotebook_AllowDnD);
#endif
    if(EditorConfigST::Get()->GetOptions()->IsTabColourDark()) {
        style &= ~kNotebook_LightTabs;
        style |= kNotebook_DarkTabs;
    }
    style |= kNotebook_UnderlineActiveTab;
    if(EditorConfigST::Get()->GetOptions()->IsMouseScrollSwitchTabs()) {
        style |= kNotebook_MouseScrollSwitchTabs;
    }
    m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
    m_book->SetTabDirection(EditorConfigST::Get()->GetOptions()->GetWorkspaceTabsDirection());
    m_book->SetArt(GetNotebookRenderer());

    // Calculate the widest tab (the one with the 'Workspace' label)
    int xx, yy;
    wxFont fnt = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    wxWindow::GetTextExtent(_("Workspace"), &xx, &yy, NULL, NULL, &fnt);

    mainSizer->Add(m_book, 1, wxEXPAND | wxALL, 0);

    // Add the parsing progress controls
    m_staticText = new wxStaticText(this, wxID_ANY, _("Parsing workspace..."));
    mainSizer->Add(m_staticText, 0, wxEXPAND | wxALL, 2);

    m_parsingProgress =
        new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(-1, 15), wxGA_HORIZONTAL | wxGA_SMOOTH);
    mainSizer->Add(m_parsingProgress, 0, wxEXPAND | wxALL, 1);
    m_parsingProgress->Hide();
    m_staticText->Hide();

    // create tabs (possibly detached)
    DetachedPanesInfo dpi;
    EditorConfigST::Get()->ReadObject(wxT("DetachedPanesList"), &dpi);

    wxArrayString detachedPanes;
    detachedPanes = dpi.GetPanes();

    // Add the workspace tab
    wxString name;

    // the IManager instance
    IManager* mgr = PluginManager::Get();

    name = _("Workspace");
    if(IS_DETACHED(name)) {
        DockablePane* cp = new DockablePane(GetParent(), m_book, name, false, wxNullBitmap, wxSize(200, 200));
        m_workspaceTab = new WorkspaceTab(cp, name);
        cp->SetChildNoReparent(m_workspaceTab);
    } else {
        m_workspaceTab = new WorkspaceTab(m_book, name);
        m_book->AddPage(m_workspaceTab, name, true, wxNullBitmap);
    }
    m_tabs.insert(std::make_pair(name, Tab(name, m_workspaceTab)));
    mgr->AddWorkspaceTab(name);

    // Add the explorer tab
    name = _("Explorer");
    if(IS_DETACHED(name)) {
        DockablePane* cp = new DockablePane(GetParent(), m_book, name, false, wxNullBitmap, wxSize(200, 200));
        m_explorer = new FileExplorer(cp, name);
        cp->SetChildNoReparent(m_explorer);
    } else {
        m_explorer = new FileExplorer(m_book, name);
        m_book->AddPage(m_explorer, name, false);
    }
    m_tabs.insert(std::make_pair(name, Tab(name, m_explorer)));
    mgr->AddWorkspaceTab(name);

    // Add the "File Explorer" view to the list of files managed by the workspace-view
    m_workspaceTab->GetView()->AddPage(m_explorer, _("File Explorer"), false);

// Add the Open Windows Panel (Tabs)
#ifndef __WXOSX__
    name = _("Tabs");
    if(IS_DETACHED(name)) {
        DockablePane* cp = new DockablePane(GetParent(), m_book, name, false, wxNullBitmap, wxSize(200, 200));
        m_openWindowsPane = new OpenWindowsPanel(cp, name);
        cp->SetChildNoReparent(m_openWindowsPane);
    } else {
        m_openWindowsPane = new OpenWindowsPanel(m_book, name);
        m_book->AddPage(m_openWindowsPane, name, false);
    }
    m_tabs.insert(std::make_pair(name, Tab(name, m_openWindowsPane)));
    mgr->AddWorkspaceTab(name);
#endif

    // Add the Tabgroups tab
    name = _("Tabgroups");
    if(IS_DETACHED(name)) {
        DockablePane* cp = new DockablePane(GetParent(), m_book, name, false, wxNullBitmap, wxSize(200, 200));
        m_TabgroupsPane = new TabgroupsPane(cp, name);
        cp->SetChildNoReparent(m_TabgroupsPane);
    } else {
        m_TabgroupsPane = new TabgroupsPane(m_book, name);
        m_book->AddPage(m_TabgroupsPane, name, false);
    }
    m_tabs.insert(std::make_pair(name, Tab(name, m_TabgroupsPane)));
    mgr->AddWorkspaceTab(name);

    if(m_book->GetPageCount() > 0) {
        m_book->SetSelection((size_t)0);
    }
    m_mgr->Update();
}
Ejemplo n.º 11
0
wxCodeCompletionBox::wxCodeCompletionBox(wxWindow* parent, wxEvtHandler* eventObject, size_t flags)
    : wxCodeCompletionBoxBase(parent)
    , m_index(0)
    , m_stc(NULL)
    , m_startPos(wxNOT_FOUND)
    , m_useLightColours(false)
    , m_eventObject(eventObject)
    , m_tipWindow(NULL)
    , m_flags(flags)
{
    SetBackgroundStyle(wxBG_STYLE_PAINT);
    
    m_ccFont = DrawingUtils::GetDefaultFixedFont();
    SetCursor(wxCURSOR_HAND);

    // Calculate the size of the box
    int singleLineHeight = GetSingleLineHeight();
    int boxHeight = singleLineHeight * LINES_PER_PAGE;
    int boxWidth = BOX_WIDTH; // 100 pixels
    wxSize boxSize = wxSize(boxWidth, boxHeight);
    wxRect rect(boxSize);

    // Set the default bitmap list
    BitmapLoader* bmpLoader = clGetManager()->GetStdIcons();
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/class"));              // 0
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/struct"));             // 1
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/namespace"));          // 2
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_public"));      // 3
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/typedef"));            // 4
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_private"));     // 5
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_public"));      // 6
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/member_protected"));   // 7
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/function_private"));   // 8
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/function_public"));    // 9
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/function_protected")); // 10
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/typedef"));            // 11
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/enum"));               // 12
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/enumerator"));         // 13
    m_bitmaps.push_back(bmpLoader->LoadBitmap("mime/16/cpp"));              // 14
    m_bitmaps.push_back(bmpLoader->LoadBitmap("mime/16/h"));                // 15
    m_bitmaps.push_back(bmpLoader->LoadBitmap("mime/16/text"));             // 16
    m_bitmaps.push_back(bmpLoader->LoadBitmap("cc/16/cpp_keyword"));        // 17

    InitializeDefaultBitmaps();

    // Increase the size by 2 pixel for each dimension
    rect.Inflate(2, 2);
    SetSize(rect);
    m_canvas->SetBackgroundStyle(wxBG_STYLE_PAINT);
    m_canvas->Bind(wxEVT_LEFT_DOWN, &wxCodeCompletionBox::OnLeftDClick, this);
    m_canvas->Bind(wxEVT_LEFT_DCLICK, &wxCodeCompletionBox::OnLeftDClick, this);

    // Default colorus (dark theme)
    clColourPalette palette = DrawingUtils::GetColourPalette();

    m_lightBorder = wxColour("rgb(77, 77, 77)");
    m_darkBorder = wxColour("rgb(54, 54, 54)");
    m_penColour = palette.penColour;
    m_bgColour = palette.bgColour;
    m_textColour = palette.textColour;
    m_selectedTextColour = palette.selecteTextColour;
    m_selection = palette.selectionBgColour;
    m_scrollBgColour = wxColour("rgb(50, 50, 50)");

    IManager* manager = ::clGetManager();
    if(manager) {
        IEditor* editor = manager->GetActiveEditor();
        if(editor) {
            wxColour bgColour = editor->GetCtrl()->StyleGetBackground(0);
            if(!DrawingUtils::IsDark(bgColour)) {
                m_useLightColours = true;
                // Need bright colours
                m_lightBorder = *wxWHITE;
                m_darkBorder = wxColour("rgb(207, 207, 207)");
                m_scrollBgColour = wxColour("rgb(198, 198, 198)");
            }
        }
    }

    m_bmpDown = wxXmlResource::Get()->LoadBitmap("cc-box-down");
    m_bmpDownEnabled = m_bmpDown.ConvertToDisabled();

    m_bmpUp = wxXmlResource::Get()->LoadBitmap("cc-box-up");
    m_bmpUpEnabled = m_bmpUp.ConvertToDisabled();

    if(m_useLightColours) {
        // swap between the disabled and enabeld bitmaps
        {
            wxBitmap tmpBitmap;
            tmpBitmap = m_bmpDown;
            m_bmpDown = m_bmpDownEnabled;
            m_bmpDownEnabled = tmpBitmap;
        }

        {
            wxBitmap tmpBitmap;
            tmpBitmap = m_bmpUp;
            m_bmpUp = m_bmpUpEnabled;
            m_bmpUpEnabled = tmpBitmap;
        }
    }
}
void IGUIElement::init()
{
	IManager* manager = ISathraDevice::getInstance()->getManager();
	setController(manager->getController(this));
	manager->addElement(this);
}
Ejemplo n.º 13
0
void wxCodeCompletionBoxManager::InsertSelection(const wxString& selection)
{
    IManager* manager = ::clGetManager();
    IEditor* editor = manager->GetActiveEditor();
    if(editor) {
        wxStyledTextCtrl* ctrl = editor->GetCtrl();
        bool addParens(false);
        int start = wxNOT_FOUND, end = wxNOT_FOUND;
        std::vector<std::pair<int, int> > ranges;
        if(ctrl->GetSelections() > 1) {
            for(int i = 0; i < ctrl->GetSelections(); ++i) {
                int nStart = ctrl->WordStartPosition(ctrl->GetSelectionNCaret(i), true);
                int nEnd = ctrl->GetSelectionNCaret(i);
                ranges.push_back(std::make_pair(nStart, nEnd));
            }
            std::sort(ranges.begin(), ranges.end(), [&](const std::pair<int, int>& e1, const std::pair<int, int>& e2) {
                return e1.first < e2.first;
            });
        } else {
            // Default behviour: remove the partial text from teh editor and replace it
            // with the selection
            start = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
            end = ctrl->GetCurrentPos();
            ctrl->SetSelection(start, end);
            if(ctrl->GetCharAt(end) != '(') {
                addParens = true;
            }
        }

        wxString entryText = selection;
        if(entryText.Find("(") != wxNOT_FOUND) {
            // a function like
            wxString textToInsert = entryText.BeforeFirst('(');

            // Build the function signature
            wxString funcSig = entryText.AfterFirst('(');
            funcSig = funcSig.BeforeLast(')');
            funcSig.Trim().Trim(false);

            CL_DEBUG("Inserting selection: %s", textToInsert);
            CL_DEBUG("Signature is: %s", funcSig);

            // Check if already have an open paren, don't add another
            if(addParens) {
                textToInsert << "()";
            }

            if(!ranges.empty()) {
                // Multiple carets
                int offset = 0;
                for(size_t i = 0; i < ranges.size(); ++i) {
                    int from = ranges.at(i).first;
                    int to = ranges.at(i).second;
                    from += offset;
                    to += offset;
                    // Once we enter that text into the editor, it will change the original
                    // offsets (in most cases the entered text is larger than that typed text)
                    offset += textToInsert.length() - (to - from);
                    ctrl->Replace(from, to, textToInsert);
                    ctrl->SetSelectionNStart(i, from + textToInsert.length());
                    ctrl->SetSelectionNEnd(i, from + textToInsert.length());
                }
            } else {
                ctrl->ReplaceSelection(textToInsert);
                if(!funcSig.IsEmpty()) {

                    // Place the caret between the parenthesis
                    int caretPos(wxNOT_FOUND);
                    if(addParens) {
                        caretPos = start + textToInsert.length() - 1;
                    } else {
                        // Move the caret one char to the right
                        caretPos = start + textToInsert.length() + 1;
                    }
                    ctrl->SetCurrentPos(caretPos);
                    ctrl->SetSelection(caretPos, caretPos);

                    // trigger a code complete for function calltip.
                    // We do this by simply mimicing the user action of going to the menubar:
                    // Edit->Display Function Calltip
                    wxCommandEvent event(wxEVT_MENU, XRCID("function_call_tip"));
                    wxTheApp->GetTopWindow()->GetEventHandler()->AddPendingEvent(event);
                }
            }
        } else {
            if(!ranges.empty()) {
                // Multiple carets
                int offset = 0;
                for(size_t i = 0; i < ranges.size(); ++i) {
                    int from = ranges.at(i).first;
                    int to = ranges.at(i).second;
                    from += offset;
                    to += offset;
                    // Once we enter that text into the editor, it will change the original
                    // offsets (in most cases the entered text is larger than that typed text)
                    offset += entryText.length() - (to - from);
                    ctrl->Replace(from, to, entryText);
                    ctrl->SetSelectionNStart(i, from + entryText.length());
                    ctrl->SetSelectionNEnd(i, from + entryText.length());
                }
            } else {
                // Default
                ctrl->ReplaceSelection(entryText);
            }
        }
    }
}
Ejemplo n.º 14
0
void OutputPane::CreateGUIControls()
{
    wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
    SetSizer(mainSizer);
    SetMinClientSize(wxSize(-1, 250));
    long style = (kNotebook_Default | kNotebook_AllowDnD);
    if(EditorConfigST::Get()->GetOptions()->GetWorkspaceTabsDirection() == wxBOTTOM) {
        style |= kNotebook_BottomTabs;
    } else if(EditorConfigST::Get()->GetOptions()->GetWorkspaceTabsDirection() == wxLEFT) {

#ifdef __WXOSX__
        style &= ~(kNotebook_BottomTabs | kNotebook_LeftTabs | kNotebook_RightTabs);
#else
        style |= kNotebook_LeftTabs;
#endif

    } else if(EditorConfigST::Get()->GetOptions()->GetWorkspaceTabsDirection() == wxRIGHT) {
#ifdef __WXOSX__
        style |= kNotebook_BottomTabs;
#else
        style |= kNotebook_RightTabs;
#endif
    }
    //style |= kNotebook_UnderlineActiveTab;
    
    m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);

    BitmapLoader* bmpLoader = PluginManager::Get()->GetStdIcons();

    // Calculate the widest tab (the one with the 'Workspace' label) TODO: What happens with translations?
    int xx, yy;
    wxFont fnt = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    wxWindow::GetTextExtent(wxGetTranslation(REPLACE_IN_FILES), &xx, &yy, NULL, NULL, &fnt);

    mainSizer->Add(m_book, 1, wxEXPAND | wxALL | wxGROW, 0);

    // the IManager instance
    IManager* mgr = PluginManager::Get();

    // Build tab
    m_buildWin = new NewBuildTab(m_book);
    m_book->AddPage(m_buildWin, wxGetTranslation(BUILD_WIN), true, bmpLoader->LoadBitmap(wxT("build")));
    m_tabs.insert(std::make_pair(wxGetTranslation(BUILD_WIN),
                                 Tab(wxGetTranslation(BUILD_WIN), m_buildWin, bmpLoader->LoadBitmap(wxT("build")))));
    mgr->AddOutputTab(wxGetTranslation(BUILD_WIN));

    // Find in files
    m_findResultsTab = new FindResultsTab(m_book, wxID_ANY, wxGetTranslation(FIND_IN_FILES_WIN));
    m_book->AddPage(m_findResultsTab, wxGetTranslation(FIND_IN_FILES_WIN), false, bmpLoader->LoadBitmap(wxT("find")));
    m_tabs.insert(
        std::make_pair(wxGetTranslation(FIND_IN_FILES_WIN),
                       Tab(wxGetTranslation(FIND_IN_FILES_WIN), m_findResultsTab, bmpLoader->LoadBitmap(wxT("find")))));
    mgr->AddOutputTab(wxGetTranslation(FIND_IN_FILES_WIN));

    // Replace In Files
    m_replaceResultsTab = new ReplaceInFilesPanel(m_book, wxID_ANY, wxGetTranslation(REPLACE_IN_FILES));
    m_book->AddPage(
        m_replaceResultsTab, wxGetTranslation(REPLACE_IN_FILES), false, bmpLoader->LoadBitmap(wxT("find_and_replace")));
    m_tabs.insert(std::make_pair(
        REPLACE_IN_FILES, Tab(REPLACE_IN_FILES, m_replaceResultsTab, bmpLoader->LoadBitmap(wxT("find_and_replace")))));
    mgr->AddOutputTab(REPLACE_IN_FILES);

    // Show Usage ("References")
    m_showUsageTab = new FindUsageTab(m_book, wxGetTranslation(SHOW_USAGE));
    m_book->AddPage(m_showUsageTab, wxGetTranslation(SHOW_USAGE), false, bmpLoader->LoadBitmap(wxT("find")));
    m_tabs.insert(
        std::make_pair(wxGetTranslation(SHOW_USAGE),
                       Tab(wxGetTranslation(SHOW_USAGE), m_showUsageTab, bmpLoader->LoadBitmap(wxT("find")))));
    mgr->AddOutputTab(wxGetTranslation(SHOW_USAGE));

    // Output tab
    m_outputWind = new OutputTab(m_book, wxID_ANY, wxGetTranslation(OUTPUT_WIN));
    m_book->AddPage(m_outputWind, wxGetTranslation(OUTPUT_WIN), false, bmpLoader->LoadBitmap(wxT("console")));
    m_tabs.insert(
        std::make_pair(wxGetTranslation(OUTPUT_WIN),
                       Tab(wxGetTranslation(OUTPUT_WIN), m_outputWind, bmpLoader->LoadBitmap(wxT("console")))));
    mgr->AddOutputTab(wxGetTranslation(OUTPUT_WIN));

#if HAS_LIBCLANG
    // Clang tab
    NewProjImgList images;
    m_clangOutputTab = new ClangOutputTab(m_book);
    m_book->AddPage(m_clangOutputTab, wxGetTranslation(CLANG_TAB), false, images.Bitmap("clang16"));
    m_tabs.insert(std::make_pair(wxGetTranslation(CLANG_TAB),
                                 Tab(wxGetTranslation(CLANG_TAB), m_clangOutputTab, images.Bitmap("clang16"))));
    mgr->AddOutputTab(wxGetTranslation(CLANG_TAB));
#endif

    wxTextCtrl* text = new wxTextCtrl(m_book,
                                      wxID_ANY,
                                      wxEmptyString,
                                      wxDefaultPosition,
                                      wxDefaultSize,
                                      wxTE_RICH2 | wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL);

    /////////////////////////////////////
    // Set the trace's font & colors
    /////////////////////////////////////

    m_book->AddPage(text, wxGetTranslation(TRACE_TAB), false, bmpLoader->LoadBitmap("log"));
    m_logTargetOld = wxLog::SetActiveTarget(new wxclTextCtrl(text));
    m_tabs.insert(std::make_pair(wxGetTranslation(TRACE_TAB),
                                 Tab(wxGetTranslation(TRACE_TAB), text, bmpLoader->LoadBitmap("log"))));
    mgr->AddOutputTab(wxGetTranslation(TRACE_TAB));

    // Now that we set up our own log target, re-enable the logging
    wxLog::EnableLogging(true);

    // Tasks panel
    m_taskPanel = new TaskPanel(m_book, wxID_ANY, wxGetTranslation(TASKS));
    m_book->AddPage(m_taskPanel, wxGetTranslation(TASKS), false, bmpLoader->LoadBitmap("tasks"));
    m_tabs.insert(std::make_pair(wxGetTranslation(TASKS),
                                 Tab(wxGetTranslation(TASKS), m_taskPanel, bmpLoader->LoadBitmap("tasks"))));
    mgr->AddOutputTab(wxGetTranslation(TASKS));

    SetMinSize(wxSize(200, 100));
    mainSizer->Layout();
}
Ejemplo n.º 15
0
void OutputPane::CreateGUIControls()
{
    wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
    SetSizer(mainSizer);
    SetMinClientSize(wxSize(-1, 250));
#if USE_AUI_NOTEBOOK
    long style = wxAUI_NB_TOP | wxAUI_NB_TAB_MOVE | wxAUI_NB_WINDOWLIST_BUTTON | wxAUI_NB_TAB_SPLIT;
    m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
    m_book->SetTabDirection(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection());
#else
    long style = (kNotebook_Default | kNotebook_AllowDnD);
    if(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxBOTTOM) {
        style |= kNotebook_BottomTabs;
    } else if(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxLEFT) {
#ifdef __WXOSX__
        style &= ~(kNotebook_BottomTabs | kNotebook_LeftTabs | kNotebook_RightTabs);
#else
        style |= kNotebook_LeftTabs;
#endif
    } else if(EditorConfigST::Get()->GetOptions()->GetOutputTabsDirection() == wxRIGHT) {
#ifdef __WXOSX__
        style |= kNotebook_BottomTabs;
#else
        style |= kNotebook_RightTabs;
#endif
    }
    if(EditorConfigST::Get()->GetOptions()->IsTabColourDark()) {
        style &= ~kNotebook_LightTabs;
        style |= kNotebook_DarkTabs;
    }
    style |= kNotebook_UnderlineActiveTab;
    if(EditorConfigST::Get()->GetOptions()->IsMouseScrollSwitchTabs()) { style |= kNotebook_MouseScrollSwitchTabs; }
    m_book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
#endif
    BitmapLoader* bmpLoader = PluginManager::Get()->GetStdIcons();

    // Calculate the widest tab (the one with the 'Workspace' label) TODO: What happens with translations?
    int xx, yy;
    wxFont fnt = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
    wxWindow::GetTextExtent(wxGetTranslation(REPLACE_IN_FILES), &xx, &yy, NULL, NULL, &fnt);

    mainSizer->Add(m_book, 1, wxEXPAND | wxALL | wxGROW, 0);

    // the IManager instance
    IManager* mgr = PluginManager::Get();

    // Build tab
    m_buildWin = new NewBuildTab(m_book);
    m_book->AddPage(m_buildWin, wxGetTranslation(BUILD_WIN), true, bmpLoader->LoadBitmap(wxT("build")));
    m_tabs.insert(std::make_pair(wxGetTranslation(BUILD_WIN),
                                 Tab(wxGetTranslation(BUILD_WIN), m_buildWin, bmpLoader->LoadBitmap(wxT("build")))));
    mgr->AddOutputTab(wxGetTranslation(BUILD_WIN));

    // Find in files
    m_findResultsTab = new FindResultsTab(m_book, wxID_ANY, wxGetTranslation(FIND_IN_FILES_WIN));
    m_book->AddPage(m_findResultsTab, wxGetTranslation(FIND_IN_FILES_WIN), false, bmpLoader->LoadBitmap(wxT("find")));
    m_tabs.insert(
        std::make_pair(wxGetTranslation(FIND_IN_FILES_WIN),
                       Tab(wxGetTranslation(FIND_IN_FILES_WIN), m_findResultsTab, bmpLoader->LoadBitmap(wxT("find")))));
    mgr->AddOutputTab(wxGetTranslation(FIND_IN_FILES_WIN));

    // Replace In Files
    m_replaceResultsTab = new ReplaceInFilesPanel(m_book, wxID_ANY, wxGetTranslation(REPLACE_IN_FILES));
    m_book->AddPage(m_replaceResultsTab, wxGetTranslation(REPLACE_IN_FILES), false,
                    bmpLoader->LoadBitmap(wxT("find_and_replace")));
    m_tabs.insert(std::make_pair(
        REPLACE_IN_FILES, Tab(REPLACE_IN_FILES, m_replaceResultsTab, bmpLoader->LoadBitmap(wxT("find_and_replace")))));
    mgr->AddOutputTab(REPLACE_IN_FILES);

    // Show Usage ("References")
    m_showUsageTab = new FindUsageTab(m_book, wxGetTranslation(SHOW_USAGE));
    m_book->AddPage(m_showUsageTab, wxGetTranslation(SHOW_USAGE), false, bmpLoader->LoadBitmap(wxT("find")));
    m_tabs.insert(std::make_pair(wxGetTranslation(SHOW_USAGE), Tab(wxGetTranslation(SHOW_USAGE), m_showUsageTab,
                                                                   bmpLoader->LoadBitmap(wxT("find")))));
    mgr->AddOutputTab(wxGetTranslation(SHOW_USAGE));

    // Output tab
    m_outputWind = new OutputTab(m_book, wxID_ANY, wxGetTranslation(OUTPUT_WIN));
    m_book->AddPage(m_outputWind, wxGetTranslation(OUTPUT_WIN), false, bmpLoader->LoadBitmap(wxT("console")));
    m_tabs.insert(std::make_pair(wxGetTranslation(OUTPUT_WIN), Tab(wxGetTranslation(OUTPUT_WIN), m_outputWind,
                                                                   bmpLoader->LoadBitmap(wxT("console")))));
    mgr->AddOutputTab(wxGetTranslation(OUTPUT_WIN));

#if HAS_LIBCLANG
    // Clang tab
    NewProjImgList images;
    m_clangOutputTab = new ClangOutputTab(m_book);
    m_book->AddPage(m_clangOutputTab, wxGetTranslation(CLANG_TAB), false, bmpLoader->LoadBitmap("clang"));
    m_tabs.insert(std::make_pair(wxGetTranslation(CLANG_TAB),
                                 Tab(wxGetTranslation(CLANG_TAB), m_clangOutputTab, bmpLoader->LoadBitmap("clang"))));
    mgr->AddOutputTab(wxGetTranslation(CLANG_TAB));
#endif

    // Tasks panel
    m_taskPanel = new TaskPanel(m_book, wxID_ANY, wxGetTranslation(TASKS));
    m_book->AddPage(m_taskPanel, wxGetTranslation(TASKS), false, bmpLoader->LoadBitmap("tasks"));
    m_tabs.insert(std::make_pair(wxGetTranslation(TASKS),
                                 Tab(wxGetTranslation(TASKS), m_taskPanel, bmpLoader->LoadBitmap("tasks"))));
    mgr->AddOutputTab(wxGetTranslation(TASKS));

    SetMinSize(wxSize(200, 100));
    mainSizer->Layout();
}
Ejemplo n.º 16
0
	void OnCreated( wxObject* wxobject, wxWindow* /*wxparent*/ )
	{
		// For storing objects whose postion needs to be determined
		std::vector< std::pair< wxObject*, wxGBSizerItem* > > newObjects;
		wxGBPosition lastPosition( 0, 0 );

		// Get sizer
		wxGridBagSizer* sizer = wxDynamicCast( wxobject, wxGridBagSizer );
		if ( NULL == sizer )
		{
			wxLogError( wxT("This should be a wxGridBagSizer!") );
			return;
		}

		// Add the children
		IManager* manager = GetManager();
		size_t count = manager->GetChildCount( wxobject );
		if ( 0 == count )
		{
			// wxGridBagSizer gets upset sometimes without children
			sizer->Add( 0, 0, wxGBPosition( 0, 0 ) );
			return;
		}
		for ( size_t i = 0; i < count; ++i )
		{
			// Should be a GBSizerItem
			wxObject* wxsizerItem = manager->GetChild( wxobject, i );
			IObject* isizerItem = manager->GetIObject( wxsizerItem );

			// Get the location of the item
			wxGBSpan span( isizerItem->GetPropertyAsInteger( _("rowspan") ), isizerItem->GetPropertyAsInteger( _("colspan") ) );

			int column = isizerItem->GetPropertyAsInteger( _("column") );
			if ( column < 0 )
			{
				// Needs to be auto positioned after the other children are added
				wxGBSizerItem* item = GetGBSizerItem( isizerItem, lastPosition, span, manager->GetChild( wxsizerItem, 0 ) );
				if ( item != NULL )
				{
					newObjects.push_back( std::pair< wxObject*, wxGBSizerItem* >( wxsizerItem, item ) );
				}
				continue;
			}

			wxGBPosition position( isizerItem->GetPropertyAsInteger( _("row") ), column );

			// Check for intersection
			if ( sizer->CheckForIntersection( position, span ) )
			{
				continue;
			}

			lastPosition = position;

			// Add the child to the sizer
			wxGBSizerItem* item = GetGBSizerItem( isizerItem, position, span, manager->GetChild( wxsizerItem, 0 ) );
			if ( item != NULL )
			{
				sizer->Add( item );
			}
		}

		std::vector< std::pair< wxObject*, wxGBSizerItem* > >::iterator it;
		for ( it = newObjects.begin(); it != newObjects.end(); ++it )
		{
			wxGBPosition position = it->second->GetPos();
			wxGBSpan span = it->second->GetSpan();
			int column = position.GetCol();
			while ( sizer->CheckForIntersection( position, span ) )
			{
				column++;
				position.SetCol( column );
			}
			it->second->SetPos( position );
			sizer->Add( it->second );
			GetManager()->ModifyProperty( it->first, _("row"), wxString::Format( wxT("%i"), position.GetRow() ), false );
			GetManager()->ModifyProperty( it->first, _("column"), wxString::Format( wxT("%i"), column ), false );
		}
	}