Author Topic: C BASIC GUI  (Read 8933 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI
« on: November 10, 2013, 10:23:45 PM »
Ubuntu 64


Android


Windows XP



Quote
jrs@laptop:~/C_BASIC/xlate$ ./testsprite
Screen is at 32 bits per pixel
Screen is in system memory
Sprite is in system memory
Sprite blit uses RLE acceleration
438.55 frames per second
jrs@laptop:~/C_BASIC/xlate$

Code: [Select]
/* C BASIC - SDL 1.2:  Move N sprites around on the screen as fast as possible */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include "SDL.h"
#include "cbasic.h"

#define NUM_SPRITES 100
#define MAX_SPEED   1

DIM AS SDL_Surface PTR sprite;
DIM AS int numsprites;
DIM AS SDL_Rect PTR sprite_rects;
DIM AS SDL_Rect PTR positions;
DIM AS SDL_Rect PTR velocities;
DIM AS int sprites_visible;
DIM AS int debug_flip;
DIM AS Uint16 sprite_w, sprite_h;

static SUB quit(int rc)
BEGIN_SUB
  SDL_Quit();
  exit(rc);
END_SUB

FUNCTION int LoadSprite(char PTR file)
BEGIN_FUNCTION
  DIM AS SDL_Surface PTR temp;
  sprite = SDL_LoadBMP(file);
  IF (sprite EQ NULL) THEN
    PRINT_FILE (stderr, "Couldn't load %s: %s", file, SDL_GetError());
    RETURN (-1);
  END_IF
  IF (sprite->format->palette) THEN
    SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), PTR (Uint8 PTR)sprite->pixels);
  END_IF
  temp = SDL_DisplayFormat(sprite);
  SDL_FreeSurface(sprite);
  IF (temp EQ NULL) THEN
    PRINT_FILE (stderr, "Couldn't convert background: %s\n", SDL_GetError());
    RETURN (-1);
  END_IF
  sprite = temp;
  RETURN (0);
END_FUNCTION

SUB MoveSprites(SDL_Surface PTR screen, Uint32 background)
BEGIN_SUB
  DIM AS int i, nupdates;
  DIM AS SDL_Rect area, PTR position, PTR velocity;
  nupdates = 0;
  IF (sprites_visible) THEN
    SDL_FillRect(screen, NULL, background);
  END_IF
  FOR (i=0 TO i<numsprites STEP INCR i)
  BEGIN_FOR
    position = AT positions[i];
    velocity = AT velocities[i];
    position->x += velocity->x;
    IF ((position->x < 0) OR (position->x >= (screen->w - sprite_w))) THEN
      velocity->x = -velocity->x;
      position->x += velocity->x;
    END_IF
    position->y += velocity->y;
    IF ((position->y < 0) OR (position->y >= (screen->h - sprite_w)) ) THEN
      velocity->y = -velocity->y;
      position->y += velocity->y;
    END_IF
    area = PTR position;
    SDL_BlitSurface(sprite, NULL, screen, AT area);
    sprite_rects[INCR nupdates] = area;
  NEXT
  IF (debug_flip) THEN
    IF ((screen->flags & SDL_DOUBLEBUF) EQ SDL_DOUBLEBUF) THEN
      static int t = 0;
      Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
      DIM AS SDL_Rect r;
      r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
      r.y = 0;
      r.w = 20;
      r.h = screen->h;
      SDL_FillRect(screen, AT r, color);
      t += 2;
    END_IF
  END_IF
  IF ((screen->flags & SDL_DOUBLEBUF) EQ SDL_DOUBLEBUF) THEN
    SDL_Flip(screen);
  ELSE
    SDL_UpdateRects(screen, nupdates, sprite_rects);
  END_IF
  sprites_visible = 1;
END_SUB

FUNCTION Uint32 FastestFlags(Uint32 flags, int width, int height, int bpp)
BEGIN_FUNCTION
  DIM AS const SDL_VideoInfo PTR info;
  flags |= SDL_FULLSCREEN;
  info = SDL_GetVideoInfo();
  IF (info->blit_hw_CC AND info->blit_fill) THEN
    flags |= SDL_HWSURFACE;
  END_IF
  IF ((flags & SDL_HWSURFACE) EQ SDL_HWSURFACE ) THEN
    IF (info->video_mem*1024 > (height*width*bpp/8) ) THEN
      flags |= SDL_DOUBLEBUF;
    ELSE
      flags &= ~SDL_HWSURFACE;
    END_IF
  END_IF
  RETURN (flags);
END_FUNCTION

MAIN
BEGIN_FUNCTION
  DIM AS SDL_Surface PTR screen;
  DIM AS Uint8 PTR mem;
  DIM AS int width, height;
  DIM AS Uint8  video_bpp;
  DIM AS Uint32 videoflags;
  DIM AS Uint32 background;
  DIM AS int i, done;
  DIM AS SDL_Event event;
  DIM AS Uint32 start, now, frames;
  IF (SDL_Init(SDL_INIT_VIDEO) < 0) THEN
    PRINT_FILE (stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    RETURN (1);
  END_IF
  numsprites = NUM_SPRITES;
  videoflags = SDL_SWSURFACE|SDL_ANYFORMAT;
  width = 640;
  height = 480;
  video_bpp = 8;
  debug_flip = 0;
  WHILE (argc > 1)
  BEGIN_WHILE
    DECR argc;
    IF (strcmp(argv[argc-1], "-width") EQ 0 ) THEN
      width = atoi(argv[argc]);
      DECR argc;
    ELSE_IF (strcmp(argv[argc-1], "-height") EQ 0 ) THEN
      height = atoi(argv[argc]);
      DECR argc;
    ELSE_IF (strcmp(argv[argc-1], "-bpp") EQ 0 ) THEN
      video_bpp = atoi(argv[argc]);
      videoflags &= ~SDL_ANYFORMAT;
      DECR argc;
    ELSE_IF (strcmp(argv[argc], "-fast") EQ 0 ) THEN
      videoflags = FastestFlags(videoflags, width, height, video_bpp);
    ELSE_IF (strcmp(argv[argc], "-hw") EQ 0 ) THEN
      videoflags ^= SDL_HWSURFACE;
    ELSE_IF (strcmp(argv[argc], "-flip") EQ 0 ) THEN
      videoflags ^= SDL_DOUBLEBUF;
    ELSE_IF (strcmp(argv[argc], "-debugflip") EQ 0 ) THEN
      debug_flip ^= 1;
    ELSE_IF (strcmp(argv[argc], "-fullscreen") EQ 0 ) THEN
      videoflags ^= SDL_FULLSCREEN;
    ELSE_IF (isdigit(argv[argc][0]) ) THEN
      numsprites = atoi(argv[argc]);
    ELSE
      PRINT_FILE (stderr,"Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n",argv[0]);
      quit(1);
    END_IF
  WEND
  screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  IF (NOT screen) THEN
    PRINT_FILE (stderr, "Couldn't set %dx%d video mode: %s\n",width, height, SDL_GetError());
    quit(2);
  END_IF
  SDL_WM_SetCaption("C BASIC SDL 1.2 Sprites",0);
  IF (LoadSprite("icon.bmp") < 0) THEN
    quit(1);
  END_IF
  mem = (Uint8 PTR)malloc(4 * sizeof(SDL_Rect)PTR numsprites);
  IF (mem EQ NULL) THEN
    SDL_FreeSurface(sprite);
    PRINT_FILE (stderr, "Out of memory!\n");
    quit(2);
  END_IF
  sprite_rects = (SDL_Rect PTR)mem;
  positions = sprite_rects;
  sprite_rects += numsprites;
  velocities = sprite_rects;
  sprite_rects += numsprites;
  sprite_w = sprite->w;
  sprite_h = sprite->h;
  srand(time(NULL));
  FOR (i=0 TO i<numsprites STEP INCR i)
  BEGIN_FOR
    positions[i].x = rand() MOD (screen->w - sprite_w);
    positions[i].y = rand() MOD (screen->h - sprite_h);
    positions[i].w = sprite->w;
    positions[i].h = sprite->h;
    velocities[i].x = 0;
    velocities[i].y = 0;
    WHILE (NOT velocities[i].x AND NOT velocities[i].y )
    BEGIN_WHILE
      velocities[i].x = (rand() MOD (MAX_SPEED*2+1))-MAX_SPEED;
      velocities[i].y = (rand() MOD (MAX_SPEED*2+1))-MAX_SPEED;
    WEND
  NEXT
  background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
  PRINT ("Screen is at %d bits per pixel\n",screen->format->BitsPerPixel);
  IF ((screen->flags & SDL_HWSURFACE) EQ SDL_HWSURFACE) THEN
    PRINT ("Screen is in video memory\n");
  ELSE
    PRINT ("Screen is in system memory\n");
  END_IF
  IF ((screen->flags & SDL_DOUBLEBUF) EQ SDL_DOUBLEBUF) THEN
    PRINT ("Screen has double-buffering enabled\n");
  END_IF
  IF ((sprite->flags & SDL_HWSURFACE) EQ SDL_HWSURFACE ) THEN
    PRINT ("Sprite is in video memory\n");
  ELSE
    PRINT ("Sprite is in system memory\n");
  END_IF
  DIM AS SDL_Rect dst;
  dst.x = 0;
  dst.y = 0;
  dst.w = sprite->w;
  dst.h = sprite->h;
  SDL_BlitSurface(sprite, NULL, screen, AT dst);
  SDL_FillRect(screen, AT dst, background);
  IF ((sprite->flags & SDL_HWACCEL) EQ SDL_HWACCEL ) THEN
    PRINT ("Sprite blit uses hardware acceleration\n");
  END_IF
  IF ((sprite->flags & SDL_RLEACCEL) EQ SDL_RLEACCEL ) THEN
    PRINT ("Sprite blit uses RLE acceleration\n");
  END_IF
  frames = 0;
  start = SDL_GetTicks();
  done = 0;
  sprites_visible = 0;
  WHILE (NOT done)
  BEGIN_WHILE
    INCR frames;
    WHILE (SDL_PollEvent(AT event))
    BEGIN_WHILE
      SELECT_CASE(event.type)
      BEGIN_SELECT
        CASE SDL_MOUSEBUTTONDOWN:
          SDL_WarpMouse(screen->w/2, screen->h/2);
          END_CASE
        CASE SDL_KEYDOWN:
        CASE SDL_QUIT:
          done = 1;
          END_CASE
        CASE_ELSE
          END_CASE
      END_SELECT
    WEND
    MoveSprites(screen, background);
  WEND
  SDL_FreeSurface(sprite);
  free(mem);
  now = SDL_GetTicks();
  IF (now > start) THEN
    PRINT ("%2.2f frames per second\n",((double)frames*1000)/(now-start));
  END_IF
  SDL_Quit();
  RETURN (0);
END_FUNCTION

The Ubuntu 64 bit binary version is attached it you would like to give it a try yourself.
« Last Edit: November 17, 2013, 04:50:14 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - SDL 1.2 OpenGL
« Reply #1 on: November 10, 2013, 11:53:09 PM »
This is a C BASIC SDL 1.2  OpenGL example. Ubuntu 64 bit binary attached.



Code: [Select]
jrs@laptop:~/C_BASIC/SDL-1.2.15/test$ ./testgl
Screen BPP: 32

Vendor     : Tungsten Graphics, Inc
Renderer   : Mesa DRI Intel(R) Ironlake Mobile
Version    : 2.1 Mesa 8.0.4
Extensions : GL_ARB_multisample GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_copy_texture GL_EXT_polygon_offset GL_EXT_subtexture GL_EXT_texture_object GL_EXT_vertex_array GL_EXT_compiled_vertex_array GL_EXT_texture GL_EXT_texture3D GL_IBM_rasterpos_clip GL_ARB_point_parameters GL_EXT_draw_range_elements GL_EXT_packed_pixels GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_separate_specular_color GL_EXT_texture_edge_clamp GL_SGIS_generate_mipmap GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_ARB_framebuffer_sRGB GL_ARB_multitexture GL_EXT_framebuffer_sRGB GL_IBM_multimode_draw_arrays GL_IBM_texture_mirrored_repeat GL_3DFX_texture_compression_FXT1 GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_transpose_matrix GL_EXT_blend_func_separate GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_secondary_color GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_INGR_blend_func_separate GL_NV_blend_square GL_NV_light_max_exponent GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_SUN_multi_draw_arrays GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_EXT_framebuffer_object GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_MESA_window_pos GL_NV_packed_depth_stencil GL_NV_texture_rectangle GL_NV_vertex_program GL_ARB_depth_texture GL_ARB_occlusion_query GL_ARB_shadow GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_window_pos GL_ATI_envmap_bumpmap GL_EXT_stencil_two_side GL_EXT_texture_cube_map GL_NV_depth_clamp GL_NV_vertex_program1_1 GL_APPLE_packed_pixels GL_APPLE_vertex_array_object GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_vertex_program GL_ARB_vertex_shader GL_ATI_draw_buffers GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_MESA_pack_invert GL_MESA_ycbcr_texture GL_ARB_depth_clamp GL_ARB_fragment_program_shadow GL_ARB_half_float_pixel GL_ARB_point_sprite GL_ARB_shading_language_100 GL_ARB_sync GL_ARB_texture_non_power_of_two GL_ARB_vertex_buffer_object GL_ATI_blend_equation_separate GL_EXT_blend_equation_separate GL_OES_read_format GL_ARB_color_buffer_float GL_ARB_pixel_buffer_object GL_ARB_texture_compression_rgtc GL_ARB_texture_float GL_ARB_texture_rectangle GL_EXT_packed_float GL_EXT_pixel_buffer_object GL_EXT_texture_compression_rgtc GL_EXT_texture_rectangle GL_EXT_texture_sRGB GL_EXT_texture_shared_exponent GL_ARB_framebuffer_object GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_packed_depth_stencil GL_APPLE_object_purgeable GL_ARB_vertex_array_object GL_ATI_separate_stencil GL_EXT_draw_buffers2 GL_EXT_gpu_program_parameters GL_EXT_texture_array GL_EXT_texture_integer GL_EXT_texture_sRGB_decode GL_EXT_timer_query GL_OES_EGL_image GL_MESA_texture_array GL_ARB_copy_buffer GL_ARB_depth_buffer_float GL_ARB_half_float_vertex GL_ARB_map_buffer_range GL_ARB_texture_rg GL_ARB_texture_swizzle GL_ARB_vertex_array_bgra GL_EXT_separate_shader_objects GL_EXT_texture_swizzle GL_EXT_vertex_array_bgra GL_NV_conditional_render GL_ARB_ES2_compatibility GL_ARB_draw_elements_base_vertex GL_ARB_explicit_attrib_location GL_ARB_fragment_coord_conventions GL_ARB_provoking_vertex GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_shader_texture_lod GL_EXT_provoking_vertex GL_EXT_texture_snorm GL_MESA_texture_signed_rgba GL_ARB_robustness

SDL_GL_RED_SIZE: requested 5, got 8
SDL_GL_GREEN_SIZE: requested 5, got 8
SDL_GL_BLUE_SIZE: requested 5, got 8
SDL_GL_DEPTH_SIZE: requested 16, got 24
SDL_GL_DOUBLEBUFFER: requested 1, got 1
app lost mouse focus
app gained mouse focus
59.19 FPS
jrs@laptop:~/C_BASIC/SDL-1.2.15/test$

C BASIC converted SDL OpenGL example running on Ubuntu 64 bit. (see above)

Code: [Select]
// C BASIC - SDL - OpenGL
/*  gcc -o testgl testgl.c -g -O2 -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL -L/usr/lib/x86_64-linux-gnu -lSDL -lGL -lm  */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <SDL/SDL.h>

#ifdef __MACOS__
#define HAVE_OPENGL
#endif

#ifdef HAVE_OPENGL

#include <SDL/SDL_opengl.h>

/* Undefine this IF you want a flat cube instead of a rainbow cube */
#define SHADED_CUBE

/* Define this to be the name of the logo image to use with -logo */
#define LOGO_FILE "icon.bmp"

/* The SDL_OPENGLBLIT interface is deprecated.
   The code is still available FOR benchmark purposes though.
*/

#include "cbasic.h"

DIM AS static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;

DIM AS static SDL_Surface PTR global_image = NULL;
DIM AS static GLuint global_texture = 0;
DIM AS static GLuint cursor_texture = 0;

/**********************************************************************/

SUB HotKey_ToggleFullScreen()
BEGIN_SUB
  DIM AS SDL_Surface PTR screen;
  screen = SDL_GetVideoSurface();
  IF (SDL_WM_ToggleFullScreen(screen)) THEN
    PRINT("Toggled fullscreen mode - now %s\n",(screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
  ELSE
    PRINT("Unable to toggle fullscreen mode\n");
  END_IF
END_SUB

SUB HotKey_ToggleGrab()
BEGIN
  DIM AS SDL_GrabMode mode;
  PRINT("Ctrl-G: toggling input grab!\n");
  mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
  IF (mode EQ SDL_GRAB_ON) THEN
    PRINT("Grab was on\n");
  ELSE
    PRINT("Grab was off\n");
  END_IF
  mode = SDL_WM_GrabInput(!mode);
  IF (mode EQ SDL_GRAB_ON) THEN
    PRINT("Grab is now on\n");
  ELSE
    PRINT("Grab is now off\n");
  END_IF
END_SUB

SUB HotKey_Iconify()
BEGIN_SUB
  PRINT("Ctrl-Z: iconifying window!\n");
  SDL_WM_IconifyWindow();
END_SUB

FUNCTION int HandleEvent(SDL_Event PTR event)
BEGIN_FUNCTION
  DIM AS int done;
  done = 0;
  SELECT_CASE(event->type)
    BEGIN_SELECT
      CASE SDL_ACTIVEEVENT:
        PRINT("app %s ", event->active.gain ? "gained" : "lost");
        IF (event->active.state & SDL_APPACTIVE) THEN
          PRINT("active ");
        ELSE_IF (event->active.state & SDL_APPMOUSEFOCUS) THEN
          PRINT("mouse ");
        ELSE_IF (event->active.state & SDL_APPINPUTFOCUS) THEN
          PRINT("input ");
        END_IF
        PRINT("focus\n");
        END_CASE
      CASE SDL_KEYDOWN:
        IF (event->key.keysym.sym EQ SDLK_ESCAPE) THEN_DO done = 1;
        IF ((event->key.keysym.sym EQ SDLK_g) AND (event->key.keysym.mod & KMOD_CTRL)) THEN_DO HotKey_ToggleGrab();
        IF ((event->key.keysym.sym EQ SDLK_z) AND (event->key.keysym.mod & KMOD_CTRL)) THEN_DO HotKey_Iconify();
        IF ((event->key.keysym.sym EQ SDLK_RETURN) AND (event->key.keysym.mod & KMOD_ALT)) THEN_DO HotKey_ToggleFullScreen();
        PRINT("key '%s' pressed\n",
        SDL_GetKeyName(event->key.keysym.sym));
        END_CASE
      CASE SDL_QUIT:
        done = 1;
        END_CASE
  END_SELECT
  RETURN(done);
END_FUNCTION

SUB SDL_GL_Enter2DMode()
BEGIN_SUB
  DIM AS SDL_Surface PTR screen = SDL_GetVideoSurface();
  glPushAttrib(GL_ENABLE_BIT);
  glDisable(GL_DEPTH_TEST);
  glDisable(GL_CULL_FACE);
  glEnable(GL_TEXTURE_2D);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  glViewport(0, 0, screen->w, screen->h);
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  glOrtho(0.0, (GLdouble)screen->w, (GLdouble)screen->h, 0.0, 0.0, 1.0);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
END_SUB

SUB SDL_GL_Leave2DMode()
BEGIN_SUB
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  glPopAttrib();
END_SUB

FUNCTION static int power_of_two(int input)
BEGIN_FUNCTION
  DIM AS int value = 1;
  WHILE (value < input)
  BEGIN_WHILE
    value <<= 1;
  WEND
  RETURN(value);
END_FUNCTION

FUNCTION GLuint SDL_GL_LoadTexture(SDL_Surface PTR surface, GLfloat PTR texcoord)
BEGIN_FUNCTION
  DIM AS GLuint texture;
  DIM AS int w, h;
  DIM AS SDL_Surface PTR image;
  DIM AS SDL_Rect area;
  DIM AS Uint32 saved_flags;
  DIM AS Uint8 saved_alpha;
  w = power_of_two(surface->w);
  h = power_of_two(surface->h);
  texcoord[0] = 0.0f;
  texcoord[1] = 0.0f;
  texcoord[2] = (GLfloat)surface->w / w;
  texcoord[3] = (GLfloat)surface->h / h;
  image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
#if SDL_BYTEORDER EQ SDL_LIL_ENDIAN
    0x000000FF,
    0x0000FF00,
    0x00FF0000,
    0xFF000000
#else
    0xFF000000,
    0x00FF0000,
    0x0000FF00,
    0x000000FF
#endif
  );
  IF (image EQ NULL) THEN_DO RETURN 0;
  saved_flags = surface->flags AT (SDL_SRCALPHA|SDL_RLEACCELOK);
  saved_alpha = surface->format->alpha;
  IF ((saved_flags & SDL_SRCALPHA) EQ SDL_SRCALPHA) THEN_DO SDL_SetAlpha(surface, 0, 0);
  area.x = 0;
  area.y = 0;
  area.w = surface->w;
  area.h = surface->h;
  SDL_BlitSurface(surface, AT area, image, AT area);
  IF ((saved_flags & SDL_SRCALPHA) EQ SDL_SRCALPHA) THEN_DO SDL_SetAlpha(surface, saved_flags, saved_alpha);
  glGenTextures(1, AT texture);
  glBindTexture(GL_TEXTURE_2D, texture);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
  SDL_FreeSurface(image);
  RETURN(texture);
END_FUNCTION

SUB DrawLogoCursor()
BEGIN_SUB
  DIM AS static GLfloat texMinX, texMinY;
  DIM AS static GLfloat texMaxX, texMaxY;
  DIM AS static int w, h;
  DIM AS int x, y;
  IF (NOT cursor_texture) THEN
    DIM AS SDL_Surface PTR image;
    DIM AS GLfloat texcoord[4];
    image = SDL_LoadBMP(LOGO_FILE);
    IF (image EQ NULL) THEN_DO RETURN;
    w = image->w;
    h = image->h;
    cursor_texture = SDL_GL_LoadTexture(image, texcoord);
    texMinX = texcoord[0];
    texMinY = texcoord[1];
    texMaxX = texcoord[2];
    texMaxY = texcoord[3];
    SDL_FreeSurface(image);
    IF (NOT cursor_texture) THEN_DO RETURN;
  END_IF
  SDL_GetMouseState(AT x, AT y);
  x -= w/2;
  y -= h/2;
  SDL_GL_Enter2DMode();
  glBindTexture(GL_TEXTURE_2D, cursor_texture);
  glBegin(GL_TRIANGLE_STRIP);
  glTexCoord2f(texMinX, texMinY); glVertex2i(x,   y  );
  glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y  );
  glTexCoord2f(texMinX, texMaxY); glVertex2i(x,   y+h);
  glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
  glEnd();
  SDL_GL_Leave2DMode();
END_SUB

SUB DrawLogoTexture()
BEGIN_SUB
  DIM AS static GLfloat texMinX, texMinY;
  DIM AS static GLfloat texMaxX, texMaxY;
  DIM AS static int x = 0;
  DIM AS static int y = 0;
  DIM AS static int w, h;
  DIM AS static int delta_x = 1;
  DIM AS static int delta_y = 1;
  DIM AS SDL_Surface PTR screen = SDL_GetVideoSurface();
  IF (NOT global_texture) THEN
    SDL_Surface PTR image;
    GLfloat texcoord[4];
    image = SDL_LoadBMP(LOGO_FILE);
    IF (image EQ NULL) THEN_DO RETURN;
    w = image->w;
    h = image->h;
    global_texture = SDL_GL_LoadTexture(image, texcoord);
    texMinX = texcoord[0];
    texMinY = texcoord[1];
    texMaxX = texcoord[2];
    texMaxY = texcoord[3];
    SDL_FreeSurface(image);
    IF (NOT global_texture) RETURN;
  END_IF
  x += delta_x;
  IF (x < 0) THEN
    x = 0;
    delta_x = -delta_x;
  ELSE_IF ((x+w) > screen->w) THEN
    x = screen->w-w;
    delta_x = -delta_x;
  END_IF
  y += delta_y;
  IF (y < 0) THEN
    y = 0;
    delta_y = -delta_y;
  ELSE_IF ((y+h) > screen->h) THEN
    y = screen->h-h;
    delta_y = -delta_y;
  END_IF
  SDL_GL_Enter2DMode();
  glBindTexture(GL_TEXTURE_2D, global_texture);
  glBegin(GL_TRIANGLE_STRIP);
  glTexCoord2f(texMinX, texMinY); glVertex2i(x, y);
  glTexCoord2f(texMaxX, texMinY); glVertex2i(x+w, y);
  glTexCoord2f(texMinX, texMaxY); glVertex2i(x, y+h);
  glTexCoord2f(texMaxX, texMaxY); glVertex2i(x+w, y+h);
  glEnd();
  SDL_GL_Leave2DMode();
END_SUB

SUB DrawLogoBlit()
BEGIN_SUB
  DIM AS static int x = 0;
  DIM AS static int y = 0;
  DIM AS static int w, h;
  DIM AS static int delta_x = 1;
  DIM AS static int delta_y = 1;
  DIM AS SDL_Rect dst;
  DIM AS SDL_Surface PTR screen = SDL_GetVideoSurface();
  IF (global_image EQ NULL) THEN
    DIM AS SDL_Surface PTR temp;
    temp = SDL_LoadBMP(LOGO_FILE);
    IF (temp EQ NULL) RETURN;
    w = temp->w;
    h = temp->h;
    global_image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
      screen->format->BitsPerPixel,
      screen->format->Rmask,
      screen->format->Gmask,
      screen->format->Bmask,
      screen->format->Amask);
    IF (global_image) THEN_DO SDL_BlitSurface(temp, NULL, global_image, NULL);
    SDL_FreeSurface(temp);
    IF (NOT global_image) THEN_DO RETURN;
  END_IF
  x += delta_x;
  IF (x < 0) THEN
    x = 0;
    delta_x = -delta_x;
  ELSE_IF ((x+w) > screen->w) THEN
    x = screen->w-w;
    delta_x = -delta_x;
  END_IF
  y += delta_y;
  IF (y < 0) THEN
    y = 0;
    delta_y = -delta_y;
  ELSE_IF ((y+h) > screen->h) THEN
    y = screen->h-h;
    delta_y = -delta_y;
  END_IF
  dst.x = x;
  dst.y = y;
  dst.w = w;
  dst.h = h;
  SDL_BlitSurface(global_image, NULL, screen, AT dst);
  SDL_UpdateRects(screen, 1, AT dst);
