Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members  

/home/micah/picogui/pg1/client/c/include/picogui/client_c.h

Go to the documentation of this file.
00001 /* $Id: client_c.h 3806 2003-05-04 06:11:21Z micah $
00002  *
00003  * picogui/client_c.h - The PicoGUI API provided by the C client lib
00004  *
00005  * PicoGUI small and efficient client/server GUI
00006  * Copyright (C) 2000-2003 Micah Dowty <micahjd@users.sourceforge.net>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  * 
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021  * 
00022  * Contributors: 
00023  * 
00024  *  Philippe Ney <philippe.ney@smartdata.ch>
00025  * 
00026  * 
00027  */
00028 
00029 #ifndef _H_PG_CLI_C
00030 #define _H_PG_CLI_C
00031 
00032 #include <stdio.h>   /* For NULL and FILE */
00033 #ifdef __NetBSD__  
00034 #include <sys/types.h>
00035 #include <sys/time.h>
00036 #include <unistd.h>
00037 #endif
00038 
00039 #ifdef __linux__
00040 #include <sys/types.h>
00041 #include <sys/time.h>
00042 #include <unistd.h>
00043 #endif
00044 
00067 /******************** Client-specific constants and data types */
00068 
00094 struct pgEvent {
00095    s16 type;      
00096    pghandle from;   
00097    void *extra;     
00098    
00100    union {
00101       
00103       u32 param;
00104       
00106       struct {
00107          s16 w;
00108          s16 h;
00109       } size;
00110 
00112       struct {
00113          s16 mods;  
00114 
00118          s16 key;
00119       } kbd;
00120       
00122       struct {
00123          s16 x,y;
00124          s16 btn;    
00125          s16 chbtn;  
00126       } pntr;
00127       
00129       struct {
00130          u32 size;
00133          char *pointer; 
00134 
00136          union pg_client_trigger *trigger;
00137       } data;
00138       
00139    } e;
00140 };
00141 
00143 #define PGBIND_ANY      -1
00144 
00146 #define PGFONT_ANY      0
00147 
00171 typedef u32 pgcolor;
00172 
00193 #define PGDEFAULT       0
00194 
00196 #define pgFraction(n,d) (((n)<<8)|(d))
00197 
00204 typedef int (*pgevthandler)(struct pgEvent *evt);
00206 typedef void (*pgidlehandler)(void);
00207 #ifdef FD_SET
00208 
00209 typedef int (*pgselecthandler)(int n, fd_set *readfds, fd_set *writefds,
00210                                fd_set *exceptfds, struct timeval *timeout);
00211 typedef void (*pgselectbh)(int result, fd_set *readfds, fd_set *writefds,
00212                            fd_set *exceptfds);
00213 #endif
00214 
00215 typedef int (*pgfilter)(const char *string,const char *pattern);
00216 
00217 #define PG_FILE_SAVEBTN    (1<<0)  
00218 #define PG_FILE_MUSTEXIST  (1<<1)  
00219 #define PG_FILE_MUSTWRITE  (1<<2)  
00220 #define PG_FILE_MUSTREAD   (1<<3)  
00221 #define PG_FILE_SHOWDOT    (1<<4)  
00222 #define PG_FILE_SHOWHIDDEN (1<<5)  
00223 #define PG_FILE_SHOWBAK    (1<<6)  
00224 #define PG_FILE_SHOWDEV    (1<<7)  
00225 #define PG_FILE_FIELD      (1<<8)  
00226 
00227 
00228 #define PG_FILEOPEN     PG_FILE_MUSTREAD
00229 
00230 #define PG_FILESAVE    (PG_FILE_SAVEBTN | PG_FILE_FIELD)
00231 
00232 /* Constants for the message dialog box flags */
00233 #define PG_MSGBTN_OK        0x0001
00234 #define PG_MSGBTN_CANCEL    0x0002
00235 #define PG_MSGBTN_YES       0x0004
00236 #define PG_MSGBTN_NO        0x0008
00237 #define PG_MSGICON_ERROR    0x0010
00238 #define PG_MSGICON_MESSAGE  0x0020
00239 #define PG_MSGICON_QUESTION 0x0040
00240 #define PG_MSGICON_WARNING  0x0080
00241 
00242 #define PG_MSGBTNMASK       (PG_MSGBTN_OK|PG_MSGBTN_CANCEL|\
00243                              PG_MSGBTN_YES|PG_MSGBTN_NO)
00244 #define PG_MSGICONMASK      (PG_MSGICON_ERROR|PG_MSGICON_MESSAGE|\
00245                              PG_MSGICON_QUESTION|PG_MSGICON_WARNING)
00246 
00257 struct pgmemdata {
00258   void *pointer;       
00259   u32 size;  
00260   int flags;           
00261 };
00262 #define PGMEMDAT_NEED_FREE    0x0001   
00263 #define PGMEMDAT_NEED_UNMAP   0x0002   
00264 
00265 
00266 
00267 /******************** Administration */
00268 
00305 void pgInit(int argc, char **argv);
00306 
00323 void pgSetErrorHandler(void (*handler)(u16 errortype,
00324                                        const char *msg));
00325 
00333 pghandle pgLoadDriver(const char *name);
00334 
00342 const char *pgErrortypeString(u16 errortype);
00343 
00362 pgidlehandler pgSetIdle(s32 t, pgidlehandler handler); 
00363 
00375 void pgFlushRequests(void);
00376 
00392 void pgUpdate(void);
00393 
00408 void pgSubUpdate(pghandle widget);
00409 
00428 void pgBind(pghandle widgetkey,s16 eventkey,
00429             pgevthandler handler,void *extra);
00430 
00431 #ifdef FD_SET
00432 
00455 void pgCustomizeSelect(pgselecthandler handler, pgselectbh bottomhalf);
00456 #endif
00457 
00468 void pgRegisterOwner(int resource);
00469 
00480 void pgUnregisterOwner(int resource);
00481 
00508 void pgSetVideoMode(u16 xres,u16 yres,
00509                     u16 bpp,u16 flagmode,
00510                     u32 flags);
00511 
00527 struct pgmodeinfo *pgGetVideoMode(void);
00528 
00538 void pgDriverMessage(u32 message, u32 param);
00539 
00549 void pgAppMessage(pghandle dest, struct pgmemdata data);
00550 
00574 void * pgSyncAppMessage (pghandle dest, struct pgmemdata data);
00575 
00594 pghandle pgEvalRequest(s16 reqtype, void *data, u32 datasize);
00595 
00607 void pgSetInactivity(u32 time);
00608 
00619 u32 pgGetInactivity(void);
00620 
00626 pghandle pgGetServerRes(u32 id);
00627 
00629 
00630 /******************** Objects */
00631 
00648 void pgDelete(pghandle object);
00649 
00662 pghandle pgDup(pghandle object);
00663 
00685 void pgChangeContext(pghandle object, s16 delta);
00686 
00688 void pgFocus(pghandle widget);
00689 
00718 pghandle pgRegisterApp(s16 type,const char *name, ...);
00719 
00736 pghandle pgNewWidget(s16 type,s16 rship,
00737                      pghandle parent);
00738 
00750 pghandle pgCreateWidget(s16 type);
00751 
00765 void pgAttachWidget(pghandle parent, s16 rship, pghandle widget);
00766 
00782 pghandle pgTraverseWidget(pghandle widget, int direction, int count);
00783 
00797 pghandle pgNewPopup(int width,int height);
00798 
00805 pghandle pgNewCursor(void);
00806 
00818 pghandle pgNewInFilter(pghandle insert_after, u32 accept_trigs, u32 absorb_trigs);
00819 
00827 void pgInFilterSend(union pg_client_trigger *trig);
00828 
00846 pghandle pgNewPopupAt(int x,int y,int width,int height);
00847 
00865 void pgSetWidget(pghandle widget, ...);
00866 
00877 s32 pgGetWidget(pghandle widget,s16 property);
00878 
00887 pghandle pgNewBitmap(struct pgmemdata obj);
00888 
00898 pghandle pgCreateBitmap(s16 width, s16 height);
00899 
00911 struct pgshmbitmap *pgMakeSHMBitmap(pghandle bitmap);
00912 
00921 pghandle pgNewString(const char *str);
00922 
00931 pghandle pgNewArray(const s32* dat, u16 size);  
00932  
00944 char *pgGetString(pghandle string);
00945 
00964 void pgReplaceText(pghandle widget,const char *str);
00965 
00973 void pgReplaceTextFmt(pghandle widget,const char *fmt, ...);
00974 
00995 pghandle pgNewFont(const char *name,s16 size,u32 style);
00996 
01035 int pgGetFontStyle(s16 index, char *name, u16 *size,
01036                    u16 *fontrep, u32 *flags);
01037 
01070 void pgSizeText(int *w,int *h,pghandle font,pghandle text);
01071 
01081 void pgSizeBitmap(int *w, int *h, pghandle bitmap);
01082 
01094 pghandle pgLoadTheme(struct pgmemdata obj);
01095 
01107 pghandle pgLoadWidgetTemplate(struct pgmemdata obj);
01108 
01122 int pgFindThemeObject(const char *key);
01123 
01136 pghandle pgDataString(struct pgmemdata obj);
01137 
01148 u32 pgThemeLookup(s16 object, s16 property);
01149 
01168 void pgSetPayload(pghandle object,u32 payload);
01169 
01180 u32 pgGetPayload(pghandle object);
01181 
01194 void pgWriteData(pghandle widget,struct pgmemdata data);
01195 
01209 void pgWriteCmd(pghandle widget,s32 command,s16 numparams, ...);
01210 
01221 void pgRender(pghandle bitmap,s16 groptype, ...);
01222 
01237 pghandle pgFindWidget(const char *key);
01238 
01240 
01241 /******************** Data loading */
01242 
01266 struct pgmemdata pgFromMemory(void *data,u32 length);
01267 
01280 struct pgmemdata pgFromTempMemory(void *data,u32 length);
01281 
01282 
01293 struct pgmemdata pgFromFile(const char *file);
01294 
01308 struct pgmemdata pgFromStream(FILE *f, u32 length);
01309 
01310 /* TODO: Load from resource. Allow apps to package necessary bitmaps
01311    and things in a file, named after their binary but with a '.res'
01312    extension.
01313    The server will also be able to request reloading data from these
01314    resource files, for example to reload bitmaps when the bit depth
01315    changes.
01316 
01317    This is just an idea, and I'll implement it later...
01318    This whole pgmemdata business is just my attempt to leave enough
01319    hooks to make this work.
01320 */
01321 
01323 
01324 /******************** Program flow */
01325 
01350 void pgEventLoop(void);
01351 
01360 void pgExitEventLoop(void);
01361 
01397 struct pgEvent *pgGetEvent(void);
01398 
01418 int pgCheckEvent(void);
01419 
01433 void pgDispatchEvent(struct pgEvent *evt);
01434 
01448 void pgEventPoll(void);
01449 
01475 int pgEnterContext(void);
01476 
01486 void pgLeaveContext(void);
01487 
01500 void pgDeleteHandleContext(int id);
01501 
01507 void pgSetContext(int id);
01508 
01509 
01515 int pgGetContext(void);
01516 
01518 
01520 
01521 #endif /* __H_PG_CLI_C */
01522 /* The End */

Generated on Fri May 23 03:39:44 2003 for PicoGUI by doxygen1.3-rc3