GrafX2 2.9.3227
The ultimate 256-color painting program
sdlscreen.c File Reference
#include <string.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_endian.h>
#include <SDL_image.h>
#include <SDL_syswm.h>
#include "global.h"
#include "sdlscreen.h"
#include "errors.h"
#include "misc.h"
#include "gfx2log.h"
#include "io.h"
+ Include dependency graph for sdlscreen.c:

Macros

#define UPDATE_METHOD_MULTI_RECTANGLE   1
 
#define UPDATE_METHOD_CUMULATED   2
 
#define UPDATE_METHOD_FULL_PAGE   3
 
#define UPDATE_METHOD   UPDATE_METHOD_CUMULATED
 

Functions

byte Get_Screen_pixel (int x, int y)
 
void Set_Screen_pixel (int x, int y, byte value)
 
byteGet_Screen_pixel_ptr (int x, int y)
 
void Screen_FillRect (int x, int y, int w, int h, byte color)
 
void GFX2_Set_mode (int *width, int *height, int fullscreen)
 Sets the new screen/window dimensions. More...
 
void Flush_update (void)
 
void Update_rect (short x, short y, unsigned short width, unsigned short height)
 
void Update_status_line (short char_pos, short width)
 
byteSurface_to_bytefield (SDL_Surface *source, byte *dest)
 Converts a SDL_Surface (indexed colors or RGB) into an array of bytes (indexed colors). More...
 
SDL_Color Color_to_SDL_color (byte index)
 Gets the RGB 24-bit color currently associated with a palette index. More...
 
byte Get_SDL_pixel_8 (const SDL_Surface *bmp, int x, int y)
 Reads a pixel in a 8-bit SDL surface. More...
 
void Set_SDL_pixel_8 (SDL_Surface *bmp, int x, int y, byte color)
 Writes a pixel in a 8-bit SDL surface. More...
 
dword Get_SDL_pixel_hicolor (const SDL_Surface *bmp, int x, int y)
 Reads a pixel in a multi-byte SDL surface. More...
 
void Get_SDL_Palette (const SDL_Palette *sdl_palette, T_Palette palette)
 Convert a SDL Palette to a grafx2 palette. More...
 
int GFX2_SetPalette (const T_Components *colors, int firstcolor, int ncolors)
 
void Clear_border (byte color)
 Clears the parts of screen that are outside of the editing area. More...
 
void Allow_drag_and_drop (int flag)
 Activates or desactivates file drag-dropping in program window. More...
 
void Define_icon (void)
 Set application icon(s) More...
 
void Set_mouse_position (void)
 set (system) mouse cursor position More...
 
int GFX2_MessageBox (const char *text, const char *caption, unsigned int type)
 Display a modal message. More...
 

Variables

static SDL_Surface * Screen_SDL = NULL
 
volatile int Allow_colorcycling =1
 
static SDL_Rect render_dstrect
 
short Min_X =0
 
short Min_Y =0
 
short Max_X =10000
 
short Max_Y =10000
 
short Status_line_dirty_begin =0
 
short Status_line_dirty_end =0
 

Macro Definition Documentation

◆ UPDATE_METHOD_MULTI_RECTANGLE

#define UPDATE_METHOD_MULTI_RECTANGLE   1

◆ UPDATE_METHOD_CUMULATED

#define UPDATE_METHOD_CUMULATED   2

◆ UPDATE_METHOD_FULL_PAGE

#define UPDATE_METHOD_FULL_PAGE   3

◆ UPDATE_METHOD

#define UPDATE_METHOD   UPDATE_METHOD_CUMULATED

Function Documentation

◆ Get_Screen_pixel()

byte Get_Screen_pixel ( int  x,
int  y 
)

◆ Set_Screen_pixel()

void Set_Screen_pixel ( int  x,
int  y,
byte  value 
)

◆ Get_Screen_pixel_ptr()

byte * Get_Screen_pixel_ptr ( int  x,
int  y 
)

◆ Screen_FillRect()

void Screen_FillRect ( int  x,
int  y,
int  w,
int  h,
byte  color 
)

◆ GFX2_Set_mode()

void GFX2_Set_mode ( int *  width,
int *  height,
int  fullscreen 
)

Sets the new screen/window dimensions.

◆ Flush_update()

void Flush_update ( void  )

◆ Update_rect()

void Update_rect ( short  x,
short  y,
unsigned short  width,
unsigned short  height 
)

Referenced by GFX2_SetPalette().

◆ Update_status_line()

void Update_status_line ( short  char_pos,
short  width 
)

◆ Surface_to_bytefield()

byte * Surface_to_bytefield ( SDL_Surface *  source,
byte dest 
)

Converts a SDL_Surface (indexed colors or RGB) into an array of bytes (indexed colors).

If dest is NULL, it's allocated by malloc(). Otherwise, be sure to pass a buffer of the right dimensions.

References NULL.

Referenced by Render_text_TTF().

◆ Color_to_SDL_color()

SDL_Color Color_to_SDL_color ( byte  index)

Gets the RGB 24-bit color currently associated with a palette index.

References Main, and T_Document::palette.

◆ Get_SDL_pixel_8()

byte Get_SDL_pixel_8 ( const SDL_Surface *  bmp,
int  x,
int  y 
)

Reads a pixel in a 8-bit SDL surface.

◆ Set_SDL_pixel_8()

void Set_SDL_pixel_8 ( SDL_Surface *  bmp,
int  x,
int  y,
byte  color 
)

Writes a pixel in a 8-bit SDL surface.

◆ Get_SDL_pixel_hicolor()

dword Get_SDL_pixel_hicolor ( const SDL_Surface *  bmp,
int  x,
int  y 
)

Reads a pixel in a multi-byte SDL surface.

Referenced by Define_icon().

◆ Get_SDL_Palette()

void Get_SDL_Palette ( const SDL_Palette *  sdl_palette,
T_Palette  palette 
)

Convert a SDL Palette to a grafx2 palette.

Referenced by Render_text_TTF().

◆ GFX2_SetPalette()

int GFX2_SetPalette ( const T_Components colors,
int  firstcolor,
int  ncolors 
)

◆ Clear_border()

void Clear_border ( byte  color)

Clears the parts of screen that are outside of the editing area.

There is such area only if the screen mode is not a multiple of the pixel size, eg: 3x3 pixels in 1024x768 leaves 1 column on the right, 0 rows on bottom.

◆ Allow_drag_and_drop()

void Allow_drag_and_drop ( int  flag)

Activates or desactivates file drag-dropping in program window.

◆ Define_icon()

void Define_icon ( void  )

Set application icon(s)

◆ Set_mouse_position()

void Set_mouse_position ( void  )

set (system) mouse cursor position

◆ GFX2_MessageBox()

int GFX2_MessageBox ( const char *  text,
const char *  caption,
unsigned int  type 
)

Display a modal message.

Parameters
textbody of the modal message
captiontitle of the message
typeone of GFX2_MB_INFO, GFX2_MB_ERROR, GFX2_MB_WARNING
Returns
0 for error

Variable Documentation

◆ Screen_SDL

◆ Allow_colorcycling

volatile int Allow_colorcycling =1

◆ render_dstrect

SDL_Rect render_dstrect
static

Referenced by GFX2_Set_mode().

◆ Min_X

short Min_X =0

Referenced by Flush_update(), and Update_rect().

◆ Min_Y

short Min_Y =0

◆ Max_X

short Max_X =10000

Referenced by Flush_update(), and Update_rect().

◆ Max_Y

short Max_Y =10000

◆ Status_line_dirty_begin

short Status_line_dirty_begin =0

Referenced by Flush_update(), and Update_status_line().

◆ Status_line_dirty_end

short Status_line_dirty_end =0

Referenced by Flush_update(), and Update_status_line().