summaryrefslogtreecommitdiffstats
path: root/kjsembed/qtbindings/qcanvasview_imp.cpp
blob: f32faef7c6a9fe357a7295184baa544da889e034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276



#include <tqcstring.h>
#include <tqimage.h>
#include <tqpainter.h>
#include <tqpalette.h>
#include <tqpixmap.h>
#include <tqfont.h>

#include <kjs/object.h>

#include <kjsembed/global.h>
#include <kjsembed/jsobjectproxy.h>
#include <kjsembed/jsopaqueproxy.h>
#include <kjsembed/jsbinding.h>

#include <tqcanvas.h>
#include "qcanvasview_imp.h"

/**
 * Namespace containing the KJSEmbed library.
 */
namespace KJSEmbed {

TQCanvasViewImp::TQCanvasViewImp( KJS::ExecState *exec, int mid, bool constructor )
   : JSProxyImp(exec), id(mid), cons(constructor)
{
}

TQCanvasViewImp::~TQCanvasViewImp()
{
}

/**
 * Adds bindings for static methods and enum constants to the specified Object.
 */
void TQCanvasViewImp::addStaticBindings( KJS::ExecState *exec, KJS::Object &object )
{
    JSProxy::MethodTable methods[] = {

	{ 0, 0 }
    };

    int idx = 0;
    TQCString lastName;

    while( methods[idx].name ) {
        if ( lastName != methods[idx].name ) {
            TQCanvasViewImp *meth = new TQCanvasViewImp( exec, methods[idx].id );
            object.put( exec , methods[idx].name, KJS::Object(meth) );
            lastName = methods[idx].name;
        }
        ++idx;
    }


}

/**
 * Adds bindings for instance methods to the specified Object.
 */
void TQCanvasViewImp::addBindings( KJS::ExecState *exec, KJS::Object &object )
{
    JSProxy::MethodTable methods[] = {

        { Method_canvas_4, "canvas" },
        { Method_setCanvas_5, "setCanvas" },
        { Method_worldMatrix_6, "worldMatrix" },
        { Method_inverseWorldMatrix_7, "inverseWorldMatrix" },
        { Method_setWorldMatrix_8, "setWorldMatrix" },
	{ 0, 0 }
    };

    int idx = 0;
    TQCString lastName;

    while( methods[idx].name ) {
        if ( lastName != methods[idx].name ) {
            TQCanvasViewImp *meth = new TQCanvasViewImp( exec, methods[idx].id );
            object.put( exec , methods[idx].name, KJS::Object(meth) );
            lastName = methods[idx].name;
        }
        ++idx;
    }
}

/**
 * Extract a TQCanvasView pointer from an Object.
 */
TQCanvasView *TQCanvasViewImp::toTQCanvasView( KJS::Object &self )
{
    JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() );
    if ( ob ) {
        TQObject *obj = ob->object();
	if ( obj )
           return dynamic_cast<TQCanvasView *>( obj );
    }

    JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
    if ( !op )
        return 0;

    if ( op->typeName() != "TQCanvasView" )
        return 0;

    return op->toNative<TQCanvasView>();
}

/**
 * Select and invoke the correct constructor.
 */
KJS::Object TQCanvasViewImp::construct( KJS::ExecState *exec, const KJS::List &args )
{
   switch( id ) {

         case Constructor_QCanvasView_1:
             return TQCanvasView_1( exec, args );
             break;

         case Constructor_QCanvasView_2:
             return TQCanvasView_2( exec, args );
             break;

         default:
             break;
    }

    TQString msg = i18n("TQCanvasViewCons has no constructor with id '%1'.").arg(id);
    return throwError(exec, msg,KJS::ReferenceError);
}


KJS::Object TQCanvasViewImp::TQCanvasView_1( KJS::ExecState *exec, const KJS::List &args )
{

    TQWidget *arg0 = extractTQWidget(exec, args, 0);


    const char *arg1 = (args.size() >= 2) ? args[1].toString(exec).ascii() : 0;

    TQt::WFlags arg2 = 0; // TODO (hack for TQCanvasView)


    // We should now create an instance of the TQCanvasView object

    TQCanvasView *ret = new TQCanvasView(

          arg0,
          arg1,
          arg2 );

    JSOpaqueProxy *prx = new JSOpaqueProxy( ret, "TQCanvasView");
    return KJS::Object( prx );
}

KJS::Object TQCanvasViewImp::TQCanvasView_2( KJS::ExecState *exec, const KJS::List &args )
{
    TQCanvas * arg0 = 0L;;

    KJS::Object obj = args[0].toObject(exec);
    JSObjectProxy *proxy = JSProxy::toObjectProxy( obj.imp() );
    if ( proxy ) arg0 = dynamic_cast<TQCanvas *>( proxy->widget() );

    TQWidget * arg1 = extractTQWidget(exec, args, 1);

    const char *arg2 = (args.size() >= 3) ? args[2].toString(exec).ascii() : 0;

    TQt::WFlags arg3 = 0; // TODO (hack for TQCanvasView)


    // We should now create an instance of the TQCanvasView object

    TQCanvasView *ret = new TQCanvasView(
          arg0,
          arg1,
          arg2,
          arg3 );

    JSOpaqueProxy *prx = new JSOpaqueProxy( ret, "TQCanvasView");
    return KJS::Object( prx );
}

KJS::Value TQCanvasViewImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args )
{
    instance = TQCanvasViewImp::toTQCanvasView( self );

    switch( id ) {

    case Method_canvas_4:
        return canvas_4( exec, self, args );
        break;

    case Method_setCanvas_5:
        return setCanvas_5( exec, self, args );
        break;

    case Method_worldMatrix_6:
        return worldMatrix_6( exec, self, args );
        break;

    case Method_inverseWorldMatrix_7:
        return inverseWorldMatrix_7( exec, self, args );
        break;

    case Method_setWorldMatrix_8:
        return setWorldMatrix_8( exec, self, args );
        break;

    default:
        break;
    }

    TQString msg = i18n( "TQCanvasViewImp has no method with id '%1'." ).arg( id );
    return throwError(exec, msg,KJS::ReferenceError);
}


KJS::Value TQCanvasViewImp::canvas_4( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

      instance->canvas(  );
      return KJS::Value(); // Returns 'TQCanvas *'

}

KJS::Value TQCanvasViewImp::setCanvas_5( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    // Unsupported parameter TQCanvas *
    return KJS::Value();

    TQCanvas * arg0; // Dummy

      instance->setCanvas(
       arg0 );
      return KJS::Value(); // Returns void

}

KJS::Value TQCanvasViewImp::worldMatrix_6( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

      instance->worldMatrix(  );
      return KJS::Value(); // Returns 'const TQWMatrix &'

}

KJS::Value TQCanvasViewImp::inverseWorldMatrix_7( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

      instance->inverseWorldMatrix(  );
      return KJS::Value(); // Returns 'const TQWMatrix &'

}

KJS::Value TQCanvasViewImp::setWorldMatrix_8( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
{

    TQWMatrix arg0; // TODO (hack for qcanvasview)

      bool ret;
      ret = instance->setWorldMatrix(
       arg0 );
      return KJS::Boolean( ret );

}


} // namespace KJSEmbed

// Local Variables:
// c-basic-offset: 4
// End: