In progress...

This commit is contained in:
Kolan Sh 2018-01-20 13:27:10 +03:00
parent 620a1c167c
commit 2390bfdf8d
3 changed files with 16 additions and 32 deletions

View File

@ -303,7 +303,7 @@ namespace CairoChart {
} }
protected virtual void rot_axes_titles () { protected virtual void rot_axes_titles () {
foreach (var s in series) foreach (var s in series)
s.axis_y.title.style.direct = FontDirect.VERTICAL; s.axis_y.title.style.orient = Gtk.Orientation.VERTICAL;
} }
protected virtual void eval_plarea () { protected virtual void eval_plarea () {

View File

@ -1,21 +1,5 @@
namespace CairoChart { namespace CairoChart {
/**
* ``Font`` direction.
*/
public enum FontDirect {
/**
* Horizontal font/text direction.
*/
HORIZONTAL = 0,
/**
* Vertical font/text direction.
*/
VERTICAL
}
/** /**
* ``Font`` style. * ``Font`` style.
*/ */
@ -42,9 +26,9 @@ namespace CairoChart {
Cairo.FontWeight weight; Cairo.FontWeight weight;
/** /**
* Font/Text direction. * Font/Text orientation.
*/ */
FontDirect direct; Gtk.Orientation orient;
/** /**
* Constructs a new ``Font``. * Constructs a new ``Font``.
@ -52,19 +36,19 @@ namespace CairoChart {
* @param size the new font size, in user space units. * @param size the new font size, in user space units.
* @param slant the slant for the font. * @param slant the slant for the font.
* @param weight the weight for the font. * @param weight the weight for the font.
* @param direct font/text direction. * @param orient font/text orientation.
*/ */
public Font (string family = "Sans", public Font (string family = "Sans",
double size = 10, double size = 10,
Cairo.FontSlant slant = Cairo.FontSlant.NORMAL, Cairo.FontSlant slant = Cairo.FontSlant.NORMAL,
Cairo.FontWeight weight = Cairo.FontWeight.NORMAL, Cairo.FontWeight weight = Cairo.FontWeight.NORMAL,
FontDirect direct = FontDirect.HORIZONTAL Gtk.Orientation orient = Gtk.Orientation.HORIZONTAL
) { ) {
this.family = family; this.family = family;
this.size = size; this.size = size;
this.slant = slant; this.slant = slant;
this.weight = weight; this.weight = weight;
this.direct = direct; this.orient = orient;
} }
} }
} }

View File

@ -25,18 +25,18 @@ namespace CairoChart {
public virtual double get_width (Cairo.Context ctx) { public virtual double get_width (Cairo.Context ctx) {
var extents = get_extents (ctx); var extents = get_extents (ctx);
switch (style.direct) { switch (style.orient) {
case FontDirect.HORIZONTAL: return extents.width; case Gtk.Orientation.HORIZONTAL: return extents.width;
case FontDirect.VERTICAL: return extents.height; case Gtk.Orientation.VERTICAL: return extents.height;
default: return 0.0; default: return 0.0;
} }
} }
public virtual double get_height (Cairo.Context ctx) { public virtual double get_height (Cairo.Context ctx) {
var extents = get_extents (ctx); var extents = get_extents (ctx);
switch (style.direct) { switch (style.orient) {
case FontDirect.HORIZONTAL: return extents.height; case Gtk.Orientation.HORIZONTAL: return extents.height;
case FontDirect.VERTICAL: return extents.width; case Gtk.Orientation.VERTICAL: return extents.width;
default: return 0.0; default: return 0.0;
} }
} }
@ -49,12 +49,12 @@ namespace CairoChart {
public virtual Size get_size (Cairo.Context ctx) { public virtual Size get_size (Cairo.Context ctx) {
var sz = Size(); var sz = Size();
var extents = get_extents (ctx); var extents = get_extents (ctx);
switch (style.direct) { switch (style.orient) {
case FontDirect.HORIZONTAL: case Gtk.Orientation.HORIZONTAL:
sz.width = extents.width + extents.x_bearing; sz.width = extents.width + extents.x_bearing;
sz.height = extents.height; sz.height = extents.height;
break; break;
case FontDirect.VERTICAL: case Gtk.Orientation.VERTICAL:
sz.width = extents.height; // + extents.x_bearing ? sz.width = extents.height; // + extents.x_bearing ?
sz.height = extents.width; // +- extents.y_bearing ? sz.height = extents.width; // +- extents.y_bearing ?
break; break;
@ -67,7 +67,7 @@ namespace CairoChart {
style.slant, style.slant,
style.weight); style.weight);
ctx.set_font_size(style.size); ctx.set_font_size(style.size);
if (style.direct == FontDirect.VERTICAL) { if (style.orient == Gtk.Orientation.VERTICAL) {
ctx.rotate(- GLib.Math.PI / 2.0); ctx.rotate(- GLib.Math.PI / 2.0);
ctx.show_text(text); ctx.show_text(text);
ctx.rotate(GLib.Math.PI / 2.0); ctx.rotate(GLib.Math.PI / 2.0);