END_SUB

FUNCTION int RunGLTest(int argc, char PTR argv[], int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa, int sync, int accel)
BEGIN_FUNCTION
  DIM AS int i;
  DIM AS int rgb_size[3];
  DIM AS int w = 640;
  DIM AS int h = 480;
  DIM AS int done = 0;
  DIM AS int frames;
  DIM AS Uint32 start_time, this_time;
  DIM AS float color[8][3] = {
    { 1.0,  1.0,  0.0},
    { 1.0,  0.0,  0.0},
    { 0.0,  0.0,  0.0},
    { 0.0,  1.0,  0.0},
    { 0.0,  1.0,  1.0},
    { 1.0,  1.0,  1.0},
    { 1.0,  0.0,  1.0},
    { 0.0,  0.0,  1.0}
    };
  DIM AS float cube[8][3] = {
    { 0.5,  0.5, -0.5},
    { 0.5, -0.5, -0.5},
    {-0.5, -0.5, -0.5},
    {-0.5,  0.5, -0.5},
    {-0.5,  0.5,  0.5},
    { 0.5,  0.5,  0.5},
    { 0.5, -0.5,  0.5},
    {-0.5, -0.5,  0.5}};
  DIM AS Uint32 video_flags;
  DIM AS int value;
  IF(SDL_Init(SDL_INIT_VIDEO) < 0) THEN
    PRINT_FILE(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
    exit(1);
  END_IF
  IF (bpp == 0) THEN
    IF (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) THEN
      bpp = 8;
    ELSE
      bpp = 16;
    END_IF
  END_IF
  IF (logo AND USE_DEPRECATED_OPENGLBLIT) THEN
    video_flags = SDL_OPENGLBLIT;
  ELSE
    video_flags = SDL_OPENGL;
  END_IF
  FOR (i = 1 TO argv[i] STEP INCR i)
  BEGIN_FOR
    IF (strcmp(argv[i], "-fullscreen") EQ 0) THEN_DO video_flags |= SDL_FULLSCREEN;
  NEXT
  IF (noframe) THEN_DO video_flags |= SDL_NOFRAME;
  SELECT_CASE (bpp)
  BEGIN_SELECT
    CASE 8:
      rgb_size[0] = 3;
      rgb_size[1] = 3;
      rgb_size[2] = 2;
      END_CASE
    CASE 15:
    CASE 16:
      rgb_size[0] = 5;
      rgb_size[1] = 5;
      rgb_size[2] = 5;
      END_CASE
    CASE_ELSE
      rgb_size[0] = 8;
      rgb_size[1] = 8;
      rgb_size[2] = 8;
      END_CASE
  END_SELECT
  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]);
  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]);
  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]);
  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  IF (fsaa) THEN
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
  END_IF
  IF (accel) THEN_DO SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
  IF (sync) THEN
    SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
  ELSE
    SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
  END_IF
  IF (SDL_SetVideoMode(w, h, bpp, video_flags) EQ NULL) THEN
    PRINT_FILE(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    SDL_Quit();
    exit(1);
  END_IF
  PRINT("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
  PRINT("\n");
  PRINT("Vendor     : %s\n", glGetString(GL_VENDOR));
  PRINT("Renderer   : %s\n", glGetString(GL_RENDERER));
  PRINT("Version    : %s\n", glGetString(GL_VERSION));
  PRINT("Extensions : %s\n", glGetString(GL_EXTENSIONS));
  PRINT("\n");
  SDL_GL_GetAttribute(SDL_GL_RED_SIZE, AT value);
  PRINT("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
  SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, AT value);
  PRINT("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
  SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, AT value);
  PRINT("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
  SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, AT value);
  PRINT("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value);
  SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, AT value);
  PRINT("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value);
  IF (fsaa) THEN
    SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, AT value);
    PRINT("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
    SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, AT value);
    PRINT("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value);
  END_IF
  IF (accel) THEN
    SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, AT value);
    PRINT("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
  END_IF
  IF (sync) THEN
    SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, AT value);
    printf("SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value);
  END
  SDL_WM_SetCaption("C BASIC SDL 1.2 OpenGL", "testgl");
  IF (gamma != 0.0) THEN_DO SDL_SetGamma(gamma, gamma, gamma);
  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LESS);
  glShadeModel(GL_SMOOTH);
  start_time = SDL_GetTicks();
  frames = 0;
  WHILE(NOT done)
  BEGIN_WHILE
    GLenum gl_error;
    char PTR sdl_error;
    SDL_Event event;
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_QUADS);
#ifdef SHADED_CUBE
    glColor3fv(color[0]);
    glVertex3fv(cube[0]);
    glColor3fv(color[1]);
    glVertex3fv(cube[1]);
    glColor3fv(color[2]);
    glVertex3fv(cube[2]);
    glColor3fv(color[3]);
    glVertex3fv(cube[3]);
    glColor3fv(color[3]);
    glVertex3fv(cube[3]);
    glColor3fv(color[4]);
    glVertex3fv(cube[4]);
    glColor3fv(color[7]);
    glVertex3fv(cube[7]);
    glColor3fv(color[2]);
    glVertex3fv(cube[2]);
    glColor3fv(color[0]);
    glVertex3fv(cube[0]);
    glColor3fv(color[5]);
    glVertex3fv(cube[5]);
    glColor3fv(color[6]);
    glVertex3fv(cube[6]);
    glColor3fv(color[1]);
    glVertex3fv(cube[1]);
    glColor3fv(color[5]);
    glVertex3fv(cube[5]);
    glColor3fv(color[4]);
    glVertex3fv(cube[4]);
    glColor3fv(color[7]);
    glVertex3fv(cube[7]);
    glColor3fv(color[6]);
    glVertex3fv(cube[6]);
    glColor3fv(color[5]);
    glVertex3fv(cube[5]);
    glColor3fv(color[0]);
    glVertex3fv(cube[0]);
    glColor3fv(color[3]);
    glVertex3fv(cube[3]);
    glColor3fv(color[4]);
    glVertex3fv(cube[4]);
    glColor3fv(color[6]);
    glVertex3fv(cube[6]);
    glColor3fv(color[1]);
    glVertex3fv(cube[1]);
    glColor3fv(color[2]);
    glVertex3fv(cube[2]);
    glColor3fv(color[7]);
    glVertex3fv(cube[7]);
#else
    glColor3f(1.0, 0.0, 0.0);
    glVertex3fv(cube[0]);
    glVertex3fv(cube[1]);
    glVertex3fv(cube[2]);
    glVertex3fv(cube[3]);
    glColor3f(0.0, 1.0, 0.0);
    glVertex3fv(cube[3]);
    glVertex3fv(cube[4]);
    glVertex3fv(cube[7]);
    glVertex3fv(cube[2]);
    glColor3f(0.0, 0.0, 1.0);
    glVertex3fv(cube[0]);
    glVertex3fv(cube[5]);
    glVertex3fv(cube[6]);
    glVertex3fv(cube[1]);
    glColor3f(0.0, 1.0, 1.0);
    glVertex3fv(cube[5]);
    glVertex3fv(cube[4]);
    glVertex3fv(cube[7]);
    glVertex3fv(cube[6]);
    glColor3f(1.0, 1.0, 0.0);
    glVertex3fv(cube[5]);
    glVertex3fv(cube[0]);
    glVertex3fv(cube[3]);
    glVertex3fv(cube[4]);
    glColor3f(1.0, 0.0, 1.0);
    glVertex3fv(cube[6]);
    glVertex3fv(cube[1]);
    glVertex3fv(cube[2]);
    glVertex3fv(cube[7]);
#endif
    glEnd();
    glMatrixMode(GL_MODELVIEW);
    glRotatef(5.0, 1.0, 1.0, 1.0);
    IF (logo) THEN
      IF (USE_DEPRECATED_OPENGLBLIT) THEN
        DrawLogoBlit();
      ELSE
        DrawLogoTexture();
      END_IF
    END_IF
    IF (logocursor) THEN_DO DrawLogoCursor();
    SDL_GL_SwapBuffers();
    gl_error = glGetError();
    IF(gl_error != GL_NO_ERROR) THEN_DO PRINT_FILE(stderr, "testgl: OpenGL error: %d\n", gl_error);
    sdl_error = SDL_GetError();
    IF(sdl_error[0] != '\0') THEN
      PRINT_FILE(stderr, "testgl: SDL error '%s'\n", sdl_error);
      SDL_ClearError();
    END_IF
    IF (slowly) THEN_DO SDL_Delay(20);
    WHILE (SDL_PollEvent(AT event))
    BEGIN_WHILE
      done = HandleEvent(AT event);
    WEND
    INCR frames;
  WEND
  this_time = SDL_GetTicks();
  IF (this_time != start_time) THEN_DO PRINT("%2.2f FPS\n", ((float)frames/(this_time-start_time))*1000.0);
  IF (global_image) THEN
    SDL_FreeSurface(global_image);
    global_image = NULL;
  END_IF
  IF (global_texture) THEN
    glDeleteTextures(1, AT global_texture);
    global_texture = 0;
  END_IF
  IF (cursor_texture) THEN
    glDeleteTextures(1, AT cursor_texture);
    cursor_texture = 0;
  END_IF
  SDL_Quit();
  RETURN(0);
END_FUNCTION

MAIN
BEGIN_FUNCTION
  DIM AS int i, logo, logocursor = 0;
  DIM AS int numtests;
  DIM AS int bpp = 0;
  DIM AS int slowly;
  DIM AS float gamma = 0.0;
  DIM AS int noframe = 0;
  DIM AS int fsaa = 0;
  DIM AS int accel = 0;
  DIM AS int sync = 0;
  logo = 0;
  slowly = 0;
  numtests = 1;
  FOR (i = 1 TO argv[i] STEP INCR i)
  BEGIN_FOR
    IF (strcmp(argv[i], "-twice") EQ 0) THEN_DO INCR numtests;
    IF (strcmp(argv[i], "-logo") EQ 0) THEN
      logo = 1;
      USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
    END_IF
    IF (strcmp(argv[i], "-logoblit") EQ 0) THEN
      logo = 1;
      USE_DEPRECATED_OPENGLBLIT = SDL_TRUE;
    END_IF
    IF (strcmp(argv[i], "-logocursor") EQ 0) THEN_DO logocursor = 1;
    IF (strcmp(argv[i], "-slow") EQ 0) THEN_DO slowly = 1;
    IF (strcmp(argv[i], "-bpp") EQ 0) THEN_DO bpp = atoi(argv[INCR i]);
    IF (strcmp(argv[i], "-gamma") EQ 0) THEN_DO gamma = (float)atof(argv[INCR i]);
    IF (strcmp(argv[i], "-noframe") EQ 0) THEN_DO noframe = 1;
    IF (strcmp(argv[i], "-fsaa") EQ 0) THEN_DO INCR fsaa;
    IF (strcmp(argv[i], "-accel") EQ 0) THEN_DO INCR accel;
    IF (strcmp(argv[i], "-sync") EQ 0) THEN_DO INCR sync;
    IF (strncmp(argv[i], "-h", 2) EQ 0) THEN
      PRINT("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n", argv[0]);
      exit(0);
    END_IF
  NEXT
  FOR (i = 0 TO i<numtests STEP INCR i)
  BEGIN_FOR
    RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa, sync, accel);
  NEXT
  RETURN(0);
END_FUNCTION

#else

MAIN
BEGIN_FUNCTION
  PRINT("No OpenGL support on this system\n");
  RETURN(1);
END_FUNCTION

#endif
« Last Edit: November 22, 2013, 12:53:56 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - SDL 1.2 Palette
« Reply #2 on: November 11, 2013, 12:32:58 AM »


Code: [Select]
jrs@laptop:~/C_BASIC/SDL-1.2.15/test$ ./testpalette
9195 frames, 423.05 fps
jrs@laptop:~/C_BASIC/SDL-1.2.15/test$

Attached is the Ubuntu 64 bit binary. My C to C BASIC translator isn't 100% done yet.  >:(  I'll post code when it is. Have fun playing with the examples until then.

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC IUP
« Reply #3 on: November 11, 2013, 01:14:23 AM »
Here is an example of what is coming up next for C BASIC GUI. I created this in ScriptBasic so most of the work to make a C BASIC version is already done.



Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP
« Reply #4 on: November 12, 2013, 10:41:17 PM »
Here is the IUP guage (progress bar) example in C BASIC. Attached is the the below source and the cbasic.h include file.

Ubuntu 64


WinXP


Code: [Select]
// IUP guage / progress bar example
// gcc iupguage.c -I/usr/include/iup -liup -liupcontrols -o iupguage

#include "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,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
 ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
 ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
 ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
 ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 };

SUB createimg_s()
BEGIN_SUB
  DIM AS Ihandle PTR img_start, PTR img_play, PTR img_forward, PTR img_rewind, PTR img_show;
  img_start = IupImage(22,22, pixmap_start);
  img_play = IupImage(22,22, pixmap_play);
  img_forward = IupImage(22,22, pixmap_forward);
  img_rewind = IupImage(22,22, pixmap_rewind);
  img_show = IupImage(22,22, pixmap_show);
  IupSetHandle ("img_start", img_start);
  IupSetHandle ("img_play", img_play);
  IupSetHandle ("img_forward", img_forward);
  IupSetHandle ("img_rewind", img_rewind);
  IupSetHandle ("img_show", img_show);
  IupSetAttribute (img_start, "1", "0 0 0");
  IupSetAttribute (img_start, "2", "BGCOLOR");
  IupSetAttribute (img_play, "1", "0 0 0");
  IupSetAttribute (img_play, "2", "BGCOLOR");
  IupSetAttribute (img_forward, "1", "0 0 0");
  IupSetAttribute (img_forward, "2", "BGCOLOR");
  IupSetAttribute (img_rewind, "1", "0 0 0");
  IupSetAttribute (img_rewind, "2", "BGCOLOR");
  IupSetAttribute (img_show, "1", "0 0 0");
  IupSetAttribute (img_show, "2", "BGCOLOR");
END_SUB

FUNCTION int idle_cb()
BEGIN_FUNCTION
  DIM AS char newvalue[40];
  DIM AS double value = (double)IupGetFloat(gauge, "VALUE");
  value += speed;
  IF (value > IupGetFloat(gauge, "MAX")) THEN_DO value = IupGetFloat(gauge, "MIN");
  FORMAT (newvalue, "%.7f",value);
  IupSetAttribute(gauge, "VALUE", newvalue);
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION int btn_pause_cb()
BEGIN_FUNCTION
  IF (NOT IupGetFunction("IDLE_ACTION")) THEN
    IupSetFunction("IDLE_ACTION", (Icallback) idle_cb);
  ELSE
    IupSetFunction("IDLE_ACTION", NULL);
  END_IF
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION int btn_start_cb()
BEGIN_FUNCTION
  IupSetAttribute(gauge, "VALUE", IupGetAttribute(gauge, "MIN"));
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION int btn_accelerate_cb()
BEGIN_FUNCTION
  speed *= 2;
  IF (speed > 1.0) THEN_DO speed = 1.0;
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION int btn_decelerate_cb()
BEGIN_FUNCTION
  speed /= 2;
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION int btn_show_cb()
BEGIN_FUNCTION
  IF (NOT IupGetInt(gauge,"SHOW_TEXT")) THEN
    IupSetAttribute (gauge, "SHOW_TEXT", "YES");
    IupSetAttribute (gauge, "DASHED", "NO");
  ELSE
    IupSetAttribute (gauge, "SHOW_TEXT", "NO");
    IupSetAttribute (gauge, "DASHED", "YES");
  END_IF
  RETURN IUP_DEFAULT;
END_FUNCTION

MAIN
BEGIN_FUNCTION
  DIM AS Ihandle PTR dlg;
  DIM AS Ihandle PTR vbox;
  DIM AS Ihandle PTR hbox;
  DIM AS Ihandle PTR btn_start, PTR btn_pause, PTR btn_accelerate, PTR btn_decelerate, PTR btn_show;
  IupOpen(AT argc, AT argv);       
  IupControlsOpen(); 
  gauge = IupGauge();
  IupSetAttribute(gauge,"EXPAND","YES");
  btn_start = IupButton ( "start", "btn_start_act" );
  btn_pause = IupButton ( "pause", "btn_pause_act" );
  btn_accelerate = IupButton ( "accelerate", "btn_accelerate_act" );
  btn_decelerate = IupButton ( "decelerate", "btn_decelerate_act" );
  btn_show = IupButton ( "show", "btn_show_act" );
  createimg_s();
  IupSetAttributes( btn_start, "IMAGE = img_start, TIP = Start" );
  IupSetAttributes( btn_pause, "IMAGE = img_play, TIP = Pause" );
  IupSetAttributes( btn_accelerate, "IMAGE = img_forward, TIP = Accelerate" );
  IupSetAttributes( btn_decelerate, "IMAGE = img_rewind, TIP = Decelerate" );
  IupSetAttributes( btn_show, "IMAGE = img_show, TIP = Show" );
  hbox = IupHbox
         (
           IupFill(),
           btn_pause,
           btn_start,
           btn_decelerate,
           btn_accelerate,
           btn_show,
           IupFill(),
           NULL
         );
  vbox = IupVbox ( gauge , hbox, NULL );
  IupSetAttribute(vbox, "MARGIN", "10x10");
  IupSetAttribute(vbox, "GAP", "5");
  dlg = IupDialog(vbox);
  IupSetAttributes(dlg, "TITLE=\"C BASIC - IUP Guage\"");
  IupSetCallback(btn_pause, "ACTION", (Icallback) btn_pause_cb );
  IupSetCallback(btn_start, "ACTION", (Icallback) btn_start_cb );
  IupSetCallback(btn_accelerate, "ACTION", (Icallback) btn_accelerate_cb );
  IupSetCallback(btn_decelerate, "ACTION", (Icallback) btn_decelerate_cb );
  IupSetCallback(btn_show, "ACTION", (Icallback) btn_show_cb );
  IupSetFunction( "IDLE_ACTION", (Icallback) idle_cb);
  IupShowXY(dlg,IUP_CENTER,IUP_CENTER);
  IupMainLoop ();
  IupClose (); 
  RETURN EXIT_SUCCESS;
END_FUNCTION
« Last Edit: November 13, 2013, 09:55:00 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP Scintillia
« Reply #5 on: November 13, 2013, 06:58:29 PM »
I converted the new Scintillia code edit control IUP example to C BASIC.



Code: [Select]
// C BASIC Scintillia edit control example
// gcc iupeditcode.c -I/usr/include/iup -liup -liup_scintilla -o iupeditcode

#include "cbasic.h"
#include <iup.h>
#include <iup_scintilla.h>

DIM AS const char* sampleCode = {
  "/* Block comment */\n"
  "#include<stdio.h>\n#include<iup.h>\n\n"
  "void SampleTest() {\n  printf(\"Printing float: %f\\n\", 12.5);\n}\n\n"
  "void SampleTest2() {\n  printf(\"Printing char: %c\\n\", 'c');\n}\n\n"
  "int main(int argc, char **argv) {\n"
  "  // Start up IUP\n"
  "  IupOpen(&argc, &argv);\n"
  "  IupSetGlobal(\"SINGLEINSTANCE\", \"Iup Sample\");\n\n"
  "  if(!IupGetGlobal(\"SINGLEINSTANCE\")) {\n"
  "    IupClose(); \n"
  "    return EXIT_SUCCESS; \n  }\n\n"
  "  SampleTest();\n"
  "  SampleTest2();\n"
  "  printf(\"Printing an integer: %d\\n\", 37);\n\n"
  "  IupMainLoop();\n"
  "  IupClose();\n"
  "  return EXIT_SUCCESS;\n}\n"
};

