File: nm_linux_c.h

package info (click to toggle)
waba 1.5-3
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 1,996 kB
  • ctags: 3,231
  • sloc: ansic: 17,303; java: 4,436; sh: 2,345; makefile: 417
file content (477 lines) | stat: -rw-r--r-- 16,207 bytes parent folder | download
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#ifndef __NM_LINUX_C_H__
#define __NM_LINUX_C_H__

/*
Copyright (C) 1998, 1999, 2000 Wabasoft

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later version. 

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details. 

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. 
*/

/*

Copyright (C) 2000, 2001 SMARTDATA, http://www.smartdata.ch/

More help for porting is include in the file nmport_c.c. Please read it before
porting or modify this port.

Linux port.
===========

*/

/* default font parameters */
#define DEFAULT_FONT "helvetica"
#define DEFAULT_FONT_SIZE 10

/* usefull for some implementation, like Solaris */
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned long) -1)
#endif

void WindowDestroy(WObject obj);
void MainWinDestroy(WObject obj);
void GraphicsDestroy(WObject obj);
void ImageDestroy(WObject obj);
void CatalogDestroy(WObject obj);
void FileDestroy(WObject obj);
void SocketDestroy(WObject obj);
void SerialPortDestroy(WObject obj);

/* to have a explanation of the following structure, see the the file nmport_c.c
   and my small explanation of how to access class variable below                */
extern ClassHook classHooks[];

#define FUNC(f) extern Var f (Var stack[])

/* all the native functions */

FUNC(VmPrintLn);
FUNC(VmPrint);
FUNC(VmExec);
FUNC(VmGetTimeStamp);
FUNC(copyArray);
FUNC(VmSleep);
FUNC(VmSetDeviceAutoOff);
FUNC(VmGetUserName);
FUNC(VmGetPlatform);
FUNC(VmIsColor);
FUNC(FileGetLength);
FUNC(FileCreateDir);
FUNC(FileReadBytes);
FUNC(FileRename);
FUNC(FileCreate);
FUNC(FileWriteBytes);
FUNC(FileListDir);
FUNC(FileSeekWaba);
FUNC(FileIsDir);
FUNC(FileCloseWaba);
FUNC(FileIsOpen);
FUNC(FileDeleteWaba);
FUNC(FileExists);
FUNC(ImageCreate);
FUNC(ImageFree);
FUNC(ImageSetPixels);
FUNC(ImageUseImagePalette);
FUNC(ImageLoad);
FUNC(SoundBeep);
FUNC(SoundTone);
FUNC(TimeCreate);
FUNC(SocketCreate);
FUNC(SocketRead);
FUNC(SocketWrite);
FUNC(SocketSetReadTimeout);
FUNC(SocketClose);
FUNC(SocketIsOpen);
FUNC(WindowCreate);
FUNC(CatalogListCatalogs);
FUNC(CatalogAddRecord);
FUNC(CatalogSkipBytes);
FUNC(CatalogCreate);
FUNC(CatalogRead);
FUNC(CatalogDeleteRecord);
FUNC(CatalogSetRecordPos);
FUNC(CatalogGetRecordSize);
FUNC(CatalogResizeRecord);
FUNC(CatalogWrite);
FUNC(CatalogGetRecordCount);
FUNC(CatalogClose);
FUNC(CatalogIsOpen);
FUNC(CatalogDelete);
FUNC(GraphicsCopyRect);
FUNC(GraphicsClearClip);
FUNC(GraphicsSetFont);
FUNC(GraphicsSetDrawOp);
FUNC(GraphicsSetClip);
FUNC(GraphicsSetBackColor);
FUNC(GraphicsSetColor);
FUNC(GraphicsGetClip);
FUNC(GraphicsFillRect);
FUNC(GraphicsDrawLine);
FUNC(GraphicsTranslate);
FUNC(GraphicsDrawDots);
FUNC(GraphicsDrawChars);
FUNC(GraphicsCreate);
FUNC(GraphicsDrawCursor);
FUNC(GraphicsSetClip);
FUNC(GraphicsFree);
FUNC(GraphicsSetForeColor);
FUNC(GraphicsSetTextColor);
FUNC(GraphicsFillPolygon);
FUNC(GraphicsDrawString);
FUNC(ConvertStringToInt);
FUNC(ConvertFloatToIntBitwise);
FUNC(ConvertCharToString);
FUNC(ConvertIntToFloatBitwise);
FUNC(ConvertFloatToString);
FUNC(ConvertIntToString);
FUNC(ConvertBooleanToString);
FUNC(SoundClipPlay);
FUNC(PalmOsPrefSetPalmOsPref);
FUNC(PalmOsPrefGetPalmOsPref);
FUNC(MainWinCreate);
FUNC(MainWinExit);
FUNC(MainWinSetTimerInterval);
FUNC(SerialPortReadCheck);
FUNC(SerialPortRead);
FUNC(SerialPortWrite);
FUNC(SerialPortSetReadTimeout);
FUNC(SerialPortClose);
FUNC(SerialPortSetFlowControl);
FUNC(SerialPortIsOpen);
FUNC(SerialPortCreate);
FUNC(FontMetricsGetStringWidth);
FUNC(FontMetricsGetCharWidth);
FUNC(FontMetricsCreate);
FUNC(FontMetricsGetCharArrayWidth);

