Beispiel #1
0
void wxSTEditorTreeCtrl::SetSTENotebook(wxSTEditorNotebook* notebook)
{
    if (m_steNotebook != NULL)
    {
        m_steNotebook->Disconnect(wxID_ANY, wxEVT_DESTROY,
                                  wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy),
                                  NULL, this);
        m_steNotebook->Disconnect(wxID_ANY, wxEVT_STNOTEBOOK_PAGE_CHANGED,
                                  wxNotebookEventHandler(wxSTEditorTreeCtrl::OnNotebookPageChanged),
                                  NULL, this);
        m_steNotebook->Disconnect(wxID_ANY, wxEVT_STEDITOR_STATE_CHANGED,
                                  wxSTEditorEventHandler(wxSTEditorTreeCtrl::OnSTEState),
                                  NULL, this);
    }

    m_steNotebook = notebook;

    DeleteAllItems();
    m_windowToSTETreeItemDataMap.clear();

    if (m_steNotebook != NULL)
    {
        UpdateFromNotebook();

        m_steNotebook->Connect(wxID_ANY, wxEVT_DESTROY,
                               wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy),
                               NULL, this);
        m_steNotebook->Connect(wxID_ANY, wxEVT_STNOTEBOOK_PAGE_CHANGED,
                               wxNotebookEventHandler(wxSTEditorTreeCtrl::OnNotebookPageChanged),
                               NULL, this);
        m_steNotebook->Connect(wxID_ANY, wxEVT_STEDITOR_STATE_CHANGED,
                               wxSTEditorEventHandler(wxSTEditorTreeCtrl::OnSTEState),
                               NULL, this);
    }
}
Beispiel #2
0
void KIWAY::SetTop( wxFrame* aTop )
{
#if 0
    if( m_top )
    {
        m_top->Disconnect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
    }

    if( aTop )
    {
        aTop->Connect( wxEVT_DESTROY, wxWindowDestroyEventHandler( KIWAY::player_destroy_handler ), NULL, this );
    }
#endif

    m_top = aTop;
}
void dlgNewVSCPSession::CreateControls()
{
    ////@begin dlgNewVSCPSession content construction
    dlgNewVSCPSession* itemDialog1 = this;

    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
    itemDialog1->SetSizer(itemBoxSizer2);

    wxArrayString m_ctrlListInterfacesStrings;
    m_ctrlListInterfaces = new wxListBox;
    m_ctrlListInterfaces->Create(itemDialog1, ID_LISTBOX_INTERFACES, wxDefaultPosition, wxSize(300, -1), m_ctrlListInterfacesStrings, wxLB_SINGLE);
    itemBoxSizer2->Add(m_ctrlListInterfaces, 0, wxGROW | wxALL, 5);

    wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
    itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);

    wxButton* itemButton5 = new wxButton;
    itemButton5->Create(itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0);
    itemButton5->SetDefault();
    if (dlgNewVSCPSession::ShowToolTips())
        itemButton5->SetToolTip(_("Use selected interface"));
    itemBoxSizer4->Add(itemButton5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);

    wxButton* itemButton6 = new wxButton;
    itemButton6->Create(itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
    if (dlgNewVSCPSession::ShowToolTips())
        itemButton6->SetToolTip(_("Go back without selecting any interface"));
    itemBoxSizer4->Add(itemButton6, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);

    itemBoxSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);

    wxButton* itemButton8 = new wxButton;
    itemButton8->Create(itemDialog1, ID_BUTTON_ADD, _("Add..."), wxDefaultPosition, wxDefaultSize, 0);
    if (dlgNewVSCPSession::ShowToolTips())
        itemButton8->SetToolTip(_("Add new interface"));
    itemBoxSizer4->Add(itemButton8, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);

    wxButton* itemButton9 = new wxButton;
    itemButton9->Create(itemDialog1, ID_BUTTON_EDIT, _("Edit..."), wxDefaultPosition, wxDefaultSize, 0);
    itemButton9->SetDefault();
    if (dlgNewVSCPSession::ShowToolTips())
        itemButton9->SetToolTip(_("Edit selected interface"));
    itemBoxSizer4->Add(itemButton9, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);

    wxButton* itemButton10 = new wxButton;
    itemButton10->Create(itemDialog1, ID_BUTTON_REMOVE, _("Remove"), wxDefaultPosition, wxDefaultSize, 0);
    if (dlgNewVSCPSession::ShowToolTips())
        itemButton10->SetToolTip(_("Remove selected interface"));
    itemBoxSizer4->Add(itemButton10, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);

    wxButton* itemButton11 = new wxButton;
    itemButton11->Create(itemDialog1, ID_BUTTON, _("Clone"), wxDefaultPosition, wxDefaultSize, 0);
    if (dlgNewVSCPSession::ShowToolTips())
        itemButton11->SetToolTip(_("Remove selected interface"));
    itemBoxSizer4->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);

    // Connect events and objects
    itemDialog1->Connect(ID_DIALOG_NEW_VSCP_SESSION, wxEVT_DESTROY, wxWindowDestroyEventHandler(dlgNewVSCPSession::OnDestroy), NULL, this);
    ////@end dlgNewVSCPSession content construction
}
Beispiel #4
0
bool wxPickerBase::CreateBase(wxWindow *parent,
                         wxWindowID id,
                         const wxString &text,
                         const wxPoint& pos,
                         const wxSize& size,
                         long style,
                         const wxValidator& validator,
                         const wxString& name)
{
    // remove any border style from our style as wxPickerBase's window must be
    // invisible (user styles must be set on the textctrl or the platform-dependent picker)
    style &= ~wxBORDER_MASK;
    if (!wxControl::Create(parent, id, pos, size, style | wxNO_BORDER | wxTAB_TRAVERSAL,
                           validator, name))
        return false;

    m_sizer = new wxBoxSizer(wxHORIZONTAL);

    if (HasFlag(wxPB_USE_TEXTCTRL))
    {
        // NOTE: the style of this class (wxPickerBase) and the style of the
        //       attached text control are different: GetTextCtrlStyle() extracts
        //       the styles related to the textctrl from the styles passed here
        m_text = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
                                wxDefaultPosition, wxDefaultSize,
                                GetTextCtrlStyle(style));
        if (!m_text)
        {
            wxFAIL_MSG( wxT("wxPickerBase's textctrl creation failed") );
            return false;
        }

        // set the maximum lenght allowed for this textctrl.
        // This is very important since any change to it will trigger an update in
        // the m_picker; for very long strings, this real-time synchronization could
        // become a CPU-blocker and thus should be avoided.
        // 32 characters will be more than enough for all common uses.
        m_text->SetMaxLength(32);

        // set the initial contents of the textctrl
        m_text->SetValue(text);

        m_text->Connect(wxEVT_COMMAND_TEXT_UPDATED,
                wxCommandEventHandler(wxPickerBase::OnTextCtrlUpdate),
                NULL, this);
        m_text->Connect(wxEVT_KILL_FOCUS,
                wxFocusEventHandler(wxPickerBase::OnTextCtrlKillFocus),
                NULL, this);

        m_text->Connect(wxEVT_DESTROY,
                wxWindowDestroyEventHandler(wxPickerBase::OnTextCtrlDelete),
                NULL, this);

        // the text control's proportion values defaults to 2
        m_sizer->Add(m_text, 2, GetDefaultTextCtrlFlag(), 5);
    }

    return true;
}
void CViacamController::OpenConfiguration()
{
	if (!m_pConfiguration) {
		m_pConfiguration = new WConfiguration(m_pMainWindow); //, this);
		m_pConfiguration->Connect (
			wxEVT_DESTROY, 
			wxWindowDestroyEventHandler(CViacamController::WConfigurationListener::OnDestroy), 
			NULL, 
			&m_wConfigurationListener);
	}
	
	m_pConfiguration->Show(true);
}
Beispiel #6
0
wxSTEditorTreeCtrl::~wxSTEditorTreeCtrl()
{
    delete m_popupMenu;
    SetSTENotebook(NULL);

    // Remove the wxEVT_DESTROY tracker for notebook pages so they don't call us when we're gone.
    wxLongToLongHashMap::iterator it;
    for (it = m_windowDestroyMap.begin(); it != m_windowDestroyMap.end(); it++)
    {
        wxWindow* win = (wxWindow*)it->first;
        win->Disconnect(wxID_ANY, wxEVT_DESTROY,
                        wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy),
                        NULL, this);
    }
    m_windowDestroyMap.clear();
}
Beispiel #7
0
void wxSTEditorTreeCtrl::UpdateFromNotebook()
{
    wxSTERecursionGuard guard(m_rGuard_UpdateFromNotebook);
    if (guard.IsInside()) return;

    wxSTEditorNotebook *noteBook = GetSTEditorNotebook();
    if (!noteBook)
        return;

    int n;
    int page_count = noteBook->GetPageCount();
    int note_sel   = noteBook->GetSelection();

    wxTreeItemId id, selId;

    // Check for and add a root item to the treectrl, it's hidden
    wxTreeItemId rootId = GetRootItem();
    if (!rootId)
        rootId = AddRoot(_("Root"), -1, -1, NULL);

    // Check for and add a "Opened files" item to the treectrl
    wxArrayString openedfilesPath; openedfilesPath.Add(_("Opened files"));
    wxTreeItemId openedId = FindOrInsertItem(openedfilesPath, STE_TREECTRL_FIND_OR_INSERT);

    wxLongToLongHashMap windowToSTETreeItemDataMap = m_windowToSTETreeItemDataMap;

    Freeze();

    for (n = 0; n < page_count; n++)
    {
        id = wxTreeItemId(); // start fresh

        wxSTEditor* editor = noteBook->GetEditor(n);
        wxWindow* notePage = noteBook->GetPage(n);
        wxSTETreeItemData* steTreeItemData = NULL;

        // If this editor was already added to the tree, check if it's still correct
        if (editor && editor->GetTreeItemData())
        {
            // get and check the old tree item id, the filename/path could have changed
            steTreeItemData = editor->GetTreeItemData();

            if (steTreeItemData)
                id = steTreeItemData->m_id;

            if (steTreeItemData)
            {
                if ((steTreeItemData->m_notePage == notePage) &&
                    (steTreeItemData->m_fileName == editor->GetFileName()))
                {
                    // the page didn't change name, but do resync page number
                    steTreeItemData->m_page_num = n;
                    windowToSTETreeItemDataMap.erase((long)notePage);
                }
                else
                    steTreeItemData = NULL;
            }

            // Something changed, redo it
            if (id && !steTreeItemData)
            {
                // Erase refs to this page, we will recreate it
                m_windowToSTETreeItemDataMap.erase((long)notePage);
                windowToSTETreeItemDataMap.erase((long)notePage);
                DeleteItem(id, true, -1, openedId);

                // null it and add it correctly later
                id = wxTreeItemId();
                editor->SetTreeItemData(NULL);
            }
        }

        bool modified = editor->IsModified();

        if (!id)
        {
            // Create new data to add to the wxTreeItem
            steTreeItemData = new wxSTETreeItemData(n, notePage);

            // Only connect the destroy handler once
            if (m_windowDestroyMap.find((long)notePage) == m_windowDestroyMap.end())
            {
                m_windowDestroyMap[(long)notePage] = 1;

                notePage->Connect(wxID_ANY, wxEVT_DESTROY,
                                  wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy),
                                  NULL, this);
            }

            if (editor)
            {
                modified = editor->IsModified();
                steTreeItemData->m_root = _("Opened files");
                steTreeItemData->m_fileName = editor->GetFileName();
                wxFileName fn(steTreeItemData->m_fileName);

                // Don't need to Normalize() since it is done in wxSTEditor::SetFilename()
                //if (fn.FileExists()) fn.Normalize();

                switch (m_display_type)
                {
                    case SHOW_FILENAME_ONLY :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                        steTreeItemData->m_treePath.Add(fn.GetFullName());
                        break;
                    }
                    case SHOW_FILEPATH_ONLY :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                        steTreeItemData->m_treePath.Add(fn.GetFullPath());
                        break;
                    }
                    case SHOW_PATH_THEN_FILENAME :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                        steTreeItemData->m_treePath.Add(fn.GetPath());
                        steTreeItemData->m_treePath.Add(fn.GetFullName());
                        break;
                    }
                    case SHOW_ALL_PATHS :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);

                        wxArrayString dirs = fn.GetDirs();
                        for (size_t i = 0; i < dirs.GetCount(); ++i)
                            steTreeItemData->m_treePath.Add(dirs[i]);

                        steTreeItemData->m_treePath.Add(fn.GetFullName());
                        break;
                    }
                }
            }
            else
            {
                steTreeItemData->m_root = _("Others");
                steTreeItemData->m_fileName = noteBook->GetPageText(n);

                steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                steTreeItemData->m_treePath.Add(steTreeItemData->m_fileName.GetFullPath());
            }

            // Always insert a new editor since if we already did, it'd have a treeitem id.
            // For other windows, who knows, you can only have one tree node per notebook page name
            if (editor)
            {
                id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_INSERT);
                SetItemImage(id, STE_TREECTRL_IMAGE_EDITOR);
                editor->SetTreeItemData(steTreeItemData);
                steTreeItemData->m_steRefData = editor->GetSTERefData();
            }
            else
            {
                id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_FIND_OR_INSERT);
                SetItemImage(id, STE_TREECTRL_IMAGE_OTHER);
            }

            // must set new data before deleting old in MSW since it checks old before setting new
            wxTreeItemData* oldData = GetItemData(id);
            steTreeItemData->m_id = id;
            SetItemData(id, steTreeItemData);
            if (oldData) delete oldData;

            m_windowToSTETreeItemDataMap[(long)notePage] = (long)steTreeItemData;
        }

        // we should have valid id at this point
        if (n == note_sel)
            selId = id;
        else if (IsBold(id))
            SetItemBold(id, false);

        SetItemTextColour(id, modified ? *wxRED : *wxBLACK);
    }

    wxLongToLongHashMap::iterator it;
    for( it = windowToSTETreeItemDataMap.begin(); it != windowToSTETreeItemDataMap.end(); ++it )
    {
        wxSTETreeItemData* oldData = (wxSTETreeItemData*)it->second;
        DeleteItem(oldData->m_id, true, -1, openedId);
        m_windowToSTETreeItemDataMap.erase(it->first);
    }

    if (selId)
    {
        SetItemBold(selId);
        SelectItem(selId);
    }

    SortAllChildren(GetRootItem());
    Thaw();
}