SetPangoNormalFontSize() public method

public SetPangoNormalFontSize ( ) : void
return void
        public override void DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x= DrawAreaX, y = DrawAreaY + 0.1;
            int pos = 0;
            gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, 1);

            if (Answer.Draw ==  true) {
                DrawAllFigures (gr, start_x_ans, start_y, area_width, area_height);
                return;
            }

            gr.SetPangoNormalFontSize ();
            for (int i = 0; i < figures.Length; i++)
            {
                if (i == question_pos)
                    continue;

                gr.MoveTo (x, y);
                gr.ShowPangoText (FigureType.ToString (figures[i]));

                if ((pos + 1) % 3 == 0) {
                    y += 0.2;
                    x = DrawAreaX;
                } else {
                    x+= 0.30;
                }
                pos++;
            }
        }
Ejemplo n.º 2
0
 protected void InitDraw(CairoContextEx gr, int width, int height, bool rtl)
 {
     gr.Scale(width, height);
     gr.SetSourceColor(default_color);
     gr.LineWidth = LineWidth;
     // Not all Cairo surfaces have a default font size (like PDF)
     gr.SetPangoNormalFontSize();
 }
Ejemplo n.º 3
0
        public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double y = 0.04, x = 0.05;
            const double space_small = 0.02;
            List <PlayerPersonalRecord> records;
            string s, tip, played;
            double width, height;

            gr.Scale (area_width, area_height);
            gr.Color = new Cairo.Color (0, 0, 0, 1);

            gr.MoveTo (x, y);
            gr.ShowPangoText (Translations.GetString ("Score"), false, -1, 0);
            DrawBand (gr, 0.03, y - 0.01);

            y += 0.08;
            gr.MoveTo (x, y);

            s = session.History.GetResult (Translations);

            // Translator: This will be part of the sentence "Games won: 10 (6 played)"
            played = String.Format (Translations.GetPluralString ("{0} played", "{0} played", session.History.GamesPlayed),
                session.History.GamesPlayed);

            if (s == string.Empty) {
                gr.ShowPangoText (String.Format (Translations.GetPluralString ("Games won: {0} ({1})",
                    "Games won: {0} ({1})", session.History.GamesWon), session.History.GamesWon, played));
            }
            else {
                gr.ShowPangoText (String.Format (Translations.GetPluralString ("{0}. Games won: {1} ({2})",
                    "{0}. Games won: {1} ({2})", session.History.GamesWon),	s, session.History.GamesWon, played));
            }

            y += 0.06;
            gr.MoveTo (x, y);
            gr.ShowPangoText (String.Format (Translations.GetString ("Time played {0} (average per game {1})"), session.GameTime, session.TimePerGame));

            y += 0.09;
            DrawColumnBarGraphic (gr, x, y);

            y += 0.36;
            gr.MoveTo (x, y);
            gr.SetPangoFontSize (smaller_font);
            // Translators: translated string should not be longer that the English original (space restriction on the UI)
            gr.ShowPangoText (Translations.GetString ("For details on how gbrainy's scoring works refer to the help."));

            y += 0.07;
            gr.SetPangoNormalFontSize ();
            records	= session.PlayerHistory.GetLastGameRecords ();
            gr.MoveTo (x, y);

            if (records.Count == 0) {
                bool caching = cached_sessionid != session.ID;

                gr.ShowPangoText (Translations.GetString ("Tips for your next games"), false, -1, 0);
                DrawBand (gr, 0.03, y - 0.01);

                y += 0.08;

                if (caching)
                    tips.Clear ();

                for (int i = 0; i < tips_shown; i++)
                {
                    if (caching)
                        tips.Add (game_tips.Tip);

                    tip = "- " + tips [i];

                    gr.MeasureString (tip, 1.0 - x, true, out width, out height);

                    if (y + height > 0.98)
                        break;

                    gr.DrawStringWithWrapping (x, y, tip , 1.0 - x);
                    y += height + space_small;
                }

                if (caching)
                    cached_sessionid = session.ID;
            }
            else  {
                gr.ShowPangoText (Translations.GetString ("Congratulations! New personal record"), false, -1, 0);
                DrawBand (gr, 0.03, y - 0.01);

                y += 0.08;

                for (int i = 0; i < records.Count; i++)
                {
                    switch (records[i].GameType) {
                    case GameTypes.LogicPuzzle:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in logic puzzle games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.Calculation:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in calculation games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.Memory:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in memory games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.VerbalAnalogy:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in verbal analogies you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    default:
                        break;
                    }

                    tip = "- " + s;

                    gr.MeasureString (tip, 1.0 - x, true, out width, out height);

                    if (y + height > 0.98)
                        break;

                    gr.DrawStringWithWrapping (x, y, tip , 1.0 - x);
                    y += height + space_small;
                }
            }

            gr.Stroke ();
        }
