Skip to content

Commit

Permalink
REPLACED deprectated GdkFont with Pango
Browse files Browse the repository at this point in the history
ADDED OSX menu bar integration to dlgedit
  • Loading branch information
ksterker committed Oct 6, 2009
1 parent 804808d commit 3e75bbf
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 72 deletions.
4 changes: 2 additions & 2 deletions src/dlgedit/Makefile.am
Expand Up @@ -80,8 +80,8 @@ dlgedit_SOURCES = \
main.cc

INCLUDES = -I@top_srcdir@/src/common
dlgedit_CXXFLAGS = -D_VERSION_=\"0.9pre\" $(GTK_CFLAGS) $(ADONTHELL_CFLAGS)
dlgedit_LDADD = ../common/libcommon.a $(GTK_LIBS) $(ADONTHELL_LIBS)
dlgedit_CXXFLAGS = -D_VERSION_=\"0.9pre\" $(GTK_CFLAGS) $(ADONTHELL_CFLAGS) ${IGE_MAC_CFLAGS}
dlgedit_LDADD = ../common/libcommon.a $(GTK_LIBS) $(ADONTHELL_LIBS) ${IGE_MAC_LIBS}

$(srcdir)/lex.loadlg.cc: $(top_srcdir)/src/dlgedit/loadlg.l
flex -o$(srcdir)/lex.loadlg.cc $<
Expand Down
14 changes: 9 additions & 5 deletions src/dlgedit/dlg_circle.cc
Expand Up @@ -111,12 +111,16 @@ void DlgCircle::draw (GdkPixmap *surface, DlgPoint &os, GtkWidget *widget)
if (entry_->loop ()) g_string_append_c (code, 'o');

// get the font to use
GdkFont *font = GuiResources::font ();

PangoLayout *font = GuiResources::font ();
pango_layout_set_text (font, code->str, -1);

// place text in circles center
int x = position.x () + (width () - gdk_string_width (font, code->str)) / 2;
int y = position.y () + (height () + 1 + gdk_string_height (font, code->str)) / 2;
gdk_draw_string (surface, font, gc, x, y, code->str);
int w, h;
pango_layout_get_pixel_size (font, &w, &h);

int x = position.x () + (width () - w) / 2;
int y = position.y () + (height () + 1 - h) / 2;
gdk_draw_layout (surface, gc, x, y, font);

g_string_free (code, TRUE);
}
Expand Down
31 changes: 22 additions & 9 deletions src/dlgedit/dlg_module.cc
Expand Up @@ -81,9 +81,14 @@ void DlgModule::clear ()
// calculate shape of sub-dialogue
void DlgModule::initShape (const DlgPoint &center)
{
int width;

// calculate width of the module icon
GdkFont *font = GuiResources::font ();
int width = gdk_string_width (font, name ().c_str ()) + 10;
PangoLayout *font = GuiResources::font ();
pango_layout_set_text (font, name().c_str(), -1);
pango_layout_get_pixel_size (font, &width, NULL);

width += 10;

// align module to the (imaginary) grid and set shape
top_left = DlgPoint (center.x (), center.y ());
Expand Down Expand Up @@ -288,12 +293,16 @@ void DlgModule::draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget)
gdk_draw_rectangle (surface, gc, FALSE, position.x (), position.y (), width (), height ());

// get the font to draw name
GdkFont *font = GuiResources::font ();

PangoLayout *font = GuiResources::font ();
pango_layout_set_text (font, name().c_str(), -1);

// place text in module's center
int h;
pango_layout_get_pixel_size (font, NULL, &h);

int x = position.x () + 5;
int y = position.y () + (height () + gdk_string_height (font, name ().c_str ())) / 2;
gdk_draw_string (surface, font, gc, x, y, name ().c_str ());
int y = position.y () + (height () + h) / 2;
gdk_draw_layout (surface, gc, x, y, font);

// Update the drawing area
update (widget, area);
Expand Down Expand Up @@ -481,13 +490,17 @@ void DlgModule::loadSubdialogue ()
case LOAD_POS:
{
int x, y;
GdkFont *font = GuiResources::font ();
int width = gdk_string_width (font, name ().c_str ()) + 10;
int width;

PangoLayout *font = GuiResources::font ();
pango_layout_set_text (font, name().c_str(), -1);
pango_layout_get_pixel_size (font, &width, NULL);

if (parse_dlgfile (s, n) == LOAD_NUM) x = n;
if (parse_dlgfile (s, n) == LOAD_NUM) y = n;

top_left = DlgPoint (x, y);
bottom_right = DlgPoint (x + width, y + 20);
bottom_right = DlgPoint (x + width + 10, y + 20);
}

default: break;
Expand Down

0 comments on commit 3e75bbf

Please sign in to comment.