/*************************************************************************
                               class waba/fx/Rect
*************************************************************************/

// var[0] = Class
// var[1] = int x
// var[2] = int y
// var[3] = int width
// var[4] = int height

#define WOBJ_RectX(o) (objectPtr(o))[1].intValue
#define WOBJ_RectY(o) (objectPtr(o))[2].intValue
#define WOBJ_RectWidth(o) (objectPtr(o))[3].intValue
#define WOBJ_RectHeight(o) (objectPtr(o))[4].intValue

/*************************************************************************
                               class waba/ui/Control
*************************************************************************/

// var[0] = Class
// var[1] = int x
// var[2] = int y
// var[3] = int width
// var[4] = int height

#define WOBJ_ControlX(o) (objectPtr(o))[1].intValue
#define WOBJ_ControlY(o) (objectPtr(o))[2].intValue
#define WOBJ_ControlWidth(o) (objectPtr(o))[3].intValue
#define WOBJ_ControlHeight(o) (objectPtr(o))[4].intValue

/*************************************************************************
                               class waba/ui/Window
*************************************************************************/

// var[0] = Class
// var[n] = ...other locals...
// var[n + 1] = hook var - a pointer to the MainWindow
// var[n + 2] = hook var - boolean if the Window allready a pixmap or not
//

// since Window inherits from other classes, we need to calculate the
// right base offset to start with when reading/writing to variables
extern int _winHookOffset;

#define WOBJ_WindowMain(o) (objectPtr(o))[_winHookOffset + 0].refValue
#define WOBJ_WindowHookVars 1   /* number of hook var for Window */

/*************************************************************************
                               class waba/ui/MainWindow
*************************************************************************/

// var[0] = Class
// var[n] = ...other locals...
// var[n + 1] = hook var -
//

extern int _mainWinHookOffset;

#define WOBJ_MainWinTimer(o) (objectPtr(o))[_mainWinHookOffset + 0].intValue
#define WOBJ_MainWinHookVars 1   /* number of hook var for MainWindow */

/*************************************************************************
                               class waba/fx/Image
*************************************************************************/

// var[0] = Class
// var[1] = width
// var[2] = height
// var[3] = hook var - pointer to the pixmap image

#define WOBJ_ImageWidth(o) (objectPtr(o))[1].intValue
#define WOBJ_ImageHeight(o) (objectPtr(o))[2].intValue
#define WOBJ_ImagePixmap(o) (objectPtr(o))[3].refValue

/*************************************************************************
                               class waba/io/Socket
*************************************************************************/

// var[0] = Class
// var[1] = hook var - Socket Id (int32)
//

// NOTE: The SOCKET type is an unsigned 32 bit quantity - this most closely
// matches the object type
#define WOBJ_SocketFD(o) (objectPtr(o))[1].intValue

/*************************************************************************
                               class waba/fx/Font
*************************************************************************/

// var[0] = Class
// var[1] = String name
// var[2] = int size
// var[3] = int style
//

#define WOBJ_FontName(o) (objectPtr(o))[1].obj
#define WOBJ_FontStyle(o) (objectPtr(o))[2].intValue
#define WOBJ_FontSize(o) (objectPtr(o))[3].intValue 

#define Font_PLAIN 0
#define Font_BOLD 1

/*************************************************************************
                               class waba/fx/FontMetrics
*************************************************************************/

// var[0] = Class
// var[1] = Font
// var[2] = Surface
// var[3] = int ascent
// var[4] = int descent
// var[5] = int leading

