* BUG: Remove Font.Strikeout property as it's only available in SDL_tff>2.0.9


git-svn-id: svn://localhost/gambas/trunk@3226 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Laurent Carlier 2010-09-16 12:26:09 +00:00
parent c0f29f9f90
commit 5fd4006167
5 changed files with 47 additions and 24 deletions

View file

@ -145,7 +145,7 @@ BEGIN_PROPERTY(CFONT_italic)
FONT->SetFontItalic(VPROP(GB_BOOLEAN));
END_PROPERTY
/*
BEGIN_PROPERTY(CFONT_strikeout)
if (READ_PROPERTY)
@ -154,7 +154,7 @@ BEGIN_PROPERTY(CFONT_strikeout)
FONT->SetFontStrikeout(VPROP(GB_BOOLEAN));
END_PROPERTY
*/
BEGIN_PROPERTY(CFONT_underline)
if (READ_PROPERTY)
@ -212,7 +212,7 @@ GB_DESC CFont[] =
GB_PROPERTY("Size", "i", CFONT_size),
GB_PROPERTY("Bold", "b", CFONT_bold),
GB_PROPERTY("Italic", "b", CFONT_italic),
GB_PROPERTY("StrikeOut", "b", CFONT_strikeout),
// GB_PROPERTY("StrikeOut", "b", CFONT_strikeout),
GB_PROPERTY("Underline", "b", CFONT_underline),
GB_PROPERTY_READ("Ascent", "i", CFONT_ascent),

View file

@ -73,14 +73,14 @@ void SDLcursor::Show(Window w)
if (shape == SDL::DefaultCursor)
shape = SDL::ArrowCursor;
SDLapp->LockX11();
SDLapp->LockX11();
if (shape != SDL::CustomCursor)
cursor = XcursorShapeLoadCursor(myDisplay, shape);
else
cursor = XcursorImageLoadCursor(myDisplay, hImgCursor);
XDefineCursor(myDisplay, w, cursor);
SDLapp->UnlockX11();
SDLapp->UnlockX11();
}

View file

@ -25,9 +25,9 @@
#include <string>
#define COMP_WARN "gb.sdl warning: ",
#define COMP_ERR "gb.sdl error: ",
#define COMP_INFO "gb.sdl info: ",
#define COMP_WARN "gb.sdl warning: &1",
#define COMP_ERR "gb.sdl error: &1",
#define COMP_INFO "gb.sdl info: &1",
class SDLerror
{

View file

@ -30,9 +30,11 @@
#include <string>
#include <ctype.h>
/*
#ifndef TTF_STYLE_STRIKETHROUGH
#define TTF_STYLE_STRIKETHROUGH 0x08
#endif
*/
typedef struct {
std::string name;
@ -44,7 +46,7 @@ typedef struct {
static std::vector<fontdesc> fontDB;
static StringList _FontList;
#define DEFAULT_FONT_SIZE 20
#define DEFAULT_FONT_SIZE 25
#define DEFAULT_DPI 72 /* Default DPI size in SDL_TTF */
inline bool cmp_db_nocase(const fontdesc x, const fontdesc y)
@ -142,12 +144,10 @@ SDLfont::SDLfont()
hfonttype = X_font;
hfontsize = DEFAULT_FONT_SIZE;
hfontindex = 0;
hSDLfont = 0;
hfontname = fontDB[hfontindex].path;
hSDLfont = TTF_OpenFont(hfontname.c_str(), hfontsize);
if (UNLIKELY(hSDLfont == NULL))
SDLerror::RaiseError(TTF_GetError());
OpenFont(hfontname.c_str());
}
SDLfont::SDLfont(char *fontfile)
@ -155,11 +155,9 @@ SDLfont::SDLfont(char *fontfile)
hfonttype = SDLTTF_font;
hfontsize = DEFAULT_FONT_SIZE;
hfontname = fontfile;
hSDLfont = 0;
hSDLfont = TTF_OpenFont(fontfile, hfontsize);
if (UNLIKELY(hSDLfont == NULL))
SDLerror::RaiseError(TTF_GetError());
OpenFont(fontfile);
}
SDLfont::~SDLfont()
@ -168,8 +166,34 @@ SDLfont::~SDLfont()
TTF_CloseFont(hSDLfont);
}
void SDLfont::OpenFont(const char* file)
{
if (hSDLfont)
TTF_CloseFont(hSDLfont);
hSDLfont = TTF_OpenFont(file, hfontsize);
if (UNLIKELY(hSDLfont == NULL))
SDLerror::RaiseError(TTF_GetError());
}
void SDLfont::SetFontName(char* name)
{
std::string font = name;
int i=0;
while (i<int(fontDB.size())) {
if (!fontDB[i].name.compare(font)) {
hfonttype = X_font;
hfontsize = DEFAULT_FONT_SIZE;
hfontindex = i;
hfontname = fontDB[hfontindex].path;
OpenFont(hfontname.c_str());
return;
}
i++;
}
SDLerror::RaiseError("Font not found!");
}
const char* SDLfont::GetFontName(void )
@ -185,12 +209,7 @@ void SDLfont::SetFontSize(int size)
int style = TTF_GetFontStyle(hSDLfont);
hfontsize = size;
TTF_CloseFont(hSDLfont);
hSDLfont = TTF_OpenFont(hfontname.c_str(), hfontsize);
if (UNLIKELY(hSDLfont == NULL))
SDLerror::RaiseError(TTF_GetError());
OpenFont(hfontname.c_str());
TTF_SetFontStyle(hSDLfont, style);
}
@ -223,15 +242,17 @@ bool SDLfont::IsFontItalic(void )
void SDLfont::SetFontStrikeout(bool state)
{
/*
if (state == (TTF_GetFontStyle(hSDLfont) & TTF_STYLE_STRIKETHROUGH))
return;
TTF_SetFontStyle(hSDLfont, (TTF_GetFontStyle(hSDLfont) ^ TTF_STYLE_STRIKETHROUGH));
*/
}
bool SDLfont::IsFontStrikeout(void )
{
return (TTF_GetFontStyle(hSDLfont) & TTF_STYLE_STRIKETHROUGH);
// return (TTF_GetFontStyle(hSDLfont) & TTF_STYLE_STRIKETHROUGH);
}
void SDLfont::SetFontUnderline(bool state)

View file

@ -72,6 +72,8 @@ public:
SDLsurface* RenderText(const char* text);
private:
void OpenFont(const char* file);
int hfonttype;
int hfontsize;
int hfontindex;