~ubuntu-branches/ubuntu/maverick/grafx2/maverick

« back to all changes in this revision

Viewing changes to engine.c

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2009-09-21 14:24:19 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090921142419-lhpqq102buior0ol
Tags: 2.1-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
  "Filled rectangles       ",
76
76
  "Empty circles / ellipses",
77
77
  "Filled circles / ellips.",
78
 
  "Grad. rectangles        ",
79
 
  "Gradation menu          ",
 
78
  "Grad. rect / Grad. menu ",
80
79
  "Grad. spheres / ellipses",
81
80
  "Brush grab. / Restore   ",
82
81
  "Lasso / Restore brush   ",
89
88
  "Go / Copy to other page ",
90
89
  "Save as / Save          ",
91
90
  "Load / Re-load          ",
92
 
  "Settings                ",
 
91
  "Settings / Skins        ",
93
92
  "Clear / with backcolor  ",
94
93
  "Help / Statistics       ",
95
94
  "Undo / Redo             ",
96
95
  "Kill current page       ",
97
96
  "Quit                    ",
98
 
  "Palette editor          ",
 
97
  "Palette editor / setup  ",
99
98
  "Scroll pal. bkwd / Fast ",
100
99
  "Scroll pal. fwd / Fast  ",
101
100
  "Color #"                 ,
108
107
  int index;
109
108
  if(*buffer != NULL) DEBUG("WARNING : buffer already allocated !!!",0);
110
109
  *buffer=(byte *) malloc(width*Menu_factor_X*height*Menu_factor_Y*Pixel_width);
 
110
  if(*buffer==NULL) Error(0);
111
111
  for (index=0; index<(height*Menu_factor_Y); index++)
112
112
    Read_line(x_pos,y_pos+index,width*Menu_factor_X,(*buffer)+((int)index*width*Menu_factor_X*Pixel_width));
113
113
}
119
119
  for (index=0; index<height*Menu_factor_Y; index++)
120
120
    Display_line_fast(x_pos,y_pos+index,width*Menu_factor_X,buffer+((int)index*width*Menu_factor_X*Pixel_width));
121
121
  free(buffer);
 
122
  buffer = NULL;
122
123
}
123
124
 
124
125
///Draw a pixel in a saved screen block (when you sort colors in the palette, for example)
211
212
    case BUTTON_SHAPE_RECTANGLE  :
212
213
      // On colorie le point haut droit
213
214
      Pixel_in_menu(end_x,start_y,color_diagonal);
214
 
      GFX_menu_block[start_y][end_x]=color_diagonal;
 
215
      Gfx->Menu_block[start_y][end_x]=color_diagonal;
215
216
      // On colorie le point bas gauche
216
217
      Pixel_in_menu(start_x,end_y,color_diagonal);
217
 
      GFX_menu_block[end_y][start_x]=color_diagonal;
 
218
      Gfx->Menu_block[end_y][start_x]=color_diagonal;
218
219
      // On colorie la partie haute
219
220
      for (x_pos=start_x;x_pos<=end_x-1;x_pos++)
220
221
      {
221
222
        Pixel_in_menu(x_pos,start_y,color_top_left);
222
 
        GFX_menu_block[start_y][x_pos]=color_top_left;
 
223
        Gfx->Menu_block[start_y][x_pos]=color_top_left;
223
224
      }
224
225
      for (y_pos=start_y+1;y_pos<=end_y-1;y_pos++)
225
226
      {
226
227
        // On colorie la partie gauche
227
228
        Pixel_in_menu(start_x,y_pos,color_top_left);
228
 
        GFX_menu_block[y_pos][start_x]=color_top_left;
 
229
        Gfx->Menu_block[y_pos][start_x]=color_top_left;
229
230
        // On colorie la partie droite
230
231
        Pixel_in_menu(end_x,y_pos,color_bottom_right);
231
 
        GFX_menu_block[y_pos][end_x]=color_bottom_right;
 
232
        Gfx->Menu_block[y_pos][end_x]=color_bottom_right;
232
233
      }
233
234
      // On colorie la partie basse
234
235
      for (x_pos=start_x+1;x_pos<=end_x;x_pos++)
235
236
      {
236
237
        Pixel_in_menu(x_pos,end_y,color_bottom_right);
237
 
        GFX_menu_block[end_y][x_pos]=color_bottom_right;
 
238
        Gfx->Menu_block[end_y][x_pos]=color_bottom_right;
238
239
      }
239
240
      break;
240
241
    case BUTTON_SHAPE_TRIANGLE_TOP_LEFT:
241
242
      // On colorie le point haut droit
242
243
      Pixel_in_menu(end_x,start_y,color_diagonal);
243
 
      GFX_menu_block[start_y][end_x]=color_diagonal;
 
244
      Gfx->Menu_block[start_y][end_x]=color_diagonal;
244
245
      // On colorie le point bas gauche
245
246
      Pixel_in_menu(start_x,end_y,color_diagonal);
246
 
      GFX_menu_block[end_y][start_x]=color_diagonal;
 
247
      Gfx->Menu_block[end_y][start_x]=color_diagonal;
247
248
      // On colorie le coin haut gauche
248
249
      for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
249
250
      {
250
251
        Pixel_in_menu(start_x+x_pos,start_y,color_top_left);
251
 
        GFX_menu_block[start_y][start_x+x_pos]=color_top_left;
 
252
        Gfx->Menu_block[start_y][start_x+x_pos]=color_top_left;
252
253
        Pixel_in_menu(start_x,start_y+x_pos,color_top_left);
253
 
        GFX_menu_block[start_y+x_pos][start_x]=color_top_left;
 
254
        Gfx->Menu_block[start_y+x_pos][start_x]=color_top_left;
254
255
      }
255
256
      // On colorie la diagonale
256
257
      for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
257
258
      {
258
259
        Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_bottom_right);
259
 
        GFX_menu_block[end_y-x_pos][start_x+x_pos]=color_bottom_right;
 
260
        Gfx->Menu_block[end_y-x_pos][start_x+x_pos]=color_bottom_right;
260
261
      }
261
262
      break;
262
263
    case BUTTON_SHAPE_TRIANGLE_BOTTOM_RIGHT:
263
264
      // On colorie le point haut droit
264
265
      Pixel_in_menu(end_x,start_y,color_diagonal);
265
 
      GFX_menu_block[start_y][end_x]=color_diagonal;
 
266
      Gfx->Menu_block[start_y][end_x]=color_diagonal;
266
267
      // On colorie le point bas gauche
267
268
      Pixel_in_menu(start_x,end_y,color_diagonal);
268
 
      GFX_menu_block[end_y][start_x]=color_diagonal;
 
269
      Gfx->Menu_block[end_y][start_x]=color_diagonal;
269
270
      // On colorie la diagonale
270
271
      for (x_pos=1;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
271
272
      {
272
273
        Pixel_in_menu(start_x+x_pos,end_y-x_pos,color_top_left);
273
 
        GFX_menu_block[end_y-x_pos][start_x+x_pos]=color_top_left;
 
274
        Gfx->Menu_block[end_y-x_pos][start_x+x_pos]=color_top_left;
274
275
      }
275
276
      // On colorie le coin bas droite
276
277
      for (x_pos=0;x_pos<Buttons_Pool[btn_number].Width;x_pos++)
277
278
      {
278
279
        Pixel_in_menu(end_x-x_pos,end_y,color_bottom_right);
279
 
        GFX_menu_block[end_y][end_x-x_pos]=color_bottom_right;
 
280
        Gfx->Menu_block[end_y][end_x-x_pos]=color_bottom_right;
280
281
        Pixel_in_menu(end_x,end_y-x_pos,color_bottom_right);
281
 
        GFX_menu_block[end_y-x_pos][end_x]=color_bottom_right;
 
282
        Gfx->Menu_block[end_y-x_pos][end_x]=color_bottom_right;
282
283
      }
283
284
  }
284
285
  if (Menu_is_visible)
372
373
      // the unselection of all "Tool" buttons.
373
374
      if (btn_number==BUTTON_ADJUST && click==RIGHT_SIDE)
374
375
        break;
 
376
      // Same case with the Grad. Rectangle button.
 
377
      if (btn_number==BUTTON_GRADRECT && click==RIGHT_SIDE)
 
378
        break;
375
379
      // Pour chaque bouton:
376
380
      for (b=0; b<NB_BUTTONS; b++)
377
381
        // S'il est de la m�me famille
774
778
          Key=0;
775
779
          break;
776
780
        case SPECIAL_EXCLUDE_COLORS_MENU : // Exclude colors menu
777
 
          Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL);
 
781
          Menu_tag_colors("Tag colors to exclude",Exclude_color,&temp,1, NULL, SPECIAL_EXCLUDE_COLORS_MENU);
778
782
          Key=0;
779
783
          break;
780
784
        case SPECIAL_INVERT_SIEVE :
821
825
          Button_Grid_menu();
822
826
          Key=0;
823
827
          break;
 
828
        case SPECIAL_SHOW_GRID :
 
829
          Button_Show_grid();
 
830
          Key=0;
 
831
          break;
824
832
        case SPECIAL_SIEVE_MODE :
825
833
          Button_Sieve_mode();
826
834
          Key=0;
857
865
          Button_Tiling_menu();
858
866
          Key=0;
859
867
          break;
 
868
        case SPECIAL_EFFECTS_OFF :
 
869
          Effects_off();
 
870
          Key=0;
 
871
          break;
 
872
        case SPECIAL_TRANSPARENCY_1 :
 
873
          Transparency_set(1);
 
874
          Key=0;
 
875
          break;
 
876
        case SPECIAL_TRANSPARENCY_2 :
 
877
          Transparency_set(2);
 
878
          Key=0;
 
879
          break;
 
880
        case SPECIAL_TRANSPARENCY_3 :
 
881
          Transparency_set(3);
 
882
          Key=0;
 
883
          break;
 
884
        case SPECIAL_TRANSPARENCY_4 :
 
885
          Transparency_set(4);
 
886
          Key=0;
 
887
          break;
 
888
        case SPECIAL_TRANSPARENCY_5 :
 
889
          Transparency_set(5);
 
890
          Key=0;
 
891
          break;
 
892
        case SPECIAL_TRANSPARENCY_6 :
 
893
          Transparency_set(6);
 
894
          Key=0;
 
895
          break;
 
896
        case SPECIAL_TRANSPARENCY_7 :
 
897
          Transparency_set(7);
 
898
          Key=0;
 
899
          break;
 
900
        case SPECIAL_TRANSPARENCY_8 :
 
901
          Transparency_set(8);
 
902
          Key=0;
 
903
          break;
 
904
        case SPECIAL_TRANSPARENCY_9 :
 
905
          Transparency_set(9);
 
906
          Key=0;
 
907
          break;
 
908
        case SPECIAL_TRANSPARENCY_0 :
 
909
          Transparency_set(0);
 
910
          Key=0;
 
911
          break;
 
912
        case SPECIAL_ZOOM_1 :
 
913
          Zoom_set(-1);
 
914
          Key=0;
 
915
          break;
 
916
        case SPECIAL_ZOOM_2 :
 
917
          Zoom_set(0);
 
918
          Key=0;
 
919
          break;
 
920
        case SPECIAL_ZOOM_3 :
 
921
          Zoom_set(1);
 
922
          Key=0;
 
923
          break;
 
924
        case SPECIAL_ZOOM_4 :
 
925
          Zoom_set(2);
 
926
          Key=0;
 
927
          break;
 
928
        case SPECIAL_ZOOM_5 :
 
929
          Zoom_set(3);
 
930
          Key=0;
 
931
          break;
 
932
        case SPECIAL_ZOOM_6 :
 
933
          Zoom_set(4);
 
934
          Key=0;
 
935
          break;
 
936
        case SPECIAL_ZOOM_8 :
 
937
          Zoom_set(5);
 
938
          Key=0;
 
939
          break;
 
940
        case SPECIAL_ZOOM_10 :
 
941
          Zoom_set(6);
 
942
          Key=0;
 
943
          break;
 
944
        case SPECIAL_ZOOM_12 :
 
945
          Zoom_set(7);
 
946
          Key=0;
 
947
          break;
 
948
        case SPECIAL_ZOOM_14 :
 
949
          Zoom_set(8);
 
950
          Key=0;
 
951
          break;
 
952
        case SPECIAL_ZOOM_16 :
 
953
          Zoom_set(9);
 
954
          Key=0;
 
955
          break;
 
956
        case SPECIAL_ZOOM_18 :
 
957
          Zoom_set(10);
 
958
          Key=0;
 
959
          break;
 
960
        case SPECIAL_ZOOM_20 :
 
961
          Zoom_set(11);
 
962
          Key=0;
 
963
          break;
860
964
        default   : // Gestion des touches de raccourci de bouton:
861
965
          // Pour chaque bouton
862
966
          shortcut_button=-1;
1132
1236
  T_Scroller_button * temp3;
1133
1237
  T_Special_button  * temp4;
1134
1238
  T_Dropdown_button * temp5;
 
1239
  T_List_button     * temp6;
1135
1240
 
1136
1241
  Hide_cursor();
1137
1242
 
1166
1271
    free(Window_dropdown_button_list);
1167
1272
    Window_dropdown_button_list=temp5;
1168
1273
  }
 
1274
  while (Window_list_button_list)
 
1275
  {
 
1276
    temp6=Window_list_button_list->Next;
 
1277
    free(Window_list_button_list);
 
1278
    Window_list_button_list=temp6;
 
1279
  }
1169
1280
 
1170
1281
  if (Windows_open != 1)
1171
1282
  {
1613
1724
    }
1614
1725
}
1615
1726
 
 
1727
//----------------------- Create a List control -----------------------
 
1728
// These controls are special. They work over two controls previously created:
 
1729
// - entry_button is the textual area where the list values will be printed.
 
1730
// - scroller is a scroller button attached to it
 
1731
 
 
1732
T_List_button * Window_set_list_button(T_Special_button * entry_button, T_Scroller_button * scroller, Func_draw_list_item draw_list_item)
 
1733
{
 
1734
  T_List_button *temp;
 
1735
 
 
1736
  temp=(T_List_button *)malloc(sizeof(T_List_button));
 
1737
  temp->Number          =++Window_nb_buttons;
 
1738
  temp->List_start      = 0;
 
1739
  temp->Cursor_position = 0;
 
1740
  temp->Entry_button    = entry_button;
 
1741
  temp->Scroller        = scroller;
 
1742
  temp->Draw_list_item  = draw_list_item;
 
1743
 
 
1744
  temp->Next=Window_list_button_list;
 
1745
  Window_list_button_list=temp;
 
1746
  return temp;
 
1747
}
 
1748
 
 
1749
void Window_redraw_list(T_List_button * list)
 
1750
{
 
1751
  int i;
 
1752
 
 
1753
  for (i=Min(list->Scroller->Nb_visibles-1, list->Scroller->Nb_elements-1); i>=0; i--)
 
1754
  {
 
1755
    list->Draw_list_item(
 
1756
      list->Entry_button->Pos_X,
 
1757
      list->Entry_button->Pos_Y + i * 8,
 
1758
      list->List_start + i,
 
1759
      i == list->Cursor_position);
 
1760
  }
 
1761
}
 
1762
 
1616
1763
//----------------------- Ouverture d'un pop-up -----------------------
1617
1764
 
1618
1765
void Open_popup(word x_pos, word y_pos, word width,word height)
1676
1823
  T_Palette_button  * temp2;
1677
1824
  T_Scroller_button * temp3;
1678
1825
  T_Special_button  * temp4;
1679
 
  T_Dropdown_button  * temp5;
 
1826
  T_Dropdown_button * temp5;
 
1827
  T_List_button     * temp6;
1680
1828
 
1681
1829
  Hide_cursor();
1682
1830
 
1711
1859
    free(Window_dropdown_button_list);
1712
1860
    Window_dropdown_button_list=temp5;
1713
1861
  }
1714
 
 
 
1862
  while (Window_list_button_list)
 
1863
  {
 
1864
    temp6=Window_list_button_list->Next;
 
1865
    free(Window_list_button_list);
 
1866
    Window_list_button_list=temp6;
 
1867
  }
 
1868
  
1715
1869
  if (Windows_open != 1)
