~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/embedding/qa/testembed/BrowserFrm.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
9
 *
 
10
 * Software distributed under the License is distributed on an "AS IS" basis,
 
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
 * for the specific language governing rights and limitations under the
 
13
 * License.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
17
 * The Initial Developer of the Original Code is 
 
18
 * Netscape Communications Corporation.
 
19
 * Portions created by the Initial Developer are Copyright (C) 1998
 
20
 * the Initial Developer. All Rights Reserved.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Chak Nanga <chak@netscape.com> 
 
24
 *
 
25
 *
 
26
 * Alternatively, the contents of this file may be used under the terms of
 
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
28
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
30
 * of those above. If you wish to allow use of your version of this file only
 
31
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
32
 * use your version of this file under the terms of the NPL, indicate your
 
33
 * decision by deleting the provisions above and replace them with the notice
 
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
35
 * the provisions above, a recipient may use your version of this file under
 
36
 * the terms of any one of the NPL, the GPL or the LGPL.
 
37
 *
 
38
 * ***** END LICENSE BLOCK ***** */
 
39
 
 
40
// BrowserFrm.h : interface of the CBrowserFrame class
 
41
//
 
42
/////////////////////////////////////////////////////////////////////////////
 
43
 
 
44
#ifndef _IBROWSERFRM_H
 
45
#define _IBROWSERFRM_H
 
46
 
 
47
#if _MSC_VER > 1000
 
48
#pragma once
 
49
#endif // _MSC_VER > 1000
 
50
 
 
51
#include "BrowserView.h"
 
52
#include "BrowserToolTip.h"
 
53
#include "IBrowserFrameGlue.h"
 
54
#include "MostRecentUrls.h"
 
55
 
 
56
// A simple UrlBar class...
 
57
class CUrlBar : public CComboBoxEx
 
58
{
 
59
public:
 
60
        inline void GetEnteredURL(CString& url) {
 
61
                GetEditCtrl()->GetWindowText(url);
 
62
        }
 
63
        inline void GetSelectedURL(CString& url) {
 
64
                GetLBText(GetCurSel(), url);
 
65
        }
 
66
        inline void SetCurrentURL(LPCTSTR pUrl) {
 
67
                SetWindowText(pUrl);
 
68
        }
 
69
        inline void AddURLToList(CString& url, bool bAddToMRUList = true) {
 
70
                COMBOBOXEXITEM ci;
 
71
                ci.mask = CBEIF_TEXT; ci.iItem = -1;
 
72
                ci.pszText = (LPTSTR)(LPCTSTR)url;
 
73
                InsertItem(&ci);
 
74
 
 
75
        if(bAddToMRUList)
 
76
            m_MRUList.AddURL((LPTSTR)(LPCTSTR)url);
 
77
        }
 
78
    inline void LoadMRUList() {
 
79
        for (int i=0;i<m_MRUList.GetNumURLs();i++) 
 
80
        {
 
81
            CString urlStr(_T(m_MRUList.GetURL(i)));
 
82
            AddURLToList(urlStr, false); 
 
83
        }
 
84
    }
 
85
    inline BOOL EditCtrlHasFocus() {
 
86
        return (GetEditCtrl()->m_hWnd == CWnd::GetFocus()->m_hWnd);
 
87
    }
 
88
    inline BOOL EditCtrlHasSelection() {
 
89
        int nStartChar = 0, nEndChar = 0;
 
90
        if(EditCtrlHasFocus())
 
91
            GetEditCtrl()->GetSel(nStartChar, nEndChar);
 
92
        return (nEndChar > nStartChar) ? TRUE : FALSE;
 
93
    }
 
94
    inline BOOL CanCutToClipboard() {
 
95
        return EditCtrlHasSelection();
 
96
    }
 
97
    inline void CutToClipboard() {
 
98
        GetEditCtrl()->Cut();
 
99
    }
 
100
    inline BOOL CanCopyToClipboard() {
 
101
        return EditCtrlHasSelection();
 
102
    }
 
103
    inline void CopyToClipboard() {
 
104
        GetEditCtrl()->Copy();
 
105
    }
 
106
    inline BOOL CanPasteFromClipboard() {
 
107
        return EditCtrlHasFocus();
 
108
    }
 
109
    inline void PasteFromClipboard() {
 
110
        GetEditCtrl()->Paste();
 
111
    }
 
112
    inline BOOL CanUndoEditOp() {
 
113
        return EditCtrlHasFocus() ? GetEditCtrl()->CanUndo() : FALSE;
 
114
    }
 
115
    inline void UndoEditOp() {        
 
116
        if(EditCtrlHasFocus())
 
117
            GetEditCtrl()->Undo();
 
118
    }
 
119
 
 
120
protected:
 
121
      CMostRecentUrls m_MRUList;
 
122
};
 
