[gtkada] Wrong color...
Markus
mb592923 at bahnhofbredband.se
Tue Nov 2 21:17:16 CET 2004
Hi,
I'm trying to get the color right for my drawing but it seems to be
incredible complicated. I just can't get it working. Anyone who can tell
me what I'm doing wrong... please?
This is how I try to do... Draw a, e.g., black line onto a, e.g., white
background.
<code>
Gra_Con : Gdk.Gc.Gdk_Gc;
Pixmap : Gdk.Pixmap.Gdk_Pixmap;
---------------------
-- CONFIGURE EVENT --
---------------------
function Configure_Event (
Drawing_Area : access Gtk_Drawing_Area_Record'Class )
return Boolean is
Win : Gdk_Window;
Width : Gint;
Height : Gint;
Col_Map : Gdk.Color.Gdk_Colormap;
Gra_Con_Vals : Gdk.Gc.Gdk_Gc_Values;
Colors : Gdk.Color.Gdk_Color_Array (1 .. 2);
Bool_Arr : Boolean_Array (1 .. 2);
Res : Gint;
begin
Win := Get_Window (Drawing_Area);
Get_Size (Win, Width, Height);
Gdk.Pixmap.Gdk_New (Pixmap, Win, Width, Height, -1);
Col_Map := Gtk.Widget.Get_Default_Colormap;
Gra_Con_Vals := Gdk_New;
Colors(1) := White(Col_Map);
Colors(2) := Black(Col_Map);
Alloc_Colors(
Colormap => Col_Map,
Colors => Colors,
Writeable => False,
Best_Match => True,
Success => Bool_Arr,
Result => Res);
if Bool_Arr(1)=False or Bool_Arr(2)=False then
Put_Line("ERROR Can not allocate color! Res=" & Gint'Image(Res));
end if;
Set_Background(Gra_Con_Vals, Colors(1));
Set_Foreground(Gra_Con_Vals, Colors(2));
Set_Line_Attributes(
Values => Gra_Con_Vals,
Line_Width => 0,
Line_Style => Line_Solid,
Cap_Style => Cap_Round,
Join_Style => Join_Round);
Gdk_New(
Gc => Gra_Con,
Drawable => Get_Window (Drawing_Area),
Values => Gra_Con_Vals,
Values_Mask => Gc_Foreground or Gc_Background or
Gc_Line_Width or Gc_Line_Style or Gc_Cap_Style or Gc_Join_Style);
Draw_Rectangle (Pixmap, Gra_Con,
True, 0, 0, Width, Height);
Draw_Line(Drawable => Pixmap, Gc => Gra_Con,
X1 => 0, Y1 => 0, X2 => 100, Y2 => 100);
return True;
end Configure_Event;
------------------
-- EXPOSE EVENT --
------------------
function Expose_Event (
Drawing_Area : access Gtk_Drawing_Area_Record'Class;
Event : in Gdk.Event.Gdk_Event )
return Boolean is
Area : Gdk_Rectangle := Get_Area (Event);
begin
Draw_Drawable(Get_Window(Drawing_Area),
Gra_Con,
Pixmap, Area.X, Area.Y, Area.X, Area.Y,
Gint(Area.Width), Gint(Area.Height));
return True;
end Expose_Event;
</code>
This gives me nothing but a greenish rectangle (possibly with a greenish
line in it). Why???? I expected a black line on a white background. Any
ideas would be highly appreciated!
Cheers
Markus
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
More information about the gtkada
mailing list