1716
1870
  {
1717
1871
    // Restore de ce que la fen�tre cachait
1835
1989
// -------------- R�cup�ration d'une couleur derri�re un menu ----------------
1836
1990
void Get_color_behind_window(byte * color, byte * click)
1837
1991
{
1838
 
  short width=Window_width*Menu_factor_X;
1839
 
  short height=Window_height*Menu_factor_Y;
1840
1992
  short old_x=-1;
1841
1993
  short old_y=-1;
1842
1994
  short index;
1843
1995
  short a,b,c,d; // Variables temporaires et multit�ches...
1844
 
  byte * buffer;
 
1996
  byte * buffer = NULL;
1845
1997
  char str[25];
1846
1998
  byte cursor_was_hidden;
1847
1999
 
1848
2000
 
1849
 
  if ((buffer=(byte *) malloc(width*height)))
1850
 
  {
1851
 
    Hide_cursor();
1852
 
 
1853
 
    cursor_was_hidden=Cursor_hidden;
1854
 
    Cursor_hidden=0;
1855
 
 
1856
 
    for (index=0; index<height; index++)
1857
 
      Read_line(Window_pos_X,Window_pos_Y+index,width,buffer+((int)index*width*Pixel_width));
1858
 
    a=Menu_Y;
1859
 
    Menu_Y=Menu_Y_before_window;
1860
 
    b=Menu_is_visible;
1861
 
    Menu_is_visible=Menu_is_visible_before_window;
1862
 
    Display_all_screen();
1863
 
    Display_menu();
1864
 
    Menu_Y=a;
1865
 
    Menu_is_visible=b;
1866
 
 
1867
 
    Cursor_shape=CURSOR_SHAPE_COLORPICKER;
1868
 
    b=Paintbrush_hidden;
1869
 
    Paintbrush_hidden=1;
1870
 
    c=-1; // color point�e: au d�but aucune, comme �a on initialise tout
1871
 
    if (Menu_is_visible_before_window)
1872
 
      Print_in_menu(Menu_tooltip[BUTTON_CHOOSE_COL],0);
1873
 
 
1874
 
    Display_cursor();
1875
 
 
1876
 
    do
1877
 
    {
1878
 
      if(!Get_input())SDL_Delay(20);
1879
 
 
1880
 
      if ((Mouse_X!=old_x) || (Mouse_Y!=old_y))
1881
 
      {
1882
 
        Hide_cursor();
1883
 
        a=Read_pixel(Mouse_X,Mouse_Y);
1884
 
        if (a!=c)
1885
 
        {
1886
 
          c=a; // Mise � jour de la couleur point�e
1887
 
          if (Menu_is_visible_before_window)
1888
 
          {
1889
 
            sprintf(str,"%d",a);
1890
 
            d=strlen(str);
1891
 
            strcat(str,"   (");
1892
 
            sprintf(str+strlen(str),"%d",Main_palette[a].R);
1893
 
            strcat(str,",");
1894
 
            sprintf(str+strlen(str),"%d",Main_palette[a].G);
1895
 
            strcat(str,",");
1896
 
            sprintf(str+strlen(str),"%d",Main_palette[a].B);
1897
 
            strcat(str,")");
1898
 
            a=24-d;
1899
 
            for (index=strlen(str); index<a; index++)
1900
 
              str[index]=' ';
1901
 
            str[a]=0;
1902
 
            Print_in_menu(str,strlen(Menu_tooltip[BUTTON_CHOOSE_COL]));
1903
 
 
1904
 
            Print_general((26+((d+strlen(Menu_tooltip[BUTTON_CHOOSE_COL]))<<3))*Menu_factor_X,
1905
 
                          Menu_status_Y," ",0,c);
1906
 
          }
1907
 
        }
1908
 
        Display_cursor();
1909
 
      }
1910
 
 
1911
 
      old_x=Mouse_X;
1912
 
      old_y=Mouse_Y;
1913
 
    } while (!(Mouse_K || (Key==KEY_ESC)));
1914
 
 
1915
 
    if (Mouse_K)
1916
 
    {
1917
 
      Hide_cursor();
1918
 
      *click=Mouse_K;
1919
 
      *color=Read_pixel(Mouse_X,Mouse_Y);
1920
 
    }
1921
 
    else
1922
 
    {
1923
 
      *click=0;
1924
 
      Hide_cursor();
1925
 
    }
1926
 
 
1927
 
    for (index=0; index<height; index++)
1928
 
      Display_line(Window_pos_X,Window_pos_Y+index,width,buffer+((int)index*width));
1929
 
    Update_rect(Window_pos_X, Window_pos_Y, Window_width*Menu_factor_X, Window_height*Menu_factor_Y);
1930
 
    Cursor_shape=CURSOR_SHAPE_ARROW;
1931
 
    Paintbrush_hidden=b;
1932
 
    Cursor_hidden=cursor_was_hidden;
1933
 
    Display_cursor();
1934
 
 
1935
 
    free(buffer);
 
2001
  Hide_cursor();
 
2002
 
 
2003
  cursor_was_hidden=Cursor_hidden;
 
2004
  Cursor_hidden=0;
 
2005
 
 
2006
  Save_background(&buffer,Window_pos_X,Window_pos_Y,Window_width,Window_height);
 
2007
  a=Menu_Y;
 
2008
  Menu_Y=Menu_Y_before_window;
 
2009
  b=Menu_is_visible;
 
2010
  Menu_is_visible=Menu_is_visible_before_window;
 
2011
  Display_all_screen();
 
2012
  Display_menu();
 
2013
  Menu_Y=a;
 
2014
  Menu_is_visible=b;
 
2015
 
 
2016
  Cursor_shape=CURSOR_SHAPE_COLORPICKER;
 
2017
  b=Paintbrush_hidden;
 
2018
  Paintbrush_hidden=1;
 
2019
  c=-1; // color point�e: au d�but aucune, comme �a on initialise tout
 
2020
  if (Menu_is_visible_before_window)
 
2021
          Print_in_menu(Menu_tooltip[BUTTON_CHOOSE_COL],0);
 
2022
 
 
2023
  Display_cursor();
 
2024
 
 
2025
  do
 
2026
  {
 
2027
          if(!Get_input())SDL_Delay(20);
 
2028
 
 
2029
          if ((Mouse_X!=old_x) || (Mouse_Y!=old_y))
 
2030
          {
 
2031
                  Hide_cursor();
 
2032
                  a=Read_pixel(Mouse_X,Mouse_Y);
 
2033
                  if (a!=c)
 
2034
                  {
 
2035
                          c=a; // Mise � jour de la couleur point�e
 
2036
                          if (Menu_is_visible_before_window)
 
2037
                          {
 
2038
                                  sprintf(str,"%d",a);
 
2039
                                  d=strlen(str);
 
2040
                                  strcat(str,"   (");
 
2041
                                  sprintf(str+strlen(str),"%d",Main_palette[a].R);
 
2042
                                  strcat(str,",");
 
2043
                                  sprintf(str+strlen(str),"%d",Main_palette[a].G);
 
2044
                                  strcat(str,",");
 
2045
                                  sprintf(str+strlen(str),"%d",Main_palette[a].B);
 
2046
                                  strcat(str,")");
 
2047
                                  a=24-d;
 
2048
                                  for (index=strlen(str); index<a; index++)
 
2049
                                          str[index]=' ';
 
2050
                                  str[a]=0;
 
2051
                                  Print_in_menu(str,strlen(Menu_tooltip[BUTTON_CHOOSE_COL]));
 
2052
 
 
2053
                                  Print_general((26+((d+strlen(Menu_tooltip[BUTTON_CHOOSE_COL]))<<3))*Menu_factor_X,
 
2054
                                                  Menu_status_Y," ",0,c);
 
2055
                          }
 
2056
                  }
 
2057
                  Display_cursor();
 
2058
          }
 
2059
 
 
2060
          old_x=Mouse_X;
 
2061
          old_y=Mouse_Y;
 
2062
  } while (!(Mouse_K || (Key==KEY_ESC)));
 
2063
 
 
2064
  if (Mouse_K)
 
2065
  {
 
2066
          Hide_cursor();
 
2067
          *click=Mouse_K;
 
2068
          *color=Read_pixel(Mouse_X,Mouse_Y);
1936
2069
  }
1937
2070
  else
1938
2071
  {
1939
 
    Error(0);
 
2072
          *click=0;
 
2073
          Hide_cursor();
1940
2074
  }
 
2075
 
 
2076
  Restore_background(buffer,Window_pos_X,Window_pos_Y,Window_width,Window_height);
 
2077
  Update_rect(Window_pos_X, Window_pos_Y, Window_width*Menu_factor_X, Window_height*Menu_factor_Y);
 
2078
  Cursor_shape=CURSOR_SHAPE_ARROW;
 
2079
  Paintbrush_hidden=b;
 
2080
  Cursor_hidden=cursor_was_hidden;
 
2081
  Display_cursor();
1941
2082
}
1942
2083
 
1943
2084
 
1945
2086
// ------------ Op�ration de d�placement de la fen�tre � l'�cran -------------
1946
2087
void Move_window(short dx, short dy)
1947
2088
{
1948
 
  short new_x=Mouse_X-dx;
1949
 
  short new_y=Mouse_Y-dy;
 
2089
        short new_x=Mouse_X-dx;
 
2090
        short new_y=Mouse_Y-dy;
1950
2091
  short old_x;
1951
2092
  short old_y;
1952
2093
  short width=Window_width*Menu_factor_X;
2193
2334
    Window_attribute2=item->Number;
2194
2335
    if (Button->Display_choice)
2195
2336
    {
2196
 
      // Mettre � jour automatiquement le libell� de la dropdown
2197
 
      Print_in_window(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,item->Label,MC_Black,MC_Light);
 
2337
      // Automatically update the label of the dropdown list.
 
2338
      int text_length = (Button->Width-4-(Button->Display_arrow?8:0))/8;
 
2339
      // Clear original label area
 
2340
      Window_rectangle(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,text_length*8,8,MC_Light);
 
2341
      Print_in_window_limited(Button->Pos_X+2,Button->Pos_Y+(Button->Height-7)/2,item->Label,text_length ,MC_Black,MC_Light);
2198
2342
    }
2199
2343
    return Button->Number;
2200
2344
  }
2235
2379
  }
2236
2380
}
2237
2381
 
2238
 
// --- Renvoie le num�ro du bouton clicke (-1:hors de la fen�tre, 0:aucun) ---
 
2382
// --- Returns the number of the clicked button (-1:out of the window, 0:none) ---
2239
2383
short Window_get_clicked_button(void)
2240
2384
{
2241
2385
  T_Normal_button   * temp1;
2248
2392
 
2249
2393
  Window_attribute1=Mouse_K;
2250
2394
 
2251
 
  // Test du click sur les boutons normaux
 
2395
  // Test click on normal buttons
2252
2396
  for (temp1=Window_normal_button_list; temp1; temp1=temp1->Next)
2253
2397
  {
2254
 
    if (Window_click_in_rectangle(temp1->Pos_X,temp1->Pos_Y,temp1->Pos_X+temp1->Width-1,temp1->Pos_Y+temp1->Height-1))
 
2398
    if ((Input_sticky_control == 0 || Input_sticky_control == temp1->Number)
 
2399
      && Window_click_in_rectangle(temp1->Pos_X,temp1->Pos_Y,temp1->Pos_X+temp1->Width-1,temp1->Pos_Y+temp1->Height-1))
2255
2400
    {
 
2401
      Input_sticky_control = temp1->Number;
2256
2402
      if (temp1->Repeatable)
2257
2403
      {
2258
2404
        Hide_cursor();
2268
2414
    }
2269
2415
  }
2270
2416
 
2271
 
  // Test du click sur les zones "palette"
 
2417
  // Test click on "Palette" buttons
2272
2418
  for (temp2=Window_palette_button_list; temp2; temp2=temp2->Next)
2273
2419
  {
2274
 
    if (Window_click_in_rectangle(temp2->Pos_X+5,temp2->Pos_Y+3,temp2->Pos_X+160,temp2->Pos_Y+82))
 
2420
    if ((Input_sticky_control == 0 || Input_sticky_control == temp2->Number)
 
2421
      && Window_click_in_rectangle(temp2->Pos_X+5,temp2->Pos_Y+3,temp2->Pos_X+160,temp2->Pos_Y+82))
2275
2422
    {
2276
 
      // On stocke dans Attribut2 le numero de couleur cliqu�
 
2423
      Input_sticky_control = temp2->Number;
 
2424
      // We store the clicked color in Attribute2
2277
2425
      Window_attribute2 = (((Mouse_X-Window_pos_X)/Menu_factor_X)-(temp2->Pos_X+2)) / 10 * 16 +
2278
2426
        (((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-(temp2->Pos_Y+3)) / 5;
2279
2427
        return temp2->Number;
2280
2428
    }
2281
2429
  }
2282
2430
 
2283
 
  // Test du click sur les barres de d�filement
 
2431
  // Test click oin slider/scroller bars
2284
2432
  for (temp3=Window_scroller_button_list; temp3; temp3=temp3->Next)
2285
2433
  {
2286
 
    if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
2287
 
    {
2288
 
      // Button fl�che Haut
2289
 
      if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+10))
2290
 
      {
2291
 
        Hide_cursor();
2292
 
        Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
2293
 
 
2294
 
        if (temp3->Position)
2295
 
        {
2296
 
          temp3->Position--;
2297
 
          Window_attribute1=1;
2298
 
          Window_attribute2=temp3->Position;
 
2434
    // Button Up arrow
 
2435
    if ((Input_sticky_control == 0 || Input_sticky_control == (temp3->Number|1024))
 
2436
      && Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y,temp3->Pos_X+10,temp3->Pos_Y+10))
 
2437
    {
 
2438
      Input_sticky_control = temp3->Number | 1024;
 
2439
      Hide_cursor();
 
2440
      Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
 
2441
 
 
2442
      if (temp3->Position)
 
2443
      {
 
2444
        temp3->Position--;
 
2445
        Window_attribute1=1;
 
2446
        Window_attribute2=temp3->Position;
 
2447
        Window_draw_slider(temp3);
 
2448
      }
 
2449
      else
 
2450
        Window_attribute1=0;
 
2451
      
 
2452
      Display_cursor();
 
2453
 
 
2454
      Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
 
2455
 
 
2456
      Hide_cursor();
 
2457
      Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
 
2458
      Display_cursor();
 
2459
      
 
2460
      return (Window_attribute1)? temp3->Number : 0;
 
2461
    }
 
2462
    
 
2463
    // Button Down arrow
 
2464
    if ((Input_sticky_control == 0 || Input_sticky_control == (temp3->Number|2048))
 
2465
      && Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
 
2466
    {
 
2467
      Input_sticky_control = temp3->Number | 2048;
 
2468
      Hide_cursor();
 
2469
      Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
 
2470
 
 
2471
      if (temp3->Position+temp3->Nb_visibles<temp3->Nb_elements)
 
2472
      {
 
2473
        temp3->Position++;
 
2474
        Window_attribute1=2;
 
2475
        Window_attribute2=temp3->Position;
 
2476
        Window_draw_slider(temp3);
 
2477
      }
 
2478
      else
 
2479
        Window_attribute1=0;
 
2480
 
 
2481
      Display_cursor();
 
2482
 
 
2483
      Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
 
2484
 
 
2485
      Hide_cursor();
 
2486
      Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
 
2487
      Display_cursor();
 
2488
      
 
2489
      return (Window_attribute1)? temp3->Number : 0;
 
2490
    }
 
2491
    // Middle slider
 
2492
    if ((Input_sticky_control == temp3->Number) || (Input_sticky_control==0 &&
 
2493
        Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+12,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-13)))
 
2494
    {
 
2495
      Input_sticky_control = temp3->Number;
 
2496
      if (temp3->Nb_elements>temp3->Nb_visibles)
 
2497
      {
 
2498
        // If there is enough room to make the cursor move:
 
2499
 
 
2500
        max_slider_height=(temp3->Height-24);
 
2501
 
 
2502
        // Window_attribute2 receives the position of the cursor.
 
2503
        Window_attribute2 =(Mouse_Y-Window_pos_Y) / Menu_factor_Y;
 
2504
        Window_attribute2-=(temp3->Pos_Y+12+((temp3->Cursor_height-1)>>1));
 
2505
        Window_attribute2*=(temp3->Nb_elements-temp3->Nb_visibles);
 
2506
 
 
2507
        if (Window_attribute2<0)
 
2508
          Window_attribute2=0;
 
2509
        else
 
2510
        {
 
2511
          Window_attribute2 =Round_div(Window_attribute2,max_slider_height-temp3->Cursor_height);
 
2512
          if (Window_attribute2+temp3->Nb_visibles>temp3->Nb_elements)
 
2513
            Window_attribute2=temp3->Nb_elements-temp3->Nb_visibles;
 
2514
        }
 
2515
 
 
2516
        // If the cursor moved
 
2517
 
 
2518
        if (temp3->Position!=Window_attribute2)
 
2519
        {
 
2520
          temp3->Position=Window_attribute2;
 
2521
          Window_attribute1=3;
 
2522
          Hide_cursor();
2299
2523
          Window_draw_slider(temp3);
 
2524
          Display_cursor();
2300
2525
        }
2301
2526
        else
 
2527
          // If the cursor moved
2302
2528
          Window_attribute1=0;
 
2529
      }
 
2530
      else
 
2531
        // If there's not enough room to make the cursor move:
 
2532
        Window_attribute1=0;
2303
2533
        
2304
 
        Display_cursor();
2305
 
 
2306
 
        Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
2307
 
 
2308
 
        Hide_cursor();
2309
 
        Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
2310
 
        Display_cursor();
2311
 
      }
2312
 
      else
2313
 
      // Button fl�che Bas
2314
 
      if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-1))
2315
 
      {
2316
 
        Hide_cursor();
2317
 
        Window_select_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
2318
 
 
2319
 
        if (temp3->Position+temp3->Nb_visibles<temp3->Nb_elements)
2320
 
        {
2321
 
          temp3->Position++;
2322
 
          Window_attribute1=2;
2323
 
          Window_attribute2=temp3->Position;
2324
 
          Window_draw_slider(temp3);
2325
 
        }
2326
 
        else
2327
 
          Window_attribute1=0;
2328
 
 
2329
 
        Display_cursor();
2330
 
 
2331
 
        Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
2332
 
 
2333
 
        Hide_cursor();
2334
 
        Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
2335
 
        Display_cursor();
2336
 
      }
2337
 
      else
2338
 
      // Jauge
2339
 
      if (Window_click_in_rectangle(temp3->Pos_X,temp3->Pos_Y+12,temp3->Pos_X+10,temp3->Pos_Y+temp3->Height-13))
2340
 
      {
2341
 
        if (temp3->Nb_elements>temp3->Nb_visibles)
2342
 
        {
2343
 
          // S'il y a la place de faire scroller le curseur:
2344
 
 
2345
 
          max_slider_height=(temp3->Height-24);
2346
 
 
2347
 
          // Window_attribute2 re�oit la position dans la jauge correspondant au click
2348
 
          Window_attribute2 =(Mouse_Y-Window_pos_Y) / Menu_factor_Y;
2349
 
          Window_attribute2-=(temp3->Pos_Y+12+((temp3->Cursor_height-1)>>1));
2350
 
          Window_attribute2*=(temp3->Nb_elements-temp3->Nb_visibles);
2351
 
 
2352
 
          if (Window_attribute2<0)
2353
 
            Window_attribute2=0;
2354
 
          else
2355
 
          {
2356
 
            Window_attribute2 =Round_div(Window_attribute2,max_slider_height-temp3->Cursor_height);
2357
 
            if (Window_attribute2+temp3->Nb_visibles>temp3->Nb_elements)
2358
 
              Window_attribute2=temp3->Nb_elements-temp3->Nb_visibles;
2359
 
          }
2360
 
 
2361
 
          // Si le curseur de la jauge bouge:
2362
 
 
2363
 
          if (temp3->Position!=Window_attribute2)
2364
 
          {
2365
 
            temp3->Position=Window_attribute2;
2366
 
            Window_attribute1=3;
2367
 
            Hide_cursor();
2368
 
            Window_draw_slider(temp3);
2369
 
            Display_cursor();
2370
 
          }
2371
 
          else
2372
 
            // Si le curseur de la jauge ne bouge pas:
2373
 
            Window_attribute1=0;
2374
 
        }
2375
 
        else
2376
 
          // S'il n'y a pas la place de bouger le curseur de la jauge:
2377
 
          Window_attribute1=0;
2378
 
      }
2379
 
      else
2380
 
        // Le click se situe dans la zone de la jauge mais n'est sur aucune
2381
 
        // des 3 parties importantes de la jauge
2382
 
        Window_attribute1=0;
2383
 
 
2384
 
      return (Window_attribute1)? temp3->Number : 0;
 
2534
      return (Window_attribute1)? temp3->Number : 0; 
2385
2535
    }
2386
2536
  }
2387
2537
 
2388
 
  // Test du click sur une zone sp�ciale
 
2538
  // Test click on a special button
2389
2539
  for (temp4=Window_special_button_list; temp4; temp4=temp4->Next)
2390
2540
  {
2391
 
    if (Window_click_in_rectangle(temp4->Pos_X,temp4->Pos_Y,temp4->Pos_X+temp4->Width-1,temp4->Pos_Y+temp4->Height-1))
2392
 
      return temp4->Number;
 
2541
    if ((Input_sticky_control == 0 || Input_sticky_control == temp4->Number)
 
2542
      && Window_click_in_rectangle(temp4->Pos_X,temp4->Pos_Y,temp4->Pos_X+temp4->Width-1,temp4->Pos_Y+temp4->Height-1))
 
2543
    {
 
2544
       Input_sticky_control = temp4->Number;
 
2545
       return temp4->Number;
 
2546
    }
2393
2547
  }
2394
2548
 
2395
 
  // Test du click sur une dropdown
 
2549
  // Test click on a dropdown box
2396
2550
  for (temp5=Window_dropdown_button_list; temp5; temp5=temp5->Next)
2397
2551
  {
2398
 
    if (Window_click_in_rectangle(temp5->Pos_X,temp5->Pos_Y,temp5->Pos_X+temp5->Width-1,temp5->Pos_Y+temp5->Height-1))
 
2552
    if ((Input_sticky_control == 0 || Input_sticky_control == temp5->Number)
 
2553
     && Window_click_in_rectangle(temp5->Pos_X,temp5->Pos_Y,temp5->Pos_X+temp5->Width-1,temp5->Pos_Y+temp5->Height-1))
2399
2554
    {
 
2555
      Input_sticky_control = temp5->Number;
2400
2556
      if (Mouse_K & temp5->Active_button)
2401
2557
        return Window_dropdown_on_click(temp5);
2402
2558
      else
2454
2610
      temp=temp->Next;
2455
2611
    }
2456
2612
  }
2457
 
 
 
2613
  
 
2614
  // Handle arrow keys, end/home, and mouse wheel that have
 
2615
  // a certain behavior if a list control is present.
 
2616
  if (Window_list_button_list)
 
2617
  {
 
2618
    T_List_button *list = Window_list_button_list;
 
2619
    // If there's more than one of such control, only capture
 
2620
    // events if the mouse cursor is over it.
 
2621
    if (list->Next)
 
2622
    {
 
2623
      // to do
 
2624
    }
 
2625
  
 
2626
  
 
2627
  
 
2628
  
 
2629
  
 
2630
  
 
2631
  }
2458
2632
  return 0;
2459
2633
}
2460
2634
 
