Gtk Cross Platform Bug



Gentle People:

     The code below exhibits a most interesting cross platform bug:

     First the three platforms:
         1) Solaris 10 gcc
         2) Fedora 14
         3) Mxe Cross Compiler with testing on MS Vista.

     The version information for both GTK and Gcc are shown below:

; Gtk Solaris 10
pkg-config --modversion gtk+-2.0
2.12.0

; Gtk Fedora 14
pkg-config --modversion gtk+-2.0
2.22.0

; Gtk MXE Cross Environment
pkg-config --modversion gtk+-2.0
2.24.20

; Solaris 10
gcc --version
gcc (GCC) 3.4.6

; Fedora 14
gcc --version
gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

; MXE Cross Environment
i686-pc-mingw32-gcc --version
i686-pc-mingw32-gcc (GCC) 4.8.1

Now the bug specifics: The code shown below opens a Gtk window which includes a hbox with Cairo Paint and some GTK Menus. cairo_show_text is used to display some text in the Cairo window.

Now The Bug: The text appears as expected on Solaris 10 and Fedora 14, but dose NOT appear when run on MS Vista. (The window is blank on MS Vista). Note the the EXACT same code is built in
all three environments (No conditional compiles).

This bug is particularly disturbing in that I use the exact same coding concepts in other parts of the
application and it works properly on MS Vista.

An irony the newest version of the Gtk library and the newest version of the Gcc compiler
seem to exhibit the bug.

Thomas Dineen

/******************************************************************************/
/* */
/* TA_Bench: Moving_Average.c 10/05/13 */
/* */
/******************************************************************************/

/******************************************************************************/
/* */
/* Create_Moving_Average */
/* */
/******************************************************************************/

/******************************************************************************/
/* */
/* Note: gtk_widget_set_size_request Works! But In a relative way, */ /* relative to the total size of the window. */
/* */
/******************************************************************************/