FUNCTION static int marginclick_cb(Ihandle PTR self, int margin, int line, char PTR status)
BEGIN_FUNCTION
  PRINT ("MARGINCLICK_CB(Margin: %d, Line: %d, Status:%s)\n", margin, line, status);
  PRINT ("Fold Level = %s\n", IupGetAttributeId(self, "FOLDLEVEL", line));
  IupSetfAttribute(self, "FOLDTOGGLE", "%d", line);
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int hotspotclick_cb(Ihandle PTR self, int pos, int line, int col, char PTR status)
BEGIN_FUNCTION
  DIM AS char PTR text = IupGetAttributeId(self, "LINE", line);
  PRINT ("HOTSPOTCLICK_CB (Pos: %d, Line: %d, Col: %d, Status:%s)\n", pos, line, col, status);
  PRINT ("    line text = %s\n", text);
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int button_cb(Ihandle PTR self, int button, int pressed, int x, int y, char PTR status)
BEGIN_FUNCTION
  PRINT ("BUTTON_CB = button: %d, pressed: %d, x: %d, y: %d, status: %s\n", button, pressed, x, y, status);
  (void)self;
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int motion_cb(Ihandle PTR self, int x, int y, char PTR status)
BEGIN_FUNCTION
  PRINT ("MOTION_CB = x: %d, y: %d, status: %s\n", x, y, status);
  (void)self;
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int caret_cb(Ihandle PTR self, int lin, int col, int pos)
BEGIN_FUNCTION
  PRINT ("CARET_CB = lin: %d, col: %d, pos: %d\n", lin, col, pos);
  (void)self;
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int valuechanged_cb(Ihandle PTR self)
BEGIN_FUNCTION
  PRINT ("VALUECHANGED_CB\n");
  (void)self;
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int action_cb(Ihandle PTR self, int insert, int pos, int length, char PTR text)
BEGIN_FUNCTION
  PRINT ("ACTION = insert: %d, pos: %d, lenght:%d, text: %s\n", insert, pos, length, text);
  (void)self;
  RETURN IUP_IGNORE;
END_FUNCTION

FUNCTION static void set_attribs (Ihandle PTR sci)
BEGIN_FUNCTION
  IupSetAttribute(sci, "CLEARALL", "");
  IupSetAttribute(sci, "LEXERLANGUAGE", "cpp");
  IupSetAttribute(sci, "KEYWORDS0", "void struct union enum char short int long double float signed unsigned const static extern auto register volatile bool class private protected public friend inline template virtual asm explicit typename mutable"
                                    "if else switch case default break goto return for while do continue typedef sizeof NULL new delete throw try catch namespace operator this const_cast static_cast dynamic_cast reinterpret_cast true false using"
                                    "typeid and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq");
  IupSetAttribute(sci, "STYLEFONT32", "Consolas");
  IupSetAttribute(sci, "STYLEFONTSIZE32", "11");
  IupSetAttribute(sci, "STYLECLEARALL", "Yes");  /* sets all styles to have the same attributes as 32 */
  IupSetAttribute(sci, "STYLEFGCOLOR1", "0 128 0");    // 1-C comment
  IupSetAttribute(sci, "STYLEFGCOLOR2", "0 128 0");    // 2-C++ comment line
  IupSetAttribute(sci, "STYLEFGCOLOR4", "128 0 0");    // 4-Number
  IupSetAttribute(sci, "STYLEFGCOLOR5", "0 0 255");    // 5-Keyword
  IupSetAttribute(sci, "STYLEFGCOLOR6", "160 20 20");  // 6-String
  IupSetAttribute(sci, "STYLEFGCOLOR7", "128 0 0");    // 7-Character
  IupSetAttribute(sci, "STYLEFGCOLOR9", "0 0 255");    // 9-Preprocessor block
  IupSetAttribute(sci, "STYLEFGCOLOR10", "255 0 255"); // 10-Operator
  IupSetAttribute(sci, "STYLEBOLD10", "YES");
  // 11-Identifier 
  IupSetAttribute(sci, "STYLEHOTSPOT6", "YES");
  IupSetAttribute(sci, "INSERT0", sampleCode);
  IupSetAttribute(sci, "MARGINWIDTH0", "50");
  IF (1) THEN
    IupSetAttribute(sci, "PROPERTY", "fold=1");
    IupSetAttribute(sci, "PROPERTY", "fold.compact=0");
    IupSetAttribute(sci, "PROPERTY", "fold.comment=1");
    IupSetAttribute(sci, "PROPERTY", "fold.preprocessor=1");
    IupSetAttribute(sci, "MARGINWIDTH1", "20");
    IupSetAttribute(sci, "MARGINTYPE1",  "SYMBOL");
    IupSetAttribute(sci, "MARGINMASKFOLDERS1",  "Yes");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDER=PLUS");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDEROPEN=MINUS");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDEREND=EMPTY");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDERMIDTAIL=EMPTY");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDEROPENMID=EMPTY");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDERSUB=EMPTY");
    IupSetAttribute(sci, "MARKERDEFINE", "FOLDERTAIL=EMPTY");
    IupSetAttribute(sci, "FOLDFLAGS", "LINEAFTER_CONTRACTED");
    IupSetAttribute(sci, "MARGINSENSITIVE1", "YES");
  END_IF
  PRINT ("Number of chars in this text: %s\n", IupGetAttribute(sci, "COUNT"));
  PRINT ("Number of lines in this text: %s\n", IupGetAttribute(sci, "LINECOUNT"));
  PRINT ("%s\n", IupGetAttribute(sci, "LINEVALUE"));
END_FUNCTION

SUB ScintillaTest()
BEGIN_SUB
  DIM AS Ihandle PTR dlg, PTR sci;
  IupScintillaOpen();       
  // Creates an instance of the Scintilla control
  sci = IupScintilla();
  IupSetAttribute(sci, "EXPAND", "Yes");
  IupSetCallback(sci, "MARGINCLICK_CB", (Icallback)marginclick_cb);
  IupSetCallback(sci, "HOTSPOTCLICK_CB", (Icallback)hotspotclick_cb);
  IupSetCallback(sci, "CARET_CB", (Icallback)caret_cb);
  IupSetCallback(sci, "VALUECHANGED_CB", (Icallback)valuechanged_cb);
  IupSetCallback(sci, "ACTION", (Icallback)action_cb);
  // Creates a dialog containing the control
  dlg = IupDialog(IupVbox(sci, NULL));
  IupSetAttribute(dlg, "TITLE", "C BASIC - Iup Scintilla");
  IupSetAttribute(dlg, "RASTERSIZE", "700x500");
  IupSetAttribute(dlg, "MARGIN", "10x10");
  // Shows dialog
  IupShow(dlg);
  IupSetAttribute(dlg, "RASTERSIZE", NULL);
  set_attribs(sci);
END_SUB

MAIN
BEGIN_FUNCTION
  IupOpen(AT argc, AT argv);
  ScintillaTest();
  IupMainLoop();
  IupClose();
  RETURN EXIT_SUCCESS;
END_FUNCTION

jrs@laptop:~/C_BASIC/iup$ ./iupeditcode
Number of chars in this text: 527
Number of lines in this text: 31
/* Block comment */

CARET_CB = lin: 1, col: 0, pos: 20
CARET_CB = lin: 2, col: 0, pos: 38
CARET_CB = lin: 3, col: 0, pos: 54
ACTION = insert: 1, pos: 54, lenght:1, text: #
VALUECHANGED_CB
CARET_CB = lin: 3, col: 1, pos: 55
ACTION = insert: 0, pos: 54, lenght:1, text: (null)
VALUECHANGED_CB
CARET_CB = lin: 3, col: 0, pos: 54

« Last Edit: November 14, 2013, 11:00:27 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - Boxplorer
« Reply #6 on: November 24, 2013, 02:33:32 PM »
Boxplorer is my current C BASIC conversion project that I'm working on. The SourceForge site only offered a Windows 32 bit binary version and C/SDL source code. I compiled the source on my Ubuntu 64 bit laptop (see attached) which works really well. Compiling the original version generated some warnings I need to look into but it compiled. The C BASIC version of this is disabling the mouse support as it causes too great of a shift in position with just minor movements. It also locks the mouse within the application window until it is exited. (tough to do screen shots or anything else)

Update

I have spent a couple hours on this an should have been finished with this already. The code is a mess and I'm spending half my time cleaning it up. Getting any of the other graphics to work seems to be a project in itself. A bit too alpha for me to try to make a C BASIC demo I would be willing to post. Cool stuff once this matures. Feel free to download what I already compiled and try it for yourself. Maybe the Windows version is a better choice at this point.

Ubuntu 64 screen capture - <spacebar>


Pre-compiled Boxplorer on Wine


Code: [Select]
Controls
--------
ESC                - exit the program in fullscreen mode, release the mouse in window mode (click to regrab)
ESC ESC            - exit the program
Enter              - toggle fullscreen and reload shaders
Space              - take a screenshot (.tga) and save parameters (.cfg)

mouse movement     - look around
mouse buttons      - move forward/back, remember movement direction
Alt                - move forward
press Shift, Ctrl  - double/halve movement speed
W, A, S, D         - strafe (move sideways)
Q, E               - roll

W+S, A+D           - move forward/back
forward+back       - move forward at 25% speed

up/down arrow      - modify active parameter .y
left/right arrow   - modify active parameter .x

Modes
-----
One of these modes can be active:

L      - "look around" mode: rotate camera
F      - field of vision mode: zoom / aspect ratio
R      - raymarching mode: required distance from fractal / max step count
I      - iteration mode: iteration count / iteration count for coloring
O      - ambient occlusion mode: strength of AO / scale for AO
G      - glow mode: glow strength / object distance to color curve
0...9  - user mode: modify parameters par0...par9

Par0 is used for |minRadius2| and |scale| in the default Mandelbox shader.

Here are a couple other examples that can be run in the Boxplorer.





Note: Full screen captures make great screen backgrounds.

* See site galley for more.
« Last Edit: November 25, 2013, 01:16:15 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - New IUP Matrix List
« Reply #7 on: November 25, 2013, 02:04:50 AM »
I installed the recently release IUP 3.9 version and created a C BASIC version of the new Matrix List control.



Code: [Select]
// C BASIC IUP Matrix List
// gcc cbmatrixlist.c -I/usr/include/iup -I/usr/include/cd -liup -liupcd -liupcontrols -o cbmatrixlist

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "iup.h"
#include "iupcontrols.h"
#include "cd.h"
#include "cbasic.h"


FUNCTION static int listclick_cb(Ihandle PTR self, int lin, int col, char PTR status)
BEGIN_FUNCTION
  DIM AS char PTR value = IupGetAttributeId(self, "", lin);
  IF (NOT value) THEN_DO value = "NULL";
  PRINT("click_cb(%d, %d)\n", lin, col);
  PRINT("  VALUE%d:%d = %s\n", lin, col, value);
  RETURN(IUP_DEFAULT);
END_FUNCTION

MAIN
BEGIN_FUNCTION
  DIM AS Ihandle PTR dlg, PTR mlist;
  IupOpen(AT argc, AT argv);       
  IupControlsOpen();
  mlist = IupMatrixList();
  IupSetInt(mlist, "COUNT", 10);
  IupSetInt(mlist, "VISIBLELINES", 5);
  IupSetAttribute(mlist, "COLUMNORDER", "LABEL:COLOR:IMAGE");
  IupSetAttribute(mlist, "EDITABLE", "Yes");
  IupSetAttribute(mlist, "TITLE", "Test");
  IupSetAttribute(mlist, "BGCOLOR", "220 230 240");
  IupSetAttribute(mlist, "FRAMECOLOR", "120 140 160");
  IupSetAttribute(mlist, "ITEMBGCOLOR0", "120 140 160");
  IupSetAttribute(mlist, "ITEMFGCOLOR0", "255 255 255");
  IupSetAttribute(mlist, "1", "AAA");
  IupSetAttribute(mlist, "2", "BBB");
  IupSetAttribute(mlist, "3", "CCC");
  IupSetAttribute(mlist, "4", "DDD");
  IupSetAttribute(mlist, "5", "EEE");
  IupSetAttribute(mlist, "6", "FFF");
  IupSetAttribute(mlist, "7", "GGG");
  IupSetAttribute(mlist, "8", "HHH");
  IupSetAttribute(mlist, "9", "III");
  IupSetAttribute(mlist, "10","JJJ");
  IupSetAttribute(mlist, "COLOR1", "255 0 0");
  IupSetAttribute(mlist, "COLOR2", "255 255 0");
  IupSetAttribute(mlist, "COLOR4", "0 255 255");
  IupSetAttribute(mlist, "COLOR5", "0 0 255");
  IupSetAttribute(mlist, "COLOR6", "255 0 255");
  IupSetAttribute(mlist, "COLOR7", "255 128 0");
  IupSetAttribute(mlist, "COLOR8", "255 128 128");
  IupSetAttribute(mlist, "COLOR9", "0 255 128");
  IupSetAttribute(mlist, "COLOR10", "128 255 128");
  IupSetAttribute(mlist, "ITEMACTIVE3", "NO");
  IupSetAttribute(mlist, "ITEMACTIVE7", "NO");
  IupSetAttribute(mlist, "ITEMACTIVE8", "NO");
  IupSetAttribute(mlist, "IMAGEACTIVE9", "No");
  IupSetAttribute(mlist, "IMAGEVALUE1", "ON");
  IupSetAttribute(mlist, "IMAGEVALUE2", "ON");
  IupSetAttribute(mlist, "IMAGEVALUE3", "ON");
  dlg = IupDialog(IupVbox(mlist, NULL));
  IupSetAttribute(dlg, "TITLE", "IupMatrixList");
  IupSetAttribute(dlg, "MARGIN", "10x10");
  IupSetCallback(mlist,"LISTCLICK_CB",(Icallback)listclick_cb);
  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
  IupMainLoop();
  IupClose(); 
  RETURN(EXIT_SUCCESS);
END_FUNCTION

jrs@laptop:~/C_BASIC/xlate$ ./cbmatrixlist
click_cb(4, 2)
  VALUE4:2 = DDD
click_cb(0, 3)
  VALUE0:3 = Test
jrs@laptop:~/C_BASIC/xlate$
« Last Edit: November 25, 2013, 02:12:35 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP CBox example
« Reply #8 on: November 26, 2013, 10:00:36 PM »
I have been trying to fine a simple way to compile IUP GUI application under Windows as easily as it is under Linux. I thought I would share my way of creating console-less Windows applications that uses themes, icons and other .RC resources. Here is the screen shot from the next C BASIC IUP example  I'm doing that shows how to use fixed positioning. I will also be showing the Gtk Linux IUP version of this and the standard IUP way of placing controls in containers and using attributes for positioning and size.



I use my F: drive for development and keep the libraries I use in separate directories.

Code: [Select]
F:\C_BASIC\xlate>windres -i iup.rc -o iup.o
F:\C_BASIC\xlate>gcc cbox.c -I F:\iup\include -L F:\iup -mwindows -lcomctl32 -liup -liupcontrols iup.o -o cbox.exe
F:\C_BASIC\xlate>cbox

cbox.exe = 44,032 bytes

This is how it works on Ubuntu 64 bit Linux.



Code: [Select]
jrs@laptop:~/C_BASIC/xlate$ gcc cbox.c -I /usr/include/iup -liup -liupcontrols -o cbox
jrs@laptop:~/C_BASIC/xlate$ ./cbox

Code: [Select]
// C BASIC - IUP CBox example (fixed positioning)
// gcc cbox.c -I /usr/include/iup -liup -liupcontrols -o cbox

#include <stdlib.h>
#include <stdio.h>
#include <iup.h>
#include <iupcontrols.h>

#include "cbasic.h"

DIM AS static unsigned char img_bits1[] =
{
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1
,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1
,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,2,0,2,0,2,0,2,2,0,2,2,2,0,0,0,2,2,2,0,0,2,0,2,2,0,0,0,2,2,2
,2,2,2,0,2,0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2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
};

FUNCTION static Ihandle PTR create_mat()
BEGIN_FUNCTION
  DIM AS Ihandle *mat = IupMatrix(NULL);
  IupSetAttribute(mat, "NUMCOL", "1");
  IupSetAttribute(mat, "NUMLIN", "3");
  IupSetAttribute(mat, "NUMCOL_VISIBLE", "1");
  IupSetAttribute(mat, "NUMLIN_VISIBLE", "3");
  IupSetAttribute(mat, "EXPAND", "NO");
  IupSetAttribute(mat, "SCROLLBAR", "NO");
  IupSetAttribute(mat, "0:0", "Inflation");
  IupSetAttribute(mat, "1:0", "Medicine ");
  IupSetAttribute(mat, "2:0", "Food");
  IupSetAttribute(mat, "3:0", "Energy");
  IupSetAttribute(mat, "0:1", "January 2000");
  IupSetAttribute(mat, "1:1", "5.6");
  IupSetAttribute(mat, "2:1", "2.2");
  IupSetAttribute(mat, "3:1", "7.2");
  IupSetAttribute(mat,"BGCOLOR","255 255 255");
  IupSetAttribute(mat,"BGCOLOR1:0","255 128 0");
  IupSetAttribute(mat,"BGCOLOR2:1","255 128 0");
  IupSetAttribute(mat,"FGCOLOR2:0","255 0 128");
  IupSetAttribute(mat,"FGCOLOR1:1","255 0 128");
  IupSetAttribute(mat,"CX","600");
  IupSetAttribute(mat,"CY","250");
  RETURN(mat);
END_FUNCTION

FUNCTION static Ihandle PTR createtree()
BEGIN_FUNCTION
  DIM AS Ihandle *tree = IupTree();
  IupSetAttributes(tree, "FONT=COURIER_NORMAL_10, \
                          NAME=Figures, \
                          ADDBRANCH=3D, \
                          ADDBRANCH=2D, \
                          ADDLEAF1=trapeze, \
                          ADDBRANCH1=parallelogram, \
                          ADDLEAF2=diamond, \
                          ADDLEAF2=square, \
                          ADDBRANCH4=triangle, \
                          ADDLEAF5=scalenus, \
                          ADDLEAF5=isosceles, \
                          ADDLEAF5=equilateral, \
                          RASTERSIZE=180x180, \
                          VALUE=6, \
                          CTRL=ON, \
                          SHIFT=ON, \
                          CX=600, \
                          CY=10, \
                          ADDEXPANDED=NO");
  RETURN(tree);
END FUNCTION

SUB func_1 ()
BEGIN_SUB
  DIM AS Ihandle PTR _cbox,
                 PTR _cnv_1,
                 PTR dlg,
                 PTR img,
                 PTR _frm_1,
                 PTR _frm_2,
                 PTR _frm_3,
                 PTR hbox,
                 PTR _ctrl_1,
                 PTR _list_1,
                 PTR _list_2,
                 PTR _list_3,
                 PTR _text_1,
                 PTR _ml_1;
  img = IupImage(32,32, img_bits1);
  IupSetHandle ("img1", img);
  IupSetAttribute (img, "0", "0 0 0");
  IupSetAttribute (img, "1", "BGCOLOR");
  IupSetAttribute (img, "2", "255 0 0");
  img = IupImage(32,32, img_bits2);
  IupSetHandle ("img2", img);
  IupSetAttribute (img, "0", "0 0 0");
  IupSetAttribute (img, "1", "0 255 0");
  IupSetAttribute (img, "2", "BGCOLOR");
  IupSetAttribute (img, "3", "255 0 0");
  _frm_1 = IupFrame(
    IupVbox(
      IupSetAttributes(IupButton("Button Text", NULL), "CINDEX=1"),
      IupSetAttributes(IupButton("", NULL), "IMAGE=img1,CINDEX=2"),
      IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2,CINDEX=3"),
      NULL));
  IupSetAttribute(_frm_1,"TITLE","IupButton");
  IupSetAttribute(_frm_1,"CX","10");
  IupSetAttribute(_frm_1,"CY","180");
  _frm_2 = IupFrame(
    IupVbox(
      IupSetAttributes(IupLabel("Label Text"), "CINDEX=1"),
      IupSetAttributes(IupLabel(""), "SEPARATOR=HORIZONTAL,CINDEX=2"),
      IupSetAttributes(IupLabel(""), "IMAGE=img1,CINDEX=3"),
      NULL));
  IupSetAttribute(_frm_2,"TITLE","IupLabel");
  IupSetAttribute(_frm_2,"CX","200");
  IupSetAttribute(_frm_2,"CY","250");
  _frm_3 = IupFrame(
    IupVbox(
      IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON,CINDEX=1"),
      IupSetAttributes(IupToggle("", NULL), "IMAGE=img1,IMPRESS=img2,CINDEX=2"),
      IupSetAttributes(IupFrame(IupRadio(IupVbox(
        IupSetAttributes(IupToggle("Toggle Text", NULL), "CINDEX=3"),
        IupSetAttributes(IupToggle("Toggle Text", NULL), "CINDEX=4"),
        NULL))), "TITLE=IupRadio"),
      NULL));
  IupSetAttribute(_frm_3,"TITLE","IupToggle");
  IupSetAttribute(_frm_3,"CX","400");
  IupSetAttribute(_frm_3,"CY","250");
  _text_1 = IupText( NULL);
  IupSetAttribute(_text_1,"VALUE","IupText Text");
  IupSetAttribute(_text_1,"SIZE","80x");
  IupSetAttribute(_text_1,"CINDEX","1");
  IupSetAttribute(_text_1,"CX","10");
  IupSetAttribute(_text_1,"CY","100");
  _ml_1 = IupMultiLine( NULL);
  IupSetAttribute(_ml_1,"VALUE","IupMultiline Text\nSecond Line\nThird Line");
  IupSetAttribute(_ml_1,"SIZE","80x60");
  IupSetAttribute(_ml_1,"CINDEX","1");
  IupSetAttribute(_ml_1,"CX","200");
  IupSetAttribute(_ml_1,"CY","100");
  _list_1 = IupList( NULL);
  IupSetAttribute(_list_1,"VALUE","1");
  IupSetAttribute(_list_1,"1","Item 1 Text");
  IupSetAttribute(_list_1,"2","Item 2 Text");
  IupSetAttribute(_list_1,"3","Item 3 Text");
  IupSetAttribute(_list_1,"CINDEX","1");
  IupSetAttribute(_list_1,"CX","10");
  IupSetAttribute(_list_1,"CY","10");
  _list_2 = IupList( NULL);
  IupSetAttribute(_list_2,"DROPDOWN","YES");
  IupSetAttribute(_list_2,"VALUE","2");
  IupSetAttribute(_list_2,"1","Item 1 Text");
  IupSetAttribute(_list_2,"2","Item 2 Text");
  IupSetAttribute(_list_2,"3","Item 3 Text");
  IupSetAttribute(_list_2,"CINDEX","2");
  IupSetAttribute(_list_2,"CX","200");
  IupSetAttribute(_list_2,"CY","10");
  _list_3 = IupList( NULL);
  IupSetAttribute(_list_3,"EDITBOX","YES");
  IupSetAttribute(_list_3,"VALUE","3");
  IupSetAttribute(_list_3,"1","Item 1 Text");
  IupSetAttribute(_list_3,"2","Item 2 Text");
  IupSetAttribute(_list_3,"3","Item 3 Text");
  IupSetAttribute(_list_3,"CINDEX","3");
  IupSetAttribute(_list_3,"CX","400");
  IupSetAttribute(_list_3,"CY","10");
  _cnv_1 = IupCanvas( NULL);
  IupSetAttribute(_cnv_1,"RASTERSIZE","100x100");
  IupSetAttribute(_cnv_1,"POSX","0");
  IupSetAttribute(_cnv_1,"POSY","0");
  IupSetAttribute(_cnv_1,"BGCOLOR","128 255 0");
  IupSetAttribute(_cnv_1,"CX","400");
  IupSetAttribute(_cnv_1,"CY","150");
  _ctrl_1 = IupVal(NULL);
  IupSetAttribute(_ctrl_1,"CX","600");
  IupSetAttribute(_ctrl_1,"CY","200");
  _cbox = IupCbox(
    _text_1,
    _ml_1,
    _list_1,
    _list_2,
    _list_3,
    _cnv_1,
    _ctrl_1,
    createtree(),
    create_mat(),
    _frm_1,
    _frm_2,
    _frm_3,
    NULL);
  IupSetAttribute(_cbox,"SIZE","480x200");
  hbox = IupSetAttributes(IupHbox(_cbox, NULL), "MARGIN=10x10");
  dlg = IupDialog(hbox);
  IupSetHandle("dlg",dlg);
  IupSetAttribute(dlg,"TITLE","C BASIC IUP CBox example");
END_SUB

MAIN
BEGIN_FUNCTION
  IupOpen(AT argc, AT argv);     
  IupControlsOpen();     
  func_1();
  IupShowXY(IupGetHandle("dlg"),IUP_CENTER,IUP_CENTER);
  IupMainLoop();
  IupClose(); 
  RETURN(EXIT_SUCCESS);
END_FUNCTION
« Last Edit: November 28, 2013, 08:54:43 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - SDL Draw
« Reply #9 on: November 27, 2013, 08:29:48 PM »
I have converted the SDL Draw (2D graphic primitives) library example to C BASIC.



Code: [Select]
// C BASIC SDL Draw example
// gcc -o sdldrawtest sdldrawtest.c -g -O2 -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -DHAVE_OPENGL -lSDL -lm -lSDL_draw

#ifdef WIN32
#include <windows.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>

#include "SDL.h"
#include "SDL_draw.h"

#include "cbasic.h"

FUNCTION Uint32 FastestFlags(Uint32 flags, unsigned int width, unsigned int height, unsigned int bpp)
BEGIN_FUNCTION
  DIM AS const SDL_VideoInfo PTR info;
  flags |= SDL_FULLSCREEN;
  info = SDL_GetVideoInfo();
  IF (info->blit_hw_CC AND info->blit_fill) THEN_DO flags |= SDL_HWSURFACE;
  IF ((flags & SDL_HWSURFACE) EQ SDL_HWSURFACE) THEN
    IF (info->video_mem * 1024 > (height * width * bpp / 8)) THEN
      flags |= SDL_DOUBLEBUF;
    ELSE
      flags &= ~SDL_HWSURFACE;
    END_IF
  END_IF
  RETURN(flags);
END_FUNCTION

#ifdef WIN32
FUNCTION int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
BEGIN_FUNCTION
  RETURN(main(__argc, __argv));
END_FUNCTION
#endif

MAIN
BEGIN_FUNCTION
  DIM AS SDL_Surface PTR screen;
  DIM AS int width, height;
  DIM AS Uint8  video_bpp;
  DIM AS Uint32 videoflags;
  DIM AS int done;
  DIM AS SDL_Event event;
  DIM AS Uint32 then, now, frames;
  IF (SDL_Init(SDL_INIT_VIDEO) < 0 ) THEN
    PRINT_FILE(stderr, "SDL_Init problem: %s", SDL_GetError());
    exit(1);
  END_IF
  atexit(SDL_Quit);
  videoflags = SDL_SWSURFACE | SDL_ANYFORMAT;
  width = 640;
  height = 480;
  video_bpp = 0;
  WHILE (argc > 1)
  BEGIN_WHILE
    DECR argc;
    IF (strcmp(argv[argc-1], "-width") EQ 0) THEN
      width = atoi(argv[argc]);
      DECR argc;
    ELSE_IF (strcmp(argv[argc-1], "-height") EQ 0) THEN
      height = atoi(argv[argc]);
      DECR argc;
    ELSE_IF (strcmp(argv[argc-1], "-bpp") EQ 0) THEN
      video_bpp = atoi(argv[argc]);
      videoflags &= ~SDL_ANYFORMAT;
      DECR argc;
    ELSE_IF (strcmp(argv[argc], "-fast") EQ 0) THEN
      videoflags = FastestFlags(videoflags, width, height, video_bpp);
    ELSE_IF (strcmp(argv[argc], "-hw") EQ 0) THEN
      videoflags ^= SDL_HWSURFACE;
    ELSE_IF (strcmp(argv[argc], "-flip") EQ 0 ) THEN
      videoflags ^= SDL_DOUBLEBUF;
    ELSE_IF (strcmp(argv[argc], "-fullscreen") EQ 0) THEN
      videoflags ^= SDL_FULLSCREEN;
    ELSE
      PRINT_FILE( stderr, "Use: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen]\n", argv[0]);
      exit(1);
    END_IF
  WEND
  screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  IF (NOT screen) THEN
    PRINT_FILE (stderr, "I can not activate video mode: %dx%d: %s\n", width, height, SDL_GetError());
    exit(2);
  END_IF
  SDL_WM_SetCaption("C BASIC SDL Graphic Primitives", 0);
  DIM AS Uint32 c_white = SDL_MapRGB(screen->format, 255, 255, 255);
  DIM AS Uint32 c_gray = SDL_MapRGB(screen->format, 200, 200, 200);
  DIM AS Uint32 c_dgray= SDL_MapRGB(screen->format, 64, 64, 64);
  DIM AS Uint32 c_cyan = SDL_MapRGB(screen->format, 32, 255, 255);
  Draw_Line(screen, 100, 100, 30, 0, c_white);
  Draw_Line(screen, 30, 0, 100, 100, c_white);
  Draw_Line(screen, 100, 100, 30, 0, c_white);
  Draw_Line(screen, 30, 0, 100, 100, c_white);
  Draw_Line(screen, 0, 0, 100, 100, c_white);
  Draw_Line(screen, 100, 100, 300, 200, c_white);
  Draw_Line(screen, 200, 300, 250, 400, SDL_MapRGB(screen->format, 128, 128, 255));
  Draw_Line(screen, 500, 50, 600, 70, SDL_MapRGB(screen->format, 128, 255, 128));
  Draw_Line(screen, 500, 50, 600, 70, SDL_MapRGB(screen->format, 128, 255, 128));
  Draw_Circle(screen, 100, 100, 50, c_white);
  Draw_Circle(screen, 150, 150, 5, c_white);
  Draw_Circle(screen, 150, 150, 4, SDL_MapRGB(screen->format, 64, 64, 64));
  Draw_Circle(screen, 150, 150, 3, SDL_MapRGB(screen->format, 255, 0, 0));
  Draw_Circle(screen, 150, 150, 2, SDL_MapRGB(screen->format, 0, 255, 0));
  Draw_Circle(screen, 150, 150, 1, SDL_MapRGB(screen->format, 0, 0, 255));
  Draw_Line(screen, 500, 100, 600, 120, SDL_MapRGB(screen->format, 128, 255, 128));
  Draw_Circle(screen, 601, 121, 2, c_white);
  Draw_Circle(screen, 400, 200, 2, c_white);
  Draw_Line(screen, 400, 200, 409, 200, c_white);
  Draw_Circle(screen, 409, 200, 2, c_white);
  Draw_Line(screen, 400, 200, 400, 250, c_white);
  Draw_Circle(screen, 400, 250, 2, c_white);
  Draw_Line(screen, 409, 200, 400, 250, c_white);
  Draw_Line(screen, 400, 300, 409, 300, c_gray);
  Draw_Line(screen, 400, 300, 400, 350, c_gray);
  Draw_Line(screen, 409,300, 400, 350, c_dgray);
  Draw_Rect(screen, 398, 298, 4, 4, c_cyan);
  Draw_Rect(screen, 407, 298, 4, 4, c_cyan);
  Draw_Rect(screen, 398, 348, 4, 4, c_cyan);
  Draw_HLine(screen, 10, 400, 50, c_white);
  Draw_VLine(screen, 60, 400, 360, c_white);
  Draw_Rect(screen, 500, 400, 50, 50, c_white);
  Draw_Pixel(screen, 510, 410, c_white);
  Draw_Pixel(screen, 520, 420, SDL_MapRGB(screen->format, 255, 0, 0));
  Draw_Pixel(screen, 530, 430, SDL_MapRGB(screen->format, 0, 255, 0));
  Draw_Pixel(screen, 540,440, SDL_MapRGB(screen->format, 0, 0, 255));
  Draw_Ellipse(screen, 100, 300, 60, 30, c_white);
  Draw_FillEllipse(screen, 300, 300, 30, 60, SDL_MapRGB(screen->format, 64, 64, 200));
  Draw_Ellipse(screen, 300, 300, 30, 60, SDL_MapRGB(screen->format, 255, 0, 0));
  Draw_Round(screen, 200, 20, 70, 50, 10, c_white);
  Draw_Round(screen, 300, 20, 70, 50, 20, SDL_MapRGB(screen->format, 255, 0, 0));
  Draw_FillRound(screen, 390, 20, 70, 50, 20, SDL_MapRGB(screen->format, 255, 0, 0));
  Draw_Round(screen, 390, 20, 70, 50, 20, c_cyan);
  Draw_Rect(screen, 499, 199, 52, 72, SDL_MapRGB(screen->format, 255, 255, 0));
  Draw_FillRect(screen, 500, 200, 50, 70, SDL_MapRGB(screen->format, 64, 200, 64));
  Draw_FillCircle(screen, 500, 330, 30, c_cyan);
  SDL_UpdateRect(screen, 0, 0, 0, 0);
  frames = 0;
  then = SDL_GetTicks();
  done = 0;
  WHILE (NOT done)
  BEGIN_WHILE
    INCR frames;
    WHILE (SDL_PollEvent(AT event))
    BEGIN_WHILE
      SELECT_CASE (event.type)
      BEGIN_SELECT
        CASE SDL_KEYDOWN:
        CASE SDL_QUIT:
          done = 1;
          END_CASE
        CASE_ELSE
          END_CASE
      END_SELECT
    WEND
  WEND
  now = SDL_GetTicks();
  IF (now > then) THEN_DO PRINT("%2.2f frames per second\n", ((double)frames * 1000) / (now - then));
  PRINT_FILE(stderr, "[END]\n");
  RETURN(0);
END_FUNCTION

jrs@laptop:~/C_BASIC/xlate$ ./sdldrawtest
1343906.66 frames per second
[END]
jrs@laptop:~/C_BASIC/xlate$

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP Sample
« Reply #10 on: November 27, 2013, 11:32:57 PM »
This is an example of using IUP's container positioning and sizing to obtain the desired design results. I resized the Ubuntu 64 version horizontally from the initial size created at load time.  Notice the second row (hbox) is not defined to resize. (val, progress bar, tabs)

Ubuntu 64


Windows XP


« Last Edit: November 28, 2013, 12:39:42 AM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP Sample - Windows 7 64 bit
« Reply #11 on: November 28, 2013, 10:05:18 PM »
I was able to get the C BASIC IUP Sample to compile on Windows 7 64 bit using TDM-GCC64 and a bit of AIR manifest magic to make it all work. This is my first Windows 64 bit build with IUP and I plan to continue on this path. There is no future in WinBox32 (sysWOW64 32 bit emulator) and those that continue to predict otherwise will find themselves frozen in time. (DOS, QB, Rapid-Q, PowerBASIC, ...)



IUP allows nesting of controls and attributes forwarding its ID down the line. If you prefer the line by line create, set attributes and attach for readability, it's your choice.

Code: [Select]
// C BASIC IUP Sample
// gcc sample.c -I/usr/include/iup -liup -o sample

#include <stdlib.h>
#include <stdio.h>
#include <iup.h>

#include "cbasic.h"

FUNCTION static Ihandle* load_image_Tecgraf()
BEGIN_FUNCTION
  DIM AS unsigned char imgdata[] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 95, 108, 1, 90, 100, 117, 99, 123, 138, 166, 126, 137, 152, 181, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 105, 123, 147, 122, 137, 165, 255, 136, 152, 183, 255, 132, 149, 179, 250, 133, 149, 178, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 100, 115, 43, 111, 125, 150, 253, 140, 158, 190, 255, 135, 151, 182, 255, 132, 149, 179, 255, 131, 147, 177, 217, 153, 164, 188, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 113, 134, 148, 134, 151, 182, 255, 137, 154, 185, 255, 115, 129, 154, 252, 114, 128, 155, 255, 130, 146, 175, 255, 132, 147, 175, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 158, 159, 162, 3, 108, 121, 145, 230, 144, 162, 195, 255, 137, 154, 185, 197, 74, 79, 86, 45, 41, 46, 55, 246, 120, 134, 162, 255, 129, 145, 174, 156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 101, 113, 48, 124, 139, 167, 255, 144, 161, 194, 255, 138, 155, 186, 67, 0, 0, 0, 0, 49, 54, 62, 150, 87, 98, 118, 255, 128, 144, 173, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 113, 132, 105, 137, 154, 185, 255, 139, 156, 188, 231, 143, 159, 187, 3, 0, 0, 0, 0, 64, 68, 76, 61, 70, 79, 95, 255, 127, 143, 172, 254, 134, 149, 175, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 121, 142, 153, 141, 159, 191, 255, 139, 156, 188, 164, 0, 0, 0, 0, 0, 0, 0, 0, 79, 82, 87, 3, 69, 77, 92, 241, 122, 137, 165, 255, 127, 142, 170, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 122, 146, 191, 145, 163, 196, 255, 139, 156, 188, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 86, 101, 190, 115, 129, 156, 255, 126, 141, 170, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 125, 149, 227, 150, 168, 201, 255, 141, 157, 188, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 91, 107, 144, 113, 127, 153, 255, 125, 140, 169, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 163, 165, 167, 2, 112, 125, 150, 252, 155, 173, 203, 255, 143, 159, 189, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 94, 110, 109, 114, 128, 155, 255, 125, 140, 168, 175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 167, 181, 1, 120, 130, 149, 33, 48, 53, 59, 69, 43, 46, 52, 100, 50, 54, 59, 137, 116, 130, 156, 255, 155, 171, 201, 255, 105, 118, 142, 155, 104, 117, 141, 151, 105, 118, 141, 151, 105, 118, 142, 151, 101, 113, 136, 185, 111, 124, 150, 255, 116, 130, 156, 220, 112, 125, 148, 95, 115, 127, 150, 67, 123, 134, 156, 33, 168, 176, 190, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 119, 129, 147, 5, 109, 121, 142, 71, 106, 118, 140, 140, 105, 117, 140, 197, 107, 120, 144, 242, 120, 135, 162, 255, 123, 137, 163, 255, 44, 49, 58, 255, 28, 32, 39, 255, 125, 139, 164, 255, 150, 167, 197, 255, 138, 155, 186, 255, 131, 148, 178, 255, 125, 141, 170, 255, 119, 134, 162, 255, 114, 128, 154, 255, 108, 122, 147, 255, 104, 117, 141, 255, 102, 115, 138, 255, 103, 116, 139, 255, 107, 120, 145, 255, 111, 124, 149, 245, 113, 126, 151, 200, 113, 127, 152, 140, 116, 129, 154, 71, 122, 135, 158, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 118, 128, 145, 14, 106, 118, 140, 130, 104, 116, 139, 234, 105, 118, 142, 255, 128, 144, 173, 255, 147, 165, 199, 255, 157, 177, 213, 255, 150, 168, 202, 255, 140, 156, 187, 229, 41, 45, 52, 196, 39, 43, 51, 183, 130, 143, 168, 255, 144, 161, 192, 233, 109, 122, 145, 109, 105, 116, 138, 109, 99, 110, 130, 109, 92, 103, 123, 109, 91, 100, 117, 145, 97, 109, 131, 255, 95, 106, 128, 248, 74, 83, 97, 193, 64, 72, 85, 227, 56, 63, 75, 255, 55, 62, 75, 255, 65, 73, 88, 255, 90, 101, 121, 255, 111, 125, 150, 255, 114, 128, 154, 236, 116, 129, 155, 130, 127, 140, 165, 16, 0, 0, 0, 0,
    95, 101, 113, 22, 103, 115, 137, 220, 103, 116, 140, 255, 110, 123, 148, 255, 146, 165, 198, 255, 147, 165, 197, 232, 142, 158, 188, 147, 131, 144, 169, 78, 115, 123, 139, 20, 0, 0, 0, 0, 0, 0, 0, 0, 91, 97, 108, 68, 128, 142, 167, 255, 144, 162, 193, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 100, 107, 31, 120, 135, 163, 255, 133, 150, 180, 231, 0, 0, 0, 0, 0, 0, 0, 0, 86, 89, 93, 20, 50, 54, 61, 73, 37, 40, 46, 141, 33, 36, 42, 230, 46, 52, 63, 255, 107, 120, 144, 255, 116, 130, 157, 255, 118, 133, 159, 223, 132, 147, 174, 24,
    76, 83, 95, 114, 104, 117, 140, 255, 105, 117, 141, 255, 118, 133, 160, 253, 139, 155, 184, 116, 134, 143, 161, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 100, 110, 74, 122, 137, 163, 255, 143, 160, 191, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 114, 120, 31, 123, 138, 166, 255, 136, 153, 183, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90, 93, 97, 5, 42, 45, 51, 111, 86, 97, 117, 253, 118, 133, 160, 255, 119, 133, 161, 255, 133, 149, 180, 116,
    46, 50, 56, 109, 67, 76, 91, 255, 105, 118, 142, 255, 107, 120, 145, 254, 112, 125, 149, 131, 127, 139, 161, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 98, 109, 74, 116, 130, 156, 255, 142, 159, 190, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 115, 122, 31, 128, 143, 172, 255, 141, 157, 185, 228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 124, 137, 163, 7, 122, 136, 162, 122, 120, 135, 162, 254, 121, 136, 164, 255, 136, 152, 184, 255, 126, 141, 168, 116,
    71, 74, 79, 17, 31, 35, 41, 206, 42, 47, 57, 255, 77, 87, 105, 255, 103, 116, 140, 255, 110, 124, 149, 239, 112, 125, 150, 157, 115, 128, 153, 89, 122, 134, 158, 30, 147, 158, 177, 2, 0, 0, 0, 0, 81, 87, 96, 65, 109, 123, 148, 255, 141, 158, 190, 212, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 103, 112, 31, 135, 151, 180, 255, 141, 156, 183, 231, 0, 0, 0, 0, 153, 164, 183, 1, 134, 147, 171, 30, 124, 138, 165, 84, 123, 138, 165, 154, 122, 137, 164, 235, 127, 143, 172, 255, 140, 157, 189, 255, 144, 162, 195, 255, 129, 144, 172, 218, 126, 138, 161, 22,
    0, 0, 0, 0, 64, 68, 73, 7, 39, 43, 49, 118, 32, 36, 42, 225, 30, 35, 42, 255, 50, 57, 68, 255, 72, 81, 97, 255, 91, 102, 123, 255, 105, 118, 142, 255, 113, 127, 152, 240, 115, 129, 155, 204, 111, 124, 149, 196, 111, 125, 150, 255, 126, 141, 170, 234, 119, 133, 159, 120, 120, 134, 160, 116, 121, 135, 161, 117, 121, 135, 162, 119, 116, 130, 155, 152, 127, 142, 170, 255, 125, 140, 168, 248, 123, 138, 166, 199, 130, 145, 173, 235, 140, 155, 183, 255, 143, 160, 190, 255, 143, 161, 193, 255, 147, 165, 199, 255, 145, 164, 197, 255, 132, 148, 177, 230, 127, 140, 166, 126, 124, 134, 151, 12, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 141, 144, 3, 55, 58, 63, 58, 37, 40, 46, 126, 34, 38, 44, 184, 34, 38, 44, 235, 35, 39, 47, 254, 49, 55, 66, 255, 64, 72, 87, 255, 77, 87, 104, 255, 88, 98, 118, 255, 96, 108, 130, 255, 103, 116, 139, 255, 108, 122, 147, 255, 113, 127, 153, 255, 118, 133, 160, 255, 124, 140, 168, 255, 133, 148, 176, 255, 141, 156, 183, 255, 146, 161, 187, 255, 144, 159, 186, 255, 131, 146, 174, 254, 127, 141, 168, 237, 126, 141, 168, 188, 123, 137, 162, 131, 112, 123, 143, 61, 128, 132, 140, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 94, 98, 19, 64, 68, 73, 56, 53, 57, 65, 82, 62, 67, 76, 116, 66, 74, 89, 255, 95, 107, 129, 255, 80, 88, 103, 155, 81, 90, 105, 151, 86, 95, 112, 151, 95, 104, 122, 151, 98, 109, 128, 180, 124, 139, 166, 255, 109, 122, 146, 218, 100, 110, 128, 84, 96, 104, 118, 56, 105, 109, 117, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 174, 176, 2, 74, 83, 98, 252, 131, 147, 178, 255, 140, 155, 184, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 122, 134, 157, 114, 151, 169, 203, 255, 123, 138, 165, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 76, 90, 224, 122, 137, 165, 255, 136, 152, 182, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 125, 139, 165, 147, 146, 164, 198, 255, 122, 137, 165, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 69, 81, 191, 110, 124, 149, 255, 134, 151, 181, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 170, 193, 142, 160, 192, 255, 122, 137, 164, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 63, 74, 150, 94, 105, 127, 255, 133, 149, 179, 166, 0, 0, 0, 0, 0, 0, 0, 0, 115, 119, 128, 5, 130, 145, 174, 242, 137, 154, 186, 255, 125, 139, 166, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 58, 66, 102, 72, 81, 97, 255, 132, 148, 178, 236, 148, 161, 187, 5, 0, 0, 0, 0, 110, 121, 140, 64, 140, 157, 189, 255, 127, 142, 171, 254, 131, 144, 169, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 65, 71, 43, 47, 52, 63, 255, 127, 143, 172, 255, 132, 148, 177, 75, 0, 0, 0, 0, 121, 134, 158, 160, 139, 156, 188, 255, 123, 138, 165, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 156, 158, 1, 36, 39, 46, 227, 106, 119, 143, 255, 130, 145, 175, 203, 114, 125, 147, 51, 123, 138, 166, 247, 131, 147, 177, 255, 123, 138, 165, 151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 41, 47, 143, 68, 77, 93, 255, 128, 144, 174, 255, 126, 141, 170, 252, 129, 145, 174, 255, 123, 138, 166, 255, 127, 141, 167, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 68, 73, 40, 34, 38, 46, 250, 117, 131, 158, 255, 126, 142, 171, 255, 124, 140, 168, 255, 125, 139, 166, 214, 140, 152, 172, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 44, 50, 134, 58, 66, 79, 255, 123, 138, 166, 255, 123, 138, 166, 250, 127, 140, 165, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 154, 156, 158, 1, 46, 50, 55, 83, 82, 89, 102, 123, 106, 116, 136, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

  DIM AS Ihandle* image = IupImageRGBA(32, 32, imgdata);
  RETURN(image);
END_FUNCTION

