SRC_DIR = src
MAKE_CMD = $(MAKE) -C $(SRC_DIR)
-DEFAULT_TARGET = x11
-# DEFAULT_TARGET = sdl
+# DEFAULT_TARGET = x11
+DEFAULT_TARGET = sdl
all:
@$(MAKE_CMD) TARGET=$(DEFAULT_TARGET)
-#define COMPILE_DATE_STRING "[2003-04-04 01:21]"
+#define COMPILE_DATE_STRING "[2003-04-04 02:13]"
cursor_string[1] = (cursor_letter != '\0' ? cursor_letter : ' ');
cursor_string[2] = '\0';
+ SetInverseTextColor(gi->text.inverse_color);
+
/* draw cursor, if active */
if (pressed)
DrawTextExt(drawto,
gi->selectbox.x + border,
gi->selectbox.y + border + i * font_height,
gi->selectbox.width - 2 * border, font_height,
- gi->selectbox.reverse_color);
+ gi->selectbox.inverse_color);
text[0] = '~';
strncpy(&text[1], gi->selectbox.values[i], gi->selectbox.size);
text[1 + gi->selectbox.size] = '\0';
+
+ SetInverseTextColor(gi->selectbox.inverse_color);
}
else
{
if (gi->type & GD_TYPE_TEXTINPUT)
{
- int font_width = getFontWidth(gi->text.font_type);
- int font_height = getFontHeight(gi->text.font_type);
+ int font_nr = gi->text.font_type;
+ int font_bitmap_id = gfx.select_font_function(font_nr);
+ struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id];
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
int border_size = gi->border.size;
+ int src_x, src_y;
gi->width = 2 * border_size + (gi->text.size + 1) * font_width;
gi->height = 2 * border_size + font_height;
+
+ if (!getFontChar(font_nr, '|', &src_x, &src_y))
+ Error(ERR_EXIT, "text input gadget incomplete (cannot get cursor)");
+
+ src_x += font_width / 2;
+ src_y += font_height / 2;
+ gi->text.inverse_color = GetPixel(font->bitmap, src_x, src_y);
}
if (gi->type & GD_TYPE_SELECTBOX)
int font_nr = gi->selectbox.font_type;
int font_bitmap_id = gfx.select_font_function(font_nr);
struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id];
- int font_width = getFontWidth(gi->selectbox.font_type);
- int font_height = getFontHeight(gi->selectbox.font_type);
+ int font_width = getFontWidth(font_nr);
+ int font_height = getFontHeight(font_nr);
int border_size = gi->border.size;
int button_size = gi->border.size_selectbutton;
int src_x, src_y;
src_x += font_width / 2;
src_y += font_height / 2;
- gi->selectbox.reverse_color = GetPixel(font->bitmap, src_x, src_y);
+ gi->selectbox.inverse_color = GetPixel(font->bitmap, src_x, src_y);
/* always start with closed selectbox */
gi->selectbox.open = FALSE;
int number_min; /* minimal allowed numeric value */
int number_max; /* maximal allowed numeric value */
int size; /* maximal size of input text */
- int cursor_position; /* actual cursor position */
int font_type; /* font to use for text input */
+ int cursor_position; /* actual cursor position */
+ Pixel inverse_color; /* color for highlighting */
};
struct GadgetSelectbox
int x, y; /* open selectbox position */
int width, height; /* open selectbox size */
int num_values; /* number of text strings */
- Pixel reverse_color; /* color for highlighting */
+ Pixel inverse_color; /* color for highlighting */
/* runtime values */
boolean open; /* opening state of selectbox */
}
void sge_PutPixelRGB(SDL_Surface *surface, Sint16 x, Sint16 y,
- Uint8 R, Uint8 G, Uint8 B)
+ Uint8 r, Uint8 g, Uint8 b)
{
- sge_PutPixel(surface, x, y, SDL_MapRGB(surface->format, R, G, B));
+ sge_PutPixel(surface, x, y, SDL_MapRGB(surface->format, r, g, b));
}
Sint32 sge_CalcYPitch(SDL_Surface *dest, Sint16 y)
}
+/*
+ -----------------------------------------------------------------------------
+ quick (no, it's slow) and dirty hack to "invert" rectangle inside SDL surface
+ -----------------------------------------------------------------------------
+*/
+
+inline void SDLInvertArea(Bitmap *bitmap, int src_x, int src_y,
+ int width, int height, Uint32 color)
+{
+ SDL_Surface *surface = bitmap->surface;
+ int x, y;
+
+ for (y=src_y; y < src_y + height; y++)
+ {
+ for (x=src_x; x < src_x + width; x++)
+ {
+ Uint32 pixel = SDLGetPixel(bitmap, x, y);
+
+ sge_PutPixel(surface, x, y, pixel == BLACK_PIXEL ? color : BLACK_PIXEL);
+ }
+ }
+}
+
+
/* ========================================================================= */
/* The following functions were taken from the SDL_gfx library version 2.0.3 */
/* (Rotozoomer) by Andreas Schiffler */
inline void SDLDrawLine(Bitmap *, int, int, int, int, Uint32);
inline Pixel SDLGetPixel(Bitmap *, int, int);
+inline void SDLInvertArea(Bitmap *, int, int, int, int, Uint32);
+
void SDLZoomBitmap(Bitmap *, Bitmap *);
Bitmap *SDLLoadImage(char *);
inline static void sysFillRectangle(Bitmap *bitmap, int x, int y,
int width, int height, Pixel color)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDLFillRectangle(bitmap, x, y, width, height, color);
#else
X11FillRectangle(bitmap, x, y, width, height, color);
int src_x, int src_y, int width, int height,
int dst_x, int dst_y, int mask_mode)
{
-#ifdef TARGET_SDL
- SDLCopyArea(src_bitmap, dst_bitmap,
- src_x, src_y, width, height, dst_x, dst_y, mask_mode);
+#if defined(TARGET_SDL)
+ SDLCopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height,
+ dst_x, dst_y, mask_mode);
#else
- X11CopyArea(src_bitmap, dst_bitmap,
- src_x, src_y, width, height, dst_x, dst_y, mask_mode);
+ X11CopyArea(src_bitmap, dst_bitmap, src_x, src_y, width, height,
+ dst_x, dst_y, mask_mode);
#endif
}
video.fullscreen_available = FULLSCREEN_STATUS;
video.fullscreen_enabled = FALSE;
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDLInitVideoBuffer(backbuffer, window, fullscreen);
#else
X11InitVideoBuffer(backbuffer, window);
inline Bitmap *CreateBitmapStruct(void)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
return checked_calloc(sizeof(struct SDLSurfaceInfo));
#else
return checked_calloc(sizeof(struct X11DrawableInfo));
Bitmap *new_bitmap = CreateBitmapStruct();
int real_depth = GetRealDepth(depth);
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDLCreateBitmapContent(new_bitmap, width, height, real_depth);
#else
X11CreateBitmapContent(new_bitmap, width, height, real_depth);
if (bitmap == NULL)
return;
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDLFreeBitmapPointers(bitmap);
#else
X11FreeBitmapPointers(bitmap);
inline void CloseWindow(DrawWindow *window)
{
-#ifdef TARGET_X11
+#if defined(TARGET_X11)
if (window->drawable)
{
XUnmapWindow(display, window->drawable);
inline void SetClipMask(Bitmap *bitmap, GC clip_gc, Pixmap clip_pixmap)
{
-#ifdef TARGET_X11
+#if defined(TARGET_X11)
if (clip_gc)
{
bitmap->clip_gc = clip_gc;
inline void SetClipOrigin(Bitmap *bitmap, GC clip_gc, int clip_x, int clip_y)
{
-#ifdef TARGET_X11
+#if defined(TARGET_X11)
if (clip_gc)
{
bitmap->clip_gc = clip_gc;
inline void DrawSimpleWhiteLine(Bitmap *bitmap, int from_x, int from_y,
int to_x, int to_y)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, WHITE_PIXEL);
#else
X11DrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, WHITE_PIXEL);
inline void KeyboardAutoRepeatOn(void)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
SDL_DEFAULT_REPEAT_INTERVAL / 2);
SDL_EnableUNICODE(1);
inline void KeyboardAutoRepeatOff(void)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableUNICODE(0);
#else
inline boolean PointerInWindow(DrawWindow *window)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
return TRUE;
#else
Window root, child;
inline boolean SetVideoMode(boolean fullscreen)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
return SDLSetVideoMode(&backbuffer, fullscreen);
#else
boolean success = TRUE;
inline boolean ChangeVideoModeIfNeeded(boolean fullscreen)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
if ((fullscreen && !video.fullscreen_enabled && video.fullscreen_available)||
(!fullscreen && video.fullscreen_enabled))
fullscreen = SetVideoMode(fullscreen);
FreeBitmap(tmp_bitmap_2);
FreeBitmap(tmp_bitmap_8);
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
src_bitmap->surface = tmp_bitmap->surface;
tmp_bitmap->surface = NULL;
#else
inline void InitEventFilter(EventFilter filter_function)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
/* set event filter to filter out certain events */
SDL_SetEventFilter(filter_function);
#endif
inline boolean PendingEvent(void)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
return (SDL_PollEvent(NULL) ? TRUE : FALSE);
#else
return (XPending(display) ? TRUE : FALSE);
inline void NextEvent(Event *event)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
SDLNextEvent(event);
#else
XNextEvent(display, event);
inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
{
-#ifdef TARGET_SDL
+#if defined(TARGET_SDL)
#if 0
printf("unicode == '%d', sym == '%d', mod == '0x%04x'\n",
(int)event->keysym.unicode,
{
int i;
-#ifdef NO_JOYSTICK
+#if defined(NO_JOYSTICK)
return; /* joysticks generally deactivated by compile-time directive */
#endif
int num_fonts;
struct FontBitmapInfo *font_bitmap_info;
int (*select_font_function)(int);
+ Pixel inverse_text_color;
int anim_random_frame;
};
gfx.num_fonts = num_fonts;
gfx.font_bitmap_info = font_bitmap_info;
gfx.select_font_function = select_font_function;
+ gfx.inverse_text_color = WHITE_PIXEL;
#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
InitFontClipmasks();
#endif
}
+void SetInverseTextColor(Pixel inverse_text_color)
+{
+ gfx.inverse_text_color = inverse_text_color;
+}
+
int getFontWidth(int font_nr)
{
int font_bitmap_id = gfx.select_font_function(font_nr);
{
if (print_inverse) /* special mode for text gadgets */
{
+#if defined(TARGET_SDL)
+ /* blit normally (non-masked) */
+ BlitBitmap(font->bitmap, dst_bitmap, src_x, src_y,
+ font->width, font->height, dst_x, dst_y);
+
+ /* invert character */
+ SDLInvertArea(dst_bitmap, dst_x, dst_y, font->width, font->height,
+ gfx.inverse_text_color);
+#else
/* first step: draw solid colored rectangle (use "cursor" character) */
if (print_inverse_cursor)
BlitBitmap(font->bitmap, dst_bitmap,
dst_x - src_x, dst_y - src_y);
BlitBitmapMasked(font->bitmap, dst_bitmap,
0, 0, font->width, font->height, dst_x, dst_y);
+#endif
}
else if (mask_mode == BLIT_MASKED)
{
/* font structure definitions */
-void InitFontInfo(struct FontBitmapInfo *, int,
- int (*select_font_function)(int));
+void InitFontInfo(struct FontBitmapInfo *, int, int (*function)(int));
+void SetInverseTextColor(Pixel);
+
int getFontWidth(int);
int getFontHeight(int);
boolean getFontChar(int, char, int *, int *);