int Create_Moving_Average()
   { /* Start Create_Moving_Average */
   GtkWidget *vbox_top_main;
   GtkWidget *HBox_Top_Menu_Bar;
   GtkWidget *hbox_top0;
   GtkWidget *hbox_top1;
   GtkWidget *hbox_top2;
   GtkWidget *hbox_top3;
   GtkWidget *hbox_top4;
   GtkWidget *hscale;
   GtkWidget *Button_Sel;
   GtkWidget *frame;
   GtkWidget *label;
   GtkWidget *Menu_Bar_Top;
   GtkWidget *Top_Menu;
   GtkWidget *Menu_Top;
   GtkWidget *Menu_Item;
   GtkWidget *Hor_Separator;
   GdkColor color;
   double Red;
   double Green;
   double Blue;
   int Red_I;
   int Green_I;
   int Blue_I;
   char Color_String[16];
   int Window_Height;
   int Window_Width;
   int Menu_Height;
   int Scale_Height;
   int Label_Height;
   int Separator_Height;
   int Cairo_Box_Height;
   int Cairo_Box_Width;
   int i;
   int Done;
   printf ( "Running Create_Moving_Average\n" );

/******************************************************************************/
/* */
/* Initialixe Valiables. */
/* */
/******************************************************************************/

   Label_Height = 15;
   Menu_Height  = 35;
   Scale_Height = 40;
   Window_Width = 1000;
   Separator_Height = 5;
   Cairo_Box_Height = 200;
   Cairo_Box_Width  = Window_Width;

   MA_Select_Index = 0;
   MA_Select_Algorithm = MA_NONE;
   Ind_Input_Data_Series = SELECT_INPUT_NULL;
   Ind_Display_Select = SELECT_NULL;
   MA_Color.Red   = Color_Default_Basic_Blue.Red;
   MA_Color.Green = Color_Default_Basic_Blue.Green;
   MA_Color.Blue  = Color_Default_Basic_Blue.Blue;

   i = 0;
   Done = FALSE;
   while ( Done == FALSE )
     {
     if ( MA_Control[i].MA_Enabled == 0 )
       {
       Done = TRUE;
       MA_Select_Index = i;
       }
       else
       i++;
     };

/******************************************************************************/
/* */
/* Set Up The Top Level Window */
/* */
/******************************************************************************/

Window_Height = Cairo_Box_Height + 2*Menu_Height + 2*Scale_Height + 2*Label_Height
      + 2*Separator_Height;

   MA_Window = gtk_window_new( GTK_WINDOW_TOPLEVEL );

   gtk_window_set_position( GTK_WINDOW(MA_Window), GTK_WIN_POS_MOUSE );

gtk_window_set_default_size( GTK_WINDOW(MA_Window), Window_Width, Window_Height );
   /* Width:Height*/

   gtk_window_set_title( GTK_WINDOW(MA_Window),
      "Create Moving Average" );

/******************************************************************************/
/* */
/* Set Up The Top Level VBox. */
/* */
/******************************************************************************/

   vbox_top_main = gtk_vbox_new (FALSE, 0);
gtk_widget_set_size_request ( vbox_top_main, Window_Width, Window_Height ); /* Width : Height */
   gtk_container_set_border_width (GTK_CONTAINER (vbox_top_main), 1 );
   gtk_container_add (GTK_CONTAINER (MA_Window), vbox_top_main);

/******************************************************************************/
/* */
/* Set Up The Status View Box For Cairo. */
/* */
/******************************************************************************/

   MA_Hbox_Cairo = gtk_hbox_new (FALSE, 0);
gtk_widget_set_size_request (MA_Hbox_Cairo, Cairo_Box_Width, Cairo_Box_Height );
   /* Width : Height */
   gtk_container_set_border_width (GTK_CONTAINER (MA_Hbox_Cairo), 1 );
   gtk_container_add (GTK_CONTAINER (vbox_top_main), MA_Hbox_Cairo );

   gtk_widget_set_app_paintable( MA_Hbox_Cairo, TRUE);
   gtk_widget_add_events ( MA_Hbox_Cairo, GDK_BUTTON_PRESS_MASK);
   gtk_widget_add_events ( MA_Hbox_Cairo, GDK_BUTTON_RELEASE_MASK);
   g_signal_connect( MA_Hbox_Cairo, "expose-event",
       G_CALLBACK(MA_On_Expose_Event), NULL);

/******************************************************************************/
/* */
/* Set Up The Top Menu Bar */
/* */
/******************************************************************************/

   HBox_Top_Menu_Bar = gtk_hbox_new (FALSE, 0);
gtk_widget_set_size_request (HBox_Top_Menu_Bar, Window_Width, Menu_Height); /* Width : Height */
   gtk_container_set_border_width (GTK_CONTAINER (HBox_Top_Menu_Bar), 1 );
   gtk_container_add (GTK_CONTAINER (vbox_top_main), HBox_Top_Menu_Bar);

/******************************************************************************/
/* */
/* Create The Top Menu Bar Entries. */
/* */
/******************************************************************************/

/******************************************************************************/
/* */
/* Create The Select Moving Average Algorithm. */
/* */
/******************************************************************************/

   Top_Menu = gtk_option_menu_new ();
   Menu_Top = gtk_menu_new ();

   Menu_Item = make_menu_item ("Step 1: Select MA Algorithm",
                           G_CALLBACK (Func_Moving_Average_Simple),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Simple MA",
                           G_CALLBACK (Func_Moving_Average_Simple),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Exponential MA",
                           G_CALLBACK (Func_Moving_Average_Exponetial),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   gtk_option_menu_set_menu (GTK_OPTION_MENU (Top_Menu), Menu_Top);
gtk_box_pack_start (GTK_BOX (HBox_Top_Menu_Bar), Top_Menu, TRUE, TRUE, 0);

/******************************************************************************/
/* */
/* Create The Input Data Series Select Menu. */
/* */
/******************************************************************************/

   Top_Menu = gtk_option_menu_new ();
   Menu_Top = gtk_menu_new ();

   Menu_Item = make_menu_item ("Step 2: Select Input Data Series",
                           G_CALLBACK (Func_Input_Select_Primary_Price),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);


  if ( enable_func_menu_price1 == TRUE )
     {
     Menu_Item = make_menu_item ("Primary Price",
                           G_CALLBACK (Func_Input_Select_Primary_Price),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
     gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);
     };

  if ( enable_func_menu_volume1 == TRUE )
     {
     Menu_Item = make_menu_item ("Primary Volume",
                           G_CALLBACK (Func_Input_Select_Primary_Volume),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
     gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);
     };

  if ( enable_func_menu_price2 == TRUE )
     {
     Menu_Item = make_menu_item ("Secondary Price",
                           G_CALLBACK (Func_Input_Select_Secondary_Price),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
     gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);
     };

  if ( enable_func_menu_volume2 == TRUE )
     {
     Menu_Item = make_menu_item ("Secondary Volume",
                           G_CALLBACK (Func_Input_Select_Secondary_Volume),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
     gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);
     };

   gtk_option_menu_set_menu (GTK_OPTION_MENU (Top_Menu), Menu_Top);
gtk_box_pack_start (GTK_BOX (HBox_Top_Menu_Bar), Top_Menu, TRUE, TRUE, 0);

/******************************************************************************/
/* */
/* Create The Output Display Select. */
/* */
/******************************************************************************/

   Top_Menu = gtk_option_menu_new ();
   Menu_Top = gtk_menu_new ();

   Menu_Item = make_menu_item ("Step 3: Output Display Select",
                           G_CALLBACK (Func_Input_Select_Primary_Price),
                           GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);


   Menu_Item = make_menu_item ("Primary Price Window",
                         G_CALLBACK (Func_Display_Select_Primary_Price),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Primary Volume Window",
                         G_CALLBACK (Func_Display_Select_Primary_Volume),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Secondary Price Window",
                         G_CALLBACK (Func_Display_Select_Secondary_Price),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Secondary Volume Window",
                         G_CALLBACK (Func_Display_Select_Secondary_Volume),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 1",
                         G_CALLBACK (Func_Display_Select_Window1),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 2",
                         G_CALLBACK (Func_Display_Select_Window2),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 3",
                         G_CALLBACK (Func_Display_Select_Window3),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 4",
                         G_CALLBACK (Func_Display_Select_Window4),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 5",
                         G_CALLBACK (Func_Display_Select_Window5),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 6",
                         G_CALLBACK (Func_Display_Select_Window6),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 7",
                         G_CALLBACK (Func_Display_Select_Window7),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   Menu_Item = make_menu_item ("Window 8",
                         G_CALLBACK (Func_Display_Select_Window8),
                         GINT_TO_POINTER (GTK_UPDATE_CONTINUOUS));
   gtk_menu_shell_append (GTK_MENU_SHELL (Menu_Top), Menu_Item);

   gtk_option_menu_set_menu (GTK_OPTION_MENU (Top_Menu), Menu_Top);
gtk_box_pack_start (GTK_BOX (HBox_Top_Menu_Bar), Top_Menu, TRUE, TRUE, 0);

/******************************************************************************/
/* */
/* Set Up The Color Select Button. */
/* */
/******************************************************************************/

   Button_Sel = gtk_button_new_with_label ("Step 4: Select Line Color");
gtk_widget_set_size_request(GTK_WIDGET(Button_Sel),(Window_Width/4), Menu_Height);
   /* Width:Height*/
   g_signal_connect (Button_Sel, "clicked",
                      G_CALLBACK (Func_Ind_Adjust_Line_Color), NULL);
gtk_box_pack_start (GTK_BOX(HBox_Top_Menu_Bar), Button_Sel, TRUE, TRUE, 0);

/******************************************************************************/
/* */
/* Horizontal Separator */
/* */
/******************************************************************************/

  Hor_Separator = gtk_hseparator_new ();
gtk_widget_set_size_request (Hor_Separator, Window_Width, Separator_Height);
  /* Width:Height*/
gtk_box_pack_start (GTK_BOX (vbox_top_main), Hor_Separator, FALSE, TRUE, 5);

/******************************************************************************/
/* */
/* Set Up The Select The Number Of Bars. */
/* */
/******************************************************************************/

label = gtk_label_new ( "Step 5: Select The Number Of Bars For The Moving Average\n" );
   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
   gtk_widget_set_size_request (GTK_WIDGET (label), 200, Label_Height );
   gtk_box_pack_start (GTK_BOX (vbox_top_main), label, FALSE, FALSE, 0);

/******************************************************************************/
/* */
/* Set Up The The Number Of Bars. */
/* */
/******************************************************************************/

/* value, lower, upper, step_increment, page_increment, page_size */ /* Note that the page_size value only makes a difference for */ /* scrollbar widgets, and the highest value you'll get is actually */ /* (upper - page_size). */

   MA_Period_Adj = gtk_adjustment_new ( 30.0, 0.0, 500.0, 1.0, 1.0, 1.0 );
   hscale = gtk_hscale_new (GTK_ADJUSTMENT (MA_Period_Adj));
gtk_widget_set_size_request (GTK_WIDGET (hscale), Window_Width, Scale_Height );
   gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
   gtk_scale_set_digits (hscale, 0);
   gtk_scale_set_value_pos (hscale, GTK_POS_TOP);
   gtk_scale_set_draw_value (hscale, TRUE);
   gtk_box_pack_start (GTK_BOX (vbox_top_main), hscale, TRUE, TRUE, 0);
   gtk_widget_show (hscale);
   g_signal_connect( MA_Period_Adj, "value_changed",
       G_CALLBACK(MA_On_Expose_Event), NULL);

/******************************************************************************/
/* */
/* Horizontal Separator */
/* */
/******************************************************************************/

  Hor_Separator = gtk_hseparator_new ();
gtk_widget_set_size_request ( Hor_Separator, Window_Width, Separator_Height);
  /* Width:Height*/
gtk_box_pack_start (GTK_BOX (vbox_top_main), Hor_Separator, FALSE, TRUE, 5);

/******************************************************************************/
/* */
/* Set Up The Shift Left Right Label. */
/* */
/******************************************************************************/

label = gtk_label_new ( "<- Left <- Step 6: Moving Average Shift Left Or Right -> Right ->\n" );
   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
   gtk_widget_set_size_request (GTK_WIDGET (label), 200, Label_Height );
   gtk_box_pack_start (GTK_BOX (vbox_top_main), label, FALSE, FALSE, 0);

/******************************************************************************/
/* */
/* Set Up The Shift Left Right Scale. */
/* */
/******************************************************************************/

/* value, lower, upper, step_increment, page_increment, page_size */ /* Note that the page_size value only makes a difference for */ /* scrollbar widgets, and the highest value you'll get is actually */ /* (upper - page_size). */

MA_Offset_Adj = gtk_adjustment_new ( 0.0, -250.0, 250.0, 1.0, 1.0, 1.0 );
   hscale = gtk_hscale_new (GTK_ADJUSTMENT (MA_Offset_Adj));
gtk_widget_set_size_request (GTK_WIDGET (hscale), Window_Width, Scale_Height );
   gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS);
   gtk_scale_set_digits (hscale, 0);
   gtk_scale_set_value_pos (hscale, GTK_POS_TOP);
   gtk_scale_set_draw_value (hscale, TRUE);
   gtk_box_pack_start (GTK_BOX (vbox_top_main), hscale, TRUE, TRUE, 0);
   gtk_widget_show (hscale);
   g_signal_connect( MA_Offset_Adj, "value_changed",
       G_CALLBACK(MA_On_Expose_Event), NULL);

/******************************************************************************/
/* */
/* Set Up The Bottom Exit Button Hbox. */
/* */
/******************************************************************************/

   hbox_top1 = gtk_hbox_new (FALSE, 0);
   gtk_widget_set_size_request (hbox_top1, Window_Width, Menu_Height );
   /* Width : Height */
   gtk_container_set_border_width (GTK_CONTAINER (hbox_top1), 1 );
   gtk_container_add (GTK_CONTAINER (vbox_top_main), hbox_top1);

/******************************************************************************/
/* */
/* Create And Process Button Exit */
/* */
/******************************************************************************/

   Button_Sel = gtk_button_new_with_label ("Step 7: Create MA And Exit");
gtk_widget_set_size_request(GTK_WIDGET(Button_Sel),(Window_Width/2),Menu_Height);
   /* Width:Height*/
   g_signal_connect (Button_Sel, "clicked",
                      G_CALLBACK (Button_MA_Create_Exit_Func), NULL);
   gtk_box_pack_start (GTK_BOX(hbox_top1), Button_Sel, TRUE, TRUE, 0);

   Button_Sel = gtk_button_new_with_label ("Cancel");
gtk_widget_set_size_request(GTK_WIDGET(Button_Sel),(Window_Width/2),Menu_Height);
   /* Width:Height*/
   g_signal_connect (Button_Sel, "clicked",
                      G_CALLBACK (Button_MA_Cancel), NULL);
   gtk_box_pack_start (GTK_BOX(hbox_top1), Button_Sel, TRUE, TRUE, 0);

   gtk_widget_show (Hor_Separator);
   gtk_widget_show ( Button_Sel );
   gtk_widget_show ( MA_Hbox_Cairo );
   gtk_widget_show ( HBox_Top_Menu_Bar );
   gtk_widget_show ( hbox_top1 );
   gtk_widget_show ( vbox_top_main );
   gtk_widget_show_all( MA_Window );

   printf ( "Finished Create_Moving_Average\n" );

   } /* End Create_Moving_Average */

/******************************************************************************/
/* */
/* Function: MA_On_Expose_Event ( ) */
/* */
/******************************************************************************/

MA_On_Expose_Event ( )
   {
   double Red;
   double Green;
   double Blue;
   int Cairo_Box_Height;
   int Cairo_Box_Width;
   Cairo_Box_Height = 200;
   Cairo_Box_Width  = 1000;

   MA_Period = gtk_adjustment_get_value ( MA_Period_Adj );
   MA_Offset = gtk_adjustment_get_value ( MA_Offset_Adj );

   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Period = %f   Offset = %f\n", MA_Period, MA_Offset );

   MA_Cr = gdk_cairo_create( MA_Hbox_Cairo->window );
   Red   = Color_Default_Basic_White.Red;
   Green = Color_Default_Basic_White.Green;
   Blue  = Color_Default_Basic_White.Blue;
   cairo_set_source_rgb( MA_Cr, Red, Green, Blue );
   cairo_rectangle( MA_Cr, 0, 0, Cairo_Box_Width, Cairo_Box_Height );
   cairo_fill( MA_Cr );
   Draw_MA_Text( );
   };

/******************************************************************************/
/* */
/* Function: Button_MA_Create_Exit_Func( ) */
/* */
/******************************************************************************/

Button_MA_Create_Exit_Func( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Button_Sel_Color_Func\n" );

   MA_Period = gtk_adjustment_get_value ( MA_Period_Adj );
   MA_Offset = gtk_adjustment_get_value ( MA_Offset_Adj );

   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Period = %f   Offset = %f\n", MA_Period, MA_Offset );

   MA_Control[MA_Select_Index].MA_Enabled = 1;
   MA_Control[MA_Select_Index].MA_Calculated = 0;
   MA_Control[MA_Select_Index].MA_Select_Algorithm = MA_Select_Algorithm;
MA_Control[MA_Select_Index].MA_Input_Data_Series = Ind_Input_Data_Series;
   MA_Control[MA_Select_Index].MA_Display_Select = Ind_Display_Select;
   MA_Control[MA_Select_Index].MA_Period = MA_Period;
   MA_Control[MA_Select_Index].MA_Offset = MA_Offset;
   MA_Control[MA_Select_Index].MA_Color.Red = Color_Selected.Red;
   MA_Control[MA_Select_Index].MA_Color.Green = Color_Selected.Green;
   MA_Control[MA_Select_Index].MA_Color.Blue = Color_Selected.Blue;

   if ( Print_Head->Print_Headers_Event == TRUE )
      {
printf ( "MA_Enabled = %d\n", MA_Control[MA_Select_Index].MA_Enabled ); printf ( "MA_Calculated = %d\n", MA_Control[MA_Select_Index].MA_Calculated ); printf ( "MA_Select_Algorithm = %d\n", MA_Control[MA_Select_Index].MA_Select_Algorithm ); printf ( "MA_Input_Data_Series = %d\n", MA_Control[MA_Select_Index].MA_Input_Data_Series ); printf ( "MA_Display_Select = %d\n", MA_Control[MA_Select_Index].MA_Display_Select ); printf ( "MA_Period = %1.0f\n", MA_Control[MA_Select_Index].MA_Period ); printf ( "MA_Offset = %1.0f\n", MA_Control[MA_Select_Index].MA_Offset ); printf ( "Red = %f\n", MA_Control[MA_Select_Index].MA_Color.Red ); printf ( "Green = %f\n", MA_Control[MA_Select_Index].MA_Color.Green ); printf ( "Blue = %f\n", MA_Control[MA_Select_Index].MA_Color.Blue );
      };

   gtk_widget_destroy( MA_Window );

   };

/******************************************************************************/
/* */
/* Function: Button_MA_Cancel( ) */
/* */
/******************************************************************************/

Button_MA_Cancel( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Button_MA_Cancel\n" );

   gtk_widget_destroy( MA_Window );

   };

/******************************************************************************/
/* */
/* Function: Draw_MA_Text() */
/* */
/******************************************************************************/

Draw_MA_Text( )
   { /* Start Draw_MA_Text */
   char Cairo_Text_String1[64];
   char Cairo_Input_String1[64];
   char Cairo_Alg_String1[64];
   char Cairo_Display_String1[64];
   char Temp_String[64];
   int X_Offset;
   int Y_Offset;

   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Draw_MA_Text\n" );

   X_Offset = 20;
   Y_Offset = 20;

   Red   = Color_Default_Basic_Blue.Red;
   Green = Color_Default_Basic_Blue.Green;
   Blue  = Color_Default_Basic_Blue.Blue;

   cairo_set_source_rgb( MA_Cr, Red, Green, Blue );
   cairo_set_font_size( MA_Cr, 14 );

   strcpy ( Cairo_Text_String1, "MA_Input_Data_Series: " );

   if ( Ind_Input_Data_Series == SELECT_INPUT_NULL )
      strcat ( Cairo_Input_String1, "None" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_PRICE1 )
      strcat ( Cairo_Input_String1, "Price1" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_VOLUME1 )
      strcat ( Cairo_Input_String1, "Volume1" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_PRICE2 )
      strcat ( Cairo_Input_String1, "Price2" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_VOLUME2 )
      strcat ( Cairo_Input_String1, "Volume2" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_0 )
      strcat ( Cairo_Input_String1, "MA_0" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_1 )
      strcat ( Cairo_Input_String1, "MA_1" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_2 )
      strcat ( Cairo_Input_String1, "MA_2" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_3 )
      strcat ( Cairo_Input_String1, "MA_3" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_4 )
      strcat ( Cairo_Input_String1, "MA_4" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_5 )
      strcat ( Cairo_Input_String1, "MA_5" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_6 )
      strcat ( Cairo_Input_String1, "MA_6" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_7 )
      strcat ( Cairo_Input_String1, "MA_7" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_8 )
      strcat ( Cairo_Input_String1, "MA_8" );
      else
   if ( Ind_Input_Data_Series == SELECT_INPUT_MA_9 )
      strcat ( Cairo_Input_String1, "MA_9" );

   if ( MA_Select_Algorithm == MA_NONE )
      strcat ( Cairo_Alg_String1, "None" );
      else
   if ( MA_Select_Algorithm == MA_SIMPLE )
      strcat ( Cairo_Alg_String1, "Simple_MA" );
      else
   if ( MA_Select_Algorithm == MA_EXPONENTIAL )
      strcat ( Cairo_Alg_String1, "Exponental_MA" );

   if ( Ind_Display_Select == SELECT_NULL )
      strcat ( Cairo_Display_String1, "None" );
      else
   if ( Ind_Display_Select == SELECT_PRICE1 )
      strcat ( Cairo_Display_String1, "Price1" );
      else
   if ( Ind_Display_Select == SELECT_VOLUME1 )
      strcat ( Cairo_Display_String1, "Volume1" );
      else
   if ( Ind_Display_Select == SELECT_PRICE2 )
      strcat ( Cairo_Display_String1, "Price2" );
      else
   if ( Ind_Display_Select == SELECT_VOLUME2 )
      strcat ( Cairo_Display_String1, "Volume2" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_1 )
      strcat ( Cairo_Display_String1, "Window 1" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_2 )
      strcat ( Cairo_Display_String1, "Window 2" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_3 )
      strcat ( Cairo_Display_String1, "Window 3" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_4 )
      strcat ( Cairo_Display_String1, "Window 4" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_5 )
      strcat ( Cairo_Display_String1, "Window 5" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_6 )
      strcat ( Cairo_Display_String1, "Window 6" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_7 )
      strcat ( Cairo_Display_String1, "Window 7" );
      else
   if ( Ind_Display_Select == SELECT_WINDOW_8 )
      strcat ( Cairo_Display_String1, "Window 8" );

   strcpy ( Cairo_Text_String1, "MA_Name: MA_" );
   sprintf ( Temp_String, "%d", MA_Select_Index );
   strcat ( Cairo_Text_String1, Temp_String );
   strcat ( Cairo_Text_String1, "_" );
   strcat ( Cairo_Text_String1, Cairo_Input_String1 );
   strcat ( Cairo_Text_String1, "_" );
   strcat ( Cairo_Text_String1, Cairo_Alg_String1  );
   strcat ( Cairo_Text_String1, "_" );
   strcat ( Cairo_Text_String1, "P" );
   sprintf ( Temp_String, "%1.0f", MA_Period );
   strcat ( Cairo_Text_String1, Temp_String );
   strcat ( Cairo_Text_String1, "_" );
   strcat ( Cairo_Text_String1, "O" );
   sprintf ( Temp_String, "%1.0f", MA_Offset );
   strcat ( Cairo_Text_String1, Temp_String );
   cairo_move_to( MA_Cr, X_Offset, Y_Offset );
   cairo_show_text( MA_Cr, Cairo_Text_String1 );

   Y_Offset = Y_Offset + 20;
   strcpy ( Cairo_Text_String1, "MA_Select_Algorithm: " );
   strcat ( Cairo_Text_String1, Cairo_Alg_String1  );
   cairo_move_to( MA_Cr, X_Offset, Y_Offset );
   cairo_show_text( MA_Cr, Cairo_Text_String1 );

   Y_Offset = Y_Offset + 20;
   strcpy ( Cairo_Text_String1, "MA_Input_Data_Series: " );
   strcat ( Cairo_Text_String1, Cairo_Input_String1 );
   cairo_move_to( MA_Cr, X_Offset, Y_Offset );
   cairo_show_text( MA_Cr, Cairo_Text_String1 );

   Y_Offset = Y_Offset + 20;
   strcpy ( Cairo_Text_String1, "MA_Output_Display_Select: " );
   strcat ( Cairo_Text_String1, Cairo_Display_String1 );
   cairo_move_to( MA_Cr, X_Offset, Y_Offset );
   cairo_show_text( MA_Cr, Cairo_Text_String1 );

   Y_Offset = Y_Offset + 20;
   strcpy ( Cairo_Text_String1, "MA_Period: " );
   sprintf ( Temp_String, "%1.0f", MA_Period );
   strcat ( Cairo_Text_String1, Temp_String );
   cairo_move_to( MA_Cr, X_Offset, Y_Offset );
   cairo_show_text( MA_Cr, Cairo_Text_String1 );

   Y_Offset = Y_Offset + 20;
   strcpy ( Cairo_Text_String1, "MA_Offset: " );
   sprintf ( Temp_String, "%1.0f", MA_Offset );
   strcat ( Cairo_Text_String1, Temp_String );
   cairo_move_to( MA_Cr, X_Offset, Y_Offset );
   cairo_show_text( MA_Cr, Cairo_Text_String1 );

   }; /* End Draw_MA_Text */

/******************************************************************************/
/* */
/* Select MA Algorithm Menu Functions. */
/* */
/******************************************************************************/

void Func_Moving_Average_Simple( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Moving_Average_Simple\n" );

   MA_Select_Algorithm = MA_SIMPLE;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Moving_Average_Exponetial( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Moving_Average_Exponetial\n" );

   MA_Select_Algorithm = MA_EXPONENTIAL;
   gtk_widget_queue_draw( MA_Window );
   };

/******************************************************************************/
/* */
/* Select Input Data Series Menu Functions. */
/* */
/******************************************************************************/

void Func_Input_Select_Primary_Price( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Input_Select_Primary_Price\n" );
   Ind_Input_Data_Series = SELECT_INPUT_PRICE1;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Input_Select_Primary_Volume( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Input_Select_Primary_Volume\n" );

   Ind_Input_Data_Series = SELECT_INPUT_VOLUME1;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Input_Select_Secondary_Price( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Input_Select_Secondary_Price\n" );

   Ind_Input_Data_Series = SELECT_INPUT_PRICE2;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Input_Select_Secondary_Volume( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Input_Select_Secondary_Volume\n" );

   Ind_Input_Data_Series = SELECT_INPUT_VOLUME2;
   gtk_widget_queue_draw( MA_Window );
   };

/******************************************************************************/
/* */
/* Select Display Select Menu Functions. */
/* */
/******************************************************************************/

void Func_Display_Select_Primary_Price( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Primary_Price\n" );

   Ind_Display_Select = SELECT_PRICE1;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Primary_Volume( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Primary_Volume\n" );

   Ind_Display_Select = SELECT_VOLUME1;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Secondary_Price( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Secondary_Price\n" );

   Ind_Display_Select = SELECT_PRICE2;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Secondary_Volume( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Secondary_Volume\n" );

   Ind_Display_Select = SELECT_VOLUME2;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window1( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window1\n" );

   Ind_Display_Select = SELECT_WINDOW_1;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window2( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window2\n" );

   Ind_Display_Select = SELECT_WINDOW_2;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window3( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window3\n" );

   Ind_Display_Select = SELECT_WINDOW_3;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window4( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window4\n" );

   Ind_Display_Select = SELECT_WINDOW_4;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window5( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window5\n" );

   Ind_Display_Select = SELECT_WINDOW_5;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window6( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window6\n" );

   Ind_Display_Select = SELECT_WINDOW_6;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window7( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window7\n" );

   Ind_Display_Select = SELECT_WINDOW_7;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Display_Select_Window8( )
   {
   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Display_Select_Window8\n" );

   Ind_Display_Select = SELECT_WINDOW_8;
   gtk_widget_queue_draw( MA_Window );
   };

void Func_Ind_Adjust_Line_Color( )
   {
   int c;
   int d;

   if ( Print_Head->Print_Headers_Event == TRUE )
      g_print ( "Menu: Func_Ind_Line_Color\n" );


   Color_Select_Menu ( );

   MA_Color.Red   = Color_Selected.Red;
   MA_Color.Green = Color_Selected.Green;
   MA_Color.Blue  = Color_Selected.Blue;

   gtk_widget_queue_draw( MA_Window );
   };






















[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]