1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: Mozilla-sample-code 1.0
4 * Copyright (c) 2002 Netscape Communications Corporation and
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this Mozilla sample software and associated documentation files
9 * (the "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to permit
12 * persons to whom the Software is furnished to do so, subject to the
13 * following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
27 * Adam Lock <adamlock@netscape.com>
29 * ***** END LICENSE BLOCK ***** */
33 #include "wx/strconv.h"
35 #include "nsIWebNavigation.h"
36 #include "nsIDOMDocument.h"
37 #include "nsIDOMHTMLDocument.h"
39 #include "ChatFrame.h"
41 BEGIN_EVENT_TABLE(ChatFrame
, GeckoFrame
)
42 EVT_TEXT_ENTER(XRCID("chat"), ChatFrame::OnChat
)
45 ChatFrame::ChatFrame(wxWindow
* aParent
)
47 wxXmlResource::Get()->LoadFrame(this, aParent
, wxT("chat_frame"));
51 SetIcon(wxICON(appicon
));
53 SetupDefaultGeckoWindow();
55 nsCOMPtr
<nsIWebNavigation
> webNav
= do_QueryInterface(mWebBrowser
);
56 webNav
->LoadURI(NS_ConvertASCIItoUTF16("about:blank").get(),
57 nsIWebNavigation::LOAD_FLAGS_NONE
, nsnull
, nsnull
, nsnull
);
61 void ChatFrame::OnChat(wxCommandEvent
&event
)
63 nsCOMPtr
<nsIWebNavigation
> webNav
= do_QueryInterface(mWebBrowser
);
64 nsCOMPtr
<nsIDOMDocument
> doc
;
65 webNav
->GetDocument(getter_AddRefs(doc
));
66 nsCOMPtr
<nsIDOMHTMLDocument
> htmlDoc
= do_QueryInterface(doc
);
67 // doc->CreateElement(getter_AddRefs(element));
69 wxTextCtrl
*chatCtrl
= (wxTextCtrl
*) FindWindowById(XRCID("chat"), this);
72 wxString
html("<p>Foo: ");
73 html
+= chatCtrl
->GetValue();
75 nsAutoString
htmlU(conv
.cWX2WC(html
));
76 htmlDoc
->Writeln(htmlU
);
77 chatCtrl
->SetValue("");