2464
2638
 
2465
2639
  if(!Get_input())SDL_Delay(20);
2466
2640
 
2467
 
  // Gestion des clicks
 
2641
  // Handle clicks
2468
2642
  if (Mouse_K)
2469
2643
  {
2470
2644
    if ((Mouse_X<Window_pos_X) || (Mouse_Y<Window_pos_Y)
2471
2645
     || (Mouse_X>=Window_pos_X+(Window_width*Menu_factor_X))
2472
2646
     || (Mouse_Y>=Window_pos_Y+(Window_height*Menu_factor_Y)))
2473
 
      return -1;
 
2647
    {
 
2648
      if (Input_sticky_control == 0 || Input_sticky_control == -1)
 
2649
      {
 
2650
        Input_sticky_control = -1;
 
2651
        return -1;
 
2652
      }
 
2653
      else
 
2654
      {
 
2655
        return 0;
 
2656
      }
 
2657
    }
 
2658
     
 
2659
    if (!Input_sticky_control && Mouse_Y < Window_pos_Y+(12*Menu_factor_Y))
 
2660
    {
 
2661
      Move_window(Mouse_X-Window_pos_X,Mouse_Y-Window_pos_Y);
 
2662
    }
2474
2663
    else
2475
2664
    {
2476
 
      if (Mouse_Y < Window_pos_Y+(12*Menu_factor_Y))
2477
 
        Move_window(Mouse_X-Window_pos_X,Mouse_Y-Window_pos_Y);
2478
 
      else
2479
 
        return Window_get_clicked_button();
 
2665
      short clicked_button;
 
2666
      T_List_button * list;
 
2667
      
 
2668
      // Check which controls was clicked (by rectangular area)
 
2669
      clicked_button = Window_get_clicked_button();
 
2670
      
 
2671
      // Check if it's part of a list control
 
2672
      for (list=Window_list_button_list; list!=NULL; list=list->Next)
 
2673
      {
 
2674
        if (list->Entry_button->Number == clicked_button)
 
2675
        {
 
2676
          // Click in the textual part of a list.
 
2677
          short clicked_line;            
 
2678
          clicked_line = (((Mouse_Y-Window_pos_Y)/Menu_factor_Y)-list->Entry_button->Pos_Y)>>3;
 
2679
          if (clicked_line == list->Cursor_position ||   // Same as before
 
2680
            clicked_line >= list->Scroller->Nb_elements) // Below last line              
 
2681
            return 0;
 
2682
          
 
2683
          Hide_cursor();
 
2684
          // Redraw one item as disabled
 
2685
          if (list->Cursor_position>=0 && list->Cursor_position<list->Scroller->Nb_visibles)
 
2686
            list->Draw_list_item(
 
2687
              list->Entry_button->Pos_X,
 
2688
              list->Entry_button->Pos_Y + list->Cursor_position * 8,
 
2689
              list->List_start + list->Cursor_position,
 
2690
              0);
 
2691
          list->Cursor_position = clicked_line;
 
2692
          // Redraw one item as enabled
 
2693
          if (list->Cursor_position>=0 && list->Cursor_position<list->Scroller->Nb_visibles)
 
2694
            list->Draw_list_item(
 
2695
              list->Entry_button->Pos_X,
 
2696
              list->Entry_button->Pos_Y + list->Cursor_position * 8,
 
2697
              list->List_start + list->Cursor_position,
 
2698
              1);
 
2699
          Display_cursor();
 
2700
 
 
2701
          // Store the selected value as attribute2
 
2702
          Window_attribute2=list->List_start + list->Cursor_position;
 
2703
          // Return the control ID of the list.
 
2704
          return list->Number;
 
2705
        }
 
2706
        else if (list->Scroller->Number == clicked_button)
 
2707
        {
 
2708
          // Click in the scroller part of a list
 
2709
          if (list->List_start == list->Scroller->Position)
 
2710
            return 0; // Didn't actually move
 
2711
          // Update scroller indices
 
2712
          list->Cursor_position += list->List_start;
 
2713
          list->List_start = list->Scroller->Position;
 
2714
          list->Cursor_position -= list->List_start;
 
2715
          // Need to redraw all
 
2716
          Hide_cursor();
 
2717
          Window_redraw_list(list);
 
2718
          Display_cursor();
 
2719
        }
 
2720
      }
 
2721
      return clicked_button;
2480
2722
    }
2481
2723
  }
