]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/activex/wxie/wxActiveXFrame.cpp
   2                 wxActiveX Library Licence, Version 3 
   3                 ==================================== 
   5   Copyright (C) 2003 Lindsay Mathieson [, ...] 
   7   Everyone is permitted to copy and distribute verbatim copies 
   8   of this licence document, but changing it is not allowed. 
  10                        wxActiveX LIBRARY LICENCE 
  11      TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 
  13   This library is free software; you can redistribute it and/or modify it 
  14   under the terms of the GNU Library General Public Licence as published by 
  15   the Free Software Foundation; either version 2 of the Licence, or (at 
  16   your option) any later version. 
  18   This library is distributed in the hope that it will be useful, but 
  19   WITHOUT ANY WARRANTY; without even the implied warranty of 
  20   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library 
  21   General Public Licence for more details. 
  23   You should have received a copy of the GNU Library General Public Licence 
  24   along with this software, usually in a file named COPYING.LIB.  If not, 
  25   write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
  26   Boston, MA 02111-1307 USA. 
  30   1. As a special exception, the copyright holders of this library give 
  31   permission for additional uses of the text contained in this release of 
  32   the library as licenced under the wxActiveX Library Licence, applying 
  33   either version 3 of the Licence, or (at your option) any later version of 
  34   the Licence as published by the copyright holders of version 3 of the 
  37   2. The exception is that you may use, copy, link, modify and distribute 
  38   under the user's own terms, binary object code versions of works based 
  41   3. If you copy code from files distributed under the terms of the GNU 
  42   General Public Licence or the GNU Library General Public Licence into a 
  43   copy of this library, as this licence permits, the exception does not 
  44   apply to the code that you add in this way.  To avoid misleading anyone as 
  45   to the status of such modified files, you must delete this exception 
  46   notice from such code and/or adjust the licensing conditions notice 
  49   4. If you write modifications of your own for this library, it is your 
  50   choice whether to permit this exception to apply to your modifications.  
  51   If you do not wish that, you must delete the exception notice from such 
  52   code and/or adjust the licensing conditions notice accordingly. 
  55 // ---------------------------------------------------------------------------- 
  57 // ---------------------------------------------------------------------------- 
  58 // For compilers that support precompilation, includes "wx/wx.h". 
  59 #if defined(__WXGTK__) || defined(__WXMOTIF__) 
  62 #include "wx/wxprec.h" 
  63 #include "wx/filedlg.h" 
  64 #include "wx/textdlg.h" 
  65 #include "wxActiveXFrame.h" 
  68 #include "wx/splitter.h" 
  69 #include "wx/textctrl.h" 
  70 #include "wx/clipbrd.h" 
  71 #include <wx/msgdlg.h> 
  76     MENU_GETTYPEINFO 
= 700, 
  81 BEGIN_EVENT_TABLE(wxActiveXFrame
, wxFrame
) 
  82     EVT_MENU(MENU_GETTYPEINFO
, wxActiveXFrame::OnGetTypeInfo
) 
  83         EVT_MENU(MENU_INVOKEMETHOD
, wxActiveXFrame::OnInvokeMethod
) 
  84         EVT_MENU(MENU_TEST
, wxActiveXFrame::OnTest
) 
  88 wxActiveXFrame::wxActiveXFrame(wxWindow 
*parent
, wxString title
) : 
  89     wxFrame(parent
, -1, title
)  
  92     wxMenu 
*xMenu 
= new wxMenu("", wxMENU_TEAROFF
); 
  94         xMenu
->Append(MENU_GETTYPEINFO
, "Get Type Info", ""); 
  95         xMenu
->Append(MENU_INVOKEMETHOD
, "Invoke Method (no params)", ""); 
  96         xMenu
->Append(MENU_TEST
, "Test", "For debugging purposes"); 
  98     // now append the freshly created menu to the menu bar... 
  99     wxMenuBar 
*menuBar 
= new wxMenuBar(); 
 100     menuBar
->Append(xMenu
, "&ActiveX"); 
 102     // ... and attach this menu bar to the frame 
 105     wxSplitterWindow 
*sp 
= new wxSplitterWindow(this); 
 106     X 
= new wxActiveX(sp
, title
, 101); 
 108     textLog 
= new wxTextCtrl(sp
, -1, "", wxPoint(0,0),  wxDefaultSize
, wxTE_MULTILINE 
| wxTE_READONLY
); 
 110     sp
->SplitHorizontally(X
, textLog
, 0); 
 112     // conenct all events 
 113     for (int i 
= 0; i 
< X
->GetEventCount(); i
++) 
 115         const wxActiveX::FuncX
& func 
= X
->GetEventDesc(i
); 
 116         const wxEventType
& ev 
= RegisterActiveXEvent((DISPID
) func
.memid
); 
 117         Connect(101, ev
, (wxObjectEventFunction
) OnActiveXEvent
); 
 121 wxString 