Ejemplo n.º 4
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            int element;
            double x = DrawAreaX;
            double y = 0.05, pos_y;

            base.Draw (gr, area_width, area_height, rtl);

            for (int i = 0; i < (Answer.Draw ? question_columns : question_columns - 1); i++)
            {
                element = question_indices [i];
                pos_y = y;
                for (int n = 0; n < figures_column; n++)
                {
                    DrawFigure (gr, x, pos_y, figures [(n * question_columns) + element]);
                    pos_y+= figure_size + space_height;
                }
                x+= figure_size + space_width;
            }

            if (Answer.Draw == false) {
                gr.Save ();
                gr.SetPangoFontSize (figure_size);
                for (int n = 0; n < figures_column; n++) {
                    gr.MoveTo (x, y - 0.02);
                    gr.ShowPangoText ("?");
                    gr.Stroke ();
                    y+= figure_size + space_height;
                }
                gr.SetPangoNormalFontSize ();
                gr.Restore ();
            }

            gr.MoveTo (0.08, 0.45);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
            gr.Stroke ();
        }
Ejemplo n.º 5
0
        protected override bool OnExposeEvent(Gdk.EventExpose args)
        {
            if (!IsRealized)
                return false;

            int w, h, total_w, total_h;

            Cairo.Context cc = Gdk.CairoHelper.Create (args.Window);
            CairoContextEx cr = new CairoContextEx (cc.Handle, this);

            args.Window.GetSize (out total_w, out total_h);

            h = total_h - question_high;
            if (UseSolutionArea)
                h -= solution_high;

            w = total_w;

            // We want a square drawing area for the puzzles then the figures are shown as designed.
            // For example, squares are squares. This also makes sure that proportions are kept when resizing
            DrawingSquare = Math.Min (w, h);

            if (DrawingSquare < w)
                OffsetX = (w - DrawingSquare) / 2d;
            else
                OffsetX = 0;

            if (DrawingSquare < h)
                OffsetY = (h - DrawingSquare) / 2d;
            else
                OffsetY = 0;

            OffsetY += question_high;

            // Draw a background taking all the window area
            cr.Save ();
            cr.Scale (total_w, total_h);
            cr.DrawBackground ();

            if (Paused == false) {
                DrawQuestionAndAnswer (cr, total_h);
            } else {
                cr.SetPangoFontSize (0.08);
                cr.DrawTextCentered (0.5, 0.5, Catalog.GetString ("Paused"));
                cr.Stroke ();
            }
            cr.Restore ();

            if (Paused == false) {
                // Draw the game area
                cr.Translate (OffsetX, OffsetY);
                cr.SetPangoNormalFontSize ();
                cr.Color = new Color (1, 1, 1, 0.5);
                Drawable.Draw (cr, DrawingSquare, DrawingSquare, Direction == Gtk.TextDirection.Rtl);
                cr.Stroke ();
            }

            ((IDisposable)cc).Dispose();
            ((IDisposable)cr).Dispose();
            return true;
        }
Ejemplo n.º 6
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double org_x = DrawAreaX + 0.1;
            double x = org_x, y = 0.08;
            double x45, y45, x135, y135, offset;

            base.Draw (gr, area_width, area_height, rtl);

            // First pattern
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.MoveTo (x, y + figure_size / 2);
            gr.LineTo (x + figure_size, y + figure_size / 2);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.MoveTo (x, y + figure_size / 2);
            gr.LineTo (x + figure_size, y + figure_size / 2);
            gr.Stroke ();

            x += figure_size + space_x;
            DrawCross (gr, x, y, figure_size);

            y += space_y;
            x = org_x;
            // Second pattern
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            DrawRotatedCross (gr, x, y, figure_size);

            // Rotated rectangle
            x += figure_size + space_x;
            x45 = figure_size * Math.Cos (45 * Math.PI / 180);
            y45 = figure_size * Math.Sin (45 * Math.PI / 180);
            x135 = figure_size * Math.Cos (135 * Math.PI / 180);
            y135 = figure_size * Math.Sin (135 * Math.PI / 180);
            offset = - 0.03;
            // Down-right
            gr.MoveTo (x + figure_size / 2, y + offset);
            gr.LineTo (x + figure_size / 2 + x45, y + offset + y45);
            // Up right
            gr.LineTo ((x + figure_size / 2 + x45) + x135, (y + offset +  y45) + y135);
            gr.Stroke ();
            // Down left
            gr.MoveTo (x + figure_size / 2, y + offset);
            gr.LineTo (x + figure_size / 2 + x135, y + offset + y135);
            // Up left
            gr.LineTo (x + figure_size / 2 + x135 + x45, y + offset + y135 + y45);
            gr.Stroke ();

            y += space_y;
            x = org_x;

            // Third pattern
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.LineTo (x + figure_size, y  + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.LineTo (x, y  + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.MoveTo (x + 0.03, y - 0.02);
            gr.SetPangoFontSize (figure_size);
            gr.ShowPangoText ("?");
            gr.SetPangoNormalFontSize ();
            gr.Stroke ();

            gr.MoveTo (0.05, y - 0.01 + space_y);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));
            gr.Stroke ();
        }