2482
2724
 
2483
 
  // Gestion des touches
 
2725
  // Intercept keys
2484
2726
  if (Key)
2485
2727
  {
 
2728
    T_List_button * list;
 
2729
 
2486
2730
    Button=Window_get_button_shortcut();
2487
2731
    if (Button)
2488
2732
    {
2489
2733
      Key=0;
2490
2734
      return Button;
2491
2735
    }
 
2736
    // Check if there's a list control and the keys can control it
 
2737
    for (list=Window_list_button_list; list!=NULL; list=list->Next)
 
2738
    {
 
2739
      // FIXME: Make only one list have the keyboard focus.
 
2740
      if (1)
 
2741
      {
 
2742
        if (Key==SDLK_UP && (list->Cursor_position+list->List_start)>0)
 
2743
        {
 
2744
          Key=0;
 
2745
          Hide_cursor();
 
2746
          list->Cursor_position--;
 
2747
          if (list->Cursor_position<0)
 
2748
          {
 
2749
            list->List_start=list->List_start+list->Cursor_position;
 
2750
            list->Cursor_position=0;
 
2751
            // Mise � jour du scroller
 
2752
            list->Scroller->Position=list->List_start;
 
2753
            Window_draw_slider(list->Scroller);
 
2754
          }
 
2755
          Window_redraw_list(list);
 
2756
          Display_cursor();
 
2757
          // Store the selected value as attribute2
 
2758
          Window_attribute2=list->List_start + list->Cursor_position;
 
2759
          // Return the control ID of the list.
 
2760
          return list->Number;
 
2761
        }
 
2762
        if (Key==SDLK_DOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
 
2763
        {
 
2764
          Key=0;
 
2765
          Hide_cursor();
 
2766
          list->Cursor_position++;
 
2767
          if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
 
2768
          {
 
2769
            list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
 
2770
            list->Cursor_position=(list->Scroller->Nb_visibles-1);
 
2771
            // Mise � jour du scroller
 
2772
            list->Scroller->Position=list->List_start;
 
2773
            Window_draw_slider(list->Scroller);
 
2774
          }
 
2775
          Window_redraw_list(list);
 
2776
          Display_cursor();
 
2777
          // Store the selected value as attribute2
 
2778
          Window_attribute2=list->List_start + list->Cursor_position;
 
2779
          // Return the control ID of the list.
 
2780
          return list->Number;
 
2781
        }
 
2782
        if (Key==SDLK_HOME && (list->Cursor_position!=0 || list->List_start!=0))
 
2783
        {
 
2784
          Key=0;
 
2785
          Hide_cursor();
 
2786
          list->Cursor_position=0;
 
2787
          list->List_start=0;
 
2788
          // Mise � jour du scroller
 
2789
          list->Scroller->Position=list->List_start;
 
2790
          Window_draw_slider(list->Scroller);
 
2791
          Window_redraw_list(list);
 
2792
          Display_cursor();
 
2793
          // Store the selected value as attribute2
 
2794
          Window_attribute2=list->List_start + list->Cursor_position;
 
2795
          // Return the control ID of the list.
 
2796
          return list->Number;
 
2797
        }
 
2798
        if (Key==SDLK_END && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
 
2799
        {
 
2800
          Key=0;
 
2801
          Hide_cursor();
 
2802
          list->Cursor_position=(list->Scroller->Nb_elements-1)-list->List_start;
 
2803
          if (list->Cursor_position>(list->Scroller->Nb_visibles-1))
 
2804
          {
 
2805
            list->List_start=list->List_start+list->Cursor_position-(list->Scroller->Nb_visibles-1);
 
2806
            list->Cursor_position=(list->Scroller->Nb_visibles-1);
 
2807
            // Mise � jour du scroller
 
2808
            list->Scroller->Position=list->List_start;
 
2809
            Window_draw_slider(list->Scroller);
 
2810
          }
 
2811
          Window_redraw_list(list);
 
2812
          Display_cursor();
 
2813
          // Store the selected value as attribute2
 
2814
          Window_attribute2=list->List_start + list->Cursor_position;
 
2815
          // Return the control ID of the list.
 
2816
          return list->Number;
 
2817
        }
 
2818
        if (Key==SDLK_PAGEDOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1))
 
2819
        {
 
2820
          Key=0;
 
2821
          Hide_cursor();
 
2822
          if (list->Scroller->Nb_elements<list->Scroller->Nb_visibles)
 
2823
          {
 
2824
            list->Cursor_position=list->Scroller->Nb_elements-1;
 
2825
          }
 
2826
          else if(list->Cursor_position!=list->Scroller->Nb_visibles-1)
 
2827
          {
 
2828
            list->Cursor_position=list->Scroller->Nb_visibles-1;
 
2829
          }
 
2830
          else
 
2831
          {
 
2832
            list->List_start+=list->Scroller->Nb_visibles;
 
2833
            if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
 
2834
            {
 
2835
              list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
 
2836
            }
 
2837
            // Mise � jour du scroller
 
2838
            list->Scroller->Position=list->List_start;
 
2839
            Window_draw_slider(list->Scroller);
 
2840
          }
 
2841
          Window_redraw_list(list);
 
2842
          Display_cursor();
 
2843
          // Store the selected value as attribute2
 
2844
          Window_attribute2=list->List_start + list->Cursor_position;
 
2845
          // Return the control ID of the list.
 
2846
          return list->Number;
 
2847
        }
 
2848
        if (Key==SDLK_PAGEUP && (list->Cursor_position+list->List_start)>0)
 
2849
        {
 
2850
          Key=0;
 
2851
          Hide_cursor();
 
2852
          if(list->Cursor_position!=0)
 
2853
          {
 
2854
            list->Cursor_position=0;
 
2855
          }
 
2856
          else
 
2857
          {
 
2858
            list->List_start-=list->Scroller->Nb_visibles;
 
2859
            if (list->List_start<0)
 
2860
            {
 
2861
              list->List_start=0;
 
2862
            }
 
2863
            // Mise � jour du scroller
 
2864
            list->Scroller->Position=list->List_start;
 
2865
            Window_draw_slider(list->Scroller);
 
2866
          }
 
2867
          Window_redraw_list(list);
 
2868
          Display_cursor();
 
2869
          // Store the selected value as attribute2
 
2870
          Window_attribute2=list->List_start + list->Cursor_position;
 
2871
          // Return the control ID of the list.
 
2872
          return list->Number;
 
2873
        }
 
2874
        if (Key == KEY_MOUSEWHEELUP && list->List_start>0)
 
2875
        {
 
2876
          list->Cursor_position+=list->List_start;
 
2877
          if (list->List_start>=3)
 
2878
            list->List_start-=3;
 
2879
          else
 
2880
            list->List_start=0;
 
2881
          list->Cursor_position-=list->List_start;
 
2882
          // On affiche � nouveau la liste
 
2883
          Hide_cursor();
 
2884
          Window_redraw_list(list);
 
2885
          // Mise � jour du scroller
 
2886
          list->Scroller->Position=list->List_start;
 
2887
          Window_draw_slider(list->Scroller);
 
2888
          Display_cursor();
 
2889
        }
 
2890
        if (Key==KEY_MOUSEWHEELDOWN && list->List_start<list->Scroller->Nb_elements-list->Scroller->Nb_visibles)
 
2891
        {
 
2892
          list->Cursor_position+=list->List_start;
 
2893
          list->List_start+=3;
 
2894
          if (list->List_start+list->Scroller->Nb_visibles>list->Scroller->Nb_elements)
 
2895
          {
 
2896
            list->List_start=list->Scroller->Nb_elements-list->Scroller->Nb_visibles;
 
2897
          }          
 
2898
          list->Cursor_position-=list->List_start;
 
2899
          // On affiche � nouveau la liste
 
2900
          Hide_cursor();
 
2901
          Window_redraw_list(list);
 
2902
          // Mise � jour du scroller
 
2903
          list->Scroller->Position=list->List_start;
 
2904
          Window_draw_slider(list->Scroller);
 
2905
          Display_cursor();
 
2906
        }
 
2907
      
 
2908
      }
 
2909
    }
2492
2910
  }
2493
2911
 
2494
2912
  return 0;