font-selector.cpp revision e3b6cd4b0523f08a6414dc0800a15a3b1710ce8a
#define __SP_FONT_SELECTOR_C__
/*
* Font selection widgets
*
* Authors:
* Chris Lahey <clahey@ximian.com>
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
* Copyright (C) 1999-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
* Copyright (C) -2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <libnrtype/font-instance.h>
#include <libnrtype/raster-glyph.h>
#include <libnrtype/RasterFont.h>
#include <libnrtype/TextWrapper.h>
#include <libnrtype/one-glyph.h>
#include <libnrtype/font-lister.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtkclist.h>
#include <gtk/gtkcombo.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkdrawingarea.h>
#include "../display/nr-plain-stuff-gdk.h"
#include "../desktop.h"
#include "font-selector.h"
/* SPFontSelector */
struct SPFontSelector
{
unsigned int block_emit : 1;
int familyidx;
int styleidx;
bool fontsize_dirty;
};
struct SPFontSelectorClass
{
};
enum {
};
static void sp_font_selector_class_init (SPFontSelectorClass *c);
namespace {
const char *sizes[] = {
"4", "6", "8", "9", "10", "11", "12", "13", "14",
"16", "18", "20", "22", "24", "28",
"32", "36", "40", "48", "56", "64", "72", "144",
};
}
{
if (!type) {
sizeof(SPFontSelectorClass),
0, // base_init
0, // base_finalize
0, // class_finalize
0, // class_data
sizeof(SPFontSelector),
0, // n_preallocs
0 // value_table
};
}
return type;
}
static void sp_font_selector_class_init(SPFontSelectorClass *c)
{
1, GTK_TYPE_POINTER);
}
{
/* Family frame */
gtk_widget_show (f);
gtk_tree_view_set_model (GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL (Glib::unwrap (store)));
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_family_select_row), fsel);
/* Style frame */
f = gtk_frame_new(_("Style"));
gtk_widget_show(f);
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel);
g_signal_connect (G_OBJECT(fsel->size), "changed", G_CALLBACK (sp_font_selector_size_changed), fsel);
gtk_widget_show_all (l);
for (unsigned int n = 0; sizes[n]; ++n)
{
}
fsel->fontsize_dirty = false;
}
{
}
}
}
}
}
{
{
}
path = gtk_tree_path_new ();
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->style_treeview)), path);
}
{
if (!fsel->block_emit)
{
}
}
{
if (text) {
value = -1;
}
if (value <= 0) {
return; // could not parse value
}
if (value > 10000)
{
fsel->fontsize_dirty = true;
}
}
{
//We need to check this here since most GtkTreeModel operations are not atomic
//See GtkListStore documenation, Chapter "Atomic Operations" --mderezynski
if (!model_family) return;
if (!model_style) return;
// FIXME: when a text object uses non-available font, font==NULL and we can't set size
// (and the size shown in the widget is invalid). To fix, here we must always get some
// default font, exactly the same as sptext uses for on-canvas display, so that
// font!=NULL ever.
if ( font ) {
}
}
}
fsel->fontsize_dirty = false;
if (font) {
}
}
{
}
{
if (font)
{
try {
} catch (...) {
return;
}
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->family_treeview)), path.gobj());
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (fsel->family_treeview), path.gobj(), NULL, TRUE, 0.5, 0.5);
unsigned int currentStyleNumber = 0;
unsigned int bestStyleNumber = 0;
if (tempFont) {
}
while (list) {
if (tempFont) {
}
if (currentMatchForFont) {
// Found a better match for the font we are looking for
}
}
}
if (bestMatchForFont)
if (incomingFont)
gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->style_treeview)), path_c);
{
gchar s[8];
}
}
}
{
}
}
{
}
/* SPFontPreview */
struct SPFontPreview
{
unsigned long rgba;
};
struct SPFontPreviewClass
{
};
static void sp_font_preview_class_init(SPFontPreviewClass *c);
{
if (!type) {
sizeof(SPFontPreviewClass),
0, // base_init
0, // base_finalize
0, // class_finalize
0, // class_data
sizeof(SPFontPreview),
0, // n_preallocs
0 // value_table
};
type = g_type_register_static(GTK_TYPE_DRAWING_AREA, "SPFontPreview", &info, static_cast<GTypeFlags>(0));
}
return type;
}
static void sp_font_preview_class_init (SPFontPreviewClass *c)
{
}
{
}
{
}
}
}
}
{
}
#define SPFP_MAX_LEN 64
{
if (GTK_WIDGET_DRAWABLE (widget)) {
int glyphs[SPFP_MAX_LEN];
double hpos[SPFP_MAX_LEN];
gchar const *p;
} else {
/* TRANSLATORS: Test string used in text and font dialog (when no
* text has been entered) to get a preview of the font. Choose
* some representative characters that users of your locale will be
* interested in. */
p = _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()");
}
int len = 0;
if ( str_text->uni32_length > 0 ) {
if ( str_text->glyph_length > 0 ) {
if (curF) {
}
if ( curPF ) {
}
}
len++;
if ( curF ) {
if (nbbox) {
}
}
}
if ( curF ) {
}
}
}
// XXX: FIXME: why does this code ignore adv.y
/* while (p && *p && (len < SPFP_MAX_LEN)) {
unsigned int unival;
NRRect gbox;
unival = g_utf8_get_char (p);
glyphs[len] = tface->MapUnicodeChar( unival);
hpos[len] = (int)px;
NR::Point adv = fprev->rfont->Advance(glyphs[len]);
fprev->rfont->BBox( glyphs[len], &gbox);
bbox.x0 = MIN (px + gbox.x0, bbox.x0);
bbox.y0 = MIN (py + gbox.y0, bbox.y0);
bbox.x1 = MAX (px + gbox.x1, bbox.x1);
bbox.y1 = MAX (py + gbox.y1, bbox.y1);
px += adv[NR::X];
len += 1;
p = g_utf8_next_char (p);
}*/
float starty = widget->allocation.height - (widget->allocation.height - (bbox.y1 - bbox.y0)) / 2 - bbox.y1;
NRPixBlock pb, m;
int x0 = x;
int y0 = y;
nr_pixblock_setup_extern(&pb, NR_PIXBLOCK_MODE_R8G8B8, x0, y0, x1, y1, ps, 3 * (x1 - x0), FALSE, FALSE);
for (int i=0; i < len; i++) {
if ( curF ) {
}
if ( curPF ) {
}
if ( curF ) {
if ( curRF ) {
}
}
}
if ( g ) {
}
}
if (curRF) {
}
if (curF) {
}
nr_pixblock_release(&m);
}
}
delete str_text;
} else {
}
}
return TRUE;
}
{
return w;
}
{
if (font)
{
}
{
}
{
}
{
}
}
{
if (GTK_WIDGET_DRAWABLE (fprev)) {
}
}
{
if (phrase) {
} else {
}
if (GTK_WIDGET_DRAWABLE(fprev)) {
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :