|
| 1 | +/* Copyright (C) 2003-2013 Runtime Revolution Ltd. |
| 2 | + |
| 3 | + This file is part of LiveCode. |
| 4 | + |
| 5 | + LiveCode is free software; you can redistribute it and/or modify it under |
| 6 | + the terms of the GNU General Public License v3 as published by the Free |
| 7 | + Software Foundation. |
| 8 | + |
| 9 | + LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 | + WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + for more details. |
| 13 | + |
| 14 | + You should have received a copy of the GNU General Public License |
| 15 | + along with LiveCode. If not see <http://www.gnu.org/licenses/>. */ |
| 16 | + |
| 17 | +#include "prefix.h" |
| 18 | + |
| 19 | +#include "globdefs.h" |
| 20 | +#include "filedefs.h" |
| 21 | +#include "objdefs.h" |
| 22 | +#include "parsedef.h" |
| 23 | +#include "mcio.h" |
| 24 | +#include "util.h" |
| 25 | + |
| 26 | +#include "globals.h" |
| 27 | +#include "debug.h" |
| 28 | +#include "handler.h" |
| 29 | + |
| 30 | +#include "mblsyntax.h" |
| 31 | +#include "mblcontrol.h" |
| 32 | + |
| 33 | +//////////////////////////////////////////////////////////////////////////////// |
| 34 | + |
| 35 | +MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, CreateControl, 2) |
| 36 | +MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, DeleteControl, 1) |
| 37 | +MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, SetProperty, 2) |
| 38 | +MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, GetProperty, 2) |
| 39 | +MC_EXEC_DEFINE_EXEC_METHOD(NativeControl, Do, 0) |
| 40 | +MC_EXEC_DEFINE_GET_METHOD(NativeControl, Target, 1) |
| 41 | +MC_EXEC_DEFINE_GET_METHOD(NativeControl, ControlList, 1) |
| 42 | + |
| 43 | +//////////////////////////////////////////////////////////////////////////////// |
| 44 | + |
| 45 | +void MCNativeControlExecCreateControl(MCExecContext& ctxt, MCStringRef p_type_name, MCStringRef p_control_name) |
| 46 | +{ |
| 47 | + ctxt . SetTheResultToEmpty(); |
| 48 | + |
| 49 | + // Make sure the name is valid. |
| 50 | + if (MCStringIsEqualTo(p_control_name, kMCEmptyString, kMCCompareCaseless)) |
| 51 | + return; |
| 52 | + |
| 53 | + int2 t_integer; |
| 54 | + if (MCU_stoi2(p_control_name, t_integer)) |
| 55 | + return; |
| 56 | + |
| 57 | + // Make sure a control does not already exist with the name |
| 58 | + MCNativeControl *t_control; |
| 59 | + if (MCNativeControl::FindByNameOrId(MCStringGetCString(p_control_name), t_control)) |
| 60 | + return; |
| 61 | + |
| 62 | + MCNativeControlType t_type; |
| 63 | + if (!MCNativeControl::LookupType(MCStringGetCString(p_type_name), t_type)) |
| 64 | + return; |
| 65 | + |
| 66 | + MCNativeControl *t_new_control; |
| 67 | + t_new_control = nil; |
| 68 | + if (MCNativeControl::CreateWithType(t_type, t_new_control)) |
| 69 | + { |
| 70 | + extern MCExecPoint *MCEPptr; |
| 71 | + t_control -> SetOwner(MCEPptr -> getobj()); |
| 72 | + t_control -> SetName(p_control_name); |
| 73 | + ctxt . SetTheResultToNumber(t_new_control -> GetId()); |
| 74 | + return; |
| 75 | + } |
| 76 | + |
| 77 | + if (t_control != nil) |
| 78 | + t_control -> Delete(); |
| 79 | +} |
| 80 | + |
| 81 | +void MCNativeControlExecDeleteControl(MCExecContext& ctxt, MCStringRef p_control_name) |
| 82 | +{ |
| 83 | + MCNativeControl *t_control; |
| 84 | + if (!MCNativeControl::FindByNameOrId(MCStringGetCString(p_control_name), t_control)) |
| 85 | + return; |
| 86 | + |
| 87 | + t_control -> Delete(); |
| 88 | + t_control -> Release(); |
| 89 | +} |
| 90 | + |
| 91 | +void MCNativeControlExecSetProperty(MCExecContext& ctxt, MCStringRef p_property, MCValueRef p_value) |
| 92 | +{ |
| 93 | + ctxt . Unimplemented(); |
| 94 | +} |
| 95 | + |
| 96 | +void MCNativeControlExecGetProperty(MCExecContext& ctxt, MCStringRef p_property, MCValueRef& r_value) |
| 97 | +{ |
| 98 | + ctxt . Unimplemented(); |
| 99 | +} |
| 100 | + |
| 101 | +void MCNativeControlExecDo(MCExecContext& ctxt) |
| 102 | +{ |
| 103 | + ctxt . Unimplemented(); |
| 104 | +} |
| 105 | + |
| 106 | +void MCNativeControlGetTarget(MCExecContext& ctxt, MCStringRef& r_target) |
| 107 | +{ |
| 108 | + // UNION TYPE! |
| 109 | + ctxt . Unimplemented(); |
| 110 | +} |
| 111 | + |
| 112 | +void MCNativeControlGetControlList(MCExecContext& ctxt, MCStringRef& r_list) |
| 113 | +{ |
| 114 | + if (MCNativeControl::GetControlList(r_list)) |
| 115 | + return; |
| 116 | + |
| 117 | + ctxt . Throw(); |
| 118 | +} |
| 119 | + |
| 120 | +//////////////////////////////////////////////////////////////////////////////// |
0 commit comments