Skip to content

Commit fd22096

Browse files
committed
using xtd::helpers::throw_helper class
1 parent 85fb6dd commit fd22096

File tree

15 files changed

+61
-47
lines changed

15 files changed

+61
-47
lines changed

src/xtd.forms.native.wxwidgets/src/xtd/forms/native/wxwidgets/timer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
using namespace xtd;
1010
using namespace xtd::forms::native;
11+
using namespace xtd::helpers;
1112

1213
intptr timer::create(int32 interval, const delegate<void(const event_args&)>& tick) {
1314
application::initialize(); // Must be first
@@ -18,7 +19,7 @@ intptr timer::create(int32 interval, const delegate<void(const event_args&)>& ti
1819
}
1920

2021
void timer::destroy(intptr handle) {
21-
if (!handle) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
22+
if (!handle) throw_helper::throws(exception_case::argument);
2223
if (!wxTheApp) return;
2324
wx_timer* timer = reinterpret_cast<class wx_timer*>(handle);
2425
timer->timer().Stop();

src/xtd.forms.native.wxwidgets/src/xtd/forms/native/wxwidgets/toggle_button.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ using namespace xtd;
99
using namespace xtd::diagnostics;
1010
using namespace xtd::drawing;
1111
using namespace xtd::forms::native;
12+
using namespace xtd::helpers;
1213

1314
void toggle_button::check_state(intptr control, int32 state) {
14-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
15+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
1516
if (!reinterpret_cast<control_handler*>(control)->control()) {
1617
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
1718
return;

src/xtd.forms.native.wxwidgets/src/xtd/forms/native/wxwidgets/tool_bar.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ using namespace xtd;
1010
using namespace xtd::diagnostics;
1111
using namespace xtd::drawing;
1212
using namespace xtd::forms::native;
13+
using namespace xtd::helpers;
1314

1415
intptr tool_bar::add_tool_bar_button(intptr tool_bar, const xtd::string& text, const xtd::string& tool_tip_text, const xtd::drawing::image& image, bool enabled, bool visible) {
15-
if (!tool_bar || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
16+
if (!tool_bar || !wxTheApp) throw_helper::throws(exception_case::argument);
1617
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
1718
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
1819
return 0;
@@ -25,7 +26,7 @@ intptr tool_bar::add_tool_bar_button(intptr tool_bar, const xtd::string& text, c
2526
}
2627

2728
intptr tool_bar::add_tool_bar_drop_down_button(intptr tool_bar, const xtd::string& text, const xtd::string& tool_tip_text, const xtd::drawing::image& image, bool enabled, bool visible, intptr drop_down_menu) {
28-
if (!tool_bar || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
29+
if (!tool_bar || !wxTheApp) throw_helper::throws(exception_case::argument);
2930
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
3031
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
3132
return 0;
@@ -39,7 +40,7 @@ intptr tool_bar::add_tool_bar_drop_down_button(intptr tool_bar, const xtd::strin
3940
}
4041

4142
intptr tool_bar::add_tool_bar_toggle_button(intptr tool_bar, const xtd::string& text, const xtd::string& tool_tip_text, const xtd::drawing::image& image, bool pushed, bool enabled, bool visible) {
42-
if (!tool_bar || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
43+
if (!tool_bar || !wxTheApp) throw_helper::throws(exception_case::argument);
4344
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
4445
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
4546
return 0;
@@ -53,7 +54,7 @@ intptr tool_bar::add_tool_bar_toggle_button(intptr tool_bar, const xtd::string&
5354
}
5455

5556
intptr tool_bar::add_tool_bar_separator(intptr tool_bar) {
56-
if (!tool_bar || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
57+
if (!tool_bar || !wxTheApp) throw_helper::throws(exception_case::argument);
5758
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
5859
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
5960
return 0;
@@ -64,7 +65,7 @@ intptr tool_bar::add_tool_bar_separator(intptr tool_bar) {
6465
}
6566

6667
intptr tool_bar::add_tool_bar_stretchable_separator(intptr tool_bar) {
67-
if (!tool_bar || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
68+
if (!tool_bar || !wxTheApp) throw_helper::throws(exception_case::argument);
6869
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
6970
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
7071
return 0;
@@ -75,7 +76,7 @@ intptr tool_bar::add_tool_bar_stretchable_separator(intptr tool_bar) {
7576
}
7677

7778
intptr tool_bar::add_tool_bar_control(intptr tool_bar, intptr control, const xtd::string& text, const xtd::string& tool_tip_text) {
78-
if (!tool_bar || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
79+
if (!tool_bar || !wxTheApp) throw_helper::throws(exception_case::argument);
7980
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
8081
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
8182
return 0;
@@ -92,8 +93,8 @@ intptr tool_bar::add_tool_bar_control(intptr tool_bar, intptr control, const xtd
9293
}
9394

9495
bool tool_bar::set_system_tool_bar(intptr control, intptr tool_bar) {
95-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
96-
if (tool_bar != 0 && !dynamic_cast<wxFrame*>(reinterpret_cast<control_handler*>(control)->control())) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument, "dialog can't have tool bar"_t);
96+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
97+
if (tool_bar != 0 && !dynamic_cast<wxFrame*>(reinterpret_cast<control_handler*>(control)->control())) throw_helper::throws(exception_case::argument, "dialog can't have tool bar"_t);
9798
if (!reinterpret_cast<control_handler*>(control)->control()) {
9899
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
99100
return false;
@@ -112,14 +113,14 @@ bool tool_bar::set_system_tool_bar(intptr control, intptr tool_bar) {
112113
}
113114

114115
void tool_bar::update_tool_bar_item(intptr tool_bar, intptr handle, const xtd::string& text, const xtd::string& tool_tip_text, const xtd::drawing::image& image, bool pushed, bool enabled, bool visible) {
115-
if (!tool_bar || !handle || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
116+
if (!tool_bar || !handle || !wxTheApp) throw_helper::throws(exception_case::argument);
116117
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
117118
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
118119
return;
119120
}
120121

121122
auto tool_bar_item = dynamic_cast<wxToolBar*>(reinterpret_cast<control_handler*>(tool_bar)->control())->FindById(static_cast<int32>(handle));
122-
if (!tool_bar_item) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
123+
if (!tool_bar_item) throw_helper::throws(exception_case::argument);
123124

124125
tool_bar_item->SetLabel(convert_string::to_wstring(text));
125126
tool_bar_item->SetNormalBitmap(*reinterpret_cast<wxImage*>(image.handle()));
@@ -129,13 +130,13 @@ void tool_bar::update_tool_bar_item(intptr tool_bar, intptr handle, const xtd::s
129130
}
130131

131132
rectangle tool_bar::tool_bar_item_rectangle(intptr tool_bar, intptr handle) {
132-
if (!tool_bar || !handle || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
133+
if (!tool_bar || !handle || !wxTheApp) throw_helper::throws(exception_case::argument);
133134
if (!reinterpret_cast<control_handler*>(tool_bar)->control()) {
134135
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(tool_bar)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
135136
return {};
136137
}
137138

138139
auto tool_bar_item = dynamic_cast<wxToolBar*>(reinterpret_cast<control_handler*>(tool_bar)->control())->FindById(static_cast<int32>(handle));
139-
if (!tool_bar_item) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
140+
if (!tool_bar_item) throw_helper::throws(exception_case::argument);
140141
return {};
141142
}

src/xtd.forms.native.wxwidgets/src/xtd/forms/native/wxwidgets/track_bar.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ using namespace xtd;
88
using namespace xtd::diagnostics;
99
using namespace xtd::drawing;
1010
using namespace xtd::forms::native;
11+
using namespace xtd::helpers;
1112

1213
void track_bar::large_change(intptr control, int32 large_change) {
13-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
14+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
1415
if (!reinterpret_cast<control_handler*>(control)->control()) {
1516
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
1617
return;
@@ -19,7 +20,7 @@ void track_bar::large_change(intptr control, int32 large_change) {
1920
}
2021

2122
void track_bar::maximum(intptr control, int32 maximum) {
22-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
23+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
2324
if (!reinterpret_cast<control_handler*>(control)->control()) {
2425
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
2526
return;
@@ -28,7 +29,7 @@ void track_bar::maximum(intptr control, int32 maximum) {
2829
}
2930

3031
void track_bar::minimum(intptr control, int32 minimum) {
31-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
32+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
3233
if (!reinterpret_cast<control_handler*>(control)->control()) {
3334
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
3435
return;
@@ -37,7 +38,7 @@ void track_bar::minimum(intptr control, int32 minimum) {
3738
}
3839

3940
void track_bar::small_change(intptr control, int32 small_change) {
40-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
41+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
4142
if (!reinterpret_cast<control_handler*>(control)->control()) {
4243
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
4344
return;
@@ -46,7 +47,7 @@ void track_bar::small_change(intptr control, int32 small_change) {
4647
}
4748

4849
void track_bar::tick_frequency(intptr control, int32 tick_frequency) {
49-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
50+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
5051
if (!reinterpret_cast<control_handler*>(control)->control()) {
5152
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
5253
return;
@@ -58,7 +59,7 @@ void track_bar::tick_frequency(intptr control, int32 tick_frequency) {
5859
}
5960

6061
int32 track_bar::value(intptr control) {
61-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
62+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
6263
if (!reinterpret_cast<control_handler*>(control)->control()) {
6364
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
6465
return 0;
@@ -67,7 +68,7 @@ int32 track_bar::value(intptr control) {
6768
}
6869

6970
void track_bar::value(intptr control, int32 value) {
70-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
71+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
7172
if (!reinterpret_cast<control_handler*>(control)->control()) {
7273
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
7374
return;

src/xtd.forms.native.wxwidgets/src/xtd/forms/native/wxwidgets/up_down_button.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ using namespace xtd;
88
using namespace xtd::diagnostics;
99
using namespace xtd::drawing;
1010
using namespace xtd::forms::native;
11+
using namespace xtd::helpers;
1112

1213
void up_down_button::maximum(intptr control, int32 maximum) {
13-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
14+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
1415
if (!reinterpret_cast<control_handler*>(control)->control()) {
1516
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
1617
return;
@@ -19,7 +20,7 @@ void up_down_button::maximum(intptr control, int32 maximum) {
1920
}
2021

2122
void up_down_button::minimum(intptr control, int32 minimum) {
22-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
23+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
2324
if (!reinterpret_cast<control_handler*>(control)->control()) {
2425
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
2526
return;
@@ -28,7 +29,7 @@ void up_down_button::minimum(intptr control, int32 minimum) {
2829
}
2930

3031
void up_down_button::value(intptr control, int32 value) {
31-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
32+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
3233
if (!reinterpret_cast<control_handler*>(control)->control()) {
3334
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
3435
return;
@@ -37,7 +38,7 @@ void up_down_button::value(intptr control, int32 value) {
3738
}
3839

3940
int32 up_down_button::value(intptr control) {
40-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
41+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
4142
if (!reinterpret_cast<control_handler*>(control)->control()) {
4243
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
4344
return 0;

src/xtd.forms.native.wxwidgets/src/xtd/forms/native/wxwidgets/user_control.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ using namespace xtd;
88
using namespace xtd::diagnostics;
99
using namespace xtd::drawing;
1010
using namespace xtd::forms::native;
11+
using namespace xtd::helpers;
1112

1213
void user_control::virtual_size(intptr control, const drawing::size& size) {
13-
if (!control || !wxTheApp) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument);
14+
if (!control || !wxTheApp) throw_helper::throws(exception_case::argument);
1415
if (!reinterpret_cast<control_handler*>(control)->control()) {
1516
wxASSERT_MSG_AT(reinterpret_cast<control_handler*>(control)->control() == 0, "Control is null", stack_frame().current().get_file_name().c_str(), stack_frame().current().get_file_line_number(), stack_frame().current().get_method().c_str());
1617
return;

src/xtd.forms/src/xtd/forms/about_dialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using namespace xtd;
2222
using namespace xtd::collections::generic;
2323
using namespace xtd::drawing;
2424
using namespace xtd::forms;
25+
using namespace xtd::helpers;
2526
using namespace xtd::reflection;
2627

2728
namespace {
@@ -59,7 +60,7 @@ namespace {
5960
protected:
6061
xtd::uptr<xtd::object> clone() const override {
6162
auto result = xtd::new_uptr<credits_item_panel>(*this);
62-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
63+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
6364
return result;
6465
}
6566

src/xtd.forms/src/xtd/forms/animation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using namespace xtd;
55
using namespace xtd::diagnostics;
66
using namespace xtd::drawing;
77
using namespace xtd::forms;
8+
using namespace xtd::helpers;
89

910
struct animation::data {
1011
uint32 frame_counter = 0;
@@ -200,7 +201,7 @@ void animation::stop() {
200201

201202
xtd::uptr<xtd::object> animation::clone() const {
202203
auto result = xtd::new_uptr<animation>(*this);
203-
if (typeof_(*result) != typeof_(*this)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
204+
if (typeof_(*result) != typeof_(*this)) throw_helper::throws(exception_case::invalid_cast, xtd::string::format("The {} does not implement clone method.", typeof_(*this).full_name()).c_str());
204205
return result;
205206
}
206207

0 commit comments

Comments
 (0)