Fix some compilation warnings (mix code and declarations, breaks on gcc2). Fileselector: Fix the names of drives, which was one character too long, overwriting the scrollbar. Reworked the drive icons for black background (all skins)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1559 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-08-06 22:37:39 +00:00
parent e0d21e2a89
commit c9a917aa85
9 changed files with 48 additions and 32 deletions

View File

@ -1201,7 +1201,7 @@ void Add_font_or_skin(const char *name)
&& (!strcasecmp(fname + namelength - 4,".png") && (!strcasecmp(fname + namelength - 4,".png")
|| !strcasecmp(fname + namelength - 4,".gif"))) || !strcasecmp(fname + namelength - 4,".gif")))
{ {
Add_element_to_list(&Skin_files_list, name, 0); Add_element_to_list(&Skin_files_list, name, 0, ICON_NONE);
if (fname[0]=='\0') if (fname[0]=='\0')
return; return;
@ -1216,7 +1216,7 @@ void Add_font_or_skin(const char *name)
else if (namelength>=10 && !strncasecmp(fname, "font_", 5) else if (namelength>=10 && !strncasecmp(fname, "font_", 5)
&& (!strcasecmp(fname + namelength - 4, ".png"))) && (!strcasecmp(fname + namelength - 4, ".png")))
{ {
Add_element_to_list(&Font_files_list, name, 0); Add_element_to_list(&Font_files_list, name, 0, ICON_NONE);
if (fname[0]=='\0') if (fname[0]=='\0')
return; return;

View File

@ -269,7 +269,8 @@ enum ICON_TYPES
ICON_NETWORK, ///< "Network" drive ICON_NETWORK, ///< "Network" drive
ICON_STAR, ///< Star (favorite) ICON_STAR, ///< Star (favorite)
ICON_DROPDOWN, ///< Dropdown arrow ICON_DROPDOWN, ///< Dropdown arrow
NB_ICON_SPRITES ///< Number of 8x8 icons NB_ICON_SPRITES, ///< Number of 8x8 icons
ICON_NONE ///< None of the above
}; };
/// Identifiers for the buttons in the menu. /// Identifiers for the buttons in the menu.

View File

@ -916,7 +916,7 @@ void Draw_script_information(T_Fileselector_item * script_item)
// Add a script to the list // Add a script to the list
void Add_script(const char *name) void Add_script(const char *name)
{ {
Add_element_to_list(&Scripts_list, Find_last_slash(name)+1, 0); Add_element_to_list(&Scripts_list, Find_last_slash(name)+1, 0, ICON_NONE);
} }
void Highlight_script(T_Fileselector *selector, T_List_button *list, const char *selected_script) void Highlight_script(T_Fileselector *selector, T_List_button *list, const char *selected_script)

View File

@ -22,7 +22,7 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <SDL/SDL_syswm.h> #include <SDL_syswm.h>
#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__)
#include <proto/dos.h> #include <proto/dos.h>
@ -81,9 +81,11 @@ byte Native_filesel(byte load)
OPENFILENAME ofn; OPENFILENAME ofn;
char szFileName[MAX_PATH] = ""; char szFileName[MAX_PATH] = "";
SDL_SysWMinfo wminfo; SDL_SysWMinfo wminfo;
HWND hwnd;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
SDL_GetWMInfo(&wminfo); SDL_GetWMInfo(&wminfo);
HWND hwnd = wminfo.window; hwnd = wminfo.window;
ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(&ofn, sizeof(ofn));
@ -126,8 +128,6 @@ T_Fileselector Filelist;
/// Filename (without directory) of the highlighted file /// Filename (without directory) of the highlighted file
static char Selector_filename[256]; static char Selector_filename[256];
int drive_types[26];
// Conventions: // Conventions:
// //
// * Le fileselect modifie le répertoire courant. Ceci permet de n'avoir // * Le fileselect modifie le répertoire courant. Ceci permet de n'avoir
@ -249,7 +249,7 @@ char * Format_filename(const char * fname, int type)
// -- Rajouter a la liste des elements de la liste un element --------------- // -- Rajouter a la liste des elements de la liste un element ---------------
void Add_element_to_list(T_Fileselector *list, const char * fname, int type) void Add_element_to_list(T_Fileselector *list, const char * fname, int type, byte icon)
// Cette procedure ajoute a la liste chainee un fichier passé en argument. // Cette procedure ajoute a la liste chainee un fichier passé en argument.
{ {
// Pointeur temporaire d'insertion // Pointeur temporaire d'insertion
@ -262,6 +262,13 @@ void Add_element_to_list(T_Fileselector *list, const char * fname, int type)
strcpy(temp_item->Short_name,Format_filename(fname, type)); strcpy(temp_item->Short_name,Format_filename(fname, type));
strcpy(temp_item->Full_name,fname); strcpy(temp_item->Full_name,fname);
temp_item->Type = type; temp_item->Type = type;
temp_item->Icon = icon;
if (icon != ICON_NONE)
{
// If the item has an icon preceding it, its short
// name must be one character shorter
temp_item->Short_name[17]='\0';
}
temp_item->Next =list->First; temp_item->Next =list->First;
temp_item->Previous=NULL; temp_item->Previous=NULL;
@ -344,7 +351,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
!isHidden(entry))) !isHidden(entry)))
{ {
// On rajoute le répertoire à la liste // On rajoute le répertoire à la liste
Add_element_to_list(list, entry->d_name, 1); Add_element_to_list(list, entry->d_name, 1, ICON_NONE);
list->Nb_directories++; list->Nb_directories++;
} }
else if (S_ISREG(Infos_enreg.st_mode) && //Il s'agit d'un fichier else if (S_ISREG(Infos_enreg.st_mode) && //Il s'agit d'un fichier
@ -357,7 +364,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
if (Check_extension(entry->d_name, ext)) if (Check_extension(entry->d_name, ext))
{ {
// On rajoute le fichier à la liste // On rajoute le fichier à la liste
Add_element_to_list(list, entry->d_name, 0); Add_element_to_list(list, entry->d_name, 0, ICON_NONE);
list->Nb_files++; list->Nb_files++;
// Stop searching // Stop searching
ext=NULL; ext=NULL;
@ -373,7 +380,7 @@ void Read_list_of_files(T_Fileselector *list, byte selected_format)
} }
#if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__) #if defined(__MORPHOS__) || defined(__AROS__) || defined (__amigaos4__) || defined(__amigaos__)
Add_element_to_list(list, "/",1); // on amiga systems, / means parent. And there is no .. Add_element_to_list(list, "/",1, ICON_NONE); // on amiga systems, / means parent. And there is no ..
list->Nb_directories ++; list->Nb_directories ++;
#endif #endif
@ -425,7 +432,7 @@ void Read_list_of_drives(T_Fileselector *list)
{ {
bstrtostr( dl->dol_Name, tmp, 254 ); bstrtostr( dl->dol_Name, tmp, 254 );
strcat( tmp, ":" ); strcat( tmp, ":" );
Add_element_to_list(list, tmp, 2 ); Add_element_to_list(list, tmp, 2, ICON_NONE );
list->Nb_directories++; list->Nb_directories++;
} }
UnLockDosList( LDF_VOLUMES | LDF_READ ); UnLockDosList( LDF_VOLUMES | LDF_READ );
@ -437,6 +444,8 @@ void Read_list_of_drives(T_Fileselector *list)
int drive_bits = GetLogicalDrives(); int drive_bits = GetLogicalDrives();
int drive_index; int drive_index;
int bit_index; int bit_index;
byte icon;
// Sous Windows, on a la totale, presque aussi bien que sous DOS: // Sous Windows, on a la totale, presque aussi bien que sous DOS:
drive_index = 0; drive_index = 0;
for (bit_index=0; bit_index<26 && drive_index<23; bit_index++) for (bit_index=0; bit_index<26 && drive_index<23; bit_index++)
@ -451,23 +460,23 @@ void Read_list_of_drives(T_Fileselector *list)
switch (GetDriveType(drive_path)) switch (GetDriveType(drive_path))
{ {
case DRIVE_CDROM: case DRIVE_CDROM:
drive_types[drive_index]=ICON_CDROM; icon=ICON_CDROM;
break; break;
case DRIVE_REMOTE: case DRIVE_REMOTE:
drive_types[drive_index]=ICON_NETWORK; icon=ICON_NETWORK;
break; break;
case DRIVE_REMOVABLE: case DRIVE_REMOVABLE:
drive_types[drive_index]=ICON_FLOPPY_3_5; icon=ICON_FLOPPY_3_5;
break; break;
case DRIVE_FIXED: case DRIVE_FIXED:
drive_types[drive_index]=ICON_HDD; icon=ICON_HDD;
break; break;
default: default:
drive_types[drive_index]=ICON_NETWORK; icon=ICON_NETWORK;
break; break;
} }
drive_name[0]='A'+bit_index; drive_name[0]='A'+bit_index;
Add_element_to_list(list, drive_name,2); Add_element_to_list(list, drive_name,2, icon);
list->Nb_directories++; list->Nb_directories++;
drive_index++; drive_index++;
} }
@ -489,11 +498,11 @@ void Read_list_of_drives(T_Fileselector *list)
#else #else
char * home_dir = getenv("HOME"); char * home_dir = getenv("HOME");
#endif #endif
Add_element_to_list(list, "/", 2); Add_element_to_list(list, "/", 2, ICON_NONE);
list->Nb_directories++; list->Nb_directories++;
if(home_dir) if(home_dir)
{ {
Add_element_to_list(list, home_dir, 2); Add_element_to_list(list, home_dir, 2, ICON_NONE);
list->Nb_directories++; list->Nb_directories++;
} }
@ -503,7 +512,7 @@ void Read_list_of_drives(T_Fileselector *list)
{ {
if(mount_points_list->me_dummy == 0 && strcmp(mount_points_list->me_mountdir,"/") && strcmp(mount_points_list->me_mountdir,"/home")) if(mount_points_list->me_dummy == 0 && strcmp(mount_points_list->me_mountdir,"/") && strcmp(mount_points_list->me_mountdir,"/home"))
{ {
Add_element_to_list(list, mount_points_list->me_mountdir,2); Add_element_to_list(list, mount_points_list->me_mountdir,2, ICON_NONE);
list->Nb_directories++; list->Nb_directories++;
} }
next = mount_points_list -> me_next; next = mount_points_list -> me_next;
@ -698,12 +707,13 @@ void Display_file_list(T_Fileselector *list, short offset_first,short selector_o
} }
// On affiche l'élément // On affiche l'élément
#ifdef __WIN32__ if (current_item->Icon != ICON_NONE)
if (current_item->Short_name[1]==':') { {
Print_in_window(17,95+index*8,current_item->Short_name,text_color,background_color); // Name preceded by an icon
Window_display_icon_sprite(8,95+index*8,drive_types[index]); Print_in_window(16,95+index*8,current_item->Short_name,text_color,background_color);
Window_display_icon_sprite(8,95+index*8,current_item->Icon);
} else } else
#endif // Name without icon
Print_in_window(8,95+index*8,current_item->Short_name,text_color,background_color); Print_in_window(8,95+index*8,current_item->Short_name,text_color,background_color);
// On passe à la ligne suivante // On passe à la ligne suivante

View File

@ -31,7 +31,7 @@
byte Button_Load_or_Save(byte load, T_IO_Context *context); byte Button_Load_or_Save(byte load, T_IO_Context *context);
void Add_element_to_list(T_Fileselector *list, const char * fname, int type); void Add_element_to_list(T_Fileselector *list, const char * fname, int type, byte icon);
/// ///
/// Formats a display name for a file, directory, or similar name (drive, volume). /// Formats a display name for a file, directory, or similar name (drive, volume).
/// The returned value is a pointer to a single static buffer of 19 characters /// The returned value is a pointer to a single static buffer of 19 characters

View File

@ -98,9 +98,11 @@ void AcceptDND(void)
{ {
#ifdef __WIN32__ #ifdef __WIN32__
SDL_SysWMinfo wminfo; SDL_SysWMinfo wminfo;
HWND hwnd;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
SDL_GetWMInfo(&wminfo); SDL_GetWMInfo(&wminfo);
HWND hwnd = wminfo.window; hwnd = wminfo.window;
DragAcceptFiles(hwnd,TRUE); DragAcceptFiles(hwnd,TRUE);
SDL_EventState (SDL_SYSWMEVENT,SDL_ENABLE ); SDL_EventState (SDL_SYSWMEVENT,SDL_ENABLE );
#endif #endif

View File

@ -442,6 +442,7 @@ int Init_program(int argc,char * argv[])
static char program_directory[MAX_PATH_CHARACTERS]; static char program_directory[MAX_PATH_CHARACTERS];
T_Gui_skin *gfx; T_Gui_skin *gfx;
int file_in_command_line; int file_in_command_line;
SDL_TimerID tid;
static char main_filename [MAX_PATH_CHARACTERS]; static char main_filename [MAX_PATH_CHARACTERS];
static char main_directory[MAX_PATH_CHARACTERS]; static char main_directory[MAX_PATH_CHARACTERS];
static char spare_filename [MAX_PATH_CHARACTERS]; static char spare_filename [MAX_PATH_CHARACTERS];
@ -545,7 +546,7 @@ int Init_program(int argc,char * argv[])
printf("Couldn't initialize SDL.\n"); printf("Couldn't initialize SDL.\n");
return(0); return(0);
} }
SDL_TimerID tid = SDL_AddTimer(10, putTimerEvent, NULL); tid = SDL_AddTimer(10, putTimerEvent, NULL);
Joystick = SDL_JoystickOpen(0); Joystick = SDL_JoystickOpen(0);
SDL_EnableKeyRepeat(250, 32); SDL_EnableKeyRepeat(250, 32);

View File

@ -51,6 +51,8 @@
void Set_mode_SDL(int *width, int *height, int fullscreen) void Set_mode_SDL(int *width, int *height, int fullscreen)
{ {
static SDL_Cursor* cur = NULL; static SDL_Cursor* cur = NULL;
static byte cursorData = 0;
Screen_SDL=SDL_SetVideoMode(*width,*height,8,(fullscreen?SDL_FULLSCREEN:0)|SDL_RESIZABLE); Screen_SDL=SDL_SetVideoMode(*width,*height,8,(fullscreen?SDL_FULLSCREEN:0)|SDL_RESIZABLE);
if(Screen_SDL != NULL) if(Screen_SDL != NULL)
{ {
@ -70,11 +72,10 @@ void Set_mode_SDL(int *width, int *height, int fullscreen)
// Trick borrowed to Barrage (http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg737265.html) : // Trick borrowed to Barrage (http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg737265.html) :
// Showing the cursor but setting it to fully transparent allows us to get absolute mouse coordinates, // Showing the cursor but setting it to fully transparent allows us to get absolute mouse coordinates,
// this means we canuse tablet in fullscreen mode. // this means we can use tablet in fullscreen mode.
SDL_ShowCursor(1); // Hide the SDL mouse cursor, we use our own SDL_ShowCursor(1); // Hide the SDL mouse cursor, we use our own
SDL_FreeCursor(cur); SDL_FreeCursor(cur);
static byte cursorData = 0;
cur = SDL_CreateCursor(&cursorData, &cursorData, 1,1,0,0); cur = SDL_CreateCursor(&cursorData, &cursorData, 1,1,0,0);
SDL_SetCursor(cur); SDL_SetCursor(cur);
} }

View File

@ -165,6 +165,7 @@ typedef struct T_Fileselector_item
char Short_name[19]; ///< Name to display. char Short_name[19]; ///< Name to display.
char Full_name[256]; ///< Filesystem value. char Full_name[256]; ///< Filesystem value.
byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive byte Type; ///< Type of item: 0 = File, 1 = Directory, 2 = Drive
byte Icon; ///< One of ::ICON_TYPES, ICON_NONE for none.
struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector. struct T_Fileselector_item * Next; ///< Pointer to next item of the current fileselector.
struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector. struct T_Fileselector_item * Previous;///< Pointer to previous item of the current fileselector.