[Gtkada-wrapper-devel] SF.net SVN: gtkada-wrapper: [21] trunk
Brought to you by:
bechir_zalila
From: <bec...@us...> - 2006-11-28 20:50:50
|
Revision: 21 http://svn.sourceforge.net/gtkada-wrapper/?rev=21&view=rev Author: bechir_zalila Date: 2006-11-28 12:50:50 -0800 (Tue, 28 Nov 2006) Log Message: ----------- * (gtkada_wrapper.ad?): Emproved considerably the rafresh mechanism. Now we draw directly on the GDK components and we backup in the pixmap. Get_Mouse_Pointer now raises an exception if the window is closed before the user gives the mouse click. * (protected_queue.ad?) customized Number_Waiting * (/examples/*): Removed useless call to refresh from the example and test the immediate refreshing on basic_drawings. Modified Paths: -------------- trunk/TODO trunk/examples/basic_drawings/basic_drawings.adb trunk/examples/fractal/fractal.adb trunk/src/gtkada_wrapper.adb trunk/src/gtkada_wrapper.ads trunk/src/protected_queue.adb trunk/src/protected_queue.ads Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/TODO 2006-11-28 20:50:50 UTC (rev 21) @@ -2,7 +2,6 @@ * Implement fill color * Implement forms * Implement Text area - * Get_Mouse_Pointer will block forever if the user closes the window /doc: * Write the documentation Modified: trunk/examples/basic_drawings/basic_drawings.adb =================================================================== --- trunk/examples/basic_drawings/basic_drawings.adb 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/examples/basic_drawings/basic_drawings.adb 2006-11-28 20:50:50 UTC (rev 21) @@ -35,26 +35,31 @@ Set_Line_Color (Color_Array (I)); Line (100.0 + 10.0 * Float (I)); Rotate (45.0); + Get_Mouse_Pointer (X, Y, Button); end loop; Set_Line_Color (My_Color_1); Jump (50.0, 50.0); Spot (20.0); + Get_Mouse_Pointer (X, Y, Button); + Jump (100.0, 100.0); Spot (10.0); + Get_Mouse_Pointer (X, Y, Button); + Set_Line_Color (My_Color_2); Jump (100.0, 400.0); Spot (10.0); + Get_Mouse_Pointer (X, Y, Button); + Set_Line_Color (My_Color_2); Set_Thickness (8.0); Line (100.0, 100.0, 200.0, 400.0); Line (100.0, 100.0, 100.0, 400.0); - Rafresh; - Get_Mouse_Pointer (X, Y, Button); Ada.Text_IO.Put_Line ("Got Click:"); Ada.Text_IO.Put_Line (" X = " & X'Img); Modified: trunk/examples/fractal/fractal.adb =================================================================== --- trunk/examples/fractal/fractal.adb 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/examples/fractal/fractal.adb 2006-11-28 20:50:50 UTC (rev 21) @@ -38,8 +38,6 @@ Draw_Fractal (150.0, 100.0, 350.0, 400.0); Draw_Fractal (350.0, 400.0, 150.0, 100.0); - Rafresh; - Get_Mouse_Pointer (X, Y, Button); Ada.Text_IO.Put_Line ("Got Click:"); Ada.Text_IO.Put_Line (" X = " & X'Img); Modified: trunk/src/gtkada_wrapper.adb =================================================================== --- trunk/src/gtkada_wrapper.adb 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/src/gtkada_wrapper.adb 2006-11-28 20:50:50 UTC (rev 21) @@ -112,7 +112,7 @@ -- The drawing area of the main window Pixmap : Gdk_Pixmap; - -- Pixmap usefult when rafreshing the drawing area + -- Pixmap useful when rafreshing the drawing area package Color_Table is new GNAT.Table (Gdk_Color, Color_Type, 1, 20, 10); @@ -536,7 +536,8 @@ ------------------- task body Event_Handler is - Cmd : Command; + Cmd : Command; + N_Wait_Rsp : Natural; begin loop select @@ -567,10 +568,20 @@ pragma Debug (O ("Event_Handler: done")); end if; end loop; + pragma Debug (O ("Resetting the event handler: firing" + &" all waiters for response")); + N_Wait_Rsp := Response_Queue.Number_Waiting + (Response_Queue.To_Dequeue); + for I in 1 .. N_Wait_Rsp loop + Response_Queue.Enqueue (Response'(Rsp_Kind => R_None)); + end loop; + pragma Debug (O ("Resetting the event handler: emptying queues")); + Command_Queue.Clear; Response_Queue.Clear; + pragma Debug (O ("Resetting the event handler: done")); end loop; end Event_Handler; @@ -744,15 +755,15 @@ -- one. Free the original. if Pixmap /= Null_Pixmap then - Draw_Pixmap (New_Pixmap, - Get_Fg_GC (Get_Style (Drawing_Area), State_Normal), - Pixmap, - 0, - 0, - 0, - 0, - Gint'Min (Width, New_Width), - Gint'Min (Height, New_Height)); + Draw_Drawable (New_Pixmap, + Get_Fg_GC (Get_Style (Drawing_Area), State_Normal), + Pixmap, + 0, + 0, + 0, + 0, + Gint'Min (Width, New_Width), + Gint'Min (Height, New_Height)); Gdk.Pixmap.Unref (Pixmap); end if; @@ -833,6 +844,16 @@ -- Redraw a white rectangle on the drawing area + Draw_Rectangle (Get_Window (Drawing_Area), + Get_White (Get_Style (Drawing_Area)), + True, + 0, + 0, + Width, + Height); + + -- Backup + Draw_Rectangle (Pixmap, Get_White (Get_Style (Drawing_Area)), True, @@ -1142,7 +1163,21 @@ procedure Do_Spot (Cmd : Command) is begin pragma Debug (O ("Do_Spot: begin")); + Draw_Arc + (Get_Window (Drawing_Area), + Graphic_Context, + True, + Gint (Brush_X) - Gint (Cmd.Radius), + Height - Gint (Brush_Y) - Gint (Cmd.Radius), + 2 * Gint (Cmd.Radius), + 2 * Gint (Cmd.Radius), + 0, + 360 * 64); + + -- Backup + + Draw_Arc (Pixmap, Graphic_Context, True, @@ -1152,6 +1187,7 @@ 2 * Gint (Cmd.Radius), 0, 360 * 64); + pragma Debug (O ("Drawn a spot of radius" & Cmd.Radius'Img & " at " & "(" & Brush_X'Img & ", " & Brush_Y'Img & ")")); pragma Debug (O ("Do_Spot: done")); @@ -1200,6 +1236,15 @@ begin pragma Debug (O ("Draw_Line: begin")); + Draw_Line (Get_Window (Drawing_Area), + Graphic_Context, + Gint (X_Start), + Height - Gint (Y_Start), + Gint (X_End), + Height - Gint (Y_End)); + + -- Backup + Draw_Line (Pixmap, Graphic_Context, Gint (X_Start), @@ -1226,17 +1271,18 @@ begin pragma Debug (O ("Main window exposed: handling")); - -- Restore screen from backing store pixmap + -- Restore the alterated zone of the drawing area from the + -- backup pixmap. - Draw_Pixmap (Get_Window (Drawing_Area), - Get_Fg_GC (Get_Style (Drawing_Area), State_Normal), - Pixmap, - Area.X, - Area.Y, - Area.X, - Area.Y, - Gint (Area.Width), - Gint (Area.Height)); + Draw_Drawable (Get_Window (Drawing_Area), + Get_Fg_GC (Get_Style (Drawing_Area), State_Normal), + Pixmap, + Area.X, + Area.Y, + Area.X, + Area.Y, + Gint (Area.Width), + Gint (Area.Height)); return True; end Expose_Event; @@ -1339,7 +1385,8 @@ Button := Rsp.Button; when R_None => - raise Lost_Main_Window; + raise Lost_Main_Window with "Get_Mouse_Pointer: The main" + & " window have been closed and no click have been received"; when others => raise Program_Error; Modified: trunk/src/gtkada_wrapper.ads =================================================================== --- trunk/src/gtkada_wrapper.ads 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/src/gtkada_wrapper.ads 2006-11-28 20:50:50 UTC (rev 21) @@ -185,7 +185,8 @@ Button : out Natural); -- Wait for a mous button action and stores the mouse pointer -- coordinate in X and Y and the mouse button used to do the - -- action. + -- action. If the user closes the windows before giving a mouse + -- click, 'Lost_Main_Window' will be raised. --------------------------------- -- Text Area Specific Routines -- Modified: trunk/src/protected_queue.adb =================================================================== --- trunk/src/protected_queue.adb 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/src/protected_queue.adb 2006-11-28 20:50:50 UTC (rev 21) @@ -4,9 +4,6 @@ package body Protected_Queue is - type Waiting_Type is (To_Enqueue, To_Dequeue, To_Enqueue_Plus_Dequeue); - -- To choose which number of waiting task we want to get - type Queue_Array_Type is array (1 .. Max_Length) of Element_Type; -- The protected object that ensure concurrency safety @@ -156,9 +153,9 @@ -- Number_Waiting -- -------------------- - function Number_Waiting return Natural is + function Number_Waiting (To : Waiting_Type := To_Dequeue)return Natural is begin - return The_Protected_Queue.Number_Waiting; + return The_Protected_Queue.Number_Waiting (To); end Number_Waiting; end Protected_Queue; Modified: trunk/src/protected_queue.ads =================================================================== --- trunk/src/protected_queue.ads 2006-11-27 21:18:02 UTC (rev 20) +++ trunk/src/protected_queue.ads 2006-11-28 20:50:50 UTC (rev 21) @@ -29,8 +29,10 @@ procedure Clear; -- Delete all the elements of the queue - function Number_Waiting return Natural; + type Waiting_Type is (To_Enqueue, To_Dequeue, To_Enqueue_Plus_Dequeue); + -- To choose which number of waiting task we want to get + + function Number_Waiting (To : Waiting_Type := To_Dequeue) return Natural; -- Return the number of tasks waiting on the queue entries - -- (enqueuing and dequeuing). end Protected_Queue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |