1 // @file wxBindDialog.cpp
3 // @author Charlie Frasch <cfrasch@atdesk.com>
5 #include "wxBindDialog.h"
7 #include "wxAutoDialog.h"
8 #include "wxNamingViewer.h"
9 #include "wxViewIORDialog.h"
13 namespace // anonymous
15 void create_dialog_components(wxDialog
* dialog
)
17 wxBoxSizer
*topsizer
= new wxBoxSizer(wxVERTICAL
);
20 wxBoxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
21 sizer
->Add(new wxStaticText(dialog
, -1, "ID:" ), 0, wxALL
, 5);
22 wxTextCtrl
* text
= new wxTextCtrl(dialog
, IDC_ID
);
23 text
->SetName("idTextCtrl");
24 sizer
->Add(text
, 1, wxALL
, 5);
25 topsizer
->Add(sizer
, 0, wxALIGN_LEFT
| wxEXPAND
);
29 wxBoxSizer
*sizer
= new wxBoxSizer(wxHORIZONTAL
);
30 sizer
->Add(new wxStaticText(dialog
, -1, "Kind:" ), 0, wxALL
, 5);
31 wxTextCtrl
* text
= new wxTextCtrl(dialog
, IDC_KIND
);
32 text
->SetName("kindTextCtrl");
33 sizer
->Add(text
, 1, wxALL
, 5);
34 topsizer
->Add(sizer
, 0, wxALIGN_LEFT
| wxEXPAND
);
38 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
39 sizer
->Add(new wxStaticText( dialog
, -1, "IOR:" ), 0, wxALL
, 5);
40 wxTextCtrl
* text
= new wxTextCtrl(dialog
, IDC_IOR
);
41 text
->SetName( "iorTextCtrl");
42 sizer
->Add(text
, 1, wxALL
, 5);
43 topsizer
->Add(sizer
, 0, wxALIGN_LEFT
| wxEXPAND
);
46 wxBoxSizer
* button_sizer
= new wxBoxSizer( wxHORIZONTAL
);
48 wxButton
* button
= new wxButton( dialog
, wxID_OK
, "OK" );
49 button
->SetName( "okButton");
50 button_sizer
->Add(button
, 0, wxALL
, 5);
53 button_sizer
->Add(new wxButton( dialog
, wxID_CANCEL
, "Cancel" ),
58 topsizer
->Add(button_sizer
, 0, wxALIGN_CENTER
);
60 dialog
->SetSizer( topsizer
);
61 topsizer
->SetSizeHints( dialog
);
67 BEGIN_EVENT_TABLE( WxBindDialog
, wxDialog
)
68 EVT_BUTTON( IDC_VIEWIOR
, WxBindDialog::onViewIOR
)
72 WxBindDialog::WxBindDialog(
76 #if defined(wxUSE_RESOURCES) && (wxUSE_RESOURCES == 1)
82 "Bind Object/Context",
85 wxRAISED_BORDER
| wxCAPTION
| wxTHICK_FRAME
| wxSYSTEM_MENU
,
87 #endif // defined(wxUSE_RESOURCES) && (wxUSE_RESOURCES == 1)
94 , isContext (isContext
)
96 #if defined(wxUSE_RESOURCES) && (wxUSE_RESOURCES == 1)
97 LoadFromResource( parent
, "bindObject");
99 create_dialog_components( this);
100 #endif // defined(wxUSE_RESOURCES) && (wxUSE_RESOURCES == 1)
102 SetTitle( "Bind Context");
104 SetTitle( "Bind Object");
106 wxButton
* ctrl
= static_cast<wxButton
*>( wxFindWindowByName(
114 void WxBindDialog::onViewIOR( wxCommandEvent
& WXUNUSED(event
))
116 TransferDataFromWindow();
117 WxAutoDialog
<WxViewIORDialog
> dialog( new WxViewIORDialog( orb
, object
.in(), 0));
122 bool WxBindDialog::TransferDataFromWindow()
124 wxTextCtrl
* ctrl
= static_cast<wxTextCtrl
*>( wxFindWindowByName(
128 ior
= ctrl
->GetValue();
130 ctrl
= static_cast<wxTextCtrl
*>( wxFindWindowByName(
134 id
= ctrl
->GetValue();
136 ctrl
= static_cast<wxTextCtrl
*>( wxFindWindowByName(
140 kind
= ctrl
->GetValue();
143 name
[0].id
= CORBA::string_dup( id
);
144 name
[0].kind
= CORBA::string_dup( kind
);
146 object
= orb
->string_to_object( ior
);
147 } catch(CORBA::Exception
& ex
) {
148 wxMessageBox( ex
._rep_id(), "Invalid IOR");
149 object
= CORBA::Object::_nil();