Example #1
0
void SCH_VIEW::HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin )
{
    if( !aItem )
    {
        for( auto item : *m_allItems )
        {
            // Not all view items can be highlighted, only EDA_ITEMs
            // So clear flag of only EDA_ITEMs.
            auto eitem = dynamic_cast<EDA_ITEM *>( item );

            if( eitem )
            {
                eitem->ClearFlags( HIGHLIGHTED );

                if( eitem->Type() == SCH_COMPONENT_T )
                {
                    // Items inside a component (pins, fields can be highlighted.
                    static_cast<SCH_COMPONENT*>( eitem )->ClearAllHighlightFlags();
                }
            }
        }
    }
    else
    {
        if( ( aItem->Type() == SCH_COMPONENT_T ) && aPin )
        {
            static_cast<SCH_COMPONENT*>( aItem )->HighlightPin( aPin );
        }
        else
            aItem->SetFlags( HIGHLIGHTED );
    }

    // ugly but I guess OK for the moment...
    UpdateAllItems( ALL );
}
Example #2
0
bool wxSTEditorNotebook::CloseAllPages(bool query_save_if_modified, int except_this_page)
{
    if (query_save_if_modified && !QuerySaveIfModified())
        return false;

    if (except_this_page < 0)
    {
        DeleteAllPages();
    }
    else
    {
        wxWindow* win = GetPage(except_this_page);
        wxString title(GetPageText(except_this_page));

        if (win && RemovePage(except_this_page))
        {
            DeleteAllPages();
            AddPage(win, title, true);
        }
    }

    if ((GetPageCount() == 0) && !GetOptions().HasNotebookOption(STN_ALLOW_NO_PAGES))
        InsertEditorSplitter(-1, wxID_ANY, GetOptions().GetDefaultFileName(), true);

    UpdateAllItems();
    return true;
}
Example #3
0
void wxSTEditorFrame::ShowSidebar(bool show_left_side)
{
    wxSplitterWindow* sideSplitter = GetSideSplitter();

    if (sideSplitter && m_sideSplitterWin1 && m_sideSplitterWin2)
    {
        if (show_left_side)
        {
            if (!sideSplitter->IsSplit())
            {
                // If they want it shown, make it large enough to be vagely useful
                // but never wider than the window itself.
                int win_width = sideSplitter->GetSize().GetWidth();
                int sash_pos  = wxMax(m_sideSplitter_pos, 100);
                sash_pos      = wxMin(m_sideSplitter_pos, int(0.8*win_width));
                sideSplitter->SplitVertically(m_sideSplitterWin1, m_sideSplitterWin2, sash_pos);
                GetSideNotebook()->Show();
            }
        }
        else if (sideSplitter->IsSplit())
        {
            m_sideSplitter_pos = sideSplitter->GetSashPosition();
            sideSplitter->Unsplit(m_sideSplitterWin1);
        }
        UpdateAllItems();
    }
}
Example #4
0
bool wxSTEditorNotebook::ClosePage(int n, bool query_save_if_modified)
{
    wxCHECK_MSG((n >= 0) && (n < (int)GetPageCount()), false, wxT("Invalid page"));
    wxSTEditor *editor = GetEditor(n);

    if (!editor)
        return false;

    int ret = wxID_NO;
    int sel = GetSelection();

    if (query_save_if_modified)
        ret = editor->QuerySaveIfModified(true);

    if (ret != wxCANCEL)
        ret = int(DeletePage(n));

    if ((GetPageCount() == 0) && !GetOptions().HasNotebookOption(STN_ALLOW_NO_PAGES))
        InsertEditorSplitter(-1, wxID_ANY, GetOptions().GetDefaultFileName(), true);

    // Force selection for GTK, else if try to close the "current page" without
    //  first clicking in it you delete some other page
    int page_count = (int)GetPageCount();
    if ((sel >= page_count) && (page_count > 0))
        SetSelection(wxMax(0, wxMin(sel, page_count-1)));

    UpdateAllItems();

    return ret != 0;
}
Example #5
0
// 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();
	}
}
Example #6
0
bool wxSTEditorNotebook::InsertEditorSplitter(int nPage, wxSTEditorSplitter* splitter,
                                              bool bSelect)
{
    wxCHECK_MSG(splitter && (splitter->GetParent() == this), false,
                wxT("Invalid wxSTEditorSplitter or parent"));

    if (GetPageCount() >= GetMaxPageCount())
    {
        wxMessageBox(_("Maximum number of notebook pages exceeded,\nplease close one first."),
                     _("Too many pages opened"), wxOK|wxICON_ERROR, this);

        delete splitter;
        return false;
    }

    wxString title(FileNameToTabName(splitter->GetEditor()));
    size_t n_pages = GetPageCount();

    if (nPage < 0) // they want to insert it anywhere
    {
        // presort the insert page to reduce flicker
        if ((n_pages > 0) && GetOptions().HasNotebookOption(STN_ALPHABETICAL_TABS))
        {
            wxArrayString names;
            names.Add(title+wxT("=999999")); // insert after any other pages with same name

            for (size_t n = 0; n < n_pages; n++)
            {
                wxString name(GetPageText(n));
                if ((name.Length() > 0) && (name[0u] == wxT('*')))
                    name = name.Mid(1);

                names.Add(name + wxString::Format(wxT("=%d"), (int)n));
            }

            names.Sort(STN_SortNameCompareFunction);
            nPage = names.Index(title+wxT("=999999"));
        }
        else
            nPage = (int)n_pages;
    }

    if (n_pages < 1)
        bSelect = true;
    if (nPage < int(n_pages))
        return InsertPage(nPage, splitter, title, bSelect);

    bool ret = AddPage(splitter, title, bSelect);
    UpdateAllItems();
    return ret;
}
Example #7
0
void CServerDoc::OnOptionsFont()
{
	CClientDC dc(NULL);
	LOGFONT lf = m_logfont;
	lf.lfHeight = -::MulDiv(-lf.lfHeight, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFontDialog dlg(&lf);
	dlg.m_cf.rgbColors = m_crText;
	if (dlg.DoModal() == IDOK)
	{
		lf.lfHeight = -::MulDiv(-lf.lfHeight, 72, dc.GetDeviceCaps(LOGPIXELSY));
		m_crText = dlg.GetColor();
		m_logfont = lf;
		SetModifiedFlag();
		UpdateAllItems(NULL);
		UpdateAllViews(NULL);
	}
}
Example #8
0
void wxSTEditorNotebook::UpdatePageState()
{
    int page_count = (int)GetPageCount();
    int selection  = GetSelection();
    if (page_count < 1) selection = -1; // force for gtk

    if ((page_count == m_stn_page_count) && (selection == m_stn_selection))
        return;

    wxNotebookEvent stnEvent(wxEVT_STNOTEBOOK_PAGE_CHANGED, GetId());
    stnEvent.SetEventObject(this);
    stnEvent.SetSelection(selection);
    stnEvent.SetOldSelection(m_stn_selection);

    m_stn_page_count = page_count;
    m_stn_selection  = selection;

    GetEventHandler()->ProcessEvent(stnEvent);

    UpdateAllItems();
}
void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
{
    myframe->SetVisibleElementColor( (GERBVIEW_LAYER_ID) aId, aColor );

    auto galCanvas = myframe->GetGalCanvas();

    if( galCanvas && myframe->IsGalCanvasActive() )
    {
        auto view = galCanvas->GetView();
        view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
        view->UpdateLayerColor( aId );

        view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
        view->UpdateAllItems( KIGFX::COLOR );
    }

    if( galCanvas && myframe->IsGalCanvasActive() )
        galCanvas->Refresh();
    else
        myframe->GetCanvas()->Refresh();
}
Example #10
0
void wxSTEditorNotebook::OnSTEState(wxSTEditorEvent &event)
{
    event.Skip(true);
    wxSTEditor *editor = event.GetEditor();

    if ( event.HasStateChange(STE_FILENAME | STE_MODIFIED) )
    {
        if (GetOptions().HasNotebookOption(STN_UPDATE_TITLES))
        {
            int page = FindEditorPage(editor);
            if (page >= 0) // if < 0 then not in notebook (or at least yet)
            {
                SetPageText(page, FileNameToTabName(editor));
                SortTabs(GetOptions().GetNotebookOptions());
            }
        }
    }

    if (event.HasStateChange(STE_FILENAME | STE_MODIFIED | STE_CANSAVE))
    {
        UpdateAllItems();
    }
}
Example #11
0
void wxSTEditorFrame::CreateOptions( const wxSTEditorOptions& options )
{
    m_options = options;

    wxConfigBase *config = GetConfigBase();
    wxSTEditorMenuManager *steMM = GetOptions().GetMenuManager();

    if (steMM && GetOptions().HasFrameOption(STF_CREATE_MENUBAR))
    {
        wxMenuBar *menuBar = GetMenuBar();

        if (!menuBar)
            menuBar = new wxMenuBar(wxMB_DOCKABLE);

        steMM->CreateMenuBar(menuBar, true);

        SetMenuBar(menuBar);
        wxAcceleratorHelper::SetAcceleratorTable(this, *steMM->GetAcceleratorArray());
        wxAcceleratorHelper::SetAccelText(menuBar, *steMM->GetAcceleratorArray());

        if (GetOptions().HasFrameOption(STF_CREATE_FILEHISTORY) && !GetOptions().GetFileHistory())
        {
            // If there is wxID_OPEN then we can use wxFileHistory to save them
            wxMenu* menu = NULL;
            wxMenuItem* item = menuBar->FindItem(wxID_OPEN, &menu);

            if (menu && item)
            {
                int open_index = menu->GetMenuItems().IndexOf(item);

                if (open_index != wxNOT_FOUND)
                {
                    wxMenu* submenu = new wxMenu();
                    menu->Insert(open_index + 1, wxID_ANY, _("Open &Recent"), submenu);
                    GetOptions().SetFileHistory(new wxFileHistory(9), false);
                    GetOptions().GetFileHistory()->UseMenu(submenu);
                    if (config)
                    {
                        GetOptions().LoadFileConfig(*config);
                    }
                }
            }

            GetOptions().SetMenuBar(menuBar);
        }
    }
    if (steMM && GetOptions().HasFrameOption(STF_CREATE_TOOLBAR))
    {
        wxToolBar* toolBar = (GetToolBar() != NULL) ? GetToolBar() : CreateToolBar();
        steMM->CreateToolBar(toolBar);
        GetOptions().SetToolBar(toolBar);
    }
    if ((GetStatusBar() == NULL) && GetOptions().HasFrameOption(STF_CREATE_STATUSBAR))
    {
        CreateStatusBar(1);
        GetOptions().SetStatusBar(GetStatusBar());
    }
    if (steMM)
    {
        if (GetOptions().HasEditorOption(STE_CREATE_POPUPMENU))
        {
            wxMenu* menu = steMM->CreateEditorPopupMenu();

            wxAcceleratorHelper::SetAccelText(menu, *steMM->GetAcceleratorArray());
            GetOptions().SetEditorPopupMenu(menu, false);
        }
        if (GetOptions().HasSplitterOption(STS_CREATE_POPUPMENU))
            GetOptions().SetSplitterPopupMenu(steMM->CreateSplitterPopupMenu(), false);
        if (GetOptions().HasNotebookOption(STN_CREATE_POPUPMENU))
            GetOptions().SetNotebookPopupMenu(steMM->CreateNotebookPopupMenu(), false);
    }

    if (!m_sideSplitter && GetOptions().HasFrameOption(STF_CREATE_SIDEBAR))
    {
        m_sideSplitter = new wxSplitterWindow(this, ID_STF_SIDE_SPLITTER);
        m_sideSplitter->SetMinimumPaneSize(10);
        m_sideNotebook = new wxNotebook(m_sideSplitter, ID_STF_SIDE_NOTEBOOK);
        m_steTreeCtrl  = new wxSTEditorTreeCtrl(m_sideNotebook, ID_STF_FILE_TREECTRL);
        m_dirCtrl      = new wxGenericDirCtrl(m_sideNotebook, ID_STF_FILE_DIRCTRL,
                                              wxFileName::GetCwd(),
                                              wxDefaultPosition, wxDefaultSize,
                                              wxDIRCTRL_3D_INTERNAL
#if wxCHECK_VERSION(2, 9, 2)
                                              |(GetOptions().HasFrameOption(STF_CREATE_NOTEBOOK) ? wxDIRCTRL_MULTIPLE : 0)
#endif // wxCHECK_VERSION(2, 9, 2)
                                              );

        m_sideNotebook->AddPage(m_steTreeCtrl, _("Files"));
        m_sideNotebook->AddPage(m_dirCtrl,     _("Open"));

        m_sideSplitterWin1 = m_sideNotebook;
    }

    if (!m_steNotebook && GetOptions().HasFrameOption(STF_CREATE_NOTEBOOK))
    {
        m_mainSplitter = new wxSplitterWindow(m_sideSplitter ? (wxWindow*)m_sideSplitter : (wxWindow*)this, ID_STF_MAIN_SPLITTER);
        m_mainSplitter->SetMinimumPaneSize(1);

        m_steNotebook = new wxSTEditorNotebook(m_mainSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize,
                                               wxCLIP_CHILDREN);
        m_steNotebook->CreateOptions(m_options);
        (void)m_steNotebook->InsertEditorSplitter(-1, wxID_ANY, GetOptions().GetDefaultFileName(), true);
        // update after adding a single page
        m_steNotebook->UpdateAllItems();
        m_mainSplitter->Initialize(m_steNotebook);
        m_mainSplitterWin1 = m_steNotebook;
        m_sideSplitterWin2 = m_mainSplitter;

        if (m_steTreeCtrl)
            m_steTreeCtrl->SetSTENotebook(m_steNotebook);
    }
    else if (!m_steSplitter && GetOptions().HasFrameOption(STF_CREATE_SINGLEPAGE))
    {
        m_mainSplitter = new wxSplitterWindow(m_sideSplitter ? (wxWindow*)m_sideSplitter : (wxWindow*)this, ID_STF_MAIN_SPLITTER);
        m_mainSplitter->SetMinimumPaneSize(1);

        m_steSplitter = new wxSTEditorSplitter(m_mainSplitter, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
        m_steSplitter->CreateOptions(m_options);
        m_mainSplitter->Initialize(m_steSplitter);
        m_mainSplitterWin1 = m_steSplitter;
    }
    //else user will set up the rest

    if (m_mainSplitter && m_mainSplitterWin1 && !m_resultsNotebook && GetOptions().HasFrameOption(STF_CREATE_RESULT_NOTEBOOK))
    {
        m_resultsNotebook = new wxNotebook(m_mainSplitter, wxID_ANY);

        m_findResultsEditor = new wxSTEditorFindResultsEditor(m_resultsNotebook, wxID_ANY);
        m_findResultsEditor->CreateOptionsFromEditorOptions(options);
        m_resultsNotebook->AddPage(m_findResultsEditor, _("Search Results"));

        wxSTEditorFindReplacePanel::SetFindResultsEditor(m_findResultsEditor);
        m_mainSplitter->SplitHorizontally(m_mainSplitterWin1, m_resultsNotebook, GetClientSize().GetHeight()*2/3);
        m_mainSplitterWin2 = m_resultsNotebook;
    }

    if (GetOptions().HasFrameOption(STF_CREATE_SIDEBAR) && GetSideSplitter() && m_sideSplitterWin1 && m_sideSplitterWin2)
    {
        GetSideSplitter()->SplitVertically(m_sideSplitterWin1, m_sideSplitterWin2, m_sideSplitter_pos);
    }

#if wxUSE_DRAG_AND_DROP
    if (GetOptions().HasFrameOption(STF_DO_DRAG_AND_DROP))
    {
        SetDropTarget(new wxSTEditorFileDropTarget(this));
    }
#endif //wxUSE_DRAG_AND_DROP

    if (GetOptions().HasConfigOption(STE_CONFIG_FINDREPLACE) && config)
    {
        if (GetOptions().GetFindReplaceData() &&
            !GetOptions().GetFindReplaceData()->HasLoadedConfig())
            GetOptions().GetFindReplaceData()->LoadConfig(*config);
    }

    if (config)
        LoadConfig(*config);

    // The config may change the frame size so relayout the splitters
    if (m_mainSplitter && m_mainSplitter->IsSplit()) //m_mainSplitterWin1 && m_resultsNotebook)
        m_mainSplitter->SetSashPosition(GetClientSize().GetHeight()*2/3);

    UpdateAllItems();

    // if we've got an editor let it update gui
    wxSTEditor *editor = GetEditor();
    if (editor)
        editor->UpdateAllItems();
}
Example #12
0
void CPadDoc::OnViewUpdatenow()
{
	UpdateAllItems(NULL);
}