forked from yisea123/minigui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minigui.h
3520 lines (3202 loc) · 104 KB
/
minigui.h
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* \file minigui.h
* \author Wei Yongming <vincent@minigui.org>
* \date 2002/01/06
*
* \brief This file includes global and miscellaneous interfaces of MiniGUI.
*
\verbatim
This file is part of MiniGUI, a mature cross-platform windowing
and Graphics User Interface (GUI) support system for embedded systems
and smart IoT devices.
Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
Copyright (C) 1998~2002, WEI Yongming
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 3 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, see <http://www.gnu.org/licenses/>.
Or,
As this program is a library, any link to this program must follow
GNU General Public License version 3 (GPLv3). If you cannot accept
GPLv3, you need to be licensed from FMSoft.
If you have got a commercial license of this program, please use it
under the terms and conditions of the commercial license.
For more information about the commercial license, please refer to
<http://www.minigui.com/en/about/licensing-policy/>.
\endverbatim
*/
/*
* $Id: minigui.h 13674 2010-12-06 06:45:01Z wanzheng $
*
* MiniGUI for Linux/uClinux, eCos, uC/OS-II, VxWorks,
* pSOS, ThreadX, NuCleus, OSE, and Win32.
*/
#ifndef _MGUI_MINIGUI_H
#define _MGUI_MINIGUI_H
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* \addtogroup global_vars Global variables
* @{
*/
/**
* \defgroup rect_vars Global Rectangles
* @{
*/
/**
* \var RECT g_rcScr
* \brief Contains the rectangle of the whole screen.
*/
extern MG_EXPORT RECT g_rcScr;
/**
* \def g_rcDesktop
* \brief Contains the rectangle of desktop of the application.
*
* \a g_rcDesktop is defined as an alias (macro) of \a g_rcScr.
*
* \sa g_rcScr
*/
#define g_rcDesktop g_rcScr
/** @} end of rect_vars */
/**
* \defgroup lite_vars MiniGUI-Processes specific variables
* @{
*/
#ifdef _MGRM_PROCESSES
#include <sys/types.h>
/**
* \var BOOL mgIsServer
* \brief Indicates whether the process is the server or a client on
* MiniGUI-Processes.
*
* \note Only defined for MiniGUI-Processes.
*/
extern MG_EXPORT BOOL mgIsServer;
/**
* \var void* mgSharedRes
* \brief Contains the pointer to the shared resource of MiniGUI-Processes.
*
* \note Not defined for MiniGUI-Threads, and the shared resource is
* read-only for all clients.
*
* \sa mgSizeRes
*/
extern MG_EXPORT void* mgSharedRes;
/**
* \var void* mgSizeRes
* \brief Contains the length of shared resource of MiniGUI-Processes.
*
* \note Only defined for MiniGUI-Processes.
*
* \sa mgSharedRes
*/
extern MG_EXPORT size_t mgSizeRes;
/**
* \def LEN_LAYER_NAME
* \brief The maximum length of name of layer in MiniGUI-Processes.
**/
#define LEN_LAYER_NAME 14
/**
* \def LEN_CLIENT_NAME
* \brief The maximum length of name of client in MiniGUI-Processes.
**/
#define LEN_CLIENT_NAME 14
/**
* \def INV_LAYER_HANDLE
* \brief Invalid handle value of the layer.
**/
#define INV_LAYER_HANDLE 0
struct _MG_Layer;
/** Client information. */
typedef struct _MG_Client
{
/** The name of the client. */
char name [LEN_CLIENT_NAME + 1];
/** PID of the client process. */
pid_t pid;
/** UID of the client process. */
uid_t uid;
/** The file descriptor of the socket connected to the client. */
int fd;
/** Flag indicate whether this client has dirty windows. */
BOOL has_dirty;
/** The last active tick count of the client. */
DWORD last_live_time;
/** The additional data of the client. */
DWORD dwAddData;
/** The pointer to the next client in the same layer. */
struct _MG_Client* next;
/** The pointer to the previous client in the same layer. */
struct _MG_Client* prev;
/** The pointer to the layer on which the client lays. */
struct _MG_Layer* layer;
/** The pointer to the global resoures of the client. */
struct GlobalRes* global_res;
} MG_Client;
/** Layer information. */
typedef struct _MG_Layer
{
/** The name of the layer. */
char name [LEN_LAYER_NAME + 1];
/** The pointer to the active client on the layer. */
DWORD dwAddData;
/** The pointer to the list of clients in the layer. */
MG_Client* cli_head;
/** The pointer to the active client on the layer. */
MG_Client* cli_active;
/** The pointer to the next layer. */
struct _MG_Layer* next;
/** The pointer to the previous layer. */
struct _MG_Layer* prev;
/** Internal field. */
void* zorder_info;
/** Internal field. */
int zorder_shmid;
} MG_Layer;
/*screen attr type*/
#define SCREEN_ATTR_ALPHA_CHANNEL 0x01 //alpha channel
#define SCREEN_ATTR_COLORKEY 0x02 //colorkey
#define SCREEN_ATTR_COLORSPACE 0x03 //colorspace
#define SCREEN_ATTR_ALPHA 0x04
#define SCREEN_NO_EXIST -99 //screen don't exist
/**
* \var int mgClientSize
* \brief The current size of the array \a mgClients.
*
* \sa mgClients
*/
extern MG_EXPORT int mgClientSize;
/**
* \var MG_Client* mgClients
* \brief The pointer to the array contains all clients' information.
*
* You can access the elements in \a mgClients as a normal array. If the
* field \a fd of one element is not less than zero, then the element
* will be a vaild client.
*
* \sa MG_Client
*/
extern MG_EXPORT MG_Client* mgClients;
/**
* \var MG_Layer* mgTopmostLayer
* \brief The pointer to the topmost layer.
*
* \sa MG_Layer
*/
extern MG_EXPORT MG_Layer* mgTopmostLayer;
/**
* \var MG_Layer* mgLayers
* \brief The pointer to the array of layers.
*
* \sa MG_Layer
*/
extern MG_EXPORT MG_Layer* mgLayers;
#endif /* _MGRM_PROCESSES */
/** @} end of lite_vars */
/** @} end of global_vars */
/**
* \fn int GUIAPI InitGUI (int, const char **)
* \brief Initialize MiniGUI.
*
* The meaning of two parameters is same with parameters of main function.
*
**/
MG_EXPORT int GUIAPI InitGUI (int, const char **);
/**
* \fn void GUIAPI TerminateGUI (int not_used)
* \brief Terminate MiniGUI.
*
* \param not_used not used
*
**/
MG_EXPORT void GUIAPI TerminateGUI (int not_used);
/**
* \fn void GUIAPI MiniGUIPanic (int exitcode)
* \brief The panic of MiniGUI application.
*
* The function forces to close GAL and IAL engine.
*
* \param exitcode The value of exitcode, now it can be any values.
*
**/
MG_EXPORT void GUIAPI MiniGUIPanic (int exitcode);
/**
* \addtogroup fns Functions
* @{
*/
/**
* \addtogroup global_fns Global/general functions
* @{
*/
/**
* \defgroup lite_fns MiniGUI-Processes specific functions
* @{
*/
#ifndef _MGRM_THREADS
/**
* \defgroup lite_listenfd_fns Listening a file descriptor
*
* Register/Unregister a listen fd to MiniGUI.
*
* When you need to listen a file descriptor, you can use \a select(2)
* system call. In MiniGUI, you can also register it to MiniGUI to
* be a listened fd, and when there is a read/write/except event on
* the registered fd , MiniGUI will sent a notification message to
* the registered window.
*
* Example:
*
* \include listenfd.c
*
* @{
*/
/**
* \def MAX_NR_LISTEN_FD
* \brief The max number of listen fd which user can use.
**/
#define MAX_NR_LISTEN_FD 5
#ifdef WIN32
#ifndef POLLIN
#define POLLIN 0x001
#endif
#ifndef POLLOUT
#define POLLOUT 0x004
#endif
#ifndef POLLERR
#define POLLERR 0x008
#endif
#endif
/**
* \fn BOOL GUIAPI RegisterListenFD (int fd, int type,\
HWND hwnd, void* context)
* \brief Registers a listening file descriptor to MiniGUI-Lite.
*
* This function registers the file desciptor \a fd to MiniGUI-Lite for
* listening.
*
* When there is a read/write/except event on this \a fd, MiniGUI
* will post a MSG_FDEVENT message with wParam being equal to
* MAKELONG (fd, type), and the lParam being set to \a context
* to the target window \a hwnd.
*
* \param fd The file descriptor to be listened.
* \param type The type of the event to be listened, can be POLLIN, POLLOUT,
* or POLLERR.
* \param hwnd The handle to the window will receive MSG_FDEVENT message.
* \param context The value will be passed to the window as lParam of
* MSG_FDEVENT message.
*
* \return TRUE if all OK, and FALSE on error.
*
* \note Only available on MiniGUI-Processes.
*
* \sa UnregisterListenFD, system_msgs
*/
MG_EXPORT BOOL GUIAPI RegisterListenFD (int fd, int type,
HWND hwnd, void* context);
/**
* \fn BOOL GUIAPI UnregisterListenFD (int fd)
* \brief Unregisters a being listened file descriptor.
*
* This function unregisters the being listened file descriptor \a fd.
*
* \param fd The file descriptor to be unregistered, should be a being
* listened file descriptor.
* \return TRUE if all OK, and FALSE on error.
*
* \note Only available on MiniGUI-Processes.
*
* \sa RegisterListenFD
*/
MG_EXPORT BOOL GUIAPI UnregisterListenFD (int fd);
/** @} end of lite_listenfd_fns */
#ifdef _MGRM_PROCESSES
/**
* \defgroup lite_layer_fns Layer operations
*
* A client in MiniGUI-Processes can create a new layer or join
* an existed layer.
*
* Example:
*
* \include client_startup.c
*
* @{
*/
/**
* \def NAME_SELF_LAYER
* \brief The name of the self layer.
**/
#define NAME_SELF_LAYER ""
/**
* \def NAME_TOPMOST_LAYER
* \brief The name of the topmost layer.
**/
#define NAME_TOPMOST_LAYER ""
/**
* \def NAME_DEF_LAYER
* \brief The default name of the layer.
**/
#define NAME_DEF_LAYER "mginit"
/**
* \fn GHANDLE GUIAPI JoinLayer (const char* layer_name,\
const char* client_name,\
int max_nr_topmosts, int max_nr_normals)
* \brief Joins to a layer.
*
* This function should be called by clients before calling any other MiniGUI
* functions. You can call \a GetLayerInfo to get the layer information.
* If the layer to be joined does not exist, the server, i.e. \a mginit, will
* try to create a new one. If you passed a NULL pointer or a null string for
* \a layer_name, the client will join to the default layer.
*
* If the client want to create a new layer, you should specify the maximal
* number of topmost frame objects (max_nr_topmosts) and the maximal number of
* normal frame objects (max_nr_normals) in the new layer. Passing zero to
* \a max_nr_topmosts and max_nr_normals will use the default values, and the default
* values are specified by ServerStartup.
*
* Note that the server will create a default layer named "mginit".
*
* \param layer_name The name of the layer.You can use NAME_TOPMOST_LAYER to
* specify the current topmost layer.
* \param client_name The name of the client.
* \param max_nr_topmosts The maximal number of topmost z-order nodes in
* the new layer.
* \param max_nr_normals The maximal number of normal z-order nodes in
* the new layer.
*
* \return The handle to the layer on success, INV_LAYER_HANDLE on error.
*
* \note Only call this function in clients of MiniGUI-Processes.
*
* \sa GetLayerInfo, ServerStartup, ServerCreateLayer
*/
MG_EXPORT GHANDLE GUIAPI JoinLayer (const char* layer_name,
const char* client_name,
int max_nr_topmosts, int max_nr_normals);
/**
* \fn GHANDLE GUIAPI GetLayerInfo (const char* layer_name,\
int* nr_clients, BOOL* is_topmost, int* cli_active)
* \brief Gets information of a layer by a client.
*
* You can get the information of a layer through this function.
* The information will be returned through the pointer arguments
* if the specific pointer is not NULL.
*
* \param layer_name The name of the layer. You can use NAME_SELF_LAYER to
* specify the layer the calling client belongs to.
* \param nr_clients The number of clients in the layer will be returned
* through this pointer.
* \param is_topmost A boolean which indicates whether the layer is the
* topmost layer will be returned.
* \param cli_active The identifier of the active client in the layer.
*
* \return Returns the handle to the layer on success,
* INV_LAYER_HANDLE on error.
*
* \note Only call this function in clients of MiniGUI-Processes.
*
* \sa JoinLayer
*/
MG_EXPORT GHANDLE GUIAPI GetLayerInfo (const char* layer_name,
int* nr_clients, BOOL* is_topmost, int* cli_active);
/**
* \fn BOOL GUIAPI SetTopmostLayer (BOOL handle_name,\
* GHANDLE handle, const char* name)
* \brief Brings a layer to be the topmost one.
*
* This function brings the specified layer \a handle to be the topmost layer.
*
* \param handle_name The way specifing the layer; TRUE for handle of
* the layer, FALSE for name.
* \param handle The handle to the layer.
* \param name The name of the layer. You can use NAME_SELF_LAYER to
* specify the layer to which the calling client belongs.
*
* \return TRUE on success, otherwise FALSE.
*
* \note Only call this function in clients of MiniGUI-Processes.
*/
MG_EXPORT BOOL GUIAPI SetTopmostLayer (BOOL handle_name,
GHANDLE handle, const char* name);
/**
* \fn BOOL GUIAPI DeleteLayer (BOOL handle_name,\
GHANDLE handle, const char* layer_name)
* \brief Deletes a specific layer.
*
* \param handle_name The way specifing the layer; TRUE for handle of
* the layer, FALSE for name.
* \param handle The handle to the layer.
* \param layer_name The name of the layer. You can use NAME_SELF_LAYER to
* specify the layer to which the calling client belongs.
*
* \return TRUE for success, FALSE on error.
*
* \note Only call this function in clients of MiniGUI-Processes.
*
* \sa JoinLayer
*/
MG_EXPORT BOOL GUIAPI DeleteLayer (BOOL handle_name,
GHANDLE handle, const char* layer_name);
/** @} end of lite_layer_fns */
/**
* \defgroup lite_server_fns Server-only operations
*
* MiniGUI provides some server-only functions for you to create a
* customized server for MiniGUI-Processes, i.e. \a mginit.
*
* Example:
*
* \include server_startup.c
*
* @{
*/
/**
* \var typedef void (* ON_LOCK_CLIENT_REQ) (void)
* \brief Type of client request lock callback.
*
* \sa OnTrylockClientReq, OnLockClientReq, OnUnlockClientReq
*/
typedef int (* ON_LOCK_CLIENT_REQ) (void);
/**
* \var typedef void (* ON_TRYLOCK_CLIENT_REQ) (void)
* \brief Type of client request lock callback.
*
* \sa OnTrylockClientReq, OnLockClientReq, OnUnlockClientReq
*/
typedef int (* ON_TRYLOCK_CLIENT_REQ) (void);
/**
* \var typedef void (* ON_UNLOCK_CLIENT_REQ) (void)
* \brief Type of client request unlock callback.
*
* \sa OnTrylockClientReq, OnLockClientReq, OnUnlockClientReq
*/
typedef void (* ON_UNLOCK_CLIENT_REQ) (void);
/**
* \var ON_LOCK_CLIENT_REQ OnLockClientReq
* \brief Sets to a function to lock a client request.
*
* \note Only available for the client of MiniGUI-Processes.
*
* \sa ON_LOCK_CLIENT_REQ
*/
extern MG_EXPORT ON_LOCK_CLIENT_REQ OnLockClientReq;
/**
* \var ON_TRYLOCK_CLIENT_REQ OnTrylockClientReq
* \brief Sets to a function to lock a client request.
*
* \note Only available for the client of MiniGUI-Processes.
*
* \sa ON_TRYLOCK_CLIENT_REQ
*/
extern MG_EXPORT ON_TRYLOCK_CLIENT_REQ OnTrylockClientReq;
/**
* \var ON_UNLOCK_CLIENT_REQ OnUnlockClientReq
* \brief Sets to a function to unlock a client request.
*
* \note Only available for the client of MiniGUI-Processes.
*
* \sa ON_UNLOCK_CLIENT_REQ
*/
extern MG_EXPORT ON_UNLOCK_CLIENT_REQ OnUnlockClientReq;
#define LCO_NEW_CLIENT 1
#define LCO_DEL_CLIENT 2
/**
* \var typedef void (* ON_NEW_DEL_CLIENT) (int op, int cli)
* \brief Type of client event callback.
*
* \sa OnNewDelClient, OnChangeLayer
*/
typedef void (* ON_NEW_DEL_CLIENT) (int op, int cli);
#define LCO_NEW_LAYER 1
#define LCO_DEL_LAYER 2
#define LCO_JOIN_CLIENT 3
#define LCO_REMOVE_CLIENT 4
#define LCO_TOPMOST_CHANGED 5
#define LCO_ACTIVE_CHANGED 6
/**
* \var typedef void (* ON_CHANGE_LAYER) (int op,
MG_Layer* layer, MG_Client* client)
* \brief Type of layer change event callback.
*
* \sa OnNewDelClient, OnChangeLayer
*/
typedef void (* ON_CHANGE_LAYER) (int op, MG_Layer* layer,
MG_Client* client);
#define ZNOP_ALLOCATE 1
#define ZNOP_FREE 2
#define ZNOP_MOVE2TOP 3
#define ZNOP_SHOW 4
#define ZNOP_HIDE 5
#define ZNOP_MOVEWIN 6
#define ZNOP_SETACTIVE 7
#define ZNOP_ENABLEWINDOW 11
#define ZNOP_DISABLEWINDOW 12
#define ZNOP_STARTDRAG 13
#define ZNOP_CANCELDRAG 14
#define ZNOP_CHANGECAPTION 15
/**
* \var typedef void (* ON_ZNODE_OPERATION) (int op, int cli, int idx_znode)
* \brief Type of z-node operation callback.
*
* \sa OnNewDelClient, OnChangeLayer, OnZNodeOperation
*/
typedef void (* ON_ZNODE_OPERATION) (int op, int cli, int idx_znode);
/**
* \var ON_NEW_DEL_CLIENT OnNewDelClient
* \brief Sets to a function to handle a comming in (going away)
* connection of client.
*
* When a client is connecting to or disconnecting from the server, MiniGUI
* will call this function to tell you the event and the client identifier.
* The event could be one of the following:
*
* - LCO_NEW_CLIENT\n
* A new client is connecting to the server.
* - LCO_DEL_CLIENT\n
* A new client is disconnecting from the server.
*
* The event will be passed through the argument of \a op, and the client
* identifier will be passed through the argument of \a cli.
* You can get the information of the client by accessing \a mgClients
* with \a cli.
*
* \note Only available for the server of MiniGUI-Processes.
*
* \sa ON_NEW_DEL_CLIENT, mgClients
*/
extern MG_EXPORT ON_NEW_DEL_CLIENT OnNewDelClient;
/**
* \var ON_CHANGE_LAYER OnChangeLayer
* \brief Sets to a function to handle events of layers.
*
* When a layer is changing, MiniGUI will call this function to tell
* you the event and the layer or the client which leads to the event.
* The event could be one of the following:
*
* - LCO_NEW_LAYER\n
* A new layer is creating.
* - LCO_DEL_LAYER\n
* A new layer is deleting.
* - LCO_JOIN_CLIENT\n
* A client is joining to the layer.
* - LCO_REMOVE_CLIENT\n
* A client is removing from the layer.
* - LCO_TOPMOST_CHANGED\n
* The topmost layer changed, the layer will be the topmost one.
* - LCO_ACTIVE_CHANGED\n
* The active client changed, the client will be the active one.
*
* The event will be passed through the argument of \a op, and the
* pointers to the relevant layer and client will be passed through
* the argument of \a layer and \a client respectively.
*
* \note Only available for the server of MiniGUI-Processes.
*
* \sa ON_NEW_DEL_CLIENT, mgClients
*/
extern MG_EXPORT ON_CHANGE_LAYER OnChangeLayer;
/**
* \var ON_ZNODE_OPERATION OnZNodeOperation
* \brief Sets to a function to handle events of z-node.
*
* After the server does an operation on a znode, MiniGUI will call
* this function to tell you the event and the layer, the client, and
* the z-node which leads to the event.
*
* The event could be one of the following:
*
* - ZNOP_ALLOCATE\n
* The z-node has been created.
* - ZNOP_FREE\n
* The z-node has been destroyed.
* - ZNOP_MOVE2TOP\n
* The z-node has been moved to be the topmost one.
* - ZNOP_SHOW\n
* The z-node has been shown.
* - ZNOP_HIDE\n
* The z-node has been hidden.
* - ZNOP_MOVEWIN\n
* The z-node has been moved or its size has changed.
* - ZNOP_SETACTIVE\n
* The z-node has been set to be the active one.
* - ZNOP_ENABLEWINDOW\n
* The z-node is disabled or enabled.
* - ZNOP_STARTDRAG\n
* Start to drag the z-node.
* - ZNOP_CANCELDRAG\n
* Cancel to drag the z-node.
* - ZNOP_CHANGECAPTION\n
* The caption of the z-node has changed.
*
* The event will be passed through the argument of \a op; the
* pointers to the layer, the identifier of the client, and the index of
* the z-node will be passed through the argument of \a layer, \a cli,
* and \a idx_znode respectively.
*
* \note Only available for the server of MiniGUI-Processes.
*
* \sa ON_ZNODE_OPERATION, ServerGetZNodeInfo, mgClients
*/
extern MG_EXPORT ON_ZNODE_OPERATION OnZNodeOperation;
/**
* \fn BOOL GUIAPI ServerStartup (int nr_globals,\
int def_nr_topmosts, int def_nr_normals)
* \brief Initializes the server of MiniGUI-Processes.
*
* This function initializes the server, i.e. \a mginit. It creates the
* shared resource, the listening socket, the default layer, and other
* internal objects. Your costomized \a mginit program should call
* this function before calling any other function.
*
* Note that the default layer created by the server called
* "mginit" (NAME_DEF_LAYER).
*
* \param nr_globals The number of the global z-order nodes. All z-order nodes
* created by mginit are global ones.
* \param def_nr_topmosts The maximal number of the topmost z-order nodes in
* the default layer. It is also the default number of topmost
* z-order nodes of a new layer.
* \param def_nr_normals The maximal number of normal global z-order nodes in
* the new layer. It is also the default number of normal
* z-order nodes of a new layer.
*
* \return TRUE on success, otherwise FALSE.
*
* \note Server-only function, i.e. \em only can be called by \a mginit.
*/
MG_EXPORT BOOL GUIAPI ServerStartup (int nr_globals,
int def_nr_topmosts, int def_nr_normals);
/**
* \fn MG_Layer* GUIAPI ServerCreateLayer (const char* layer_name,\
int max_nr_topmosts, int max_nr_normals)
* \brief Create a new layer from the server.
*
* This function creates a new layer named by \a layer_name.
* You should specify the maximal number of topmost frame
* objects (max_nr_topmosts) and the maximal number of normal frame
* objects (max_nr_normals) in the new layer. Passing zero to
* max_nr_topmosts and max_nr_normals will use the default values,
* and the default values are specified by ServerStartup.
*
* Note that the server will create a default layer named "mginit".
*
* \param layer_name The name of the layer. If there is already a layer
* named \a layer_name, the function will return the pointer to the layer.
* \param max_nr_topmosts The maximal number of topmost z-order nodes in
* the new layer.
* \param max_nr_normals The maximal number of normal z-order nodes in
* the new layer.
*
* \return The handle to the layer on success, NULL on error.
*
* \note Only call this function in the server of MiniGUI-Processes.
*
* \sa ServerDeleteLayer, ServerStartup
*/
MG_EXPORT MG_Layer* GUIAPI ServerCreateLayer (const char* layer_name,
int max_nr_topmosts, int max_nr_normals);
/**
* \fn BOOL GUIAPI ServerSetTopmostLayer (MG_Layer* layer)
* \brief Sets topmost layer from the server.
*
* This functions sets the specified layer \a layer to be the topmost layer.
*
* \param layer The pointer to the layer.
*
* \return TRUE on success, otherwise FALSE.
*
* \note Server-only function.
*
* \sa SetTopmostClient, SetTopmostLayer
*/
MG_EXPORT BOOL GUIAPI ServerSetTopmostLayer (MG_Layer* layer);
/**
* \fn BOOL GUIAPI ServerDeleteLayer (MG_Layer* layer)
* \brief Delete a layer from the server.
*
* This functions deletes the specified layer \a layer.
*
* \param layer The pointer to the layer.
*
* \return TRUE on success, otherwise FALSE.
*
* \note Server-only function.
*
* \sa ServerCreateLayer, JoinLayer, DeleteLayer
*/
MG_EXPORT BOOL GUIAPI ServerDeleteLayer (MG_Layer* layer);
/**
* \fn int GUIAPI ServerGetNextZNode (MG_Layer* layer, int idx_znode, \
* int* cli)
* \brief Get the next z-node in the specified layer from the server.
*
* This functions gets the next z-node in the specified layer \a layer from
* the server.
*
* \param layer The pointer to the layer, NULL for the current topmost layer.
* \param idx_znode The initial z-node. If the initial z-node index is
* less than or equal to zero, the function will return
* the index of the first z-node in the layer.
* \param cli The client identifier of the next znode will be returned
* through this pointer. NULL is okay.
*
* \return The index of the next z-node. Zero when the next z-node is
* the last one; < 0 when error;
*
* \note Server-only function. Note that this function will not return
* the z-node of the desktop, and the desktop always has the index
* of z-node zero.
*
* \sa ServerGetZNodeInfo
*/
MG_EXPORT int GUIAPI ServerGetNextZNode (MG_Layer* layer, int idx_znode,
int* cli);
#define ZNIT_DESKTOP 0x50000000
#define ZNIT_GLOBAL_MAINWIN 0x31000000
#define ZNIT_GLOBAL_TOOLWIN 0x32000000
#define ZNIT_GLOBAL_CONTROL 0x30000000
#define ZNIT_TOPMOST_MAINWIN 0x21000000
#define ZNIT_TOPMOST_TOOLWIN 0x22000000
#define ZNIT_TOPMOST_CONTROL 0x20000000
#define ZNIT_NORMAL_MAINWIN 0x11000000
#define ZNIT_NORMAL_TOOLWIN 0x12000000
#define ZNIT_NORMAL_CONTROL 0x10000000
#define ZNIT_NULL 0x00000000
#define ZNIF_VISIBLE 0x00000002
#define ZNIF_DISABLED 0x00000004
/** Z-node information structure */
typedef struct _ZNODEINFO
{
/**
* The type of the znode, can be one of the following values:
* - ZNIT_GLOBAL_MAINWIN\n
* a global main window.
* - ZNIT_GLOBAL_TOOLWIN\n
* a global tool window.
* - ZNIT_GLOBAL_CONTROL\n
* a global control with WS_EX_CTRLASMAINWIN style.
* - ZNIT_TOPMOST_MAINWIN\n
* a topmost main window.
* - ZNIT_TOPMOST_TOOLWIN\n
* a topmost tool window.
* - ZNIT_TOPMOST_CONTROL\n
* a topmost control with WS_EX_CTRLASMAINWIN style.
* - ZNIT_NORMAL_MAINWIN\n
* a normal main window.
* - ZNIT_NORMAL_TOOLWIN\n
* a normal tool window.
* - ZNIT_NORMAL_CONTROL\n
* a normal control with WS_EX_CTRLASMAINWIN style.
* - ZNIT_DESKTOP\n
* the desktop.
* - ZNIT_NULL\n
* a null and not-used z-node which does not refer to any window.
*/
DWORD type;
/**
* The flags of the znode, can be OR'd with the following values:
* - ZNIF_VISIBLE\n
* a visible window.
* - ZNIF_DISABLED\n
* a disabled window.
* Note that the flags are only applied to window.
*/
DWORD flags;
/** The pointer to the caption string of the znode if it is a window. */
const char* caption;
/** The rectangle of the znode in the screen. */
RECT rc;
/** Client id of the znode. */
int cli;
/** The window handle of the znode if it is a window. */
HWND hwnd;
/**
* The window handle of the znode's main window if it is a control
* with WS_EX_CTRLASMAINWIN style.
*/
HWND main_win;
} ZNODEINFO;
/**
* \fn BOOL GUIAPI ServerGetZNodeInfo (MG_Layer* layer, int idx_znode, \
* ZNODEINFO* znode_info)
* \brief Get the z-node information in the specified layer from the server.
*
* This functions gets the z-node information in the specified layer \a layer
* from the server.
*
* \param layer The pointer to the layer, NULL for the current topmost layer.
* \param idx_znode The index of the znode.
* \param znode_info The information of the requested znode will be returned
* through this structure.
*
* \return TRUE on success, otherwise FALSE.
*
* \note Server-only function.
*
* \sa ServerGetNextZNode, ZNODEINFO
*/
MG_EXPORT BOOL GUIAPI ServerGetZNodeInfo (MG_Layer* layer, int idx_znode,
ZNODEINFO* znode_info);
/**
* \fn BOOL GUIAPI ServerDoZNodeOperation (MG_Layer* layer, int idx_znode, \
* int op_code, void* op_data, BOOL notify)
* \brief Does an operation on the z-node in the specified layer
* from the server.
*
* This functions does an operation upon the z-node in the specified
* layer \a layer from the server.
*
* \param layer The pointer to the layer, NULL for the current topmost layer.
* \param idx_znode The index of the znode.
* \param op_code The code of the operation, can be one of the following
* values:
* - ZNOP_MOVE2TOP\n
* Move the znode to be the topmost one.
* - ZNOP_SETACTIVE\n
* Set the znode to be the active one.
* Note that the operation can be applied only for a main window.
* \param op_data The data of the operation, used to pass the data need by
* the operation. For example, if the operation is moving the z-node,
* \a op_data will be a pointer to a RECT structure, which contains
* the new position and size of the znode. Not used currently, reserved
* for future use.
* \param notify Whether to notify the client about the change of the znode.
*
* \return TRUE on success, otherwise FALSE.
*
* \note Server-only function, and the operation can be applied only for
* a main window.
*
* \sa ServerGetZNodeInfo
*/
MG_EXPORT BOOL GUIAPI ServerDoZNodeOperation (MG_Layer* layer, int idx_znode,
int op_code, void* op_data, BOOL notify);
/**
* \fn int GUIAPI GetClientByPID (int pid)
* \brief Returns the client identifier from PID of a client.
*
* This function gets the identifier of the sepcified client from the PID of it.
*