The following functions are not part of the CGUI library nor Allegro. They are for IKON programs only!
For a full idea of what is exported to applications from CGUI or ALLEGRO see the ikon.h header file.
Some of the ALLEGRO routines have been exported for use by your application. This was done
because we haven't found an easy way to link allegro into your application.
HOME
CGUI API
ALLEGRO FUNCTIONS
-----------------------------------------------------------
Sample Application
Sample DLL Source
IKON API |
All these functions are declared in the ikon.h file. All of the CGUI functions are exported and declared in this header file as well.
int Load_DLL(char *filename)
Loads a DLL (dynamic link library) and provides a handle to it. Returns 0 on error.
A DLL is simplyan application with a few function pointers. When Ikon launches the DLL program the main routine of the file is blank because there is nothing that needs to be executed.
An example of a DLL is here.
void *Get_DLL_Function(int handle,int function)
Returns a pointer to the specified function.
eg.
----> in the DLL int something(int x,int y); ----> Your Program int temp; int (*myfunc)(int x,int y); myfunc=Get_DLL_Function(dllhandle,1); temp=myfunc(5,5);
void Unload_DLL(int handle)
Closes and unloads a DLL.
void exitapp(int pid)
Exits your application. Pass your PID(Program ID) to it.
int RunApp(char *appfilename)
Launches another application. Returns a PID.
BITMAP *load_jpg(AL_CONST char *filename, RGB *palette);
Loads a jpg. Provided by jpgalleg library.
int save_jpg(AL_CONST char *filename, BITMAP *image, AL_CONST RGB *palette);
Saves a jpg image.
void SystemMessage(char *message);
Opens a system message window and displays message.
void RefreshDesktop(void);
Refreshes the screen.
char *GetPath(int pid);
returns the path where your application was launched from
eg. c:\ikon\programs\test.app would return c:\ikon
*trailing \ is not returned
int AddCloseButton(id windowid,void (*Callback));
Registers the close button in top corner, returns an ID. By default all windows show the close button in the
top corner, but it is not active unless this function is called.
void RegisterTaskButton(int windowid,int pid,char *caption);
Shows a button for your app on the taskbar. Call this AFTER your window has been created and displayed!
Allegro Functions |
Since you can't link your application against Allegro, you can use these functions that are exported from the kernel. They are all declared in the IKON.H file.
BITMAP *getscreen(void);
void line(BITMAP *bmp,int x,int y,int x2,int y2,int col);
void getmouse(int *mousex,int *mousey,int *mouseb);
void rectfill(BITMAP *bmp,int x,int y,int x2,int y2,int color);
void rect(BITMAP *bmp,int x,int y,int x2,int y2,int color);
void circle(BITMAP *bmp,int x,int y,int radius,int color);
void circlefill(BITMAP *bmp,int x,int y,int radius,int color);
int makecol(int r,int g,int b);
int getpixel(BITMAP *bmp,int x,int y);
void floodfill(BITMAP *bmp,int x,int y,int color);
BITMAP *load_bitmap(const char *filename,RGB *pal);
void save_bitmap(const char *filename,BITMAP *bmp);
void blit(BITMAP *source,BITMAP *dest,int source_x,int source_y,int dest_x,int dest_y,int width,int height);
void destroy_bitmap(BITMAP *bmp);
void putpixel(BITMAP *bmp,int x,int y,int color);
BITMAP *create_bitmap(int width,int height);
void textout(BITMAP *bmp,FONT *f,const char *s,int x,int y,int color);
void textout_centre(BITMAP *bmp,FONT *f,const char *s,int x,int y,int color);
void draw_sprite(BITMAP *bmp,BITMAP *sprite,int x,int y);
void masked_blit(BITMAP *source,BITMAP *dest,int source_x,int source_y,int dest_x,int dest_y,int width,int height);
void set_clip(BITMAP *bitmap,int x1,int y1,int x2,int y2);
void textprintf(BITMAP *bmp,const FONT *f,int x,int y,int color,const char *fmt,...);
void textprintf_centre(BITMAP *bmp,const FONT *f,int x,int y,int color,const char *fmt,...);
BITMAP *load_jpg(AL_CONST char *filename,RGB *pallette);
int save_jpg(AL_CONST char *filename,BITMAP *image, RGB *palette);
void scare_mouse();
void unscare_mouse();
BITMAP *create_sub_bitmap(BITMAP *parent,int x,int y,int w,int h);
void triangle(BITMAP *bmp,int x1,int y1,int x2,int y2,int x2,int y2,int color);
void rotate_sprite(BITMAP *bmp,BITMAP *sprite,int x,int y,fixed angle);
void stretch_sprite(BITMAP *bmp,BITMAP *sprite,int x,int y,int w,int h);
void stretch_blit(BITMAP *src,BITMAP *dest,int src_x,int src_y,int src_w,int src_h,int dest_x,int dest_y,int dest_w,int dest_h);
SAMPLE APPLICATION SOURCE |
// Sample Ikon Application #include "ikon.h" /* ikon.h should ALWAYS be first included file */ void mod_init(DCM *dcm); void *var_router(DCM *dcm, int var); void *proc_router(DCM *dcm, int proc); static void shutdown(); static void appmain(); int pid; /* The pid Ikon sends us */ int ourwinid; /* the id of our window */ void mod_init(DCM *dcm) { dcm->dcm_var=&var_router; dcm->dcm_proc=&proc_router; } void *var_router(DCM *dcm, int var) { pid=var; return(0); } void *proc_router(DCM *dcm, int proc) { if (proc==0) { appinit(dcm); return(0); } return(0); } static void appmain() { //*********[ Your main program routine ]**************** ourwinid=MkDialogue(280,100,"Test Application",W_FLOATING); AddCloseButton(ourwinid,shutdown); //activates close button in top right corner AddButton(1,60,"Cancel",shutdown,0); DisplayWin(); SetFocusOn(ourwinid); //set focus on your main window to bring it to top RegisterTaskButton(ourwinid,pid,"Test"); //activates a taskbar button for your app (CALL THIS LAST) }; static void shutdown() { exitapp(pid); };
SAMPLE DLL SOURCE |
//Ikon Dynamic Link Library Template #include "..\dcm\dcm.h" #include "allegro.h" #include "..\include\ikon.h" /* ikon.h should ALWAYS be after dcm.h */ void mod_init(DCM *dcm); void *var_router(DCM *dcm, int var); void *proc_router(DCM *dcm, int proc); static void appmain(); int function1(void); void mod_init(DCM *dcm) { dcm->dcm_var=&var_router; dcm->dcm_proc=&proc_router; } void *var_router(DCM *dcm, int function) { if (function==1) { return &function1; //this is here so we can return a pointer to function } return(0); } void *proc_router(DCM *dcm, int proc) { if (proc==0) { appinit(dcm); //required to be here for initialization of functions return(0); } return(0); } static void appmain() { //this remains empty as it is a DLL not an application }; int function1(void) { int ourwinid; ourwinid=MkDialogue(280,100,"DLL Function 1",W_FLOATING); DisplayWin(); SetFocusOn(ourwinid); //set focus on the window return ourwinid; };