123
 
 
124
class CBrowserFrame : public CFrameWnd
 
125
{       
 
126
public:
 
127
        CBrowserFrame(PRUint32 chromeMask);
 
128
 
 
129
protected: 
 
130
        DECLARE_DYNAMIC(CBrowserFrame)
 
131
 
 
132
public:
 
133
        inline CBrowserImpl *GetBrowserImpl() { return m_wndBrowserView.mpBrowserImpl; }
 
134
 
 
135
        CToolBar    m_wndToolBar;
 
136
        CStatusBar  m_wndStatusBar;
 
137
        CProgressCtrl m_wndProgressBar;
 
138
        CUrlBar m_wndUrlBar;
 
139
        CReBar m_wndReBar;
 
140
        // The view inside which the embedded browser will
 
141
        // be displayed in
 
142
        CBrowserToolTip m_wndTooltip;
 
143
        CBrowserView    m_wndBrowserView;
 
144
 
 
145
    // Wrapper functions for UrlBar clipboard operations
 
146
    inline BOOL CanCutUrlBarSelection() { return m_wndUrlBar.CanCutToClipboard(); }
 
147
    inline void CutUrlBarSelToClipboard() { m_wndUrlBar.CutToClipboard(); }
 
148
    inline BOOL CanCopyUrlBarSelection() { return m_wndUrlBar.CanCopyToClipboard(); }
 
149
    inline void CopyUrlBarSelToClipboard() { m_wndUrlBar.CopyToClipboard(); }
 
150
    inline BOOL CanPasteToUrlBar() { return m_wndUrlBar.CanPasteFromClipboard(); }
 
151
    inline void PasteFromClipboardToUrlBar() { m_wndUrlBar.PasteFromClipboard(); }
 
152
    inline BOOL CanUndoUrlBarEditOp() { return m_wndUrlBar.CanUndoEditOp(); }
 
153
    inline void UndoUrlBarEditOp() { m_wndUrlBar.UndoEditOp(); }
 
154
 
 
155
        // This specifies what UI elements this frame will sport
 
156
        // w.r.t. toolbar, statusbar, urlbar etc.
 
157
        PRUint32 m_chromeMask;
 
158
 
 
159
protected:
 
160
        //
 
161
        // This nested class implements the IBrowserFramGlue interface
 
162
        // The Gecko embedding interfaces call on this interface
 
163
        // to update the status bars etc.
 
164
        //
 
165
        class BrowserFrameGlueObj : public IBrowserFrameGlue 
 
166
        {
 
167
                //
 
168
                // NS_DECL_BROWSERFRAMEGLUE below is a macro which expands
 
169
                // to the function prototypes of methods in IBrowserFrameGlue
 
170
                // Take a look at IBrowserFrameGlue.h for this macro define
 
171
                //
 
172
 
 
173
                NS_DECL_BROWSERFRAMEGLUE
 
174
 
 
175
        } m_xBrowserFrameGlueObj;
 
176
        friend class BrowserFrameGlueObj;
 
177
 
 
178
public:
 
179
        void SetupFrameChrome();
 
180
 
 
181
// Overrides
 
182
        // ClassWizard generated virtual function overrides
 
183
        //{{AFX_VIRTUAL(CBrowserFrame)
 
184
        virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 
185
        virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
 
186
        //}}AFX_VIRTUAL
 
187
 
 
188
// Implementation
 
189
public:
 
190
        virtual ~CBrowserFrame();
 
191
#ifdef _DEBUG
 
192
        virtual void AssertValid() const;
 
193
        virtual void Dump(CDumpContext& dc) const;
 
194
#endif
 
195
 
 
196
// Generated message map functions
 
197
protected:
 
198
        //{{AFX_MSG(CBrowserFrame)
 
199
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
 
200
        afx_msg void OnSetFocus(CWnd *pOldWnd);
 
201
        afx_msg void OnSize(UINT nType, int cx, int cy);
 
202
        afx_msg void OnClose();
 
203
        afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
 
204
        //}}AFX_MSG
 
205
        DECLARE_MESSAGE_MAP()
 
206
};
 
207
 
 
208
/////////////////////////////////////////////////////////////////////////////
 
209
 
 
210
//{{AFX_INSERT_LOCATION}}
 
211
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 
212
 
 
213
#endif //_IBROWSERFRM_H