#define WOBJ_FontMetricsFont(o) (objectPtr(o))[1].obj
#define WOBJ_FontMetricsSurface(o) (objectPtr(o))[2].obj
#define WOBJ_FontMetricsAscent(o) (objectPtr(o))[3].intValue
#define WOBJ_FontMetricsDescent(o) (objectPtr(o))[4].intValue
#define WOBJ_FontMetricsLeading(o) (objectPtr(o))[5].intValue

/* what type of width we can compute */
#define FM_STRINGWIDTH 1
#define FM_CHARARRAYWIDTH 2
#define FM_CHARWIDTH 3

/*************************************************************************
                               class waba/fx/Graphics
*************************************************************************/

// var[0] = Class
// var[1] = Surface
// var[2] = hook var - isValid flag
// var[3] = hook var - pointer to the main window, NULL if it's an Image
// var[4] = hook var - pointer to the Pixmap if it's an Image, NULL otherwise
// var[5] = hook var - pointer to the drawing pixmap where all draw are made
// var[6] = hook var - pointer to the used font
// var[7] = hook var - the start x of the clip region
// var[8] = hook var - the start y of the clip region
// var[9] = hook var - the width of the clip region
// var[10] = hook var - the height of the clip region
// var[11] = hook var - the operation used for the draw (AND/OR/XOR...)
// var[12] = hook var - the value of the red color used for the draw
// var[13] = hook var - the value of the green color used for the draw
// var[14] = hook var - the value of the blue color used for the draw
// var[15] = hook var - the X used for translation
// var[16] = hook var - the Y used for translation

#define WOBJ_GraphicsSurface(o) (objectPtr(o))[1].obj
#define WOBJ_GraphicsIsValid(o) (objectPtr(o))[2].intValue
#define WOBJ_GraphicsWindowMain(o) (objectPtr(o))[3].refValue
#define WOBJ_GraphicsPixmap(o) (objectPtr(o))[4].refValue
#define WOBJ_GraphicsDrawingPixmap(o) (objectPtr(o))[5].refValue
#define WOBJ_GraphicsFont(o) (objectPtr(o))[6].refValue
#define WOBJ_GraphicsClipRegionX(o) (objectPtr(o))[7].intValue
#define WOBJ_GraphicsClipRegionY(o) (objectPtr(o))[8].intValue
#define WOBJ_GraphicsClipRegionW(o) (objectPtr(o))[9].intValue
#define WOBJ_GraphicsClipRegionH(o) (objectPtr(o))[10].intValue
#define WOBJ_GraphicsDrawOp(o) (objectPtr(o))[11].intValue
#define WOBJ_GraphicsRED(o) (objectPtr(o))[12].intValue
#define WOBJ_GraphicsGREEN(o) (objectPtr(o))[13].intValue
#define WOBJ_GraphicsBLUE(o) (objectPtr(o))[14].intValue
#define WOBJ_GraphicsTransX(o) (objectPtr(o))[15].intValue
#define WOBJ_GraphicsTransY(o) (objectPtr(o))[16].intValue

/* how we can draw */
#define DRAW_OVER 1
#define DRAW_AND 2
#define DRAW_OR 3
#define DRAW_XOR 4

/* some constants giving the existing type of drawing */
#define GR_FILLRECT   0
#define GR_DRAWLINE   1
#define GR_FILLPOLY   2
#define GR_DRAWCHARS  3
#define GR_DRAWSTRING 4
#define GR_DOTS       5
#define GR_COPYRECT   6
#define GR_DRAWCURSOR 7

/* existing surface type */
#define SURF_UNKNOWN 0
#define SURF_WINDOW 1
#define SURF_IMAGE 2

/*************************************************************************
                               class waba/fx/SoundClip
*************************************************************************/

// var[0] = Class
// var[1] = path
// var[2] = loaded

#define WOBJ_SoundClipPath(o) (objectPtr(o))[1].obj
#define WOBJ_SoundClipLoaded(o) (objectPtr(o))[2].intValue

/*************************************************************************
                               class waba/io/Catalog
As linux has no catalog, this is not implemented at this time
*************************************************************************/

// var[0] = Class
// var[1] = hook var - database handle (null if no open db)
// var[2] = hook var - database oid
// var[3] = hook var - current record position
// var[4] = hook var - current record oid
// var[5] = hook var - current record memory pointer
// var[6] = hook var - current record memory allocation pointer
// var[7] = hook var - length of current record
// var[8] = hook var - current offset in record
// var[9] = hook var - 1 if record has been modified, 0 otherwise

