Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 6455 → Rev 6456

/contrib/C_Layer/EXAMPLE/libguic_kolibri/make_boardmsg
0,0 → 1,37
NAME=boardmsg
CC = kos32-gcc
LD = kos32-ld
FASM=fasm
 
SDK_DIR:= $(abspath ../../sdk)
 
LDFLAGS = -static -S -nostdlib -T $(SDK_DIR)/sources/newlib/app.lds \
--image-base 0 -lgcc /home/autobuild/tools/win32/lib/libdll.a\
/home/autobuild/tools/win32/lib/libc.dll.a\
/home/autobuild/tools/win32/lib/libapp.a
 
CFLAGS = -g -U_Win32 -U_WIN32 -U__MINGW32__
 
INCLUDES= -I $(SDK_DIR)/sources/newlib/libc/include
LIBPATH:= -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib
 
 
SOURCES = loadboxlib.asm boardmsg.c
 
OBJECTS = $(patsubst %.asm, %.obj, $(patsubst %.c, %.o, $(SOURCES)))
 
all:$(NAME)
 
$(NAME): $(OBJECTS) Makefile
$(LD) $(LIBPATH) -o $@ $(OBJECTS) $(LDFLAGS)
# -ldll -lapp -lc.dll -lgcc -Map $(NAME).map
kos32-objcopy $@ -O binary
 
%.o : %.c Makefile
$(CC) -c $(INCLUDES) $(CFLAGS) -o $@ $<
 
%.obj : %.asm Makefile
$(FASM) $< $@
 
clean:
-rm -f *.o *.obj
/contrib/C_Layer/EXAMPLE/libguic_kolibri/make_boardmsg.sh
0,0 → 1,11
#Please set up kolibrios sources here : /home/<username>/kolibrios
 
kos32-gcc -c -I${HOME}/kolibrios/contrib/sdk/sources/newlib/libc/include -g -U_Win32 -U_WIN32 -U__MINGW32__ boardmsg.c -o boardmsg.o
 
fasm loadboxlib.asm loadboxlib.obj
 
kos32-ld *.o *.obj -T${HOME}/kolibrios/contrib/sdk/sources/newlib/libc/app.lds -nostdlib -static --image-base 0 -lgcc -L/home/autobuild/tools/win32/mingw32/lib /home/autobuild/tools/win32/lib/libdll.a /home/autobuild/tools/win32/lib/libapp.a /home/autobuild/tools/win32/lib/libc.dll.a -static -o boardxmsg -Map=boardxmsg.map
 
objcopy -O binary boardxmsg
 
echo "If everything went well, boardxmsg should be your binary!"
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c
0,0 → 1,74
#include "kolibri_gui.h"
 
int main()
{
/* Load all libraries, initialize global tables like system color table and
operations table. kolibri_gui_init() will EXIT with mcall -1 if it fails
to do it's job. This is all you need to call and all libraries and GUI
elements can be used after a successful call to this function
*/
kolibri_gui_init();
/* Set gui_event to REDRAW so that window is drawn in first iteration */
unsigned int gui_event = KOLIBRI_EVENT_REDRAW;
oskey_t key;
 
struct kolibri_window *main_window = kolibri_new_window(50, 50, 400, 100, "BoardMsg: OpenDialog 0.12");
struct check_box *checkbox = kolibri_new_check_box(20, 40, 12, 12, "Append BOARDMSG to entered message.");
struct edit_box *textbox = kolibri_new_edit_box(20, 55, 40);
struct kolibri_button *button = kolibri_new_button(310, 55, 24, 14, 0x21, kolibri_color_table.color_work_button);
 
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
kolibri_window_add_element(main_window, KOLIBRI_CHECK_BOX, checkbox);
kolibri_window_add_element(main_window, KOLIBRI_BUTTON, button);
 
extern volatile unsigned press_key;
 
do /* Start of main activity loop */
{
if(gui_event == KOLIBRI_EVENT_REDRAW)
{
kolibri_handle_event_redraw(main_window);
}
else if(gui_event == KOLIBRI_EVENT_KEY)
{
key = get_key();
switch (key.code)
{
case 13:
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
debug_board_write_str("BOARDMSG: ");
 
debug_board_write_str(textbox->text);
debug_board_write_str("\n");
break;
}
press_key = key.val;
 
kolibri_handle_event_key(main_window);
}
else if(gui_event == KOLIBRI_EVENT_BUTTON)
{
unsigned int pressed_button = kolibri_button_get_identifier();
switch (pressed_button)
{
case 0x21:
if(checkbox -> flags & CHECKBOX_IS_SET) /* Append BoardMsg checkbox is set */
debug_board_write_str("BOARDMSG: ");
debug_board_write_str(textbox->text);
debug_board_write_str("\n");
break;
case 0x00000001:
kolibri_exit();
}
}
else if(gui_event == KOLIBRI_EVENT_MOUSE)
{
kolibri_handle_event_mouse(main_window);
}
 
} while(gui_event = get_os_event()); /* End of main activity loop */
 
/* kolibri_quit(); */
 
return 0;
}
/contrib/C_Layer/EXAMPLE/libguic_kolibri/README
0,0 → 1,57
Welcome to the README for GUI LIBRARY FOR KOLIBRIOS IN C.
 
This library tries to use the wealth of code already written for KolibriOS in assembly.
 
The files currently available are :
 
0) loadboxlib.asm :
This is a wrapper created so that C can call assembly functions.
Assemble this to loadboxlib.obj and use with cross compiler linker the .obj file
to create correct executables which use this GUI library.
 
1) kolibri_boxlib.h :
This file contains functions for initializing boxlib from C. This is used by the
function kolibri_gui_init() in kolibri_gui.h
 
2)kolibri_button.h:
This file contains functions to create and use kolibriOS buttons.
3)kolibri_checkbox.h:
This file contains functions to create and use Check boxes from BOXLIB.
 
4)kolibri_editbox.h:
This file contains functions for creating text boxes (edit boxes from Boxlib)
 
5)kolibri_colors.h:
This file has functions to initialize global kolibri color table
so that the GUI can use colors from the System theme.
 
6)kolibri_gui_elements.h:
This defines generic containers for GUI elements so that ANY element
(buttons, editboxes, checkboxes, etc) can have their redraw/mouse/key event
functions. This helps create a list of all the elements and draw them together.
 
ALL FILES ABOVE ARE INCLUDED IN KOLIBRI_GUI.H SO THEY DO NOT NEED TO BE INCLUDED IN THE CODE YOU WRITE.
 
7)kolibri_gui.h:
This is the master file we use. This baby contains everything you need (all GUI elements are included).
This also contains event handlers that can be simply called from the main application loop.
This will make your life easy on KolibriOS ;) USE IT!
The function kolibri_gui_init() needs to be called from all applications using this library.
 
8)boardmsg.c:
Sample application written to show off the library.
This application sends messages to Debug Board on KolibriOS.
Enter a msg and press the button with the mouse to send messages!
This is the first of many applications to come with this library.
 
---
NOTES
 
Refer to boardmsg.c to see how the library is used.
Use instructions from here to build files in C : http://board.kolibrios.org/viewtopic.php?f=24&t=3117
 
---
Suggestions, Feedback and Ideas are welcome and appreciated!
Please contact : ashmew2 (on board.kolibrios.org) or ashmew2 at gmail dot com for discussing,
Or post on : http://board.kolibrios.org/viewtopic.php?f=24&t=3117#p62536 so that everyone can participate!
/contrib/C_Layer/EXAMPLE/libguic_kolibri/quirks
0,0 → 1,6
USE .section '.init' code for writing loader asm C mixed code (in FASM)
Got to know this by checking out the linker script on KGCC. -Xlinker -verbose .
Inside the .text section that is being assembled, the .init is placed at the very beginning.
Let the macros expand, GCC simply places .init on the top and therefore it works.
 
Inexplicable errors if .init is not used and .text or .flat is used... Took 4 hours to figure out.