Пример #1
0
void wxHtmlHelpController::UseConfig(wxConfigBase *config, const wxString& rootpath)
{
    m_Config = config;
    m_ConfigRoot = rootpath;
    if (m_helpWindow) m_helpWindow->UseConfig(config, rootpath);
    ReadCustomization(config, rootpath);
}
Пример #2
0
void wxHtmlHelpController::CreateHelpWindow()
{
    wxBusyCursor cur;
    wxString oldpath;
    wxStatusBar *sbar;

    if (m_Frame) {
        m_Frame -> Raise();
    	m_Frame -> Show(TRUE);
        return;
    }

#if wxUSE_BUSYINFO
    wxBusyInfo busyinfo(_("Preparing help window..."));
#endif

    if (m_Config) ReadCustomization(m_Config, m_ConfigRoot);

    m_Frame = new wxFrame(NULL, -1, "", wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h));
    m_Frame -> PushEventHandler(this);
    sbar = m_Frame -> CreateStatusBar();

    {
        wxToolBar *toolBar;
        toolBar = m_Frame -> CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE);
        toolBar -> SetMargins(2, 2);
        wxBitmap* toolBarBitmaps[3];

#ifdef __WXMSW__
        toolBarBitmaps[0] = new wxBitmap("panel");
        toolBarBitmaps[1] = new wxBitmap("back");
        toolBarBitmaps[2] = new wxBitmap("forward");
        int width = 24;
#else
        toolBarBitmaps[0] = new wxBitmap(panel_xpm);
        toolBarBitmaps[1] = new wxBitmap(back_xpm);
        toolBarBitmaps[2] = new wxBitmap(forward_xpm);
        int width = 16;
#endif

        int currentX = 5;

        toolBar -> AddTool(wxID_HTML_PANEL, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Show/hide navigation panel"));
        currentX += width + 5;
        toolBar -> AddSeparator();
        toolBar -> AddTool(wxID_HTML_BACK, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go back to the previous HTML page"));
        currentX += width + 5;
        toolBar -> AddTool(wxID_HTML_FORWARD, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go forward to the next HTML page"));
        currentX += width + 5;

        toolBar -> Realize();

        // Can delete the bitmaps since they're reference counted
        for (int i = 0; i < 3; i++) delete toolBarBitmaps[i];
    }


    {
        m_Splitter = new wxSplitterWindow(m_Frame);

        m_HtmlWin = new wxHtmlWindow(m_Splitter);
        m_HtmlWin -> SetRelatedFrame(m_Frame, m_TitleFormat);
        m_HtmlWin -> SetRelatedStatusBar(0);
        if (m_Config) m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot);

        m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
        {
            m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
            m_ContentsBox -> SetImageList(m_ContentsImageList);
            m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
        }

        {
            wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
            wxLayoutConstraints *b1 = new wxLayoutConstraints;
            b1 -> top.SameAs        (dummy, wxTop, 0);
            b1 -> left.SameAs       (dummy, wxLeft, 0);
            b1 -> width.PercentOf   (dummy, wxWidth, 100);
            b1 -> bottom.SameAs     (dummy, wxBottom, 0);
            m_IndexBox = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0);
            m_IndexBox -> SetConstraints(b1);
            dummy -> SetAutoLayout(TRUE);
            m_NavigPan -> AddPage(dummy, _("Index"));
        }

        {
            wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE);

            wxLayoutConstraints *b1 = new wxLayoutConstraints;
            m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT);
            b1 -> top.SameAs        (dummy, wxTop, 0);
            b1 -> left.SameAs       (dummy, wxLeft, 0);
            b1 -> right.SameAs      (dummy, wxRight, 0);
            b1 -> height.AsIs();
            m_SearchText -> SetConstraints(b1);

            wxLayoutConstraints *b2 = new wxLayoutConstraints;
            m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search!"));
            b2 -> top.Below         (m_SearchText, 10);
            b2 -> right.SameAs      (dummy, wxRight, 10);
            b2 -> width.AsIs();
            b2 -> height.AsIs();
            m_SearchButton -> SetConstraints(b2);

            wxLayoutConstraints *b3 = new wxLayoutConstraints;
            m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0);
            b3 -> top.Below         (m_SearchButton, 10);
            b3 -> left.SameAs       (dummy, wxLeft, 0);
            b3 -> right.SameAs      (dummy, wxRight, 0);
            b3 -> bottom.SameAs     (dummy, wxBottom, 0);
            m_SearchList -> SetConstraints(b3);

            dummy -> SetAutoLayout(TRUE);
            dummy -> Layout();
            m_NavigPan -> AddPage(dummy, _("Search"));
        }

        RefreshLists();
        m_NavigPan -> Show(TRUE);
        m_HtmlWin -> Show(TRUE);
        m_Splitter -> SetMinimumPaneSize(20);
        m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
        if (!m_Cfg.navig_on) m_Splitter -> Unsplit(m_NavigPan);
        wxYield();
    }

    m_Frame -> Show(TRUE);
    wxYield();
}