Logo Search packages:      
Sourcecode: xchm version File versions



  Copyright (C) 2003  Razvan Cojocaru <razvanco@gmx.net>
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  GNU General Public License for more details.
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.



#include <wx/html/htmlwin.h>
#include <wx/treectrl.h>
#include <wx/menu.h>

#     include <chmfinddialog.h>

//! Event IDs.
enum {
      ID_CopySel = 1216,

//! Minimize dependencies. Forward declaration.
00045 class CHMFrame;

  \class wxHtmlWindow
  \brief wxWidgets HTML widget class.

  \brief Custom HTML widget class. Needed for sychnronization between
  the topics tree control and the currently displayed page.
00058 class CHMHtmlWindow : public wxHtmlWindow {

        \brief Initializes the widget.
        \param parent The parent widget.
        \param tc Pointer to the tree control we want to synchronize
        \param frame Outer frame.
      CHMHtmlWindow(wxWindow *parent, wxTreeCtrl *tc, CHMFrame* frame);

      //! Destructor. Deletes heap objects allocated in the constructor.

      //! Override. Looks up the wanted page in the tree and selects it.
      bool LoadPage(const wxString& location);

        \brief Dictates the behaviour of LoadPage(). If SetSync()
        has been called with a true parameter, the tree control will
        be updated by LoadPage(). Otherwise, it will not be updated.
        \param value Synchronize the tree widget on load?
00082       void SetSync(bool value) { _syncTree = value; }
        Returns true if the tree control's EVT_TREE_SEL_CHANGED
        event happened as a result of the CHMHtmlWindow calling
        SelectItem() on it.
00089       bool IsCaller() const { return _found; }

        \brief Let the htmlWindow know the next param to LoadPage() will 
        be an absolute path.
00095       void AbsoluteFollows() { _absolute = true; }

        \brief Finds the first occurence of word in the displayed page.
        \param parent Root of the wxHtmlCell tree where the search should
        \param word The word we're looking for. If more words separated
        by spaces are typed in, only the first one is taken into
        \param wholeWords If true, will search for words that match
        word exactly.
        \param caseSensitive If true, the search will be performed
        case sensitive.
        \return A valid cell if the result was found, NULL otherwise.
      wxHtmlCell* FindFirst(wxHtmlCell* parent, const wxString& word, 
                        bool wholeWords, bool caseSensitive);
        \brief Same as FindFirst(), but continues the search from start
        (start is considered in the search process).
      wxHtmlCell* FindNext(wxHtmlCell *start, 
                       const wxString& word, bool wholeWords,
                       bool caseSensitive);

      //! Clears the current selection.
      void ClearSelection();
      // Needs to be public, cause I call it from CHMHtmlFrame.
      //! Called when the user selects 'Find' from the popup menu.
      void OnFind(wxCommandEvent& event);

      //! Called when the user selects 'Copy' from the popup menu.
      void OnCopy(wxCommandEvent& event);
      //! Called when the user selects 'Forward' from the popup menu.
      void OnForward(wxCommandEvent& event);

      //! Called when the user selects 'Back' from the popup menu.
      void OnBack(wxCommandEvent& event);

      //! Called when the user right clicks the HTML window.
      void OnRightClick(wxMouseEvent& event);
#ifdef __WXMAC__
      //! Handles scrollwheel support.
      void HandleOnMouseWheel(wxMouseEvent& event);
      //! Overridden to correct relative images paths.
      wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
                               const wxString& url,
                               wxString *redirect) const;

      //! Overridden. Called when the user clicks on a link.
      void OnLinkClicked(const wxHtmlLinkInfo& link);

      //! Helper. Recursively looks for the opened page in the tree.
      void Sync(wxTreeItemId root, const wxString& page);

      //! Helper. Returns the prefix of the currently loaded page.
      wxString GetPrefix(const wxString& location) const;

      //! Helper. Fixes ../dir/file locations.
      bool FixRelativePath(wxString& location, const wxString& prefix) const;
      wxTreeCtrl* _tcl;
      bool _syncTree;
      bool _found;
      wxMenu *_menu;
      wxString _prefix;
      bool _absolute;
      CHMFrame *_frame;

      CHMFindDialog* _fdlg;


#endif // __CHMHTMLWINDOW_H_

Generated by  Doxygen 1.6.0   Back to index