mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-16 14:42:44 +00:00
Remove all deprecated jinete and raster samples.
This commit is contained in:
parent
4fae085d60
commit
2e87a9013f
@ -1,90 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* widgets to use */
|
||||
JWidget manager, window, box, label, button;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
/* create main window */
|
||||
window = jwindow_new("Example 00");
|
||||
|
||||
/* create a vertical box to set label and button positions */
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
|
||||
/* create a simple centered label with "Hello World!" text */
|
||||
label = jlabel_new("Hello World!");
|
||||
label->set_align(JI_CENTER | JI_MIDDLE);
|
||||
|
||||
/* create a button to close the window */
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
/* a expansive widget can get more space that other ones */
|
||||
jwidget_expansive(label, true);
|
||||
|
||||
/* put the label and button in the box and that box in the window */
|
||||
jwidget_add_child(box, label);
|
||||
jwidget_add_child(box, button);
|
||||
jwidget_add_child(window, box);
|
||||
|
||||
/* show the window in the screen and leave it in the background (the
|
||||
manager will free it) */
|
||||
window->open_window_bg();
|
||||
|
||||
/* run windows */
|
||||
jmanager_run(manager);
|
||||
|
||||
/* Jinete finalization */
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,80 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, box2, label, button_ok, button_cancel;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init ();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
|
||||
/* create main window */
|
||||
window = jwindow_new ("Example 01");
|
||||
box1 = jbox_new (JI_VERTICAL);
|
||||
box2 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label = jlabel_new ("A simple window");
|
||||
button_ok = jbutton_new ("&OK");
|
||||
button_cancel = jbutton_new ("&Cancel");
|
||||
|
||||
label->set_align(JI_CENTER | JI_MIDDLE);
|
||||
jwidget_expansive (label, true);
|
||||
|
||||
jwidget_add_child (window, box1);
|
||||
jwidget_add_child (box1, label);
|
||||
jwidget_add_child (box1, box2);
|
||||
jwidget_add_child (box2, button_ok);
|
||||
jwidget_add_child (box2, button_cancel);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,82 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box, label1, label2, label3, label4;
|
||||
|
||||
allegro_init ();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
|
||||
window = jwindow_new ("Example 02");
|
||||
box = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
label1 = jlabel_new ("&Left Top");
|
||||
label2 = jlabel_new ("&Center Middle");
|
||||
label3 = jlabel_new ("&Right Bottom");
|
||||
label4 = jlabel_new ("&Disabled");
|
||||
|
||||
label1->set_align(JI_LEFT | JI_TOP);
|
||||
label2->set_align(JI_CENTER | JI_MIDDLE);
|
||||
label3->set_align(JI_RIGHT | JI_BOTTOM);
|
||||
label4->set_align(JI_CENTER | JI_BOTTOM);
|
||||
|
||||
jwidget_disable (label4);
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, label1);
|
||||
jwidget_add_child (box, label2);
|
||||
jwidget_add_child (box, label3);
|
||||
jwidget_add_child (box, label4);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,90 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box;
|
||||
JWidget slider1, slider2, slider3, slider4, slider5, button1;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new("Example 03");
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
slider1 = jslider_new(0, 1, 0);
|
||||
slider2 = jslider_new(0, 2, 0);
|
||||
slider3 = jslider_new(0, 10, 0);
|
||||
slider4 = jslider_new(0, 63, 1);
|
||||
slider5 = jslider_new(0, 255, 1);
|
||||
button1 = jbutton_new("&Close");
|
||||
|
||||
jwidget_set_min_size(slider1, 128, 0);
|
||||
jwidget_set_min_size(slider2, 128, 0);
|
||||
jwidget_set_min_size(slider3, 128, 0);
|
||||
jwidget_set_min_size(slider4, 128, 0);
|
||||
jwidget_set_min_size(slider5, 128, 0);
|
||||
|
||||
jwidget_expansive(slider1, true);
|
||||
jwidget_expansive(slider2, true);
|
||||
jwidget_expansive(slider3, true);
|
||||
jwidget_expansive(slider4, true);
|
||||
jwidget_expansive(slider5, true);
|
||||
|
||||
jwidget_add_child(window, box);
|
||||
jwidget_add_children(box,
|
||||
slider1, slider2, slider3,
|
||||
slider4, slider5, button1, NULL);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,91 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager;
|
||||
int ret;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
jmanager_refresh_screen();
|
||||
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
||||
|
||||
jalert("Normal==First Alert||&Ok");
|
||||
jalert ("Error"
|
||||
"==This is a long text line"
|
||||
"--"
|
||||
"<<Left text"
|
||||
"==Centre text"
|
||||
">>Right text"
|
||||
"||&Continue");
|
||||
|
||||
do {
|
||||
ret = jalert ("Warning"
|
||||
"<<Select some option:"
|
||||
"--"
|
||||
"<<Yes: first option"
|
||||
"<<No: second option"
|
||||
"<<Cancel: third option"
|
||||
"--"
|
||||
"||&Yes||&No||&Cancel");
|
||||
|
||||
} while (jalert ("Progress"
|
||||
"<<You select \"%s\""
|
||||
"<<Are you sure?"
|
||||
"||&Yeah||&Hmmm...",
|
||||
ret == 1 ? "Yes":
|
||||
ret == 2 ? "No":
|
||||
ret == 3 ? "Cancel": "Nothing") != 1);
|
||||
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN ();
|
@ -1,93 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window1, box1, box2, box3, box4, box5;
|
||||
JWidget label1, label2, entry1, entry2;
|
||||
JWidget button1, button2;
|
||||
|
||||
allegro_init ();
|
||||
set_color_depth (8);
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
|
||||
window1 = jwindow_new ("Example 06");
|
||||
box1 = jbox_new (JI_VERTICAL);
|
||||
box2 = jbox_new (JI_HORIZONTAL);
|
||||
box3 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box4 = jbox_new (JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box5 = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label1 = jlabel_new ("Entry1:");
|
||||
label2 = jlabel_new ("Entry2:");
|
||||
entry1 = jentry_new (8, "");
|
||||
entry2 = jentry_new (256, "%d+%d=%d", 4, 5, 4+5);
|
||||
button1 = jbutton_new ("&OK");
|
||||
button2 = jbutton_new ("&Cancel");
|
||||
|
||||
jwidget_expansive (box4, true);
|
||||
jwidget_expansive (box5, true);
|
||||
jwidget_magnetic (button1, true);
|
||||
|
||||
/* hierarchy */
|
||||
jwidget_add_child (window1, box1);
|
||||
jwidget_add_child (box1, box2);
|
||||
jwidget_add_child (box2, box3);
|
||||
jwidget_add_child (box3, label1);
|
||||
jwidget_add_child (box3, label2);
|
||||
jwidget_add_child (box2, box4);
|
||||
jwidget_add_child (box4, entry1);
|
||||
jwidget_add_child (box4, entry2);
|
||||
jwidget_add_child (box1, box5);
|
||||
jwidget_add_child (box5, button1);
|
||||
jwidget_add_child (box5, button2);
|
||||
|
||||
window1->open_window_bg();
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,76 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, box2, view1, view2, button;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new("Example 07");
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jpanel_new(JI_HORIZONTAL);
|
||||
view1 = jview_new();
|
||||
view2 = jview_new();
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
jwidget_expansive(view1, true);
|
||||
jwidget_expansive(view2, true);
|
||||
jwidget_expansive(box2, true);
|
||||
|
||||
jwidget_add_child(window, box1);
|
||||
jwidget_add_children(box1, box2, button, NULL);
|
||||
jwidget_add_children(box2, view1, view2, NULL);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN ();
|
@ -1,119 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
void do_text(const char *title, int align)
|
||||
{
|
||||
const char *LGPL_text =
|
||||
"This library is free software; you can redistribute it and/or\n"
|
||||
"modify it under the terms of the GNU Lesser General Public\n"
|
||||
"License as published by the Free Software Foundation; either\n"
|
||||
"version 2.1 of the License, or (at your option) any later version.\n"
|
||||
"\n"
|
||||
"This library is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
|
||||
"Lesser General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU Lesser General Public\n"
|
||||
"License along with this library; if not, write to the Free Software\n"
|
||||
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
|
||||
|
||||
JWidget window, box1, box2, box3, box4, label1, label2;
|
||||
JWidget view1, view2, text_box1, text_box2, button;
|
||||
|
||||
window = jwindow_new(title);
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
box3 = jbox_new(JI_VERTICAL);
|
||||
box4 = jbox_new(JI_VERTICAL);
|
||||
label1 = jlabel_new("With word-wrap");
|
||||
label2 = jlabel_new("Without word-wrap");
|
||||
view1 = jview_new();
|
||||
view2 = jview_new();
|
||||
text_box1 = jtextbox_new(LGPL_text, align | JI_WORDWRAP);
|
||||
text_box2 = jtextbox_new(LGPL_text, align | 0);
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
jview_attach(view1, text_box1);
|
||||
jview_attach(view2, text_box2);
|
||||
|
||||
jwidget_expansive(view1, true);
|
||||
jwidget_expansive(view2, true);
|
||||
jwidget_expansive(box2, true);
|
||||
|
||||
jwidget_set_min_size(view1, 64, 64);
|
||||
jwidget_set_min_size(view2, 64, 64);
|
||||
|
||||
jwidget_add_child(box3, label1);
|
||||
jwidget_add_child(box3, view1);
|
||||
jwidget_add_child(box4, label2);
|
||||
jwidget_add_child(box4, view2);
|
||||
jwidget_add_child(box2, box3);
|
||||
jwidget_add_child(box2, box4);
|
||||
jwidget_add_child(box1, box2);
|
||||
jwidget_add_child(box1, button);
|
||||
jwidget_add_child(window, box1);
|
||||
|
||||
window->open_window_bg();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
do_text("Right", JI_RIGHT);
|
||||
do_text("Center", JI_CENTER);
|
||||
do_text("Left", JI_LEFT);
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,207 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
JRect test1();
|
||||
void test2(JRect pos);
|
||||
void test3(JRect pos);
|
||||
void test4(JRect pos);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager;
|
||||
JRect pos;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
pos = test1();
|
||||
test2 (pos);
|
||||
test3 (pos);
|
||||
test4 (pos);
|
||||
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
JRect test1()
|
||||
{
|
||||
JWidget window, box, listbox, button;
|
||||
char buf[256];
|
||||
JRect pos;
|
||||
int c;
|
||||
|
||||
window = jwindow_new("Without Viewport");
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
listbox = jlistbox_new();
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
for (c=0; c<8; c++) {
|
||||
usprintf(buf, "Long item (%d)", c);
|
||||
jwidget_add_child (listbox, jlistitem_new (buf));
|
||||
}
|
||||
|
||||
jlistbox_select_index(listbox, 0);
|
||||
|
||||
jwidget_expansive(listbox, true);
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, listbox);
|
||||
jwidget_add_child (box, button);
|
||||
|
||||
window->center_window();
|
||||
pos = jwidget_get_rect(window);
|
||||
|
||||
window->open_window_fg();
|
||||
jwidget_free(window);
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
void test2(JRect pos)
|
||||
{
|
||||
JWidget window, box, view, listbox, button;
|
||||
char buf[256];
|
||||
int c;
|
||||
|
||||
window = jwindow_new("With Viewport");
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
view = jview_new();
|
||||
listbox = jlistbox_new();
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
for (c=0; c<8; c++) {
|
||||
usprintf(buf, "Long item (%d)", c);
|
||||
jwidget_add_child (listbox, jlistitem_new (buf));
|
||||
}
|
||||
|
||||
jlistbox_select_index(listbox, 0);
|
||||
|
||||
jview_attach(view, listbox);
|
||||
|
||||
jwidget_expansive(view, true);
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, view);
|
||||
jwidget_add_child (box, button);
|
||||
|
||||
window->remap_window();
|
||||
jwidget_set_rect(window, pos);
|
||||
|
||||
window->open_window_fg();
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
void test3(JRect pos)
|
||||
{
|
||||
JWidget window, box, view, listbox, button;
|
||||
char buf[256];
|
||||
int c;
|
||||
|
||||
window = jwindow_new("Big List");
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
view = jview_new();
|
||||
listbox = jlistbox_new();
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
for (c=0; c<512; c++) {
|
||||
usprintf(buf, "Long item (%d)", c);
|
||||
jwidget_add_child (listbox, jlistitem_new (buf));
|
||||
}
|
||||
|
||||
jlistbox_select_index(listbox, 0);
|
||||
|
||||
jview_attach(view, listbox);
|
||||
|
||||
jwidget_expansive(view, true);
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, view);
|
||||
jwidget_add_child (box, button);
|
||||
|
||||
window->remap_window();
|
||||
jwidget_set_rect(window, pos);
|
||||
|
||||
window->open_window_fg();
|
||||
jwidget_free(window);
|
||||
}
|
||||
|
||||
void test4(JRect pos)
|
||||
{
|
||||
JWidget window, box, view, widget, listbox, button;
|
||||
char buf[256];
|
||||
int c;
|
||||
|
||||
window = jwindow_new("Magic List");
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
view = jview_new();
|
||||
listbox = jlistbox_new();
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
for (c=0; c<8; c++) {
|
||||
usprintf(buf, "Long item (%d)", c);
|
||||
widget = jlistitem_new(NULL);
|
||||
jwidget_add_child (widget, jcheck_new (buf));
|
||||
jwidget_add_child (listbox, widget);
|
||||
}
|
||||
|
||||
jlistbox_select_index(listbox, 0);
|
||||
|
||||
jview_attach(view, listbox);
|
||||
|
||||
jwidget_expansive(view, true);
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, view);
|
||||
jwidget_add_child (box, button);
|
||||
|
||||
window->remap_window();
|
||||
jwidget_set_rect(window, pos);
|
||||
|
||||
window->open_window_fg();
|
||||
jwidget_free(window);
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
static JWidget check, radio[12];
|
||||
|
||||
static int radio_flags[] = {
|
||||
JI_LEFT, JI_CENTER, JI_RIGHT,
|
||||
JI_TOP, JI_MIDDLE, JI_BOTTOM
|
||||
};
|
||||
|
||||
static void update_radios ();
|
||||
static bool hooked_check_msg_proc (JWidget widget, JMessage msg);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, box2, box3, label1, label2;
|
||||
int c;
|
||||
|
||||
allegro_init ();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
|
||||
window = jwindow_new ("Example 10");
|
||||
box1 = jbox_new (JI_HORIZONTAL);
|
||||
box2 = jbox_new (JI_VERTICAL);
|
||||
box3 = jbox_new (JI_VERTICAL);
|
||||
label1 = jlabel_new ("Text:");
|
||||
label2 = jlabel_new ("Icon:");
|
||||
check = jcheck_new ("Check Button");
|
||||
radio[0] = jradio_new ("Left", 1);
|
||||
radio[1] = jradio_new ("Center", 1);
|
||||
radio[2] = jradio_new ("Right", 1);
|
||||
radio[3] = jradio_new ("Top", 2);
|
||||
radio[4] = jradio_new ("Middle", 2);
|
||||
radio[5] = jradio_new ("Bottom", 2);
|
||||
radio[6] = jradio_new ("Left", 3);
|
||||
radio[7] = jradio_new ("Center", 3);
|
||||
radio[8] = jradio_new ("Right", 3);
|
||||
radio[9] = jradio_new ("Top", 4);
|
||||
radio[10] = jradio_new ("Middle", 4);
|
||||
radio[11] = jradio_new ("Bottom", 4);
|
||||
|
||||
for (c=0; c<12; c++)
|
||||
jwidget_add_hook(radio[c], JI_WIDGET, hooked_check_msg_proc, NULL);
|
||||
|
||||
jwidget_add_child (window, box1);
|
||||
jwidget_add_child (box1, check);
|
||||
jwidget_add_child (box1, box2);
|
||||
jwidget_add_child (box1, box3);
|
||||
jwidget_add_child (box2, label1);
|
||||
jwidget_add_child (box2, radio[0]);
|
||||
jwidget_add_child (box2, radio[1]);
|
||||
jwidget_add_child (box2, radio[2]);
|
||||
jwidget_add_child (box2, radio[3]);
|
||||
jwidget_add_child (box2, radio[4]);
|
||||
jwidget_add_child (box2, radio[5]);
|
||||
jwidget_add_child (box3, label2);
|
||||
jwidget_add_child (box3, radio[6]);
|
||||
jwidget_add_child (box3, radio[7]);
|
||||
jwidget_add_child (box3, radio[8]);
|
||||
jwidget_add_child (box3, radio[9]);
|
||||
jwidget_add_child (box3, radio[10]);
|
||||
jwidget_add_child (box3, radio[11]);
|
||||
|
||||
jwidget_expansive (check, true);
|
||||
update_radios ();
|
||||
|
||||
window->open_window_bg();
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN ();
|
||||
|
||||
static void update_radios ()
|
||||
{
|
||||
#define SET_STATUS(index, status) \
|
||||
if (status) \
|
||||
jwidget_select (radio[index]); \
|
||||
else \
|
||||
jwidget_deselect (radio[index]);
|
||||
|
||||
int text_align = jwidget_get_align (check);
|
||||
int icon_align = ji_generic_button_get_icon_align(check);
|
||||
|
||||
SET_STATUS (0, text_align & JI_LEFT);
|
||||
SET_STATUS (1, text_align & JI_CENTER);
|
||||
SET_STATUS (2, text_align & JI_RIGHT);
|
||||
SET_STATUS (3, text_align & JI_TOP);
|
||||
SET_STATUS (4, text_align & JI_MIDDLE);
|
||||
SET_STATUS (5, text_align & JI_BOTTOM);
|
||||
|
||||
SET_STATUS (6, icon_align & JI_LEFT);
|
||||
SET_STATUS (7, icon_align & JI_CENTER);
|
||||
SET_STATUS (8, icon_align & JI_RIGHT);
|
||||
SET_STATUS (9, icon_align & JI_TOP);
|
||||
SET_STATUS (10, icon_align & JI_MIDDLE);
|
||||
SET_STATUS (11, icon_align & JI_BOTTOM);
|
||||
}
|
||||
|
||||
static bool hooked_check_msg_proc (JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_SIGNAL &&
|
||||
msg->signal.num == JI_SIGNAL_RADIO_CHANGE) {
|
||||
int text_align = 0;
|
||||
int icon_align = 0;
|
||||
int c;
|
||||
|
||||
for (c=0; c<12; c++) {
|
||||
if (c < 6) {
|
||||
if (jwidget_is_selected(radio[c]))
|
||||
text_align |= radio_flags[c];
|
||||
}
|
||||
else {
|
||||
if (jwidget_is_selected(radio[c]))
|
||||
icon_align |= radio_flags[c-6];
|
||||
}
|
||||
}
|
||||
|
||||
if (text_align != jwidget_get_align(check))
|
||||
check->set_align(text_align);
|
||||
|
||||
if (icon_align != ji_generic_button_get_icon_align(check))
|
||||
ji_generic_button_set_icon_align(check, icon_align);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
static void poll_button (JWidget widget);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init ();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
|
||||
window = ji_load_widget ("11file.jid", "Window1");
|
||||
if (window) {
|
||||
JWidget button_poll = jwidget_find_name (window, "Poll");
|
||||
jbutton_add_command (button_poll, poll_button);
|
||||
window->open_window_bg();
|
||||
}
|
||||
else
|
||||
jalert ("Error loading main window||&OK");
|
||||
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
static void poll_button (JWidget widget)
|
||||
{
|
||||
char filename[512], path[512];
|
||||
JWidget window;
|
||||
|
||||
get_executable_name (path, sizeof (path));
|
||||
replace_filename (filename, path, "11file.jid", sizeof (filename));
|
||||
|
||||
window = ji_load_widget (filename, "Window2");
|
||||
if (window) {
|
||||
JWidget button_select = jwidget_find_name (window, "Select");
|
||||
|
||||
window->open_window_fg();
|
||||
|
||||
if (window->get_killer() == button_select) {
|
||||
JWidget option1 = jwidget_find_name (window, "Option1");
|
||||
JWidget option2 = jwidget_find_name (window, "Option2");
|
||||
JWidget option3 = jwidget_find_name (window, "Option3");
|
||||
|
||||
if (option1 && option2 && option3) {
|
||||
const char *msg = "";
|
||||
|
||||
if (jwidget_is_selected (option1))
|
||||
msg = "When you don't program it :-)";
|
||||
else if (jwidget_is_selected (option2))
|
||||
msg =
|
||||
"You lier, that is because"
|
||||
"<<you don't see the Allegro one :-)";
|
||||
else if (jwidget_is_selected (option3))
|
||||
msg = "You are blind :-)";
|
||||
else
|
||||
msg = "Mhh... you must select a item";
|
||||
|
||||
jalert ("Message from the Author<<%s||&Close", msg);
|
||||
}
|
||||
}
|
||||
|
||||
jwidget_free (window);
|
||||
}
|
||||
else {
|
||||
jalert ("Error loading %s file||&OK", filename);
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
<window desktop name="Window1" text="My Window">
|
||||
<panel vertical>
|
||||
<panel expansive horizontal>
|
||||
<view expansive>
|
||||
<box vertical>
|
||||
<label text="First label" center />
|
||||
<label text="Second label" center />
|
||||
<label text="Third label" center />
|
||||
<label text="Fourth label" center />
|
||||
<check text="My check" />
|
||||
<button name="Poll" text="&Poll" />
|
||||
<box horizontal homogeneous>
|
||||
<button text="&OK" />
|
||||
<button text="&Close" />
|
||||
</box>
|
||||
</box>
|
||||
</view>
|
||||
<box vertical>
|
||||
<view expansive>
|
||||
<box vertical>
|
||||
<separator text="First Radio Group" horizontal vertical>
|
||||
<box vertical>
|
||||
<radio text="Check1.1" group=1 />
|
||||
<radio text="Check1.2" group=1 />
|
||||
<radio text="Check1.3" group=1 />
|
||||
<radio text="Check1.4" group=1 />
|
||||
</box>
|
||||
</separator>
|
||||
<separator text="Second Radio Group" center horizontal vertical>
|
||||
<box vertical>
|
||||
<radio text="Check2.1" group=2 />
|
||||
<radio text="Check2.2" group=2 />
|
||||
<radio text="Check2.3" group=2 />
|
||||
<radio text="Check2.4" group=2 />
|
||||
</box>
|
||||
</separator>
|
||||
<separator text="Third Radio Group" right horizontal vertical>
|
||||
<box vertical>
|
||||
<radio text="Check3.1" group=3 />
|
||||
<radio text="Check3.2" group=3 />
|
||||
<radio text="Check3.3" group=3 />
|
||||
<radio text="Check3.4" group=3 />
|
||||
</box>
|
||||
</separator>
|
||||
</box>
|
||||
</view>
|
||||
</box>
|
||||
</panel>
|
||||
<view expansive>
|
||||
<listbox>
|
||||
<listitem text="Item1" />
|
||||
<listitem text="Item2" />
|
||||
<listitem text="Item3" />
|
||||
<listitem text="Item4" />
|
||||
<listitem text="Item5" />
|
||||
</listbox>
|
||||
</view>
|
||||
</panel>
|
||||
</window>
|
||||
|
||||
<window name="Window2" text="Answer this poll">
|
||||
<box vertical homogeneous>
|
||||
<label text="&Select an option" />
|
||||
<radio name="Option1" text="Jinete is amazing!!!" group=1 />
|
||||
<radio name="Option2" text="I see ugly GUIs, but like Jinete, no one" group=1 />
|
||||
<radio name="Option3" text="I prefer Allegro GUI" group=1 />
|
||||
<box horizontal homogeneous>
|
||||
<button name="Select" text="&Select" />
|
||||
<button text="&Cancel" />
|
||||
</box>
|
||||
</box>
|
||||
</window>
|
@ -1,101 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
static void handle_menuitem_selected (JWidget widget, int user_data);
|
||||
|
||||
static struct jquickmenu quickmenu[] =
|
||||
{
|
||||
{ 0, "&File", NULL, NULL, 0 },
|
||||
{ 1, "&New", NULL, NULL, 0 },
|
||||
{ 2, "&Sprite", NULL, handle_menuitem_selected, 0 },
|
||||
{ 2, "&Image", NULL, handle_menuitem_selected, 0 },
|
||||
{ 2, "&Font", NULL, handle_menuitem_selected, 0 },
|
||||
{ 2, "&Palette", NULL, handle_menuitem_selected, 0 },
|
||||
{ 1, "&Open", "<Ctrl+O>", handle_menuitem_selected, 0 },
|
||||
{ 1, "&Save", "<Ctrl+S>", handle_menuitem_selected, 0 },
|
||||
{ 1, NULL, NULL, NULL, 0 },
|
||||
{ 1, "&Quit", "<Ctrl+Q> <Alt+X> <Esc>", handle_menuitem_selected, 0 },
|
||||
{ 0, "&Edit", NULL, NULL, 0 },
|
||||
{ 1, "Cu&t", "<Shift+Del>", handle_menuitem_selected, 0 },
|
||||
{ 1, "&Copy", "<Ctrl+Ins>", handle_menuitem_selected, 0 },
|
||||
{ 1, "&Paste", "<Shift+Ins>", handle_menuitem_selected, 0 },
|
||||
{ 1, "C&lear", "<Ctrl+Del>", handle_menuitem_selected, 0 },
|
||||
{ 0, "&Tools", NULL, handle_menuitem_selected, 0 },
|
||||
{ 0, "&Help", NULL, handle_menuitem_selected, 0 },
|
||||
{ -1, NULL, NULL, NULL, 0 },
|
||||
};
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box, button, menubar;
|
||||
|
||||
allegro_init ();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
manager = jmanager_new ();
|
||||
ji_set_standard_theme ();
|
||||
|
||||
window = jwindow_new ("Menus");
|
||||
box = jbox_new (JI_VERTICAL);
|
||||
button = jbutton_new ("&Close");
|
||||
menubar = jmenubar_new_quickmenu (quickmenu);
|
||||
|
||||
jwidget_add_child (window, box);
|
||||
jwidget_add_child (box, menubar);
|
||||
jwidget_add_child (box, button);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run (manager);
|
||||
jmanager_free (manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN ();
|
||||
|
||||
static void handle_menuitem_selected (JWidget widget, int user_data)
|
||||
{
|
||||
printf ("Selected item: %s\n", widget->text);
|
||||
}
|
||||
|
@ -1,167 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
static JWidget new_menuitem(const char *text, const char *accel_string);
|
||||
static bool hooked_menuitem_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, button;
|
||||
JWidget menu;
|
||||
JWidget menubar;
|
||||
JWidget menuitem_file;
|
||||
JWidget menuitem_edit;
|
||||
JWidget menuitem_tool;
|
||||
JWidget menuitem_help;
|
||||
JWidget menu_file;
|
||||
JWidget menuitem_file_new;
|
||||
JWidget menuitem_file_open;
|
||||
JWidget menuitem_file_save;
|
||||
JWidget menuitem_file_sep1;
|
||||
JWidget menuitem_file_quit;
|
||||
JWidget menu_filenew;
|
||||
JWidget menuitem_filenew_sprite;
|
||||
JWidget menuitem_filenew_image;
|
||||
JWidget menuitem_filenew_font;
|
||||
JWidget menuitem_filenew_palette;
|
||||
JWidget menu_edit;
|
||||
JWidget menuitem_edit_cut;
|
||||
JWidget menuitem_edit_copy;
|
||||
JWidget menuitem_edit_paste;
|
||||
JWidget menuitem_edit_clear;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new("Menus");
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
button = jbutton_new("&Close");
|
||||
menu = jmenu_new();
|
||||
menubar = jmenubar_new();
|
||||
menuitem_file = jmenuitem_new("&File");
|
||||
menuitem_edit = jmenuitem_new("&Edit");
|
||||
menuitem_tool = new_menuitem("&Tools", NULL);
|
||||
menuitem_help = new_menuitem("&Help", NULL);
|
||||
menu_file = jmenu_new();
|
||||
menuitem_file_new = jmenuitem_new("&New");
|
||||
menuitem_file_open = new_menuitem("&Open", "<Ctrl+O>");
|
||||
menuitem_file_save = new_menuitem("&Save", "<Ctrl+S>"); jwidget_disable (menuitem_file_save);
|
||||
menuitem_file_sep1 = ji_separator_new(NULL, JI_HORIZONTAL);
|
||||
menuitem_file_quit = new_menuitem("&Quit", "<Ctrl+Q>");
|
||||
menu_filenew = jmenu_new();
|
||||
menuitem_filenew_sprite = new_menuitem("&Sprite", NULL);
|
||||
menuitem_filenew_image = new_menuitem("&Image", NULL);
|
||||
menuitem_filenew_font = new_menuitem("&Font", NULL);
|
||||
menuitem_filenew_palette = new_menuitem("&Palette", NULL);
|
||||
menu_edit = jmenu_new ();
|
||||
menuitem_edit_cut = new_menuitem("Cu&t", "<Shift+Del>");
|
||||
menuitem_edit_copy = new_menuitem("&Copy", "<Ctrl+Ins>");
|
||||
menuitem_edit_paste = new_menuitem("&Paste", "<Shift+Ins>");
|
||||
menuitem_edit_clear = new_menuitem("C&lear", "<Ctrl+Del>");
|
||||
|
||||
jwidget_add_child(menu_file, menuitem_file_new);
|
||||
jwidget_add_child(menu_file, menuitem_file_open);
|
||||
jwidget_add_child(menu_file, menuitem_file_save);
|
||||
jwidget_add_child(menu_file, menuitem_file_sep1);
|
||||
jwidget_add_child(menu_file, menuitem_file_quit);
|
||||
jmenuitem_set_submenu(menuitem_file, menu_file);
|
||||
|
||||
jwidget_add_child(menu_filenew, menuitem_filenew_sprite);
|
||||
jwidget_add_child(menu_filenew, menuitem_filenew_image);
|
||||
jwidget_add_child(menu_filenew, menuitem_filenew_font);
|
||||
jwidget_add_child(menu_filenew, menuitem_filenew_palette);
|
||||
jmenuitem_set_submenu(menuitem_file_new, menu_filenew);
|
||||
|
||||
jwidget_add_child(menu_edit, menuitem_edit_cut);
|
||||
jwidget_add_child(menu_edit, menuitem_edit_copy);
|
||||
jwidget_add_child(menu_edit, menuitem_edit_paste);
|
||||
jwidget_add_child(menu_edit, menuitem_edit_clear);
|
||||
jmenuitem_set_submenu(menuitem_edit, menu_edit);
|
||||
|
||||
jwidget_add_child(menu, menuitem_file);
|
||||
jwidget_add_child(menu, menuitem_edit);
|
||||
jwidget_add_child(menu, menuitem_tool);
|
||||
jwidget_add_child(menu, menuitem_help);
|
||||
jmenubar_set_menu(menubar, menu);
|
||||
|
||||
jwidget_add_child(box1, menubar);
|
||||
jwidget_add_child(box1, button);
|
||||
jwidget_add_child(window, box1);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
static JWidget new_menuitem(const char *text, const char *accel_string)
|
||||
{
|
||||
JWidget menuitem = jmenuitem_new(text);
|
||||
JAccel accel = jaccel_new();
|
||||
|
||||
jwidget_add_hook(menuitem, JI_WIDGET,
|
||||
hooked_menuitem_msg_proc, NULL);
|
||||
|
||||
if (accel_string)
|
||||
jaccel_add_keys_from_string(accel, accel_string);
|
||||
|
||||
jmenuitem_set_accel(menuitem, accel);
|
||||
|
||||
return menuitem;
|
||||
}
|
||||
|
||||
static bool hooked_menuitem_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_SIGNAL &&
|
||||
msg->signal.num == JI_SIGNAL_MENUITEM_SELECT)
|
||||
printf("Selected item: %s\n", widget->text);
|
||||
return false;
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, desktop, box, view, sub_manager, button;
|
||||
Window* subwindows[256];
|
||||
Window* window;
|
||||
char buf[256];
|
||||
int c;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
/* create desktop */
|
||||
desktop = jwindow_new_desktop();
|
||||
box = jbox_new(JI_VERTICAL);
|
||||
view = jview_new();
|
||||
sub_manager = jmanager_new();
|
||||
button = jbutton_new("&Close All");
|
||||
|
||||
jview_attach(view, sub_manager);
|
||||
jwidget_expansive(view, true);
|
||||
|
||||
jwidget_add_child(desktop, box);
|
||||
jwidget_add_child(box, view);
|
||||
jwidget_add_child(box, button);
|
||||
|
||||
desktop->open_window_bg();
|
||||
|
||||
/* generate 128 windows in random positions */
|
||||
for (c=0; c<128; c++) {
|
||||
usprintf(buf, "Window (%d)", c+1);
|
||||
|
||||
window = jwindow_new(buf);
|
||||
button = jbutton_new("&Close");
|
||||
|
||||
jwidget_add_child(window, button);
|
||||
|
||||
window->remap_window();
|
||||
jwindow_position
|
||||
(window,
|
||||
sub_manager->rc->x1 + (rand () % (jrect_w(sub_manager->rc) - jrect_w(window->rc))),
|
||||
sub_manager->rc->y1 + (rand () % (jrect_h(sub_manager->rc) - jrect_h(window->rc))));
|
||||
|
||||
_jmanager_open_window(sub_manager, window);
|
||||
subwindows[c] = window;
|
||||
}
|
||||
|
||||
jmanager_run(manager);
|
||||
|
||||
for (c=0; c<128; c++)
|
||||
jwidget_free(subwindows[c]);
|
||||
jwidget_free(desktop);
|
||||
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,220 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
static JList windows;
|
||||
|
||||
static JWidget my_button_new(const char *text, int color);
|
||||
static int my_button_get_color(JWidget widget);
|
||||
static bool my_button_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
static void new_palette_window(JWidget widget);
|
||||
|
||||
static bool hooked_window1_msg_proc(JWidget widget, JMessage msg);
|
||||
static bool hooked_window_bg_msg_proc(JWidget widget, JMessage msg);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window1, box1, button1, button2, button3, button4, button5;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
windows = jlist_new();
|
||||
window1 = jwindow_new("Colors");
|
||||
box1 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
button1 = my_button_new("&Red", makecol (255, 0, 0));
|
||||
button2 = my_button_new("&Green", makecol (0, 128, 0));
|
||||
button3 = my_button_new("&Blue", makecol (0, 0, 255));
|
||||
button4 = jbutton_new("&Palette");
|
||||
button5 = jbutton_new("&Close");
|
||||
|
||||
jbutton_set_bevel(button4, 4, 4, 0, 0);
|
||||
jbutton_set_bevel(button5, 0, 0, 4, 4);
|
||||
|
||||
jwidget_add_hook(window1, JI_WIDGET, hooked_window1_msg_proc, NULL);
|
||||
jbutton_add_command(button4, new_palette_window);
|
||||
|
||||
jwidget_add_child (box1, button1);
|
||||
jwidget_add_child (box1, button2);
|
||||
jwidget_add_child (box1, button3);
|
||||
jwidget_add_child (box1, button4);
|
||||
jwidget_add_child (box1, button5);
|
||||
jwidget_add_child (window1, box1);
|
||||
|
||||
window1->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jlist_free(windows);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
static JWidget my_button_new(const char *text, int color)
|
||||
{
|
||||
JWidget widget = jbutton_new(text);
|
||||
|
||||
widget->user_data[0] = (void *)color;
|
||||
|
||||
jwidget_add_hook(widget, JI_WIDGET, my_button_msg_proc, NULL);
|
||||
widget->set_align(JI_LEFT | JI_BOTTOM);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
static int my_button_get_color(JWidget widget)
|
||||
{
|
||||
return (int)widget->user_data[0];
|
||||
}
|
||||
|
||||
static bool my_button_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_DRAW) {
|
||||
JRect rect = jwidget_get_rect (widget);
|
||||
int color = my_button_get_color (widget);
|
||||
int bg, c1, c2;
|
||||
|
||||
/* with mouse */
|
||||
if (jwidget_has_mouse (widget))
|
||||
bg = JI_COLOR_SHADE (color, 64, 64, 64);
|
||||
/* without mouse */
|
||||
else
|
||||
bg = color;
|
||||
|
||||
/* selected */
|
||||
if (jwidget_is_selected (widget)) {
|
||||
c1 = JI_COLOR_SHADE (color, -128, -128, -128);
|
||||
c2 = JI_COLOR_SHADE (color, 128, 128, 128);
|
||||
}
|
||||
/* non-selected */
|
||||
else {
|
||||
c1 = JI_COLOR_SHADE (color, 128, 128, 128);
|
||||
c2 = JI_COLOR_SHADE (color, -128, -128, -128);
|
||||
}
|
||||
|
||||
/* 1st border */
|
||||
if (jwidget_has_focus (widget))
|
||||
jdraw_rect (rect, makecol (0, 0, 0));
|
||||
else
|
||||
jdraw_rectedge (rect, c1, c2);
|
||||
|
||||
/* 2nd border */
|
||||
jrect_shrink (rect, 1);
|
||||
if (jwidget_has_focus (widget))
|
||||
jdraw_rectedge (rect, c1, c2);
|
||||
else
|
||||
jdraw_rect (rect, bg);
|
||||
|
||||
/* background */
|
||||
jrect_shrink (rect, 1);
|
||||
jdraw_rectfill (rect, bg);
|
||||
|
||||
/* text */
|
||||
jdraw_widget_text (widget, makecol (255, 255, 255), bg, false);
|
||||
|
||||
jrect_free (rect);
|
||||
return true;
|
||||
}
|
||||
/* button select signal */
|
||||
else if (msg->type == JM_SIGNAL &&
|
||||
msg->signal.num == JI_SIGNAL_BUTTON_SELECT) {
|
||||
int color = my_button_get_color(widget);
|
||||
JWidget alert = jalert_new("#%02x%02x%02x"
|
||||
"<<Red: %d"
|
||||
"<<Green: %d"
|
||||
"<<Blue: %d"
|
||||
"||&Close",
|
||||
getr(color), getg(color), getb(color),
|
||||
getr(color), getg(color), getb(color));
|
||||
|
||||
jlist_append(windows, alert);
|
||||
jwidget_add_hook(alert, JI_WIDGET, hooked_window_bg_msg_proc, NULL);
|
||||
alert->open_window_bg();
|
||||
|
||||
/* return true to avoid close the window */
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static void new_palette_window(JWidget widget)
|
||||
{
|
||||
JWidget window = jwindow_new ("Palette");
|
||||
JWidget box = jbox_new (JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
JWidget button;
|
||||
int c, color;
|
||||
|
||||
for (c=0; c<8; c++) {
|
||||
color = makecol (rand () % 255, rand () % 255, rand () % 255);
|
||||
button = my_button_new ("", color);
|
||||
jwidget_add_child (box, button);
|
||||
}
|
||||
jwidget_add_child (window, box);
|
||||
|
||||
jlist_append(windows, window);
|
||||
jwidget_add_hook(window, JI_WIDGET, hooked_window_bg_msg_proc, NULL);
|
||||
window->open_window_bg();
|
||||
}
|
||||
|
||||
static bool hooked_window1_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_CLOSE) {
|
||||
JLink link, next;
|
||||
JI_LIST_FOR_EACH_SAFE(windows, link, next) /* close all windows */
|
||||
reinterpret_cast<Window*>(link->data)->close_window(NULL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool hooked_window_bg_msg_proc(JWidget widget, JMessage msg)
|
||||
{
|
||||
if (msg->type == JM_CLOSE)
|
||||
jlist_remove(windows, widget);
|
||||
return false;
|
||||
}
|
@ -1,349 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
void set_my_palette();
|
||||
JTheme my_theme_new();
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window1, window2, window3;
|
||||
JWidget box2, box3, button1, button2a, button2b, button3a, button3b;
|
||||
JTheme my_theme;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
set_my_palette();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
|
||||
/* change to custom theme */
|
||||
my_theme = my_theme_new();
|
||||
ji_set_theme(my_theme);
|
||||
|
||||
window1 = jwindow_new("Window1");
|
||||
window2 = jwindow_new("Window2");
|
||||
box2 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
button1 = jbutton_new("Button1");
|
||||
button2a = jbutton_new("Button2a");
|
||||
button2b = jbutton_new("Button2b");
|
||||
|
||||
/* change to default theme */
|
||||
ji_set_standard_theme();
|
||||
|
||||
window3 = jwindow_new("Window3");
|
||||
box3 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
button3a = jbutton_new("Button3a");
|
||||
button3b = jbutton_new("Button3b");
|
||||
|
||||
/* setup widgets */
|
||||
jwidget_disable(button2b);
|
||||
jwidget_disable(button3b);
|
||||
|
||||
jwidget_add_child(window1, button1);
|
||||
jwidget_add_child(window2, box2);
|
||||
jwidget_add_child(box2, button2a);
|
||||
jwidget_add_child(box2, button2b);
|
||||
jwidget_add_child(window3, box3);
|
||||
jwidget_add_child(box3, button3a);
|
||||
jwidget_add_child(box3, button3b);
|
||||
|
||||
jwindow_open(window1);
|
||||
jwindow_open(window2);
|
||||
jwindow_open(window3);
|
||||
|
||||
jmanager_run(manager);
|
||||
|
||||
/* back to the custom theme */
|
||||
ji_set_theme(my_theme);
|
||||
|
||||
jalert("Warning<<This is a test alert||&Yes||&No||&Cancel");
|
||||
|
||||
jtheme_free(my_theme);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
void set_my_palette()
|
||||
{
|
||||
PALETTE pal;
|
||||
int i, c = 0;
|
||||
|
||||
for (i=0; i<32; i++, c++) pal[c].r = pal[c].g = pal[c].b = 63 * i / 31;
|
||||
for (i=0; i<32; i++, c++) pal[c].r = 63 * i / 31, pal[c].g = pal[c].b = 0;
|
||||
for (i=0; i<32; i++, c++) pal[c].r = 0, pal[c].g = 63 * i / 31, pal[c].b = 0;
|
||||
for (i=0; i<32; i++, c++) pal[c].r = pal[c].g = 0, pal[c].b = 63 * i / 31;
|
||||
for (i=0; i<32; i++, c++) pal[c].r = pal[c].g = 63 * i / 31, pal[c].b = 0;
|
||||
|
||||
for (i=0; i<32; i++, c++) {
|
||||
pal[c].r = 0;
|
||||
pal[c].b = 63 * i / 31;
|
||||
pal[c].g = i;
|
||||
}
|
||||
|
||||
for (; c<256; c++)
|
||||
pal[c].r = pal[c].b = pal[c].g = 0;
|
||||
|
||||
set_palette(pal);
|
||||
rgb_map = (RGB_MAP*)malloc(sizeof(RGB_MAP));
|
||||
create_rgb_table(rgb_map, pal, NULL);
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Theme */
|
||||
|
||||
static void theme_regen();
|
||||
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y);
|
||||
static void theme_init_widget(JWidget widget);
|
||||
static JRegion theme_get_window_mask(JWidget widget);
|
||||
|
||||
static void theme_draw_box(JWidget widget, JRect clip);
|
||||
static void theme_draw_button(JWidget widget, JRect clip);
|
||||
static void theme_draw_label(JWidget widget, JRect clip);
|
||||
static void theme_draw_window(JWidget widget, JRect clip);
|
||||
|
||||
JTheme my_theme_new()
|
||||
{
|
||||
JTheme theme;
|
||||
|
||||
theme = jtheme_new();
|
||||
if (!theme)
|
||||
return NULL;
|
||||
|
||||
theme->name = "My Theme";
|
||||
theme->check_icon_size = 8;
|
||||
theme->radio_icon_size = 8;
|
||||
|
||||
theme->regen = theme_regen;
|
||||
theme->set_cursor = theme_set_cursor;
|
||||
theme->init_widget = theme_init_widget;
|
||||
theme->get_window_mask = theme_get_window_mask;
|
||||
|
||||
jtheme_set_method(theme, JI_BOX, theme_draw_box);
|
||||
jtheme_set_method(theme, JI_BUTTON, theme_draw_button);
|
||||
jtheme_set_method(theme, JI_LABEL, theme_draw_label);
|
||||
jtheme_set_method(theme, JI_FRAME, theme_draw_frame);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
static void theme_regen()
|
||||
{
|
||||
ji_get_theme()->desktop_color = makecol(64, 100, 128);
|
||||
}
|
||||
|
||||
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void theme_init_widget(JWidget widget)
|
||||
{
|
||||
#define BORDER(n) \
|
||||
widget->border_width.l = n; \
|
||||
widget->border_width.t = n; \
|
||||
widget->border_width.r = n; \
|
||||
widget->border_width.b = n;
|
||||
|
||||
#define BORDER4(L,T,R,B) \
|
||||
widget->border_width.l = L; \
|
||||
widget->border_width.t = T; \
|
||||
widget->border_width.r = R; \
|
||||
widget->border_width.b = B;
|
||||
|
||||
switch (widget->draw_type) {
|
||||
|
||||
case JI_BOX:
|
||||
BORDER(8);
|
||||
widget->child_spacing = 8;
|
||||
break;
|
||||
|
||||
case JI_BUTTON:
|
||||
BORDER(6);
|
||||
widget->child_spacing = 0;
|
||||
break;
|
||||
|
||||
case JI_FRAME:
|
||||
BORDER4(8, 12+jwidget_get_text_height(widget)+12, 8, 8);
|
||||
widget->child_spacing = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static JRegion theme_get_window_mask(JWidget widget)
|
||||
{
|
||||
JRegion reg1 = jregion_new(NULL, 0);
|
||||
JRegion reg2 = jregion_new(NULL, 0);
|
||||
int table[6] = { 6, 4, 3, 2, 1, 1 };
|
||||
JRect rect = jrect_new (0, 0, 0, 0);
|
||||
JRect pos = jwidget_get_rect (widget);
|
||||
bool overlap;
|
||||
int c;
|
||||
|
||||
for (c=0; c<6; c++) {
|
||||
jrect_replace(rect,
|
||||
pos->x1+table[c], pos->y1+c,
|
||||
pos->x2-table[c], pos->y1+c+1);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
|
||||
jrect_replace(rect,
|
||||
pos->x1+table[c], pos->y2-c-1,
|
||||
pos->x2-table[c], pos->y2-c);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
}
|
||||
|
||||
jrect_replace(rect, pos->x1, pos->y1+c, pos->x2, pos->y2-c);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
|
||||
jrect_free(pos);
|
||||
jrect_free(rect);
|
||||
jregion_free(reg2);
|
||||
|
||||
jregion_validate(reg1, &overlap);
|
||||
return reg1;
|
||||
}
|
||||
|
||||
static void theme_draw_box(JWidget widget, JRect clip)
|
||||
{
|
||||
JWidget window = jwidget_get_window(widget);
|
||||
if (window) {
|
||||
JRect pos = jwidget_get_child_rect(window);
|
||||
jdraw_rectshade(pos,
|
||||
makecol(128, 128, 128),
|
||||
makecol(196, 196, 196),
|
||||
JI_VERTICAL);
|
||||
jrect_free(pos);
|
||||
}
|
||||
}
|
||||
|
||||
static void theme_draw_button(JWidget widget, JRect clip)
|
||||
{
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
int c1, c2, fg, bg;
|
||||
|
||||
if (jwidget_is_disabled(widget)) {
|
||||
if (jwidget_is_selected(widget)) {
|
||||
bg = makecol(64, 64, 64);
|
||||
fg = makecol(128, 128, 128);
|
||||
c1 = makecol(0, 0, 0);
|
||||
c2 = makecol(255, 255, 255);
|
||||
}
|
||||
else {
|
||||
bg = makecol(128, 128, 128);
|
||||
fg = makecol(64, 64, 64);
|
||||
c1 = makecol(255, 255, 255);
|
||||
c2 = makecol(0, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (jwidget_is_selected(widget)) {
|
||||
bg = makecol(255, 255, 255);
|
||||
fg = makecol(128, 128, 128);
|
||||
c1 = makecol(0, 0, 0);
|
||||
c2 = makecol(255, 255, 255);
|
||||
}
|
||||
else {
|
||||
bg = makecol(128, 128, 128);
|
||||
fg = makecol(255, 255, 255);
|
||||
c1 = makecol(255, 255, 255);
|
||||
c2 = makecol(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
jdraw_rectedge(pos, c1, c2);
|
||||
|
||||
jrect_shrink(pos, 1);
|
||||
jdraw_rectedge(pos, makecol (128, 128, 128), makecol (64, 64, 64));
|
||||
|
||||
jrect_shrink(pos, 1);
|
||||
jdraw_rectshade(pos, fg, bg, JI_VERTICAL);
|
||||
|
||||
if (jwidget_get_text(widget)) {
|
||||
struct jrect text;
|
||||
int s = jwidget_is_selected(widget) ? 1: 0;
|
||||
|
||||
jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
|
||||
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text,
|
||||
text.x1+s+1, text.y1+s+1, makecol (0, 0, 0), bg, false);
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text,
|
||||
text.x1+s, text.y1+s, fg, bg, false);
|
||||
}
|
||||
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void theme_draw_label(JWidget widget, JRect clip)
|
||||
{
|
||||
/* draw background as Box */
|
||||
theme_draw_box(widget, clip);
|
||||
|
||||
jdraw_widget_text(widget, makecol(0, 0, 0), makecol(196, 196, 196), false);
|
||||
}
|
||||
|
||||
static void theme_draw_window(JWidget widget, JRect clip)
|
||||
{
|
||||
JRect pos;
|
||||
|
||||
pos = jwidget_get_rect(widget);
|
||||
jdraw_rectfill(pos, makecol(196, 196, 0));
|
||||
jrect_shrink(pos, 8);
|
||||
|
||||
/* title bar */
|
||||
pos->y2 = pos->y1+4+jwidget_get_text_height(widget)+4;
|
||||
jdraw_rectshade(pos, makecol(0, 0, 0), makecol(128, 128, 128), JI_VERTICAL);
|
||||
|
||||
pos->x1 += 1;
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text, pos->x1, pos->y1+4,
|
||||
makecol(255, 255, 255),
|
||||
makecol(196, 196, 0), false);
|
||||
|
||||
jrect_free(pos);
|
||||
}
|
@ -1,544 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
FONT *my_font = NULL;
|
||||
|
||||
void set_my_font();
|
||||
void set_my_palette();
|
||||
JTheme my_theme_new();
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, box2, box3, box4, box5, button1, button2;
|
||||
JWidget label_username, label_password;
|
||||
JWidget entry_username, entry_password;
|
||||
JTheme my_theme;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
set_color_depth(16);
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
set_color_depth(8);
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
|
||||
set_my_font();
|
||||
set_my_palette();
|
||||
|
||||
/* change to custom theme */
|
||||
my_theme = my_theme_new();
|
||||
ji_set_theme(my_theme);
|
||||
|
||||
window = jwindow_new("Login");
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL);
|
||||
box3 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box4 = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
box5 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label_username = jlabel_new("Username");
|
||||
label_password = jlabel_new("Password");
|
||||
entry_username = jentry_new(32, "");
|
||||
entry_password = jentry_new(32, "");
|
||||
button1 = jbutton_new("&OK");
|
||||
button2 = jbutton_new("&Cancel");
|
||||
|
||||
jentry_password(entry_password, true);
|
||||
jwidget_magnetic(entry_username, true);
|
||||
jwidget_magnetic(button1, true);
|
||||
|
||||
jwidget_add_child(window, box1);
|
||||
jwidget_add_child(box1, box2);
|
||||
jwidget_add_child(box1, box5);
|
||||
jwidget_add_child(box2, box3);
|
||||
jwidget_add_child(box2, box4);
|
||||
jwidget_add_child(box3, label_username);
|
||||
jwidget_add_child(box3, label_password);
|
||||
jwidget_add_child(box4, entry_username);
|
||||
jwidget_add_child(box4, entry_password);
|
||||
jwidget_add_child(box5, button1);
|
||||
jwidget_add_child(box5, button2);
|
||||
|
||||
jwindow_sizeable(window, false);
|
||||
|
||||
again:;
|
||||
window->open_window_fg();
|
||||
|
||||
if (window->get_killer() == button1) {
|
||||
if (*jwidget_get_text(entry_username) &&
|
||||
*jwidget_get_text(entry_password))
|
||||
jalert("Login Successful"
|
||||
"==Welcome \"%s\""
|
||||
"||&Done",
|
||||
jwidget_get_text(entry_username));
|
||||
else {
|
||||
jalert("Login Failed"
|
||||
"==Try to use some username==and password"
|
||||
"||&OK");
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
jwidget_free(window);
|
||||
|
||||
jtheme_free(my_theme);
|
||||
jmanager_free(manager);
|
||||
|
||||
if (my_font)
|
||||
destroy_font(my_font);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
void set_my_font()
|
||||
{
|
||||
char buf[512], argv0[512];
|
||||
get_executable_name(argv0, sizeof(argv0));
|
||||
replace_filename(buf, argv0, "zerohour.ttf", sizeof(buf));
|
||||
my_font = ji_font_load_ttf(buf);
|
||||
if (my_font) {
|
||||
font = my_font;
|
||||
ji_font_set_size(font, 8);
|
||||
}
|
||||
}
|
||||
|
||||
void set_my_palette()
|
||||
{
|
||||
char buf[512], argv0[512];
|
||||
BITMAP *bmp;
|
||||
PALETTE pal;
|
||||
get_executable_name(argv0, sizeof(argv0));
|
||||
replace_filename(buf, argv0, "pal17.pcx", sizeof(buf));
|
||||
bmp = load_bitmap(buf, pal);
|
||||
if (bmp) {
|
||||
set_palette(pal);
|
||||
rgb_map = (RGB_MAP*)malloc(sizeof(RGB_MAP));
|
||||
create_rgb_table(rgb_map, pal, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Theme */
|
||||
|
||||
static void theme_regen();
|
||||
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y);
|
||||
static void theme_init_widget(JWidget widget);
|
||||
static JRegion theme_get_window_mask(JWidget widget);
|
||||
|
||||
static void theme_draw_box(JWidget widget, JRect clip);
|
||||
static void theme_draw_button(JWidget widget, JRect clip);
|
||||
static void theme_draw_entry(JWidget widget, JRect clip);
|
||||
static void theme_draw_label(JWidget widget, JRect clip);
|
||||
static void theme_draw_window(JWidget widget, JRect clip);
|
||||
|
||||
static void draw_rect(JRect rect, int color, bool invert);
|
||||
static void draw_edge(JRect rect, int color, bool invert);
|
||||
static void draw_entry_cursor(JWidget widget, int x, int y);
|
||||
|
||||
JTheme my_theme_new()
|
||||
{
|
||||
JTheme theme;
|
||||
|
||||
theme = jtheme_new();
|
||||
if (!theme)
|
||||
return NULL;
|
||||
|
||||
theme->name = "My Theme";
|
||||
theme->check_icon_size = 8;
|
||||
theme->radio_icon_size = 8;
|
||||
|
||||
theme->regen = theme_regen;
|
||||
theme->set_cursor = theme_set_cursor;
|
||||
theme->init_widget = theme_init_widget;
|
||||
theme->get_window_mask = theme_get_window_mask;
|
||||
|
||||
jtheme_set_method(theme, JI_BOX, theme_draw_box);
|
||||
jtheme_set_method(theme, JI_BUTTON, theme_draw_button);
|
||||
jtheme_set_method(theme, JI_ENTRY, theme_draw_entry);
|
||||
jtheme_set_method(theme, JI_LABEL, theme_draw_label);
|
||||
jtheme_set_method(theme, JI_FRAME, theme_draw_frame);
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
static void theme_regen()
|
||||
{
|
||||
ji_get_theme()->desktop_color = makecol(0, 128, 196);
|
||||
}
|
||||
|
||||
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void theme_init_widget(JWidget widget)
|
||||
{
|
||||
#define BORDER(n) \
|
||||
widget->border_width.l = n; \
|
||||
widget->border_width.t = n; \
|
||||
widget->border_width.r = n; \
|
||||
widget->border_width.b = n;
|
||||
|
||||
#define BORDER4(L,T,R,B) \
|
||||
widget->border_width.l = L; \
|
||||
widget->border_width.t = T; \
|
||||
widget->border_width.r = R; \
|
||||
widget->border_width.b = B;
|
||||
|
||||
switch (widget->draw_type) {
|
||||
|
||||
case JI_BOX:
|
||||
BORDER(4);
|
||||
widget->child_spacing = 2;
|
||||
break;
|
||||
|
||||
case JI_BUTTON:
|
||||
BORDER(5);
|
||||
widget->child_spacing = 0;
|
||||
break;
|
||||
|
||||
case JI_ENTRY:
|
||||
BORDER(6);
|
||||
widget->child_spacing = 0;
|
||||
break;
|
||||
|
||||
case JI_FRAME:
|
||||
BORDER4(7, 7+jwidget_get_text_height(widget)+7, 7, 7);
|
||||
widget->child_spacing = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static JRegion theme_get_window_mask(JWidget widget)
|
||||
{
|
||||
JRegion reg1 = jregion_new(NULL, 0);
|
||||
JRegion reg2 = jregion_new(NULL, 0);
|
||||
int table[2] = { 2, 1 };
|
||||
JRect rect = jrect_new(0, 0, 0, 0);
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
int c;
|
||||
bool overlap;
|
||||
|
||||
for (c=0; c<2; c++) {
|
||||
jrect_replace(rect,
|
||||
pos->x1+table[c], pos->y1+c,
|
||||
pos->x2-table[c], pos->y1+c+1);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
|
||||
jrect_replace(rect,
|
||||
pos->x1+table[c], pos->y2-c-1,
|
||||
pos->x2-table[c], pos->y2-c);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
}
|
||||
|
||||
jrect_replace(rect, pos->x1, pos->y1+c, pos->x2, pos->y2-c);
|
||||
jregion_reset(reg2, rect);
|
||||
jregion_append(reg1, reg2);
|
||||
|
||||
jrect_free(pos);
|
||||
jrect_free(rect);
|
||||
jregion_free(reg2);
|
||||
|
||||
jregion_validate(reg1, &overlap);
|
||||
return reg1;
|
||||
}
|
||||
|
||||
static void theme_draw_box(JWidget widget, JRect clip)
|
||||
{
|
||||
JWidget window = jwidget_get_window(widget);
|
||||
if (window) {
|
||||
JRect pos = jwidget_get_child_rect(window);
|
||||
draw_edge(pos, makecol(255, 196, 64), false);
|
||||
jrect_shrink(pos, 1);
|
||||
draw_rect(pos, makecol(255, 196, 64), false);
|
||||
jrect_free(pos);
|
||||
}
|
||||
}
|
||||
|
||||
static void theme_draw_button(JWidget widget, JRect clip)
|
||||
{
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
int fg, bg;
|
||||
|
||||
if (jwidget_is_disabled(widget)) {
|
||||
fg = makecol(196, 196, 196);
|
||||
bg = makecol(128, 128, 128);
|
||||
}
|
||||
else {
|
||||
fg = makecol(0, 0, 0);
|
||||
bg = jwidget_has_mouse(widget) ? makecol(64, 224, 255):
|
||||
makecol(0, 196, 255);
|
||||
}
|
||||
|
||||
draw_edge(pos, makecol(255, 196, 64), true);
|
||||
|
||||
if (jwidget_has_focus (widget)) {
|
||||
jrect_shrink(pos, 1);
|
||||
draw_edge(pos, makecol(0, 0, 0), false);
|
||||
}
|
||||
|
||||
jrect_shrink(pos, 1);
|
||||
draw_edge(pos, bg, jwidget_is_selected(widget));
|
||||
|
||||
jrect_shrink(pos, 1);
|
||||
draw_edge(pos, makecol(128, 128, 128), !jwidget_is_selected(widget));
|
||||
|
||||
jrect_shrink(pos, 1);
|
||||
draw_rect(pos, bg, jwidget_is_selected(widget));
|
||||
|
||||
if (widget->text) {
|
||||
struct jrect text;
|
||||
|
||||
jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
|
||||
|
||||
if (jwidget_is_selected(widget))
|
||||
jrect_displace(&text, 1, 1);
|
||||
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text, text.x1+1, text.y1+1,
|
||||
makecol(255, 255, 255), bg, false);
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text,
|
||||
text.x1, text.y1, fg, bg, false);
|
||||
}
|
||||
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void theme_draw_entry(JWidget widget, JRect clip)
|
||||
{
|
||||
int scroll, cursor, state, selbeg, selend;
|
||||
bool password = jentry_is_password(widget);
|
||||
const char *text = widget->text;
|
||||
int c, ch, x, y, w, fg, bg;
|
||||
int cursor_x;
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
|
||||
jtheme_entry_info(widget, &scroll, &cursor, &state, &selbeg, &selend);
|
||||
|
||||
bg = makecol(255, 255, 255);
|
||||
|
||||
/* 1st border */
|
||||
draw_edge(pos, makecol (255, 196, 64), true);
|
||||
|
||||
/* 2nd border */
|
||||
jrect_shrink(pos, 1);
|
||||
if (jwidget_has_focus(widget)) {
|
||||
jdraw_rect(pos, makecol(0, 0, 0));
|
||||
jrect_shrink(pos, 1);
|
||||
}
|
||||
draw_edge(pos, makecol(192, 192, 192), false);
|
||||
|
||||
/* background */
|
||||
jrect_shrink(pos, 1);
|
||||
jdraw_rectshade(pos, JI_COLOR_SHADE(bg, -64, -64, -64), bg,
|
||||
JI_VERTICAL);
|
||||
|
||||
/* draw the text */
|
||||
x = widget->rc->x1 + widget->border_width.l;
|
||||
y = (widget->rc->y1+widget->rc->y2)/2 - jwidget_get_text_height(widget)/2;
|
||||
|
||||
for (c=scroll; ugetat (text, c); c++) {
|
||||
ch = password ? '*': ugetat (text, c);
|
||||
|
||||
/* normal text */
|
||||
bg = -1;
|
||||
fg = makecol(0, 0, 0);
|
||||
|
||||
/* selected */
|
||||
if ((c >= selbeg) && (c <= selend)) {
|
||||
if (jwidget_has_focus(widget))
|
||||
bg = makecol(44, 76, 145);
|
||||
else
|
||||
bg = makecol(128, 128, 128);
|
||||
fg = makecol(255, 255, 255);
|
||||
}
|
||||
|
||||
/* disabled */
|
||||
if (jwidget_is_disabled(widget)) {
|
||||
bg = -1;
|
||||
fg = makecol(128, 128, 128);
|
||||
}
|
||||
|
||||
w = ji_font_char_len(widget->text_font, ch);
|
||||
if (x+w > widget->rc->x2-3)
|
||||
return;
|
||||
|
||||
cursor_x = x;
|
||||
jdraw_char(widget->text_font, ch, x, y, fg,
|
||||
bg >= 0 ? bg: makecol (192, 192, 192), bg >= 0);
|
||||
x += w;
|
||||
|
||||
/* cursor */
|
||||
if ((c == cursor) && (state) && (jwidget_has_focus(widget)))
|
||||
draw_entry_cursor(widget, cursor_x, y);
|
||||
}
|
||||
|
||||
/* draw the cursor if it is next of the last character */
|
||||
if ((c == cursor) && (state) &&
|
||||
(jwidget_has_focus(widget)) &&
|
||||
(jwidget_is_enabled(widget)))
|
||||
draw_entry_cursor(widget, x, y);
|
||||
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void theme_draw_label(JWidget widget, JRect clip)
|
||||
{
|
||||
/* draw background as Box */
|
||||
theme_draw_box(widget, clip);
|
||||
|
||||
if (widget->text) {
|
||||
struct jrect text;
|
||||
|
||||
jwidget_get_texticon_info(widget, NULL, &text, NULL, 0, 0, 0);
|
||||
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text, text.x1+1, text.y1+1,
|
||||
makecol(0, 0, 0), makecol(196, 128, 0), false);
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text, text.x1, text.y1,
|
||||
makecol(255, 255, 255), makecol(196, 128, 0), false);
|
||||
}
|
||||
}
|
||||
|
||||
static void theme_draw_window(JWidget widget, JRect clip)
|
||||
{
|
||||
JRect pos;
|
||||
int c;
|
||||
|
||||
pos = jwidget_get_rect(widget);
|
||||
|
||||
/* borders */
|
||||
for (c=0; c<3; c++) {
|
||||
jdraw_rectedge(pos,
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), +90, +90, +90),
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), -90, -90, -90));
|
||||
jrect_shrink(pos, 1);
|
||||
}
|
||||
|
||||
/* background */
|
||||
draw_rect(pos, makecol(0, 127, 255), false);
|
||||
|
||||
/* title bar */
|
||||
pos->x1 += 8;
|
||||
pos->y1 += 6;
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text, pos->x1+1, pos->y1+1,
|
||||
makecol(0, 0, 0), makecol(0, 127, 255), false);
|
||||
jdraw_text(ji_screen, widget->text_font, widget->text, pos->x1, pos->y1,
|
||||
makecol(255, 255, 255), makecol(0, 127, 255), false);
|
||||
|
||||
/* border to client area */
|
||||
jrect_free(pos);
|
||||
pos = jwidget_get_child_rect(widget);
|
||||
jrect_stretch(pos, 1);
|
||||
jdraw_rectedge(pos,
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), -32, -32, -32),
|
||||
JI_COLOR_SHADE(makecol(0, 127, 255), +32, +32, +32));
|
||||
jrect_free(pos);
|
||||
}
|
||||
|
||||
static void draw_rect(JRect rect, int color, bool invert)
|
||||
{
|
||||
JRect p = jrect_new(0, 0, 0, 0);
|
||||
int c1 = JI_COLOR_SHADE(color, +32, +32, +32);
|
||||
int c2 = JI_COLOR_SHADE(color, -32, -32, -32);
|
||||
int c, h = 3;
|
||||
|
||||
if (invert) {
|
||||
c = c1;
|
||||
c1 = c2;
|
||||
c2 = c;
|
||||
}
|
||||
|
||||
jrect_replace(p, rect->x1, rect->y1, rect->x2, rect->y1+h);
|
||||
jdraw_rectshade(p, c1, color, JI_VERTICAL);
|
||||
|
||||
jrect_replace(p, rect->x1, rect->y1+h, rect->x2, rect->y2-h);
|
||||
jdraw_rectfill(p, color);
|
||||
|
||||
jrect_replace(p, rect->x1, rect->y2-h, rect->x2, rect->y2);
|
||||
jdraw_rectshade(p, color, c2, JI_VERTICAL);
|
||||
|
||||
jrect_free(p);
|
||||
}
|
||||
|
||||
static void draw_edge(JRect rect, int color, bool invert)
|
||||
{
|
||||
JRect p = jrect_new(0, 0, 0, 0);
|
||||
int c1 = JI_COLOR_SHADE(color, +90, +90, +90);
|
||||
int c2 = JI_COLOR_SHADE(color, -90, -90, -90);
|
||||
int c;
|
||||
|
||||
if (invert) {
|
||||
c = c1;
|
||||
c1 = c2;
|
||||
c2 = c;
|
||||
}
|
||||
|
||||
jrect_replace(p, rect->x1, rect->y1, rect->x2, rect->y1+1);
|
||||
jdraw_rectshade(p, c1, color, JI_HORIZONTAL);
|
||||
|
||||
jrect_moveto(p, p->x1, rect->y2-1);
|
||||
jdraw_rectshade(p, color, c2, JI_HORIZONTAL);
|
||||
|
||||
jrect_replace(p, rect->x1, rect->y1, rect->x1+1, rect->y2);
|
||||
jdraw_rectshade(p, c1, color, JI_VERTICAL);
|
||||
|
||||
jrect_moveto(p, rect->x2-1, p->y1);
|
||||
jdraw_rectshade(p, color, c2, JI_VERTICAL);
|
||||
|
||||
jrect_free(p);
|
||||
}
|
||||
|
||||
static void draw_entry_cursor(JWidget widget, int x, int y)
|
||||
{
|
||||
int h = jwidget_get_text_height(widget);
|
||||
|
||||
vline(ji_screen, x, y-1, y+h, makecol(0, 0, 0));
|
||||
vline(ji_screen, x+1, y-1, y+h, makecol(0, 0, 0));
|
||||
}
|
@ -1,214 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
void jwidget_add_tip (JWidget widget, const char *text);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box, check1, check2, button1, button2;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new("Example 18");
|
||||
box = jbox_new(JI_VERTICAL | JI_HOMOGENEOUS);
|
||||
check1 = jcheck_new("Check &1");
|
||||
check2 = jcheck_new("Check &2");
|
||||
button1 = jbutton_new("&OK");
|
||||
button2 = jbutton_new("&Cancel");
|
||||
|
||||
jwidget_add_tip(button1, "This is the \"OK\" button");
|
||||
jwidget_add_tip(button2, "This is the \"Cancel\" button");
|
||||
|
||||
jwidget_add_child(window, box);
|
||||
jwidget_add_child(box, check1);
|
||||
jwidget_add_child(box, check2);
|
||||
jwidget_add_child(box, button1);
|
||||
jwidget_add_child(box, button2);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
/**********************************************************************/
|
||||
/* tip */
|
||||
|
||||
static int tip_type();
|
||||
static bool tip_hook(JWidget widget, JMessage msg);
|
||||
|
||||
static JWidget tip_window_new(const char *text);
|
||||
static bool tip_window_hook(JWidget widget, JMessage msg);
|
||||
|
||||
typedef struct TipData {
|
||||
int time;
|
||||
char *text;
|
||||
int timer_id;
|
||||
} TipData;
|
||||
|
||||
void jwidget_add_tip(JWidget widget, const char *text)
|
||||
{
|
||||
TipData *tip = jnew(TipData, 1);
|
||||
|
||||
tip->time = -1;
|
||||
tip->text = jstrdup(text);
|
||||
tip->timer_id = -1;
|
||||
|
||||
jwidget_add_hook(widget, tip_type(), tip_hook, tip);
|
||||
}
|
||||
|
||||
static int tip_type()
|
||||
{
|
||||
static int type = 0;
|
||||
if (!type)
|
||||
type = ji_register_widget_type();
|
||||
return type;
|
||||
}
|
||||
|
||||
static bool tip_hook(JWidget widget, JMessage msg)
|
||||
{
|
||||
TipData* tip = reinterpret_cast<TipData*>(jwidget_get_data(widget, tip_type()));
|
||||
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_DESTROY:
|
||||
if (tip->timer_id >= 0)
|
||||
jmanager_remove_timer(tip->timer_id);
|
||||
|
||||
jfree(tip->text);
|
||||
jfree(tip);
|
||||
break;
|
||||
|
||||
case JM_MOUSEENTER:
|
||||
if (tip->timer_id < 0)
|
||||
tip->timer_id = jmanager_add_timer(widget, 1000);
|
||||
|
||||
jmanager_start_timer(tip->timer_id);
|
||||
break;
|
||||
|
||||
case JM_MOUSELEAVE:
|
||||
jmanager_stop_timer(tip->timer_id);
|
||||
break;
|
||||
|
||||
case JM_TIMER:
|
||||
if (msg->timer.timer_id == tip->timer_id) {
|
||||
JWidget window = tip_window_new(tip->text);
|
||||
int w = jrect_w(window->rc);
|
||||
int h = jrect_h(window->rc);
|
||||
window->remap_window();
|
||||
jwindow_position(window,
|
||||
MID(0, jmouse_x(0)-w/2, JI_SCREEN_W-w),
|
||||
MID(0, jmouse_y(0)-h/2, JI_SCREEN_H-h));
|
||||
jwindow_open(window);
|
||||
|
||||
jmanager_stop_timer(tip->timer_id);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static JWidget tip_window_new(const char *text)
|
||||
{
|
||||
JWidget window = jwindow_new(text);
|
||||
JLink link, next;
|
||||
|
||||
jwindow_sizeable(window, false);
|
||||
jwindow_moveable(window, false);
|
||||
|
||||
window->set_align(JI_CENTER | JI_MIDDLE);
|
||||
|
||||
/* remove decorative widgets */
|
||||
JI_LIST_FOR_EACH_SAFE(window->children, link, next) {
|
||||
jwidget_free(reinterpret_cast<JWidget>(link->data));
|
||||
}
|
||||
|
||||
jwidget_add_hook(window, JI_WIDGET, tip_window_hook, NULL);
|
||||
jwidget_init_theme(window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
static bool tip_window_hook(JWidget widget, JMessage msg)
|
||||
{
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_SIGNAL:
|
||||
if (msg->signal.num == JI_SIGNAL_INIT_THEME) {
|
||||
widget->border_width.l = 3;
|
||||
widget->border_width.t = 3+jwidget_get_text_height(widget);
|
||||
widget->border_width.r = 3;
|
||||
widget->border_width.b = 3;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case JM_MOUSELEAVE:
|
||||
case JM_BUTTONPRESSED:
|
||||
widget->close_window(NULL);
|
||||
break;
|
||||
|
||||
case JM_DRAW: {
|
||||
JRect pos = jwidget_get_rect(widget);
|
||||
|
||||
jdraw_rect(pos, makecol(0, 0, 0));
|
||||
|
||||
jrect_shrink(pos, 1);
|
||||
jdraw_rectfill(pos, makecol(255, 255, 140));
|
||||
|
||||
jdraw_widget_text(widget, makecol(0, 0, 0),
|
||||
makecol(255, 255, 140), false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
@ -1,391 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
/* GUI */
|
||||
void init_gui();
|
||||
void shutdown_gui();
|
||||
bool update_gui();
|
||||
void draw_gui();
|
||||
float get_speed();
|
||||
float get_reaction_pos();
|
||||
bool get_back_to_center();
|
||||
|
||||
/* Game */
|
||||
void play_game();
|
||||
|
||||
/**********************************************************************/
|
||||
/* Main routine */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
rgb_map = (RGB_MAP*)jmalloc(sizeof(RGB_MAP));
|
||||
color_map = (COLOR_MAP*)jmalloc(sizeof(COLOR_MAP));
|
||||
|
||||
create_rgb_table(rgb_map, default_palette, NULL);
|
||||
create_trans_table(color_map, default_palette, 128, 128, 128, NULL);
|
||||
|
||||
init_gui();
|
||||
play_game();
|
||||
shutdown_gui();
|
||||
|
||||
jfree(rgb_map);
|
||||
jfree(color_map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
/**********************************************************************/
|
||||
/* GUI handle */
|
||||
|
||||
static JWidget window, manager, entry, check;
|
||||
|
||||
static bool my_manager_hook(JWidget widget, JMessage msg);
|
||||
|
||||
void init_gui()
|
||||
{
|
||||
JWidget box1, box2, label, button;
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
/* hook manager behavior */
|
||||
jwidget_add_hook(manager, JI_WIDGET, my_manager_hook, NULL);
|
||||
|
||||
/* create main window */
|
||||
window = jwindow_new("Game Manager");
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL);
|
||||
label = jlabel_new("Speed:");
|
||||
entry = jentry_new(8, "4");
|
||||
check = jcheck_new("AI/Center after hit");
|
||||
button = jbutton_new("&Game Over");
|
||||
|
||||
jwidget_expansive(box2, true);
|
||||
jwidget_expansive(entry, true);
|
||||
|
||||
jwidget_add_child(window, box1);
|
||||
jwidget_add_children(box1, box2, check, button, NULL);
|
||||
jwidget_add_children(box2, label, entry, NULL);
|
||||
|
||||
jwindow_open(window);
|
||||
}
|
||||
|
||||
void shutdown_gui()
|
||||
{
|
||||
jwidget_free(window);
|
||||
jmanager_free(manager);
|
||||
manager = NULL;
|
||||
}
|
||||
|
||||
bool update_gui()
|
||||
{
|
||||
if (jmanager_generate_messages(manager))
|
||||
jmanager_dispatch_messages(manager);
|
||||
|
||||
return window->isVisible();
|
||||
}
|
||||
|
||||
void draw_gui()
|
||||
{
|
||||
jwidget_dirty(manager);
|
||||
jwidget_flush_redraw(manager);
|
||||
//jmanager_dispatch_draw_messages();
|
||||
}
|
||||
|
||||
float get_speed()
|
||||
{
|
||||
float speed = strtod(jwidget_get_text(entry), NULL);
|
||||
return speed;
|
||||
}
|
||||
|
||||
float get_reaction_pos()
|
||||
{
|
||||
return window->rc->x1-2;
|
||||
}
|
||||
|
||||
bool get_back_to_center()
|
||||
{
|
||||
return jwidget_is_selected(check);
|
||||
}
|
||||
|
||||
static bool my_manager_hook(JWidget widget, JMessage msg)
|
||||
{
|
||||
switch (msg->type) {
|
||||
|
||||
case JM_KEYPRESSED:
|
||||
/* don't use UP & DOWN keys for focus movement */
|
||||
if (msg->key.scancode == KEY_UP || msg->key.scancode == KEY_DOWN) {
|
||||
/* returning true means that we use that keys (we don't use
|
||||
that keys here, but the game use them) */
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case JM_DRAW:
|
||||
/* draw nothing (this avoid the default behavior: paint with the
|
||||
desktop color of the current manager's theme) */
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
/* Game handle */
|
||||
|
||||
#define BS 8 /* ball size */
|
||||
#define PS 40 /* player size */
|
||||
|
||||
static float ball_x, ball_y;
|
||||
static float ball_dx, ball_dy;
|
||||
static int p_y1, p_y2;
|
||||
|
||||
static int count = 0;
|
||||
static void count_inc()
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
END_OF_STATIC_FUNCTION(count_inc);
|
||||
|
||||
static void update_game();
|
||||
static void draw_game(BITMAP *bmp);
|
||||
static bool move_ball(float *x, float *y, float *dx, float *dy);
|
||||
static void calc_ball_dest(float *y);
|
||||
|
||||
void play_game()
|
||||
{
|
||||
bool gameover = false;
|
||||
bool trans_mode = false;
|
||||
BITMAP *bmp, *bmp2;
|
||||
|
||||
/* create a temporary bitmap to make double-buffered technique */
|
||||
bmp = create_bitmap(SCREEN_W, SCREEN_H);
|
||||
bmp2 = create_bitmap(SCREEN_W, SCREEN_H);
|
||||
|
||||
/* set Jinete output screen bitmap */
|
||||
ji_set_screen(bmp, bmp->w, bmp->h);
|
||||
show_mouse(NULL);
|
||||
|
||||
/* init game state */
|
||||
ball_x = SCREEN_W / 2;
|
||||
ball_y = SCREEN_H / 2;
|
||||
ball_dx = cos(AL_PI/4);
|
||||
ball_dy = sin(AL_PI/4);
|
||||
p_y1 = p_y2 = SCREEN_H / 2 - PS / 2;
|
||||
|
||||
LOCK_VARIABLE(count);
|
||||
LOCK_FUNCTION(count_inc);
|
||||
install_int_ex(count_inc, BPS_TO_TIMER(60));
|
||||
|
||||
while (!gameover) {
|
||||
while (count > 0 && !gameover) {
|
||||
update_game();
|
||||
gameover = update_gui();
|
||||
count--;
|
||||
}
|
||||
|
||||
/* use transparent bitmap */
|
||||
if (jwidget_pick(manager, mouse_x, mouse_y) == manager) {
|
||||
if (!trans_mode) {
|
||||
trans_mode = true;
|
||||
ji_set_screen(bmp2, bmp2->w, bmp2->h);
|
||||
show_mouse(NULL);
|
||||
}
|
||||
}
|
||||
else if (trans_mode) {
|
||||
trans_mode = false;
|
||||
ji_set_screen(bmp);
|
||||
show_mouse(NULL);
|
||||
}
|
||||
|
||||
/* draw game state */
|
||||
draw_game(bmp);
|
||||
|
||||
/* draw GUI */
|
||||
if (trans_mode)
|
||||
clear(bmp2);
|
||||
draw_gui();
|
||||
|
||||
/* blit to screen (with the mouse on it) */
|
||||
show_mouse(ji_screen);
|
||||
freeze_mouse_flag = true;
|
||||
if (trans_mode)
|
||||
draw_trans_sprite (bmp, bmp2, 0, 0);
|
||||
blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
freeze_mouse_flag = false;
|
||||
show_mouse(NULL);
|
||||
}
|
||||
|
||||
ji_set_screen(screen, SCREEN_W, SCREEN_H);
|
||||
destroy_bitmap(bmp);
|
||||
destroy_bitmap(bmp2);
|
||||
}
|
||||
|
||||
static void update_game()
|
||||
{
|
||||
float y, angle;
|
||||
|
||||
/* move ball */
|
||||
if (!move_ball(&ball_x, &ball_y, &ball_dx, &ball_dy)) {
|
||||
/* some player loses */
|
||||
ball_x = SCREEN_W / 2;
|
||||
ball_y = SCREEN_H / 2;
|
||||
ball_dx = cos(AL_PI/4);
|
||||
ball_dy = sin(AL_PI/4);
|
||||
}
|
||||
|
||||
/* collision ball<->player */
|
||||
if (ball_dx < 0) {
|
||||
if (ball_x >= 2 && ball_y+BS/2 >= p_y1-PS/2 &&
|
||||
ball_x <= 12 && ball_y-BS/2 <= p_y1-PS/2+PS-1) {
|
||||
angle = -AL_PI/4 + AL_PI/2 * (ball_y-(p_y1-PS/2))/PS;
|
||||
ball_dx = cos(angle);
|
||||
ball_dy = sin(angle);
|
||||
}
|
||||
}
|
||||
else if (ball_dx > 0) {
|
||||
if (ball_x >= SCREEN_W-1-12 && ball_y+BS/2 >= p_y2-PS/2 &&
|
||||
ball_x <= SCREEN_W-1-2 && ball_y-BS/2 <= p_y2-PS/2+PS-1) {
|
||||
angle = -AL_PI*3/4 - AL_PI/2 * (ball_y-(p_y2-PS/2))/PS;
|
||||
ball_dx = cos(angle);
|
||||
ball_dy = sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
/* player */
|
||||
if (key[KEY_UP])
|
||||
p_y1 -= 4;
|
||||
if (key[KEY_DOWN])
|
||||
p_y1 += 4;
|
||||
|
||||
/* IA */
|
||||
if (ball_dx > 0 && ball_x > get_reaction_pos())
|
||||
calc_ball_dest(&y);
|
||||
else if (get_back_to_center())
|
||||
y = SCREEN_H/2;
|
||||
else
|
||||
y = p_y2;
|
||||
|
||||
if (p_y2 > y) {
|
||||
p_y2 -= 4;
|
||||
if (p_y2 < y)
|
||||
p_y2 = y;
|
||||
}
|
||||
else if (p_y2 < y) {
|
||||
p_y2 += 4;
|
||||
if (p_y2 > y)
|
||||
p_y2 = y;
|
||||
}
|
||||
|
||||
/* limit players movement */
|
||||
p_y1 = MID(PS/2, p_y1, SCREEN_H-1-PS/2);
|
||||
p_y2 = MID(PS/2, p_y2, SCREEN_H-1-PS/2);
|
||||
}
|
||||
|
||||
static void draw_game(BITMAP *bmp)
|
||||
{
|
||||
float x = get_reaction_pos();
|
||||
|
||||
/* clear screen */
|
||||
clear(bmp);
|
||||
|
||||
/* reaction position */
|
||||
vline(bmp, x, 0, SCREEN_H-1, makecol(255, 255, 255));
|
||||
textout(bmp, font, "AI reaction position", x+2, 0, makecol(255, 255, 255));
|
||||
|
||||
/* draw ball */
|
||||
rectfill(bmp,
|
||||
ball_x-BS/2, ball_y-BS/2,
|
||||
ball_x-BS/2+BS-1, ball_y-BS/2+BS-1, makecol(255, 255, 255));
|
||||
|
||||
/* draw left & right players */
|
||||
rectfill(bmp,
|
||||
2, p_y1-PS/2,
|
||||
12, p_y1-PS/2+PS-1, makecol(255, 255, 255));
|
||||
rectfill(bmp,
|
||||
SCREEN_W-1-12, p_y2-PS/2,
|
||||
SCREEN_W-1-2, p_y2-PS/2+PS-1, makecol(255, 255, 255));
|
||||
}
|
||||
|
||||
static bool move_ball(float *x, float *y, float *dx, float *dy)
|
||||
{
|
||||
float speed = get_speed();
|
||||
|
||||
/* ball movement */
|
||||
*x += (*dx) * speed;
|
||||
*y += (*dy) * speed;
|
||||
|
||||
/* bouncing with walls */
|
||||
if (*dy < 0 && (*y)-BS/2 < 0)
|
||||
*dy = -(*dy);
|
||||
else if (*dy > 0 && (*y)+BS/2 > SCREEN_H-1)
|
||||
*dy = -(*dy);
|
||||
|
||||
/* ball goes out of screen */
|
||||
if (*x < 0 || *x > SCREEN_W-1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static void calc_ball_dest(float *y)
|
||||
{
|
||||
float speed = get_speed();
|
||||
float x = ball_x;
|
||||
float dx = ball_dx;
|
||||
float dy = ball_dy;
|
||||
|
||||
*y = ball_y;
|
||||
|
||||
if (speed >= 1)
|
||||
while (move_ball(&x, y, &dx, &dy));
|
||||
}
|
||||
|
@ -1,97 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, box1, box2, button_ok, button_cancel;
|
||||
JWidget label1, label2, combobox1, combobox2;
|
||||
char buf[256];
|
||||
int c;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
/* create main window */
|
||||
window = jwindow_new("Combo-boxes");
|
||||
box1 = jbox_new(JI_VERTICAL);
|
||||
box2 = jbox_new(JI_HORIZONTAL | JI_HOMOGENEOUS);
|
||||
label1 = jlabel_new("Non-editable");
|
||||
label2 = jlabel_new("Editable");
|
||||
combobox1 = jcombobox_new();
|
||||
combobox2 = jcombobox_new();
|
||||
button_ok = jbutton_new("&OK");
|
||||
button_cancel = jbutton_new("&Cancel");
|
||||
|
||||
jwidget_expansive(label1, true);
|
||||
jwidget_expansive(label2, true);
|
||||
|
||||
for (c=0; c<16; c++) {
|
||||
usprintf(buf, "Option %d", c);
|
||||
jcombobox_add_string(combobox1, buf, NULL);
|
||||
}
|
||||
|
||||
jcombobox_add_string(combobox2, "First", NULL);
|
||||
jcombobox_add_string(combobox2, "Second", NULL);
|
||||
jcombobox_add_string(combobox2, "Third", NULL);
|
||||
jcombobox_add_string(combobox2, "Fourth", NULL);
|
||||
jcombobox_add_string(combobox2, "Fifth", NULL);
|
||||
jcombobox_add_string(combobox2, "Sixth", NULL);
|
||||
jcombobox_editable(combobox2, true);
|
||||
|
||||
jwidget_add_child(window, box1);
|
||||
jwidget_add_children(box1, label1, combobox1, label2, combobox2, box2, 0);
|
||||
jwidget_add_children(box2, button_ok, button_cancel, 0);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,101 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
JWidget manager1, manager2, manager3;
|
||||
Window* window1, *window2, *window3;
|
||||
JWidget view2, view3;
|
||||
JRect rect;
|
||||
|
||||
/* Allegro stuff */
|
||||
allegro_init ();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer ();
|
||||
install_keyboard ();
|
||||
install_mouse ();
|
||||
|
||||
/* Jinete initialization */
|
||||
manager1 = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
manager2 = jmanager_new();
|
||||
manager3 = jmanager_new();
|
||||
|
||||
window1 = jwindow_new("Window1");
|
||||
window2 = jwindow_new("Window2");
|
||||
window3 = jwindow_new("Window3");
|
||||
view2 = jview_new();
|
||||
view3 = jview_new();
|
||||
|
||||
jview_attach(view2, manager2);
|
||||
jview_attach(view3, manager3);
|
||||
|
||||
jwidget_add_child(window1, view2);
|
||||
jwidget_add_child(window2, view3);
|
||||
|
||||
window1->remap_window();
|
||||
window2->remap_window();
|
||||
window3->remap_window();
|
||||
|
||||
rect = jrect_new(JI_SCREEN_W/2-100, JI_SCREEN_H/2-70,
|
||||
JI_SCREEN_W/2+100, JI_SCREEN_H/2+70);
|
||||
jwidget_set_rect(window1, rect);
|
||||
jrect_free(rect);
|
||||
|
||||
rect = jrect_new(JI_SCREEN_W/2-90, JI_SCREEN_H/2-50,
|
||||
JI_SCREEN_W/2+90, JI_SCREEN_H/2+50);
|
||||
jwidget_set_rect(window2, rect);
|
||||
jrect_free(rect);
|
||||
|
||||
rect = jrect_new(JI_SCREEN_W/2-80, JI_SCREEN_H/2-30,
|
||||
JI_SCREEN_W/2+80, JI_SCREEN_H/2+30);
|
||||
jwidget_set_rect(window3, rect);
|
||||
jrect_free(rect);
|
||||
|
||||
window1->open_window_bg();
|
||||
_jmanager_open_window(manager2, window2);
|
||||
_jmanager_open_window(manager3, window3);
|
||||
|
||||
jmanager_run(manager1);
|
||||
jmanager_free(manager1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,154 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
static const char *xml_src =
|
||||
"<root>" "\n"
|
||||
" <item>" "\n"
|
||||
" <value1>text" "\n"
|
||||
" </value1>" "\n"
|
||||
" more text" "\n"
|
||||
" </item>" "\n"
|
||||
"</root>";
|
||||
|
||||
static JWidget textsrc, textdst;
|
||||
|
||||
static void read_xml(JWidget widget);
|
||||
static void prt_xmlnode(JXmlNode node, int indent);
|
||||
static void prt(const char *format, ...);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window, hbox, vbox, button;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new("XML");
|
||||
hbox = jpanel_new(JI_VERTICAL);
|
||||
vbox = jbox_new(JI_VERTICAL);
|
||||
textsrc = jtextbox_new(xml_src, JI_WORDWRAP);
|
||||
textdst = jtextbox_new("", JI_WORDWRAP);
|
||||
button = jbutton_new("Read XML");
|
||||
|
||||
jbutton_add_command(button, read_xml);
|
||||
|
||||
jwidget_expansive(hbox, true);
|
||||
jwidget_expansive(textsrc, true);
|
||||
jwidget_expansive(textdst, true);
|
||||
jwidget_set_min_size(textsrc, 600, 200);
|
||||
jwidget_set_min_size(textdst, 600, 200);
|
||||
|
||||
jwidget_add_child(hbox, textsrc);
|
||||
jwidget_add_child(hbox, textdst);
|
||||
jwidget_add_child(vbox, hbox);
|
||||
jwidget_add_child(vbox, button);
|
||||
jwidget_add_child(window, vbox);
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
||||
static void read_xml(JWidget widget)
|
||||
{
|
||||
JXml xml;
|
||||
|
||||
prt("Processing XML...\n\n");
|
||||
|
||||
xml = jxml_new_from_string(jwidget_get_text(textsrc));
|
||||
if (!xml) {
|
||||
prt("ERROR\n");
|
||||
return;
|
||||
}
|
||||
|
||||
prt_xmlnode((JXmlNode)xml->root, 0);
|
||||
|
||||
jxml_free(xml);
|
||||
}
|
||||
|
||||
static void prt_xmlnode(JXmlNode node, int indent)
|
||||
{
|
||||
JLink link;
|
||||
int c;
|
||||
|
||||
for (c=0; c<indent; c++)
|
||||
prt(" ");
|
||||
prt("JXmlNode->value = %s\n", node->value);
|
||||
|
||||
JI_LIST_FOR_EACH(node->children, link)
|
||||
prt_xmlnode(reinterpret_cast<JXmlNode>(link->data), indent+1);
|
||||
}
|
||||
|
||||
static void prt(const char *format, ...)
|
||||
{
|
||||
const char *text;
|
||||
char buf[1024];
|
||||
char *final;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
uvsprintf(buf, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
text = jwidget_get_text(textdst);
|
||||
if (!text)
|
||||
final = jstrdup(buf);
|
||||
else {
|
||||
final = (char*)jmalloc(ustrlen(text) + ustrlen(buf) + 1);
|
||||
|
||||
ustrcpy(final, empty_string);
|
||||
ustrcat(final, text);
|
||||
ustrcat(final, buf);
|
||||
}
|
||||
|
||||
jwidget_set_text(textdst, final);
|
||||
jfree(final);
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
/* Jinete - a GUI library
|
||||
* Copyright (C) 2003-2010 David Capello.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the Jinete nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
JWidget manager, window;
|
||||
|
||||
allegro_init();
|
||||
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) < 0) {
|
||||
if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) < 0) {
|
||||
allegro_message("%s\n", allegro_error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
manager = jmanager_new();
|
||||
ji_set_standard_theme();
|
||||
|
||||
window = jwindow_new("GRID");
|
||||
{
|
||||
JWidget grid, label1, label2, label3, entry1, entry2, entry3;
|
||||
JWidget grid2, button1, button2;
|
||||
grid = jgrid_new(2, false);
|
||||
grid2 = jgrid_new(2, true);
|
||||
label1 = jlabel_new("A:");
|
||||
label2 = jlabel_new("BB:");
|
||||
label3 = jlabel_new("CCC:");
|
||||
entry1 = jentry_new(8, "");
|
||||
entry2 = jentry_new(256, "%d+%d=%d", 4, 5, 4+5);
|
||||
entry3 = jentry_new(8, "");
|
||||
button1 = jbutton_new("&OK");
|
||||
button2 = jbutton_new("&Cancel");
|
||||
|
||||
jgrid_add_child(grid, label1, 1, 1, JI_RIGHT);
|
||||
jgrid_add_child(grid, entry1, 1, 1, JI_HORIZONTAL);
|
||||
jgrid_add_child(grid, label2, 1, 1, JI_RIGHT);
|
||||
jgrid_add_child(grid, entry2, 1, 1, JI_HORIZONTAL);
|
||||
jgrid_add_child(grid, label3, 1, 1, JI_RIGHT);
|
||||
jgrid_add_child(grid, entry3, 1, 1, JI_HORIZONTAL);
|
||||
|
||||
jgrid_add_child(grid2, button1, 1, 1, JI_RIGHT | JI_HORIZONTAL);
|
||||
jgrid_add_child(grid2, button2, 1, 1, JI_RIGHT);
|
||||
jgrid_add_child(grid, grid2, 2, 1, 0);
|
||||
jwidget_add_child(window, grid);
|
||||
}
|
||||
|
||||
window->open_window_bg();
|
||||
|
||||
jmanager_run(manager);
|
||||
jmanager_free(manager);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
Binary file not shown.
Binary file not shown.
@ -1,39 +0,0 @@
|
||||
The font contained in this archive is Freeware.
|
||||
No payment is required for the use of this font. It's free!
|
||||
Commercial or personal use? It doesn't matter, it's free.
|
||||
|
||||
|
||||
I make all the fonts (over 113 of them) on my web page and
|
||||
they're all free.
|
||||
|
||||
Larabie Fonts
|
||||
It can be found at various mirror sites.
|
||||
|
||||
try:
|
||||
|
||||
www.goldenapple.com/larabiefonts
|
||||
www.delirium.com/larabiefonts
|
||||
highland.mit.edu/larabiefonts
|
||||
web.mit.edu/zudark/larabiefonts
|
||||
if all else fails there might be some links at www.globalserve.net/~rlarabie/freefont.htm
|
||||
|
||||
If you'd like to make a donation I'd be more than happy to accept it! :-)
|
||||
|
||||
No donation is too small!
|
||||
|
||||
Send anything to
|
||||
|
||||
Ray Larabie
|
||||
61 Wesley Ave.
|
||||
Port Credit
|
||||
Ontario, CANADA
|
||||
L5H 2M8
|
||||
|
||||
If you decide to send a cheque (that's how we spell it in Canada)
|
||||
make it payable to Ray Larabie.
|
||||
|
||||
Canadian or US funds? Any funds are fine with me.
|
||||
Whatever's easy for you.
|
||||
|
||||
Ray Larabie
|
||||
fonts@imail.org
|
@ -1,149 +0,0 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
#include "raster/image.h"
|
||||
#include "raster/mask.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Mask *mask = NULL;
|
||||
int redraw;
|
||||
|
||||
allegro_init();
|
||||
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0);
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
set_mouse_sprite_focus(0, 0);
|
||||
show_mouse(screen);
|
||||
|
||||
redraw = true;
|
||||
do {
|
||||
if (mouse_b) {
|
||||
int xbeg, ybeg, xend, yend, xold, yold;
|
||||
int first = mouse_b & 1;
|
||||
|
||||
xbeg = xend = mouse_x;
|
||||
ybeg = yend = mouse_y;
|
||||
xold = yold = -1;
|
||||
|
||||
while (mouse_b) {
|
||||
xend = mouse_x;
|
||||
yend = mouse_y;
|
||||
if ((xend != xold) || (yend != yold)) {
|
||||
xend = mouse_x;
|
||||
yend = mouse_y;
|
||||
|
||||
scare_mouse();
|
||||
|
||||
if (xold >= 0) {
|
||||
xor_mode (true);
|
||||
rect (screen, xbeg, ybeg, xold, yold, 0xff);
|
||||
xor_mode (false);
|
||||
}
|
||||
|
||||
xor_mode (true);
|
||||
rect (screen, xbeg, ybeg, xold = xend, yold = yend, 0xff);
|
||||
xor_mode (false);
|
||||
|
||||
unscare_mouse();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mask)
|
||||
mask = mask_new ();
|
||||
|
||||
if (key[KEY_ALT]) {
|
||||
if (first & 1)
|
||||
mask_replace (mask,
|
||||
MIN (xbeg, xend),
|
||||
MIN (ybeg, yend),
|
||||
MAX (xbeg, xend) - MIN (xbeg, xend) + 1,
|
||||
MAX (ybeg, yend) - MIN (ybeg, yend) + 1);
|
||||
else
|
||||
mask_intersect (mask,
|
||||
MIN (xbeg, xend),
|
||||
MIN (ybeg, yend),
|
||||
MAX (xbeg, xend) - MIN (xbeg, xend) + 1,
|
||||
MAX (ybeg, yend) - MIN (ybeg, yend) + 1);
|
||||
}
|
||||
else {
|
||||
if (first & 1)
|
||||
mask_union (mask,
|
||||
MIN (xbeg, xend),
|
||||
MIN (ybeg, yend),
|
||||
MAX (xbeg, xend) - MIN (xbeg, xend) + 1,
|
||||
MAX (ybeg, yend) - MIN (ybeg, yend) + 1);
|
||||
else
|
||||
mask_subtract (mask,
|
||||
MIN (xbeg, xend),
|
||||
MIN (ybeg, yend),
|
||||
MAX (xbeg, xend) - MIN (xbeg, xend) + 1,
|
||||
MAX (ybeg, yend) - MIN (ybeg, yend) + 1);
|
||||
}
|
||||
|
||||
redraw = true;
|
||||
}
|
||||
|
||||
if (key[KEY_SPACE]) {
|
||||
while (key[KEY_SPACE]);
|
||||
mask_invert (mask);
|
||||
redraw = true;
|
||||
}
|
||||
|
||||
if (redraw || key[KEY_R]) {
|
||||
BITMAP *bmp;
|
||||
int x, y;
|
||||
|
||||
redraw = false;
|
||||
|
||||
bmp = create_bitmap (SCREEN_W, SCREEN_H);
|
||||
clear (bmp);
|
||||
|
||||
if (mask) {
|
||||
if ((mask->w > 0) && (mask->h > 0))
|
||||
rect (bmp, mask->x-1, mask->y-1,
|
||||
mask->x+mask->w, mask->y+mask->h,
|
||||
makecol (255, 255, 0));
|
||||
|
||||
if (mask->bitmap) {
|
||||
for (y=0; y<mask->h; y++)
|
||||
for (x=0; x<mask->w; x++)
|
||||
if (mask->bitmap)
|
||||
putpixel (bmp, mask->x+x, mask->y+y,
|
||||
(mask->bitmap->method->getpixel (mask->bitmap, x, y))?
|
||||
makecol (255, 255, 255): makecol (0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
scare_mouse();
|
||||
blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
unscare_mouse();
|
||||
|
||||
destroy_bitmap(bmp);
|
||||
}
|
||||
} while (!key[KEY_ESC]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
@ -1,466 +0,0 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <allegro.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gui/jinete.h"
|
||||
|
||||
#include "raster/algo.h"
|
||||
#include "raster/image.h"
|
||||
#include "raster/path.h"
|
||||
|
||||
typedef struct BEZIER_NODE
|
||||
{
|
||||
char tangent;
|
||||
float prev_x, x, next_x;
|
||||
float prev_y, y, next_y;
|
||||
struct BEZIER_NODE *prev;
|
||||
struct BEZIER_NODE *next;
|
||||
} BEZIER_NODE;
|
||||
|
||||
typedef struct BEZIER_PATH
|
||||
{
|
||||
BEZIER_NODE *first, *last;
|
||||
} BEZIER_PATH;
|
||||
|
||||
BEZIER_PATH *create_bezier_path()
|
||||
{
|
||||
BEZIER_PATH *path;
|
||||
|
||||
path = jnew (BEZIER_PATH, 1);
|
||||
if (path)
|
||||
path->first = path->last = NULL;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
BEZIER_NODE *create_bezier_node(int tangent, float prev_x, float prev_y, float x, float y, float next_x, float next_y)
|
||||
{
|
||||
BEZIER_NODE *node;
|
||||
|
||||
node = jnew (BEZIER_NODE, 1);
|
||||
if (node) {
|
||||
node->tangent = tangent;
|
||||
node->prev_x = prev_x; node->x = x; node->next_x = next_x;
|
||||
node->prev_y = prev_y; node->y = y; node->next_y = next_y;
|
||||
node->prev = node->next = NULL;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
void add_bezier_node(BEZIER_PATH *path, BEZIER_NODE *node)
|
||||
{
|
||||
if (!path->first) {
|
||||
node->prev = NULL;
|
||||
path->first = node;
|
||||
}
|
||||
else {
|
||||
path->last->next = node;
|
||||
node->prev = path->last;
|
||||
}
|
||||
node->next = NULL;
|
||||
path->last = node;
|
||||
}
|
||||
|
||||
#define DRAW_BEZIER_LINE 1
|
||||
#define DRAW_BEZIER_NODES 2
|
||||
#define DRAW_BEZIER_CONTROL_POINTS 4
|
||||
#define DRAW_BEZIER_CONTROL_LINES 8
|
||||
|
||||
void draw_bezier_path(BITMAP *bmp, BEZIER_PATH *path, int flags, int color)
|
||||
{
|
||||
BEZIER_NODE *node;
|
||||
int points[8];
|
||||
|
||||
for (node=path->first; node; node=node->next) {
|
||||
/* draw the bezier spline */
|
||||
if ((flags & DRAW_BEZIER_LINE) && (node->next)) {
|
||||
points[0] = node->x;
|
||||
points[1] = node->y;
|
||||
points[2] = node->next_x;
|
||||
points[3] = node->next_y;
|
||||
points[4] = node->next->prev_x;
|
||||
points[5] = node->next->prev_y;
|
||||
points[6] = node->next->x;
|
||||
points[7] = node->next->y;
|
||||
spline(bmp, points, color);
|
||||
}
|
||||
|
||||
/* draw the control points */
|
||||
if (node->prev) {
|
||||
if (flags & DRAW_BEZIER_CONTROL_LINES)
|
||||
line(bmp, node->prev_x, node->prev_y, node->x, node->y, color);
|
||||
|
||||
if (flags & DRAW_BEZIER_CONTROL_POINTS)
|
||||
rectfill(bmp, node->prev_x-1, node->prev_y-1, node->prev_x, node->prev_y, color);
|
||||
}
|
||||
|
||||
if (node->next) {
|
||||
if (flags & DRAW_BEZIER_CONTROL_LINES)
|
||||
line(bmp, node->x, node->y, node->next_x, node->next_y, color);
|
||||
|
||||
if (flags & DRAW_BEZIER_CONTROL_POINTS)
|
||||
rectfill(bmp, node->next_x-1, node->next_y-1, node->next_x, node->next_y, color);
|
||||
}
|
||||
|
||||
/* draw the node */
|
||||
if (flags & DRAW_BEZIER_NODES)
|
||||
rectfill(bmp, node->x-1, node->y-1, node->x+1, node->y+1, color);
|
||||
|
||||
if (node == path->last)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct Point { int x, y; } Point;
|
||||
|
||||
static void add_shape_seg(int x1, int y1, int x2, int y2, JList shape)
|
||||
{
|
||||
Point *point = jnew(Point, 1);
|
||||
point->x = x2;
|
||||
point->y = y2;
|
||||
jlist_append(shape, point);
|
||||
}
|
||||
|
||||
void draw_filled_bezier_path(BITMAP *bmp, BEZIER_PATH *path, int color)
|
||||
{
|
||||
BEZIER_NODE *node;
|
||||
JList shape = jlist_new();
|
||||
JLink link;
|
||||
int c, vertices;
|
||||
int *points;
|
||||
|
||||
for (node=path->first; node; node=node->next) {
|
||||
/* draw the bezier spline */
|
||||
if (node->next) {
|
||||
algo_spline(node->x,
|
||||
node->y,
|
||||
node->next_x,
|
||||
node->next_y,
|
||||
node->next->prev_x,
|
||||
node->next->prev_y,
|
||||
node->next->x,
|
||||
node->next->y,
|
||||
(void *)shape, (AlgoLine)add_shape_seg);
|
||||
}
|
||||
|
||||
if (node == path->last)
|
||||
break;
|
||||
}
|
||||
|
||||
vertices = jlist_length(shape);
|
||||
if (vertices > 0) {
|
||||
points = (int*)jmalloc(sizeof(int) * vertices * 2);
|
||||
|
||||
c = 0;
|
||||
JI_LIST_FOR_EACH(shape, link) {
|
||||
points[c++] = ((Point *)link->data)->x;
|
||||
points[c++] = ((Point *)link->data)->y;
|
||||
}
|
||||
polygon(bmp, vertices, points, color);
|
||||
jfree(points);
|
||||
}
|
||||
|
||||
JI_LIST_FOR_EACH(shape, link);
|
||||
jfree(link->data);
|
||||
|
||||
jlist_free(shape);
|
||||
}
|
||||
|
||||
void draw_art_filled_bezier_path(BITMAP *bmp, BEZIER_PATH *path)
|
||||
{
|
||||
Image *image = image_new (IMAGE_RGB, SCREEN_W, SCREEN_H);
|
||||
Path *art_path = path_new (NULL);
|
||||
BEZIER_NODE *node;
|
||||
|
||||
node = path->first;
|
||||
if (node) {
|
||||
path_moveto (art_path, node->x, node->y);
|
||||
for (; node; node=node->next) {
|
||||
if (node->next) {
|
||||
path_curveto (art_path,
|
||||
node->next_x,
|
||||
node->next_y,
|
||||
node->next->prev_x,
|
||||
node->next->prev_y,
|
||||
node->next->x,
|
||||
node->next->y);
|
||||
}
|
||||
if (node == path->last)
|
||||
break;
|
||||
}
|
||||
path_close (art_path);
|
||||
}
|
||||
|
||||
image_clear (image, 0);
|
||||
path_fill (art_path, image, _rgba (255, 255, 255, 255));
|
||||
image_to_allegro (image, bmp, 0, 0);
|
||||
image_free (image);
|
||||
path_free (art_path);
|
||||
}
|
||||
|
||||
#define GOT_BEZIER_POINT_NULL 0
|
||||
#define GOT_BEZIER_POINT_PREV 1
|
||||
#define GOT_BEZIER_POINT_NODE 2
|
||||
#define GOT_BEZIER_POINT_NEXT 3
|
||||
|
||||
int get_bezier_point (BEZIER_PATH *path, float x, float y, BEZIER_NODE **the_node)
|
||||
{
|
||||
BEZIER_NODE *node;
|
||||
|
||||
for (node=path->first; node; node=node->next) {
|
||||
if (node->prev) {
|
||||
if ((x >= node->prev_x-1) &&
|
||||
(y >= node->prev_y-1) &&
|
||||
(x <= node->prev_x) &&
|
||||
(y <= node->prev_y)) {
|
||||
*the_node = node;
|
||||
return GOT_BEZIER_POINT_PREV;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->next) {
|
||||
if ((x >= node->next_x-1) &&
|
||||
(y >= node->next_y-1) &&
|
||||
(x <= node->next_x) &&
|
||||
(y <= node->next_y)) {
|
||||
*the_node = node;
|
||||
return GOT_BEZIER_POINT_NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
if ((x >= node->x-1) && (y >= node->y-1) &&
|
||||
(x <= node->x+1) && (y <= node->y+1)) {
|
||||
*the_node = node;
|
||||
return GOT_BEZIER_POINT_NODE;
|
||||
}
|
||||
|
||||
if (node == path->last)
|
||||
break;
|
||||
}
|
||||
|
||||
return GOT_BEZIER_POINT_NULL;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
BITMAP *virt, *background;
|
||||
BEZIER_PATH *path;
|
||||
int x[4], y[4];
|
||||
int level;
|
||||
int old_x;
|
||||
int old_y;
|
||||
|
||||
allegro_init();
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0);
|
||||
|
||||
rgb_map = jnew (RGB_MAP, 1);
|
||||
create_rgb_table(rgb_map, _current_palette, NULL);
|
||||
|
||||
path = create_bezier_path();
|
||||
|
||||
virt = create_bitmap(SCREEN_W, SCREEN_H);
|
||||
background = create_bitmap(SCREEN_W, SCREEN_H);
|
||||
clear(background);
|
||||
|
||||
level = 0;
|
||||
|
||||
do {
|
||||
/* erase */
|
||||
if (key[KEY_E]) {
|
||||
while (key[KEY_E]);
|
||||
path = create_bezier_path();
|
||||
}
|
||||
|
||||
/* close */
|
||||
if (key[KEY_C]) {
|
||||
while (key[KEY_C]);
|
||||
path->first->prev = path->last;
|
||||
path->last->next = path->first;
|
||||
}
|
||||
|
||||
poll_mouse();
|
||||
if ((mouse_x != old_x) || (mouse_y != old_y)) {
|
||||
poll_mouse();
|
||||
switch (level) {
|
||||
case 0:
|
||||
x[0] = mouse_x;
|
||||
y[0] = mouse_y;
|
||||
level = 1;
|
||||
break;
|
||||
case 1:
|
||||
x[1] = mouse_x;
|
||||
y[1] = mouse_y;
|
||||
level = 2;
|
||||
break;
|
||||
case 2:
|
||||
x[2] = mouse_x;
|
||||
y[2] = mouse_y;
|
||||
level = 3;
|
||||
break;
|
||||
case 3:
|
||||
x[3] = mouse_x;
|
||||
y[3] = mouse_y;
|
||||
level = 4;
|
||||
break;
|
||||
case 4:
|
||||
if (mouse_b & 1) {
|
||||
BEZIER_NODE *node;
|
||||
node = create_bezier_node(true,
|
||||
x[1], y[1],
|
||||
x[3], y[3],
|
||||
x[3] + x[3] - x[2], y[3] + y[3] - y[2]);
|
||||
add_bezier_node(path, node);
|
||||
}
|
||||
x[0] = x[3];
|
||||
y[0] = y[3];
|
||||
x[1] = x[3] + x[3] - x[2];
|
||||
y[1] = y[3] + y[3] - y[2];
|
||||
level = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
old_x = mouse_x;
|
||||
old_y = mouse_y;
|
||||
|
||||
if (mouse_b & 2) {
|
||||
BEZIER_NODE *node;
|
||||
int ret;
|
||||
|
||||
ret = get_bezier_point(path, mouse_x, mouse_y, &node);
|
||||
if (ret) {
|
||||
switch (ret) {
|
||||
case GOT_BEZIER_POINT_NODE:
|
||||
position_mouse (node->x, node->y);
|
||||
break;
|
||||
case GOT_BEZIER_POINT_PREV:
|
||||
position_mouse (node->prev_x, node->prev_y);
|
||||
break;
|
||||
case GOT_BEZIER_POINT_NEXT:
|
||||
position_mouse (node->next_x, node->next_y);
|
||||
break;
|
||||
}
|
||||
|
||||
while (mouse_b) {
|
||||
poll_mouse();
|
||||
if ((mouse_x != old_x) || (mouse_y != old_y)) {
|
||||
poll_mouse();
|
||||
|
||||
switch (ret) {
|
||||
|
||||
case GOT_BEZIER_POINT_NODE:
|
||||
{
|
||||
node->x += mouse_x - old_x;
|
||||
node->y += mouse_y - old_y;
|
||||
node->prev_x += mouse_x - old_x;
|
||||
node->prev_y += mouse_y - old_y;
|
||||
node->next_x += mouse_x - old_x;
|
||||
node->next_y += mouse_y - old_y;
|
||||
}
|
||||
break;
|
||||
|
||||
case GOT_BEZIER_POINT_PREV:
|
||||
node->prev_x = mouse_x;
|
||||
node->prev_y = mouse_y;
|
||||
if (node->tangent) {
|
||||
node->next_x = node->x + node->x - node->prev_x;
|
||||
node->next_y = node->y + node->y - node->prev_y;
|
||||
}
|
||||
break;
|
||||
|
||||
case GOT_BEZIER_POINT_NEXT:
|
||||
node->next_x = mouse_x;
|
||||
node->next_y = mouse_y;
|
||||
if (node->tangent) {
|
||||
node->prev_x = node->x + node->x - node->next_x;
|
||||
node->prev_y = node->y + node->y - node->next_y;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
blit(background, virt, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_CONTROL_LINES, makecol(32, 32, 32));
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_LINE, makecol(255, 0, 0));
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_CONTROL_POINTS, makecol(0, 128, 255));
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_NODES, makecol(255, 255, 255));
|
||||
|
||||
blit(virt, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
}
|
||||
old_x = mouse_x;
|
||||
old_y = mouse_y;
|
||||
|
||||
if (key[KEY_S])
|
||||
node->tangent = false;
|
||||
|
||||
if (key[KEY_T])
|
||||
node->tangent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* draw */
|
||||
blit(background, virt, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
|
||||
if (!key[KEY_LSHIFT])
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_CONTROL_LINES, makecol(32, 32, 32));
|
||||
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_LINE, makecol(255, 0, 0));
|
||||
|
||||
if (!key[KEY_LSHIFT]) {
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_CONTROL_POINTS, makecol(0, 128, 255));
|
||||
draw_bezier_path(virt, path, DRAW_BEZIER_NODES, makecol(255, 255, 255));
|
||||
}
|
||||
|
||||
/* filled */
|
||||
if (key[KEY_F]) {
|
||||
clear (screen);
|
||||
draw_filled_bezier_path (screen, path, makecol(128, 128, 128));
|
||||
draw_bezier_path (screen, path, DRAW_BEZIER_LINE, makecol(0, 0, 255));
|
||||
while (key[KEY_F]);
|
||||
}
|
||||
|
||||
/* art-filled */
|
||||
if (key[KEY_A]) {
|
||||
clear (screen);
|
||||
draw_art_filled_bezier_path (screen, path);
|
||||
while (key[KEY_A]);
|
||||
}
|
||||
|
||||
hline(virt, mouse_x-4, mouse_y, mouse_x+4, makecol(255, 255, 255));
|
||||
vline(virt, mouse_x, mouse_y-4, mouse_y+4, makecol(255, 255, 255));
|
||||
blit(virt, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
} while (!key[KEY_ESC]);
|
||||
|
||||
destroy_bitmap(virt);
|
||||
destroy_bitmap(background);
|
||||
|
||||
allegro_exit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
||||
|
@ -1,134 +0,0 @@
|
||||
/* ASE - Allegro Sprite Editor
|
||||
* Copyright (C) 2001-2010 David Capello
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <allegro.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "raster/raster.h"
|
||||
|
||||
void test ()
|
||||
{
|
||||
Image *image_screen;
|
||||
Image *image_bg;
|
||||
Sprite *sprite;
|
||||
BITMAP *bmp;
|
||||
|
||||
bmp = create_bitmap (SCREEN_W, SCREEN_H);
|
||||
sprite = sprite_new (IMAGE_RGB, 128, 128);
|
||||
image_screen = image_new (IMAGE_RGB, SCREEN_W, SCREEN_H);
|
||||
image_bg = image_new (IMAGE_RGB, SCREEN_W, SCREEN_H);
|
||||
|
||||
/* build bg */
|
||||
{
|
||||
int x, y, c;
|
||||
for (y=0; y<image_bg->h; y++) {
|
||||
for (x=0; x<image_bg->w; x++) {
|
||||
c = ((255 * y / (image_bg->h-1)) +
|
||||
(255 * x / (image_bg->w-1))) / 2;
|
||||
c += (rand () % 3) - 1;
|
||||
c = MID (0, c, 255);
|
||||
image_bg->method->putpixel (image_bg, x, y,
|
||||
_rgba (c, c, c, 255));
|
||||
}
|
||||
}
|
||||
|
||||
image_line (image_bg, image_bg->w-1, 0, 0, image_bg->h-1,
|
||||
_rgba (255, 0, 0, 255));
|
||||
}
|
||||
|
||||
/* build the layers */
|
||||
{
|
||||
Layer *layer = layer_new(sprite);
|
||||
|
||||
/* add this layer to the sprite */
|
||||
layer_add_layer(sprite->set, layer);
|
||||
|
||||
/* build the "stock" and the properties */
|
||||
{
|
||||
int i, c, image_index;
|
||||
Image *image;
|
||||
Cel *cel;
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
/* make the image */
|
||||
image = image_new (sprite->imgtype, sprite->w, sprite->h);
|
||||
image_clear (image, 0);
|
||||
for (c=0; c<image->w/2; c++) {
|
||||
int r = 255*i/31;
|
||||
int g = (255*c/(image->w/2-1)*0.8)-r;
|
||||
int b = 255*c/(image->w/2-1)-r;
|
||||
int a = 255*c/(image->w/2-1);
|
||||
image_ellipsefill (image, c, c, image->w-1-c, image->h-1-c,
|
||||
_rgba (MID(0, r, 255), MID(0, g, 255),
|
||||
MID(0, b, 255), MID(0, a, 255)));
|
||||
}
|
||||
|
||||
/* add the new image in the stock */
|
||||
image_index = sprite->stock->addImage(image);
|
||||
|
||||
/* cel properties */
|
||||
cel = cel_new(i, image_index);
|
||||
cel_set_position(cel,
|
||||
cos(AL_PI*i/16)*64,
|
||||
sin(AL_PI*i/16)*64);
|
||||
cel_set_opacity(cel, 128+sin(AL_PI*i/32)*127);
|
||||
|
||||
layer_add_cel(layer, cel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
image_copy(image_screen, image_bg, 0, 0);
|
||||
sprite_render(sprite, image_screen,
|
||||
mouse_x-sprite->w/2, mouse_y-sprite->h/2);
|
||||
image_to_allegro(image_screen, bmp, 0, 0);
|
||||
|
||||
if (key[KEY_LEFT]) sprite->frame--;
|
||||
if (key[KEY_RIGHT]) sprite->frame++;
|
||||
|
||||
text_mode(makecol (0, 0, 0));
|
||||
textprintf(bmp, font, 0, 0, makecol(255, 255, 255), "%d", sprite->frame);
|
||||
blit(bmp, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
|
||||
} while (!key[KEY_ESC]);
|
||||
|
||||
image_free(image_screen);
|
||||
image_free(image_bg);
|
||||
delete sprite;
|
||||
destroy_bitmap(bmp);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
allegro_init();
|
||||
set_color_depth(16);
|
||||
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0);
|
||||
install_timer();
|
||||
install_keyboard();
|
||||
install_mouse();
|
||||
|
||||
set_palette(default_palette);
|
||||
|
||||
test();
|
||||
return 0;
|
||||
}
|
||||
|
||||
END_OF_MAIN();
|
Loading…
x
Reference in New Issue
Block a user