comp.lang.ada
 help / color / mirror / Atom feed
* change colors in GtkAda  (Linux/GNAT 3-13p-7)
@ 2001-11-22 15:26 Frank
  2001-11-22 15:57 ` Preben Randhol
  2001-11-23 13:48 ` Jacob Sparre Andersen
  0 siblings, 2 replies; 5+ messages in thread
From: Frank @ 2001-11-22 15:26 UTC (permalink / raw)


Hi!

I have a little problem in GtkAda. I am trying to set a color before drawing
a polygon,
by rewriting a snippet of code from a Gtk textbook based in C:-)

However the polygons is drawed in black.
Is anyone able to see from this snippet of code, if I have used some wrong
approach somewhere?


The variabel My_Colormap is declared with Gdk.Color.Gdk_Colormap,
My_Color with Gdk.Color.Gdk_Color and My_GC with Gdk.Gdk_GC.


Frank

-------------------------------------------------------------------
....
..
.
.
.
.
      declare
        use Gdk.Color;
        use Gdk;
        Success : Boolean;
      begin

        if My_Colormap = null then
          My_Colormap := Gdk.Color.Get_System;
          Gdk.GC.Gdk_New(My_GC, Win);
        end if;

        Gdk.Color.Set_Rgb(My_Color, Gushort(10000), Gushort(0), Gushort(0));
        Gdk.Color.Alloc_Color(My_Colormap, My_Color, False, True, Success);
        Gdk.GC.Set_Foreground(My_GC, My_Color);

        if not Success then
          Text_IO.Put_Line("error on alloc color");
        end if;

        if  Win = null then
          Text_IO.Put_Line("is null");
        end if;


      end;


      Gdk.Drawable.Draw_Polygon (
        Win,
        My_GC,
        True,
        Surface_Array);







^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: change colors in GtkAda  (Linux/GNAT 3-13p-7)
  2001-11-22 15:26 change colors in GtkAda (Linux/GNAT 3-13p-7) Frank
@ 2001-11-22 15:57 ` Preben Randhol
  2001-11-22 16:12   ` Frank
  2001-11-23 13:48 ` Jacob Sparre Andersen
  1 sibling, 1 reply; 5+ messages in thread
From: Preben Randhol @ 2001-11-22 15:57 UTC (permalink / raw)


On Thu, 22 Nov 2001 16:26:14 +0100, Frank wrote:
> However the polygons is drawed in black.
> Is anyone able to see from this snippet of code, if I have used some wrong
> approach somewhere?

Hard to say, but change this:
>         Gdk.Color.Set_Rgb(My_Color, Gushort(10000), Gushort(0), Gushort(0));

to:
         Gdk.Color.Set_Rgb(My_Color, 65_000, 0, 0);

should give you a bright red colour.

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: change colors in GtkAda  (Linux/GNAT 3-13p-7)
  2001-11-22 15:57 ` Preben Randhol
@ 2001-11-22 16:12   ` Frank
  0 siblings, 0 replies; 5+ messages in thread
From: Frank @ 2001-11-22 16:12 UTC (permalink / raw)


Hi!
Thank you,
That solved the problem.

Frank






^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: change colors in GtkAda  (Linux/GNAT 3-13p-7)
  2001-11-22 15:26 change colors in GtkAda (Linux/GNAT 3-13p-7) Frank
  2001-11-22 15:57 ` Preben Randhol
@ 2001-11-23 13:48 ` Jacob Sparre Andersen
  2001-11-23 14:31   ` Preben Randhol
  1 sibling, 1 reply; 5+ messages in thread
From: Jacob Sparre Andersen @ 2001-11-23 13:48 UTC (permalink / raw)


Frank:

> I have a little problem in GtkAda. I am trying to set a color before drawing
> a polygon,
> by rewriting a snippet of code from a Gtk textbook based in C:-)
> 
> However the polygons is drawed in black.
> Is anyone able to see from this snippet of code, if I have used some wrong
> approach somewhere?

[...]

>         Gdk.Color.Set_Rgb(My_Color, Gushort(10000), Gushort(0), Gushort(0));

What range is allowed for the colour components. Have you
considered something like:

   Gdk.Color.Set_Rgb(My_Color,
                     Gushort'Last, Gushort'First,
Gushort'First);

Assuming that "Gushort" is the type of the colour
components, this will most likely give you a pure bright
red.

Jacob
-- 
"Navier-Stokes-ligningen er som Biblen,
 det er randbetingelserne der bestemmer det hele."



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: change colors in GtkAda  (Linux/GNAT 3-13p-7)
  2001-11-23 13:48 ` Jacob Sparre Andersen
@ 2001-11-23 14:31   ` Preben Randhol
  0 siblings, 0 replies; 5+ messages in thread
From: Preben Randhol @ 2001-11-23 14:31 UTC (permalink / raw)


On Fri, 23 Nov 2001 14:48:32 +0100, Jacob Sparre Andersen wrote:
> Frank:
>>         Gdk.Color.Set_Rgb(My_Color, Gushort(10000), Gushort(0), Gushort(0));
> 
> What range is allowed for the colour components. 

#0000..#FFFF or 0..65_535

Preben
-- 
 ()   Join the worldwide campaign to protect fundamental human rights.
'||}
{||'                                           http://www.amnesty.org/



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-11-23 14:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-22 15:26 change colors in GtkAda (Linux/GNAT 3-13p-7) Frank
2001-11-22 15:57 ` Preben Randhol
2001-11-22 16:12   ` Frank
2001-11-23 13:48 ` Jacob Sparre Andersen
2001-11-23 14:31   ` Preben Randhol

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox