Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6588 → Rev 6589

/contrib/C_Layer/EXAMPLE/libguic_kolibri/boardmsg.c
38,7 → 38,7
edit_box *textbox = kolibri_new_edit_box(20, 30, 40, &editbox_interlock);
edit_box *textbox2 = kolibri_new_edit_box(20, 50, 30, &editbox_interlock);
kolibri_button *button = kolibri_new_button(310, 30, 24, 14, 0x21, kolibri_color_table.color_work_button);
frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(5, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area);
frame *fr = kolibri_new_frame(X_Y(12, 350), X_Y(5, 70), 0x00FCFCFC, 0x00DCDCDC, "Frame Title", 0, kolibri_color_table.color_work_text, kolibri_color_table.color_work_area, 0);
 
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox);
kolibri_window_add_element(main_window, KOLIBRI_EDIT_BOX, textbox2);
/contrib/C_Layer/EXAMPLE/libguic_kolibri/dbutton_files.c
41,7 → 41,6
kolibri_proclib_init(); // opensave && color dialogs
kolibri_libimg_init(); // png handling
 
 
int gui_event = KOLIBRI_EVENT_REDRAW;
uint32_t pressed_button = 0;
// uint32_t mouse_button;
110,13 → 109,6
brows.folder_data = read_folderdata("/rd/1");
brows.select_panel_counter = 1; // if want to show selection
 
kolibri_handle_event_redraw(main_window);
brows.all_redraw = 1;
(*filebrowse_draw)(&brows);
 
 
//??? set_os_keyb_mode(1); // needed for keyboard use in menu
 
int extended_key = 0, act = 0;
do /* Start of main activity loop */
{
123,8 → 115,6
switch(gui_event)
{
case KOLIBRI_EVENT_REDRAW:
//???? start red
//brows.marked_file = 1;
control_minimal_window_size(430, 500);
brows.all_redraw = 1;
kolibri_handle_event_redraw(main_window);
/contrib/C_Layer/EXAMPLE/libguic_kolibri/editor_tree_msgbox.c
0,0 → 1,132
 
/*
KolibriGUI demobox
-Editor (multiline edit)
-TreeView
-MsgBox Dialog
 
Free for all
 
Initially written by Siemargl, 2016
 
 
ToDo
*/
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "kos32sys.h"
#include "kolibri_gui.h"
#include "kolibri_libimg.h"
#include "kolibri_msgbox.h"
 
char temp_path[4096];
 
char* load_file_inmem(char* fname, int32_t* read_sz); // see below
 
int main(int argc, char **argv)
{
/* 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();
kolibri_proclib_init(); // opensave && color dialogs
kolibri_libimg_init(); // png handling
 
int gui_event = KOLIBRI_EVENT_REDRAW;
uint32_t pressed_button = 0;
// uint32_t mouse_button;
// pos_t mouse_pos;
oskey_t keypress;
 
// load image for buttons
const int icon_rgb_size = 16*16*3; // every icons 16x16 24bpp
char *image_data_rgb,
*image_data,
*filedata;
// make full path + argv
strcpy(temp_path, argv[0]);
char *pc = strrchr(temp_path, '/'); // this fails if has params with '/' within. use argv[0] instead
if (pc) pc[1] = 0;
strcat(temp_path, "reload_16x16_8b.png");
// debug_board_write_str(temp_path);
 
int32_t read_bytes;
filedata = load_file_inmem(temp_path, &read_bytes);
image_data_rgb = malloc(icon_rgb_size * 3); // we know size
// îïðåäåëÿåì âèä èçîáðàæåíèÿ è ïåðåâîäèì åãî âî âðåìåííûé áóôåð image_data
image_data = (*img_decode)(filedata, read_bytes, 0);
// ïðåîáðàçóåì èçîáðàæåíèå ê ôîðìàòó rgb
(*img_to_rgb2)(image_data, image_data_rgb);
// óäàëÿåì âðåìåííûé áóôåð image_data
(*img_destroy)(image_data);
free(filedata);
 
// creating GUI using library functions
kolibri_window *main_window = kolibri_new_window(50, 40, 470, 500, "Editor, TreeView and MsgBox demo");
 
editor *ed;
editor *ed_lock;
 
gui_add_editor(main_window, ed = kolibri_new_editor(X_Y(10, 440), X_Y(20, 150), 0x1001, 2048, &ed_lock));
ed_lock = ed;
 
 
filedata = load_file_inmem("/rd/1/File managers/z_icons.png", &read_bytes);
image_data_rgb = malloc(icon_rgb_size * 20); // we know size
// îïðåäåëÿåì âèä èçîáðàæåíèÿ è ïåðåâîäèì åãî âî âðåìåííûé áóôåð image_data
image_data = (*img_decode)(filedata, read_bytes, 0);
// ïðåîáðàçóåì èçîáðàæåíèå ê ôîðìàòó rgb
(*img_to_rgb2)(image_data, image_data_rgb);
// óäàëÿåì âðåìåííûé áóôåð image_data
(*img_destroy)(image_data);
free(filedata);
 
filedata = load_file_inmem("/rd/1/File managers/icons.ini", &read_bytes);
 
 
int extended_key = 0, act = 0;
msgbox* box = kolibri_new_msgbox("Exit", "Are\rYOU\rSure?", 3, "YES", "Absolute", "Not Yet", NULL); // default NOT
 
do /* Start of main activity loop */
{
switch(gui_event)
{
case KOLIBRI_EVENT_REDRAW:
if (box->retval == 1 || box->retval == 2) return 0; // msgbox closes
 
kolibri_handle_event_redraw(main_window);
break;
case KOLIBRI_EVENT_NONE:
break;
case KOLIBRI_EVENT_KEY:
if (ed_lock == ed)
editor_key(ed);
else
kolibri_handle_event_key(main_window);
break;
case KOLIBRI_EVENT_BUTTON:
pressed_button = get_os_button();
switch (pressed_button)
{
case BTN_QUIT:
if (box->retval == 3 || box->retval == 0) // not started or cancelled, analyze when redraw after closing msgbox
kolibri_start_msgbox(box, NULL);
return 0;
break;
}
break;
case KOLIBRI_EVENT_MOUSE:
kolibri_handle_event_mouse(main_window);
break;
}
 
gui_event = get_os_event();
} while(1) ; /* End of main activity loop */
 
return 0;
}