VarTypeAsString(VARTYPE vt
) 
 123 #define VT(vtype, desc) case vtype : return desc 
 133     VT(VT_SAFEARRAY
, "SafeArray"); 
 134     VT(VT_EMPTY
, "empty"); 
 140     VT(VT_UI2
, "unsigned short"); 
 141     VT(VT_UI4
, "unsigned long"); 
 143     VT(VT_UINT
, "unsigned int"); 
 144     VT(VT_R4
, "real(4)"); 
 145     VT(VT_R8
, "real(8)"); 
 146     VT(VT_CY
, "Currency"); 
 147     VT(VT_DATE
, "wxDate"); 
 148     VT(VT_BSTR
, "wxString"); 
 149     VT(VT_DISPATCH
, "IDispatch"); 
 150     VT(VT_ERROR
, "SCode Error"); 
 152     VT(VT_VARIANT
, "wxVariant"); 
 153     VT(VT_UNKNOWN
, "IUknown"); 
 155     VT(VT_PTR
, "void *"); 
 156     VT(VT_USERDEFINED
, "*user defined*"); 
 161             s 
<< "Unknown(" << vt 
<< ")"; 
 172 void OutFunc(wxString
& os
, const wxActiveX::FuncX
& func
) 
 174     os 
<< VarTypeAsString(func
.retType
.vt
) << " " << func
.name 
<< "("; 
 175     for (unsigned int p 
= 0; p 
< func
.params
.size(); p
++) 
 177         const wxActiveX::ParamX
& param 
= func
.params
[p
]; 
 178         if (param
.IsIn() && param
.IsOut()) 
 180         else if (param
.IsIn()) 
 182         else if (param
.IsIn()) 
 184         os 
<< VarTypeAsString(param
.vt
) << " " << (param
.isPtr 
? "*" : "") << param
.name
; 
 185         if (p 
< func
.params
.size() - 1) 
 191 void wxActiveXFrame::OnGetTypeInfo(wxCommandEvent
& event
) 
 199     for (i 
= 0; i 
< X
->GetPropCount(); i
++) 
 201         wxActiveX::PropX prop 
= X
->GetPropDesc(i
); 
 202         os 
<< VarTypeAsString(prop
.type
.vt
) << " " << prop
.name 
<< "("; 
 205             os 
<< VarTypeAsString(prop
.arg
.vt
); 
 215     for (i 
= 0; i 
< X
->GetEventCount(); i
++) 
 216                 OutFunc(os
, X
->GetEventDesc(i
)); 
 222     for (i 
= 0; i 
< X
->GetMethodCount(); i
++) 
 223                 OutFunc(os
, X
->GetMethodDesc(i
)); 
 227         if (wxTheClipboard
->Open()) 
 229                 wxDataObjectSimple 
*wo 
= new wxTextDataObject(os
); 
 230                 wxTheClipboard
->SetData(wo
); 
 231         wxTheClipboard
->Flush(); 
 232                 wxTheClipboard
->Close(); 
 235     wxMessageBox(os
, "Type Info", wxOK
, this); 
 238 void wxActiveXFrame::OnInvokeMethod(wxCommandEvent
& event
) 
 240         //wxTextEntryDialog dlg(this, "Method"); 
 241         //if (dlg.ShowModal() == wxID_OK) 
 242         //      X->CallMethod(dlg.GetValue()); 
 245 void wxActiveXFrame::OnTest(wxCommandEvent
& event
) 
 248     wxVariant args
[] = {0L, "http://www.macromedia.com/support/flash/ts/documents/java_script_comm/flash_to_javascript.swf"}; 
 249     X
->CallMethod("LoadMovie", args
);    
 250         //X->Prop("Movie") = "http://www.macromedia.com/support/flash/ts/documents/java_script_comm/flash_to_javascript.swf"; 
 253     //X->Prop("year") = 1964L; 
 254     //X->Prop("Value") = wxDateTime::Now(); 
 257         //wxVariant file = "C:\\WINNT\\wx2\\docs\\pdf\\dialoged.pdf"; 
 258         //X->CallMethod("LoadFile", &file); 
 261 void wxActiveXFrame::OnActiveXEvent(wxActiveXEvent
& event
) 
 269     os 
<< (const wxChar 
*) event
.EventName() << wxT("("); 
 271     for (int p 
= 0; p 
< event
.ParamCount(); p
++) 
 274             (const wxChar 
*) event
.ParamType(p
) << wxT(" ") <<  
 275             (const wxChar 
*) event
.ParamName(p
) << wxT(" = ") << 
 276             (const wxChar 
*) (wxString
) event
[p
]; 
 277         if (p 
< event
.ParamCount() - 1) 
 280     os 
<< wxT(")") << endl
; 
 281     wxString data 
= os
.str().c_str(); 
 282     textLog
->AppendText(data
);