#define WOBJ_CatalogHandle(o) (objectPtr(o))[1].refValue
#define WOBJ_CatalogOID(o) (objectPtr(o))[2].refValue
#define WOBJ_CatalogCurRecPos(o) (objectPtr(o))[3].intValue
#define WOBJ_CatalogCurRecOid(o) (objectPtr(o))[4].refValue
#define WOBJ_CatalogCurRecPtr(o) (objectPtr(o))[5].refValue
#define WOBJ_CatalogCurRecAllocPtr(o) (objectPtr(o))[6].refValue
#define WOBJ_CatalogCurRecLen(o) (objectPtr(o))[7].intValue
#define WOBJ_CatalogCurRecOffset(o) (objectPtr(o))[8].intValue
#define WOBJ_CatalogCurRecModified(o) (objectPtr(o))[9].intValue

#define Catalog_READ_ONLY 1
#define Catalog_WRITE_ONLY 2
#define Catalog_READ_WRITE 3
#define Catalog_CREATE 4

#define Catalog_CEDBTYPE 4141

/*************************************************************************
                               class waba/io/File
*************************************************************************/

// var[0] = Class
// var[1] = String name
// var[2] = int mode
// var[3] = hook var - file handle

#define WOBJ_FileName(o) (objectPtr(o))[1].obj
#define WOBJ_FileMode(o) (objectPtr(o))[2].intValue
#define WOBJ_FileHandle(o) (objectPtr(o))[3].refValue

#define File_DONT_OPEN 0
#define File_READ_ONLY 1
#define File_WRITE_ONLY 2
#define File_READ_WRITE 3
#define File_CREATE 4

/* some file operation */
#define FILE_CREATE_DIR 1
#define FILE_IS_DIR 2
#define FILE_DELETE 3
#define FILE_RENAME 4
#define FILE_EXISTS 5

/*************************************************************************
                               class waba/io/SerialPort
*************************************************************************/

// var[0] = Class
// var[1] = hook var - Handle

#define WOBJ_SerialPortHandle(o) (objectPtr(o))[1].refValue

/*************************************************************************
                               class waba/sys/Time
*************************************************************************/

// var[0] = Class
// var[1] = int year
// var[2] = int month
// var[3] = int day
// var[4] = int hour
// var[5] = int minute
// var[6] = int second
// var[7] = int millis

#define WOBJ_TimeYear(o) (objectPtr(o))[1].intValue
#define WOBJ_TimeMonth(o) (objectPtr(o))[2].intValue
#define WOBJ_TimeDay(o) (objectPtr(o))[3].intValue
#define WOBJ_TimeHour(o) (objectPtr(o))[4].intValue
#define WOBJ_TimeMinute(o) (objectPtr(o))[5].intValue
#define WOBJ_TimeSecond(o) (objectPtr(o))[6].intValue
#define WOBJ_TimeMillis(o) (objectPtr(o))[7].intValue

/*************************************************************************
                   functions implemented in ui_xxx.c
*************************************************************************/

/* for the fonts */
ui_FontType *ui_FontCreate( WObject font );
void ui_FontDelete( ui_FontType *theFont );
gint ui_TextWidth( char *theText, ui_FontType *theFont );
gint ui_CharWidth( char theChar, ui_FontType *theFont );
void ui_FontSetProperties( ui_FontType *theFont, WObject fontMetrics );
gint ui_FontGetYOffset( ui_FontType *theFont );

/* for the draw */
ui_PixmapType *ui_createDrawingPixmap( ui_MainWindowType *mw, ui_Rectangle rect );
ui_GraphicsContextType *ui_createGC( WObject gr );
void ui_deleteGC( ui_GraphicsContextType *theGC );
void ui_setTheDrawFunction( ui_GraphicsContextType *theGC, gint32 drawOp );
void ui_ClipTo( ui_GraphicsContextType *theGC, ui_Rectangle rect );
void ui_SetColor( ui_GraphicsContextType *theGC, gint red, gint green, gint blue );
void ui_DrawPixel( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y );
void ui_DrawLine( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x1, gint y1, gint x2, gint y2 );
void ui_DrawText( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, char *theText, ui_FontType *theFont );
void ui_DrawFilledRect( ui_PixmapType *drawingPixmap, ui_GraphicsContextType *theGC, gint x, gint y, gint w, gint h );
void ui_GraphicsRepaint( WObject graphics, ui_PixmapType *drawingPixmap, ui_GraphicsContextType *gc );

/* for translating the key code to a waba key code */
int32 ui_TranslateKey( Word chr );

#endif /* __NM_LINUX_A_H__ */

/*
   Local Variables:
   c-file-style: "smartdata"
   End:
*/