Ejemplo n.º 7
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double org_x = DrawAreaX + 0.1;
            double x = org_x, y = 0.08;
            const double figure_size = 0.13, space_x = 0.1, space_y = 0.18;
            double x45, y45, x135, y135, offset;

            base.Draw (gr, area_width, area_height, rtl);

            // First pattern
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.MoveTo (x, y + figure_size / 2);
            gr.LineTo (x + figure_size, y + figure_size / 2);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.MoveTo (x, y + figure_size / 2);
            gr.LineTo (x + figure_size, y + figure_size / 2);
            gr.Stroke ();

            x += figure_size + space_x;
            DrawCross (gr, x, y, figure_size);

            y += space_y;
            x = org_x;
            // Second pattern
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            DrawRotatedCross (gr, x, y, figure_size);

            // Rotated rectangle
            x += figure_size + space_x;
            x45 = figure_size * Math.Cos (45 * Math.PI / 180);
            y45 = figure_size * Math.Sin (45 * Math.PI / 180);
            x135 = figure_size * Math.Cos (135 * Math.PI / 180);
            y135 = figure_size * Math.Sin (135 * Math.PI / 180);
            offset = - 0.03;
            // Down-right
            gr.MoveTo (x + figure_size / 2, y + offset);
            gr.LineTo (x + figure_size / 2 + x45, y + offset + y45);
            // Up right
            gr.LineTo ((x + figure_size / 2 + x45) + x135, (y + offset +  y45) + y135);
            gr.Stroke ();
            // Down left
            gr.MoveTo (x + figure_size / 2, y + offset);
            gr.LineTo (x + figure_size / 2 + x135, y + offset + y135);
            // Up left
            gr.LineTo (x + figure_size / 2 + x135 + x45, y + offset + y135 + y45);
            gr.Stroke ();

            y += space_y;
            x = org_x;

            // Third pattern
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.LineTo (x + figure_size, y  + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.LineTo (x, y  + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.MoveTo (x + 0.03, y - 0.02);
            gr.SetPangoFontSize (figure_size);
            gr.ShowPangoText ("?");
            gr.SetPangoNormalFontSize ();
            gr.Stroke ();

            gr.MoveTo (0.05, y - 0.01 + space_y);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));

            // Answers
            x = org_x;
            y += space_y + 0.07;

            for (int i = 0; i < (int) Figures.Last; i++)
            {
             	switch ((Figures) random_indices[i]) {
                case Figures.TwoLines:
                    DrawTwoLines (gr, x, y, figure_size);
                    break;
                case Figures.Cross:
                    DrawCross (gr, x, y, figure_size);
                    break;
                case Figures.RotatedCross:
                    DrawRotatedCross (gr, x, y, figure_size);
                    break;
                }

                gr.MoveTo (x, y + 0.18);
                gr.ShowPangoText (Answer.GetFigureName (i));

                x += figure_size + space_x;
            }
        }
Ejemplo n.º 8
0
        public override void DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x= DrawAreaX, y = DrawAreaY + 0.085;
            int pos = 0;
            gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, 1);

            if (Answer.Draw ==  true) {
                DrawAllFigures (gr, start_x_ans, start_y);
                return;
            }

            gr.SetPangoNormalFontSize ();
            for (int i = 0; i < figures.Length; i++)
            {
                if (i == question_pos)
                    continue;

                gr.MoveTo (x, y);
                gr.ShowPangoText (converter.ToString (figures[i]));

                if ((pos + 1) % 4 == 0) {
                    y += 0.1;
                    x = DrawAreaX;
                } else {
                    x+= 0.25;
                }
                pos++;
            }

            base.DrawPossibleAnswers (gr,  area_width, area_height, rtl);

            gr.SetPangoLargeFontSize ();
            gr.MoveTo (0, 0.4);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));

            gr.MoveTo (0, 0.08);
            gr.ShowPangoText (Translations.GetString ("List of images shown before"));
        }