FUNCTION static Ihandle* load_image_LogoTecgraf()
BEGIN_FUNCTION
  DIM AS unsigned char imgdata[] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, 120, 143, 125, 132, 148, 178, 173, 133, 149, 178, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 110, 130, 48, 130, 147, 177, 254, 124, 139, 167, 254, 131, 147, 176, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 128, 153, 134, 142, 159, 191, 194, 47, 52, 61, 110, 114, 128, 154, 222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 143, 172, 192, 140, 156, 188, 99, 65, 69, 76, 16, 97, 109, 131, 251, 129, 144, 172, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 147, 175, 232, 140, 157, 188, 43, 0, 0, 0, 0, 100, 112, 134, 211, 126, 141, 169, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 78, 88, 26, 48, 52, 57, 60, 135, 150, 178, 254, 108, 121, 145, 83, 105, 118, 142, 76, 106, 119, 143, 201, 118, 133, 159, 122, 117, 129, 152, 25, 168, 176, 190, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    118, 128, 145, 3, 104, 117, 140, 92, 114, 127, 152, 180, 131, 147, 177, 237, 133, 149, 178, 249, 38, 42, 50, 222, 137, 152, 180, 249, 126, 142, 170, 182, 114, 128, 154, 182, 104, 117, 140, 227, 95, 107, 128, 238, 83, 93, 112, 248, 84, 95, 113, 239, 104, 117, 141, 180, 115, 129, 155, 93, 127, 140, 165, 4,
    98, 109, 130, 153, 109, 123, 147, 254, 145, 163, 195, 153, 138, 154, 182, 56, 115, 123, 138, 5, 92, 99, 109, 35, 134, 149, 177, 230, 0, 0, 0, 0, 0, 0, 0, 0, 120, 133, 159, 143, 135, 151, 181, 115, 86, 89, 93, 5, 41, 45, 51, 54, 40, 45, 53, 150, 107, 120, 144, 254, 122, 137, 164, 154,
    51, 57, 66, 147, 83, 93, 112, 255, 108, 121, 145, 159, 113, 126, 151, 62, 123, 136, 159, 8, 87, 93, 103, 35, 125, 141, 169, 230, 0, 0, 0, 0, 0, 0, 0, 0, 129, 143, 169, 143, 140, 156, 184, 115, 134, 147, 172, 8, 124, 138, 165, 60, 124, 139, 167, 155, 131, 147, 177, 255, 131, 147, 176, 153,
    64, 68, 73, 2, 36, 39, 45, 86, 41, 46, 54, 173, 60, 67, 80, 232, 75, 84, 101, 251, 89, 100, 120, 228, 105, 118, 142, 250, 110, 123, 148, 187, 118, 132, 158, 187, 126, 141, 169, 229, 134, 149, 177, 239, 136, 152, 179, 250, 136, 152, 181, 234, 139, 156, 186, 175, 130, 145, 173, 90, 124, 134, 151, 3,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 74, 79, 19, 60, 64, 73, 50, 92, 103, 124, 254, 86, 95, 111, 84, 90, 100, 117, 76, 126, 141, 168, 201, 113, 126, 150, 119, 99, 105, 117, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 93, 105, 125, 231, 135, 151, 181, 46, 0, 0, 0, 0, 137, 154, 184, 212, 123, 137, 164, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 83, 98, 191, 133, 149, 179, 102, 111, 121, 139, 17, 134, 150, 180, 252, 126, 140, 166, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 48, 57, 132, 121, 136, 164, 197, 121, 135, 161, 115, 130, 146, 175, 221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 47, 52, 46, 87, 98, 118, 254, 126, 142, 170, 254, 124, 139, 166, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 57, 67, 118, 115, 128, 152, 170, 127, 140, 164, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

  DIM AS Ihandle* image = IupImageRGBA(16, 16, imgdata);
  RETURN(image);
END_FUNCTION

DIM AS static unsigned char img_bits1[] =
{
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1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(%s)=%s\n", IupGetClassName(ih), IupGetAttribute(ih, "VALUE"));
  RETURN(IUP_DEFAULT);
END_FUNCTION

FUNCTION static int getfocus_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  PRINT ("GETFOCUS_CB(%s)\n", IupGetClassName(ih));
  RETURN IUP_DEFAULT;
END_FUNCTION

FUNCTION static int killfocus_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  PRINT ("KILLFOCUS_CB(%s)\n", IupGetClassName(ih));
  RETURN(IUP_DEFAULT);
END_FUNCTION

FUNCTION static int leavewindow_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  PRINT ("LEAVEWINDOW_CB(%s)\n", IupGetClassName(ih));
  RETURN(IUP_DEFAULT);
END_FUNCTION

FUNCTION static int enterwindow_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  PRINT ("ENTERWINDOW_CB(%s)\n", IupGetClassName(ih));
  RETURN(IUP_DEFAULT);
END_FUNCTION

// Internal SDK function
char PTR iupKeyCodeToName(int code);

FUNCTION static int k_any(Ihandle PTR ih, int c)
BEGIN_FUNCTION
  IF (iup_isprint(c)) THEN
    PRINT ("K_ANY(%s, %d = %s \'%c\')\n", IupGetClassName(ih), c, iupKeyCodeToName(c), (char)c);
  ELSE
    PRINT ("K_ANY(%s, %d = %s)\n", IupGetClassName(ih), c, iupKeyCodeToName(c));
  END_IF
  IF (c EQ K_r) THEN
  IupRecordInput("inputtest.iup", IUP_RECTEXT);
  RETURN(IUP_IGNORE);
  END_IF
  IF (c EQ K_s) THEN
  IupRecordInput(NULL, 0);
  IupPlayInput(NULL);
  RETURN(IUP_IGNORE);
  END_IF
  IF (c EQ K_p) THEN
  IupPlayInput("inputtest.iup");
  RETURN(IUP_IGNORE);
  END_IF
  RETURN(IUP_CONTINUE);
END_FUNCTION

FUNCTION static int help_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  PRINT ("HELP_CB(%s)\n", IupGetClassName(ih));
  RETURN(IUP_DEFAULT);
END_FUNCTION

static SUB show_menu(Ihandle PTR ih)
BEGIN_SUB
  DIM AS int x, y;
  DIM AS Ihandle PTR menu_file = IupMenu(
    IupSetAttributes(IupItem("Item with Image", "item_cb"), "IMAGE=image_tec"),
    IupSetAttributes(IupItem("Toggle using VALUE", NULL), "VALUE=ON, KEY=K_V"),
    IupSetAttributes(IupItem("Auto &Toggle", "item_cb"), "AUTOTOGGLE=YES, VALUE=OFF, IMAGE=image_test, IMPRESS=image_test_pressed"),
    IupSeparator(),
    IupItem("E&xit (Close)", NULL),
    NULL);
  DIM AS Ihandle PTR menu = IupMenu(
    IupSetAttributes(IupSubmenu("Submenu", menu_file), "KEY=K_S, IMAGE=image_tec"),
    IupItem("Item", "item_cb"),
    IupSetAttributes(IupItem("Item", "item_cb"), "VALUE=ON"),
    IupSetAttributes(IupItem("Item", "item_cb"), "KEY=K_I, IMAGE=image_tec"),
    NULL);
  x = IupGetInt(ih, "X");
  y = IupGetInt(ih, "Y") + IupGetInt2(ih, "RASTERSIZE");
  IupPopup(menu, x, y);
  IupDestroy(menu);
END_SUB

FUNCTION static int action1_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  show_menu(ih);
  RETURN(IUP_DEFAULT);
END_FUNCTION

FUNCTION static int action2_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  IupSetAttribute(IupGetDialog(ih), "BGCOLOR", "0 128 0");
  RETURN(IUP_DEFAULT);
END_FUNCTION

FUNCTION static int action3_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  PRINT ("ACTION3\n");
  RETURN(IUP_DEFAULT);
END_FUNCTION

FUNCTION static Ihandle* set_callbacks(Ihandle PTR ih)
BEGIN_FUNCTION
  IupSetCallback(ih, "VALUECHANGED_CB", (Icallback)valuechanged_cb);
  IupSetCallback(ih, "K_ANY", (Icallback)k_any);
  RETURN(ih);
END_FUNCTION

static SUB globalkeypress_cb(int code, int pressed)
BEGIN_SUB
  PRINT ("GLOBALKEYPRESS_CB(code=%s, pressed=%d)\n", iupKeyCodeToName(code), pressed);
END_SUB

static SUB globalmotion_cb(int x, int y, char PTR status)
BEGIN_SUB
  PRINT ("GLOBALMOTION_CB(x=%d, y=%d, status=%s)\n", x, y, status);
END_SUB

static SUB globalbutton_cb(int button, int pressed, int x, int y, char PTR status)
BEGIN_SUB
  PRINT ("GLOBALBUTTON_CB(button=%c, pressed=%d, x=%d, y=%d, status=%s)\n", (char)button, pressed, x, y, status);
END_SUB

static SUB globalwheel_cb(float delta,int x, int y, char PTR status)
BEGIN_SUB
  PRINT ("GLOBALWHEEL_CB(delta=%g, x=%d, y=%d, status=%s)\n", delta, x, y, status);
END_SUB

SUB SampleTest()
BEGIN_SUB
  DIM AS Ihandle PTR mnu,
                 PTR _hbox_1,
                 PTR _cnv_1,
                 PTR _vbox_1,
                 PTR dlg,
                 PTR img,
                 PTR _frm_1,
                 PTR _frm_2,
                 PTR _frm_3,
                 PTR _frm_4,
                 PTR _frm_5,
                 PTR pbar,
                 PTR val,
                 PTR tabs,
                 PTR _list_1,
                 PTR _list_2,
                 PTR _list_3,
                 PTR _text_1,
                 PTR _ml_1,
                 PTR tree;
  img = load_image_Tecgraf();
  IupSetHandle ("img1", img);
  img = IupImage(32,32, img_bits2);
  IupSetHandle ("img2", img);
  IupSetAttribute (img, "0", "0 0 0");
  IupSetAttribute (img, "1", "0 255 0");
  IupSetAttribute (img, "2", "BGCOLOR");
  IupSetAttribute (img, "3", "255 0 0");

  mnu = IupMenu(
    IupSubmenu("IupSubmenu 1", IupMenu(
      IupSetAttributes(IupItem("IupItem 1 Checked", NULL), "VALUE=ON"),
      IupSeparator(),
      IupSetAttributes(IupItem("IupItem 2 Disabled", NULL), "ACTIVE=NO"),
      NULL)),
    IupItem("IupItem 3", NULL),
    IupItem("IupItem 4", NULL),
    NULL);
  IupSetHandle("mnu",mnu);

  _frm_1 = IupFrame(
    IupVbox(
      set_callbacks(IupSetAttributes(IupButton("Button Text", NULL), "PADDING=5x5")),
      IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton("Text", NULL), "IMAGE=img1, PADDING=5x5")),"ACTION", action1_cb, NULL),
      IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton(NULL, NULL), "IMAGE=img1")),"ACTION", action2_cb, NULL),
      IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2")),"ACTION", action3_cb, NULL),
      IupSetCallbacks(set_callbacks(IupSetAttributes(IupButton(NULL, NULL), "BGCOLOR=\"255 0 128\", SIZE=20x10")),"ACTION", action3_cb, NULL),
      NULL));
  IupSetAttribute(_frm_1,"TITLE","IupButton");

  _frm_2 = IupFrame(
    IupVbox(
      IupLabel("Label Text"),
      IupSetAttributes(IupLabel(NULL), "SEPARATOR=HORIZONTAL, MAXSIZE=150, NAME=SAMP_SEP"),
      IupSetAttributes(IupLabel(NULL), "IMAGE=img1"),
      NULL));
  IupSetAttribute(_frm_2,"TITLE","IupLabel");

  _frm_3 = IupFrame(
    IupVbox(
      set_callbacks(IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON")),
      set_callbacks(IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1,IMPRESS=img2")),
      set_callbacks(IupSetAttributes(IupToggle(NULL, NULL), "VALUE=ON,IMAGE=img1")),
      IupSetAttributes(IupFrame(IupRadio(IupVbox(
        set_callbacks(IupToggle("Toggle Text", NULL)),
        set_callbacks(IupToggle("Toggle Text", NULL)),
        NULL))), "TITLE=IupRadio"),
      NULL));
  IupSetAttribute(_frm_3,"TITLE","IupToggle");

  _text_1 = IupText( NULL);
  IupSetAttribute(_text_1,"VALUE","Single Line Text");
  IupSetAttribute(_text_1,"SIZE","80x");

  _ml_1 = IupMultiLine( NULL);
  IupSetAttribute(_ml_1,"VALUE","Multiline Text\nSecond Line\nThird Line");
  IupSetAttribute(_ml_1,"EXPAND","YES");
  IupSetAttribute(_ml_1,"SIZE","80x40");

  _frm_4 = IupFrame(IupVbox(
    set_callbacks(_text_1),
    set_callbacks(_ml_1),
    NULL));
  IupSetAttribute(_frm_4,"TITLE","IupText");

  _list_1 = IupList( NULL);
  IupSetAttribute(_list_1,"VALUE","1");
  IupSetAttribute(_list_1,"1","Item 1 Text");
  IupSetAttribute(_list_1,"2","Item 2 Text");
  IupSetAttribute(_list_1,"3","Item 3 Text");
  IupSetAttribute(_list_1,"TIP","List 1");

  _list_2 = IupList( NULL);
  IupSetAttribute(_list_2,"DROPDOWN","YES");
  IupSetAttribute(_list_2,"VALUE","2");
  IupSetAttribute(_list_2,"1","Item 1 Text");
  IupSetAttribute(_list_2,"2","Item 2 Text");
  IupSetAttribute(_list_2,"3","Item 3 Text");
  IupSetAttribute(_list_2,"TIP","List 2");

  _list_3 = IupList( NULL);
  IupSetAttribute(_list_3,"EDITBOX","YES");
  IupSetAttribute(_list_3,"VALUE","3");
  IupSetAttribute(_list_3,"1","Item 1 Text");
  IupSetAttribute(_list_3,"2","Item 2 Text");
  IupSetAttribute(_list_3,"3","Item 3 Text");
  IupSetAttribute(_list_3,"TIP","List 3");

  _frm_5 =  IupFrame(IupVbox(
      set_callbacks(_list_1),
      set_callbacks(_list_2),
      set_callbacks(_list_3),
      NULL));
  IupSetAttribute(_frm_5,"TITLE","IupList");

  _hbox_1 = IupHbox(
    _frm_1,
    _frm_2,
    _frm_3,
    _frm_4,
    _frm_5,
    NULL);

  val = IupVal(NULL);
  set_callbacks(val);
 
  pbar = IupProgressBar();
  IupSetAttribute(pbar, "VALUE", "0.5");
  set_callbacks(pbar);

  tabs = IupTabs(IupVbox(IupLabel(""), NULL), IupVbox(IupFill(), NULL), IupVbox(IupFill(), NULL), NULL);
  IupSetAttribute(tabs,"TABTITLE0","Tab Title 0");
  IupSetAttribute(tabs,"TABTITLE1","Tab Title 1");
  IupSetAttributeHandle(tabs,"TABIMAGE1", load_image_LogoTecgraf());
  IupSetAttribute(tabs,"TABTITLE2","Tab Title 2");
  IupSetAttribute(tabs,"RASTERSIZE","300x50");
  set_callbacks(tabs);

  tree = IupTree();
  IupSetAttribute(tree, "SHOWRENAME",   "YES");
  IupSetAttribute(tree,"RASTERSIZE","100x150");
  set_callbacks(tree);

  _cnv_1 = IupCanvas(NULL);
  IupSetAttribute(_cnv_1,"BGCOLOR","128 255 0");
  IupSetAttribute(_cnv_1,"SCROLLBAR","YES");
  IupSetAttribute(_cnv_1,"EXPAND","HORIZONTAL");
  IupSetAttribute(_cnv_1,"RASTERSIZE","x100");
  set_callbacks(_cnv_1);

  _vbox_1 = IupVbox(
    _hbox_1,
    IupHbox(IupSetAttributes(IupFrame(IupHbox(val, NULL)), "TITLE=IupVal"),
            IupSetAttributes(IupFrame(IupHbox(pbar, NULL)), "TITLE=IupProgressBar"),
            IupSetAttributes(IupFrame(IupHbox(tabs, NULL)), "TITLE=IupTabs"),
            NULL),
    IupHbox(IupSetAttributes(IupFrame(IupHbox(_cnv_1, NULL)), "TITLE=IupCanvas"),
            IupSetAttributes(IupFrame(IupHbox(tree, NULL)), "TITLE=IupTree"),
            NULL),
    NULL);
  IupSetAttribute(_vbox_1,"MARGIN","5x5");
  IupSetAttribute(_vbox_1,"GAP","5");

  dlg = IupDialog(_vbox_1);
  IupSetHandle("dlg",dlg);
  IupSetAttribute(dlg,"MENU","mnu");
  IupSetAttribute(dlg,"TITLE","C BASIC IUP Sample");
  IupSetCallback(dlg, "COPYDATA_CB", (Icallback)copydata_cb);
  IupMap(dlg);
  IupSetAttribute(tree, "TITLE0", "Figures"); 
  IupSetAttribute(tree, "ADDLEAF0", "Other");
  IupSetAttribute(tree, "ADDBRANCH1", "triangle");
  IupSetAttribute(tree, "ADDLEAF2", "equilateral");
  IupSetAttribute(tree, "ADDLEAF3", "isoceles");
  IupSetAttribute(tree, "ADDLEAF4", "scalenus");
  IupShow(dlg);
END_SUB

MAIN
BEGIN_FUNCTION
  IupOpen(AT argc, AT argv);
  IupSetGlobal("SINGLEINSTANCE", "Iup Sample");
  IF (NOT IupGetGlobal("SINGLEINSTANCE")) THEN
    IupClose(); 
    RETURN(EXIT_SUCCESS);
  END_IF
  SampleTest();
  IupMainLoop();
  IupClose();
  RETURN(EXIT_SUCCESS);
END_FUNCTION
« Last Edit: November 29, 2013, 03:07:25 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP val & mouse example
« Reply #12 on: November 30, 2013, 11:58:15 AM »
This is a good C BASIC example of how IUP interacts with the mouse. (click and mouse wheel button) The position text turns red if the Val control is clicked but not on the button to adjust position. (Ubuntu and Windows 64 bit)

     

Code: [Select]
// C BASIC - IUP Val / Mouse Example
// gcc val.c -I/usr/include/iup -liup -o val

#include <stdlib.h>
#include <stdio.h>
#include "cbasic.h"
#include "iup.h"

DIM AS Ihandle PTR lbl_h = NULL, PTR lbl_v = NULL;

CB_FUNCTION mousemove(Ihandle PTR c, double a)
BEGIN_FUNCTION
  DIM AS char buffer[40];
  DIM AS char PTR type = NULL;
  FORMAT(buffer, "VALUE=%.2g", a);
  type = IupGetAttribute(c, "ORIENTATION");
  SELECT_CASE(type[0])
  BEGIN_SELECT
    CASE 'V':
      IupStoreAttribute(lbl_v, "TITLE", buffer);
      END_CASE
    CASE 'H':
      IupStoreAttribute(lbl_h, "TITLE", buffer);
      END_CASE
  END_SELECT
  RETURN(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION button_press(Ihandle PTR c, double a)
BEGIN_FUNCTION
  DIM AS char PTR type = IupGetAttribute(c, "ORIENTATION");
  SELECT_CASE(type[0])
  BEGIN_SELECT
    CASE 'V':
      IupSetAttribute(lbl_v, "FGCOLOR", "255 0 0");
      END_CASE
    CASE 'H':
      IupSetAttribute(lbl_h, "FGCOLOR", "255 0 0");
      END_CASE
  END_SELECT
  mousemove(c, a);
  RETURN(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION button_release(Ihandle PTR c, double a)
BEGIN_FUNCTION
  DIM AS char PTR type = IupGetAttribute(c, "ORIENTATION");
  SELECT_CASE(type[0])
  BEGIN_SELECT
    CASE 'V':
      IupSetAttribute(lbl_v, "FGCOLOR", "0 0 0");
      END_CASE
    CASE 'H':
      IupSetAttribute(lbl_h, "FGCOLOR", "0 0 0");
      END_CASE
  END_SELECT
  mousemove(c, a);
  RETURN(IUP_DEFAULT);
END_FUNCTION

MAIN
BEGIN_FUNCTION
  DIM AS Ihandle PTR dlg_val, PTR val_h, PTR val_v;
  IupOpen(AT argc, AT argv);
  val_v = IupVal("VERTICAL");
  val_h = IupVal("HORIZONTAL");
  lbl_v = IupLabel("VALUE=");
  lbl_h = IupLabel("VALUE=");
  IupSetAttribute(lbl_v, "SIZE", "50x");
  IupSetAttribute(lbl_h, "SIZE", "50x");
  IupSetAttribute(val_v, "SHOWTICKS", "5");
  dlg_val = IupDialog(IupHbox(IupSetAttributes(IupHbox(val_v, lbl_v, NULL), "ALIGNMENT=ACENTER"),
    IupSetAttributes(IupVbox(val_h, lbl_h, NULL), "ALIGNMENT=ACENTER"), NULL));
  IupSetCallback(val_v, "BUTTON_PRESS_CB",  (Icallback)button_press);
  IupSetCallback(val_v, "BUTTON_RELEASE_CB",  (Icallback)button_release);
  IupSetCallback(val_v, "MOUSEMOVE_CB", (Icallback)mousemove);
  IupSetCallback(val_h, "BUTTON_PRESS_CB",  (Icallback)button_press);
  IupSetCallback(val_h, "BUTTON_RELEASE_CB",  (Icallback)button_release);
  IupSetCallback(val_h, "MOUSEMOVE_CB", (Icallback)mousemove);
  IupSetAttribute(dlg_val, "TITLE", "IupVal");
  IupSetAttribute(dlg_val, "MARGIN", "10x10");
  IupShowXY(dlg_val,IUP_CENTER,IUP_CENTER);
  IupMainLoop();
  IupClose();
  RETURN(EXIT_SUCCESS);
END_FUNCTION
« Last Edit: November 30, 2013, 12:45:42 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP 3D OpenGL
« Reply #13 on: December 02, 2013, 10:55:21 PM »
I converted this IUP C example twice before. (SB & BaCon) Here is the C BASIC version of it.



Code: [Select]
// C BASIC - IUP 3D OpenGL
// gcc cbiupgl.c -I/usr/include/iup -liup -liupgl -lGL -lGLU  -o cbiupgl

#include <stdio.h>
#include <stdlib.h>
#include <iup.h>
#include <iupgl.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "cbasic.h"

DIM AS Ihandle PTR canvas;
DIM AS int width = 640, height = 480;
DIM AS float t = 0;

CB_SUB polygon(int a, int b, int c, int d)
BEGIN_SUB
  DIM AS double vertices[][3] = {
    {-1,-1, 1},
    {-1, 1, 1},
    { 1, 1, 1},
    { 1,-1, 1},
    {-1,-1,-1},
    {-1, 1,-1},
    { 1, 1,-1},
    { 1,-1,-1}
    };
  glBegin(GL_POLYGON);
    glVertex3dv(vertices[a]);
    glVertex3dv(vertices[b]);
    glVertex3dv(vertices[c]);
    glVertex3dv(vertices[d]);
  glEnd();
END_SUB

CB_SUB colorCube()
BEGIN_SUB
  glColor3f(1, 0, 0);
  glNormal3f(1, 0, 0);
  polygon(2, 3, 7, 6);

  glColor3f(0, 1, 0);
  glNormal3f(0, 1, 0);
  polygon(1, 2, 6, 5);

  glColor3f(0, 0, 1);
  glNormal3f(0, 0, 1);
  polygon(0, 3, 2, 1);

  glColor3f(1, 0, 1);
  glNormal3f(0, -1, 0);
  polygon(3, 0, 4, 7);

  glColor3f(1, 1, 0);
  glNormal3f(0, 0, -1);
  polygon(4, 5, 6, 7);

  glColor3f(0, 1, 1);
  glNormal3f(-1, 0, 0);
  polygon(5, 4, 0, 1);
END_SUB

CB_FUNCTION repaint_cb(Ihandle PTR self)
BEGIN_FUNCTION
  IupGLMakeCurrent(self);
  glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glTranslatef(0.0f, 0.0f , 0.0f);
  glScalef(1.0f, 1.0f, 1.0f);
  glRotatef(t, 0, 0, 1);
  colorCube();
  glPopMatrix();
  IupGLSwapBuffers(self);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION resize_cb(Ihandle PTR self, int new_width, int new_height)
BEGIN_FUNCTION
  IupGLMakeCurrent(self);
  glViewport(0, 0, new_width, new_height);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60, 4./3., 1., 15);
  gluLookAt(3, 3, 3, 0, 0, 0, 0, 0, 1);
  width = new_width;
  height = new_height;
  repaint_cb(canvas);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION idle_cb()
BEGIN_FUNCTION
  INCR t;
  repaint_cb(canvas);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION exit_cb()
BEGIN_FUNCTION
  RETURN_FUNCTION(IUP_CLOSE);
END_FUNCTION

FUNCTION Ihandle PTR initDialog()
BEGIN_FUNCTION
  DIM AS Ihandle PTR dialog;
  canvas = IupGLCanvas("repaint_cb");
  IupSetFunction("repaint_cb", (Icallback) repaint_cb);
  IupSetAttribute(canvas,IUP_RASTERSIZE,"640x480");
  IupSetAttribute(canvas,IUP_BUFFER,IUP_DOUBLE);
  IupSetCallback(canvas, "RESIZE_CB",(Icallback) resize_cb);
  dialog = IupDialog(canvas);
  IupSetAttribute(dialog, "TITLE", "C BASIC - IUP 3D OpenGL");
  IupSetCallback(dialog, "CLOSE_CB", (Icallback) exit_cb);
  IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb);
  RETURN_FUNCTION(dialog);
END_FUNCTION

MAIN
BEGIN_FUNCTION
  DIM AS Ihandle PTR dialog;
  IupOpen(AT argc, AT argv);
  IupGLCanvasOpen();
  dialog = initDialog();
  IupShowXY(dialog, IUP_CENTER, IUP_CENTER);
  IupMainLoop();
  IupClose();
  RETURN_FUNCTION(0);
END_FUNCTION

Offline John

  • Forum Support / SB Dev
  • Posts: 2752
    • ScriptBasic Open Source Project
C BASIC GUI - IUP Web Browser Control
« Reply #14 on: December 03, 2013, 10:15:35 AM »
This is a C BASIC IUP web browser control example.



Code: [Select]
// C BASIC - IUP Web Browser Control
// gcc webrowser.c -I/usr/include/iup -liup -liupweb -o cbwebctrl

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "iup.h"
#include "iupweb.h"
#include "cbasic.h"

#ifndef WIN32
CB_FUNCTION history_cb(Ihandle PTR ih)
BEGIN_FUNCTION
  DIM AS int i;
  DIM AS char str[50];
  DIM AS int back = IupGetInt(ih, "BACKCOUNT");
  DIM AS int fwrd = IupGetInt(ih, "FORWARDCOUNT");
  PRINT ("HISTORY ITEMS\n");
  FOR (i = -(back) TO i < 0 STEP INCR i)
  BEGIN_FOR
    FORMAT(str, "ITEMHISTORY%d", i);
    PRINT ("Backward %02d: %s\n", i, IupGetAttribute(ih, str));
  NEXT
  FORMAT(str, "ITEMHISTORY%d", 0);
  PRINT ("Current  %02d: %s\n", 0, IupGetAttribute(ih, str));
  FOR (i = 1 TO i <= fwrd STEP INCR i)
  BEGIN_FOR
    FORMAT(str, "ITEMHISTORY%d", i);
    PRINT ("Forward  %02d: %s\n", i, IupGetAttribute(ih, str));
  NEXT
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION
#endif

CB_FUNCTION navigate_cb(Ihandle PTR self, char PTR url)
BEGIN_FUNCTION
  PRINT ("NAVIGATE_CB: %s\n", url);
  (void)self;
  IF (strstr(url, "download") != NULL) THEN_DO RETURN_FUNCTION(IUP_IGNORE);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION error_cb(Ihandle PTR self, char PTR url)
BEGIN_FUNCTION
  PRINT ("ERROR_CB: %s\n", url);
  (void)self;
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION completed_cb(Ihandle PTR self, char PTR url)
BEGIN_FUNCTION
  PRINT ("COMPLETED_CB: %s\n", url);
  (void)self;
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION newwindow_cb(Ihandle PTR self, char PTR url)
BEGIN_FUNCTION
  PRINT ("NEWWINDOW_CB: %s\n", url);
  IupSetAttribute(self, "VALUE", url);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION back_cb(Ihandle PTR self)
BEGIN_FUNCTION
  Ihandle PTR web  = (Ihandle PTR)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "BACKFORWARD", "-1");
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION forward_cb(Ihandle PTR self)
BEGIN_FUNCTION
  Ihandle PTR web  = (Ihandle PTR)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "BACKFORWARD", "1");
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION stop_cb(Ihandle PTR self)
BEGIN_FUNCTION
  Ihandle PTR web  = (Ihandle PTR)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "STOP", NULL);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION reload_cb(Ihandle PTR self)
BEGIN_FUNCTION
  Ihandle PTR web  = (Ihandle PTR)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "RELOAD", NULL);
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

CB_FUNCTION load_cb(Ihandle PTR self)
BEGIN_FUNCTION
  Ihandle PTR txt  = (Ihandle PTR)IupGetAttribute(self, "MY_TEXT");
  Ihandle PTR web  = (Ihandle PTR)IupGetAttribute(self, "MY_WEB");
  IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"));
  RETURN_FUNCTION(IUP_DEFAULT);
END_FUNCTION

SUB WebBrowserTest()
BEGIN_SUB
  DIM AS Ihandle PTR txt,
                 PTR dlg,
                 PTR web,
                 PTR btLoad,
                 PTR btReload,
                 PTR btBack,
                 PTR btForward,
                 PTR btStop;
#ifndef WIN32
  DIM AS Ihandle PTR history;
#endif
  IupWebBrowserOpen();
  web = IupWebBrowser();
  dlg = IupDialog(IupVbox(IupHbox(btBack = IupButton("Back", NULL),
                                  btForward = IupButton("Forward", NULL),
                                  txt = IupText(""),
                                  btLoad = IupButton("Load", NULL),
                                  btReload = IupButton("Reload", NULL),
                                  btStop = IupButton("Stop", NULL),
#ifndef WIN32
                                  history = IupButton("History", NULL),
#endif
                                  NULL),
                                  web, NULL));
  IupSetAttribute(dlg, "TITLE", "C BASIC - IUP Web Browser Control");
  IupSetAttribute(dlg, "MY_TEXT", (char PTR)txt);
  IupSetAttribute(dlg, "MY_WEB", (char PTR)web);
  IupSetAttribute(dlg, "RASTERSIZE", "800x600");
  IupSetAttribute(dlg, "MARGIN", "10x10");
  IupSetAttribute(dlg, "GAP", "10");
  IupSetAttribute(txt, "VALUE", "https://bitbucket.org/ScriptBasic/c-basic");
  IupSetAttribute(web, "VALUE", IupGetAttribute(txt, "VALUE"));
  IupSetAttributeHandle(dlg, "DEFAULTENTER", btLoad);
  IupSetAttribute(txt, "EXPAND", "HORIZONTAL");
  IupSetCallback(btLoad, "ACTION", (Icallback)load_cb);
  IupSetCallback(btReload, "ACTION", (Icallback)reload_cb);
  IupSetCallback(btBack, "ACTION", (Icallback)back_cb);
  IupSetCallback(btForward, "ACTION", (Icallback)forward_cb);
  IupSetCallback(btStop, "ACTION", (Icallback)stop_cb);
#ifndef WIN32
  IupSetCallback(history, "ACTION", (Icallback)history_cb);
#endif
  IupSetCallback(web, "NEWWINDOW_CB", (Icallback)newwindow_cb);
  IupSetCallback(web, "NAVIGATE_CB", (Icallback)navigate_cb);
  IupSetCallback(web, "ERROR_CB", (Icallback)error_cb);
  IupSetCallback(web, "COMPLETED_CB", (Icallback)completed_cb);
  IupShow(dlg);
END_SUB

MAIN
BEGIN_FUNCTION
  IupOpen(AT argc, AT argv);
  WebBrowserTest();
  IupMainLoop();
  IupClose();
  RETURN_FUNCTION(EXIT_SUCCESS);
END_FUNCTION

jrs@laptop:~/C_BASIC/xlate$ gcc webrowser.c -I/usr/include/iup -liup -liupweb -o cbwebctrl
jrs@laptop:~/C_BASIC/xlate$ ./cbwebctrl
NAVIGATE_CB: https://bitbucket.org/ScriptBasic/c-basic
COMPLETED_CB: https://bitbucket.org/ScriptBasic/c-basic
No bp log location saved, using default.
[000:000] Cpu: 6.37.5, x2, 2133Mhz, 3754MB
[000:000] Computer model: Not available
[000:000] Browser XEmbed support present: 1
[000:000] Browser toolkit is Gtk2.
[000:000] Using Gtk2 toolkit
« Last Edit: December 03, 2013, 10:17:57 AM by John »