paragui-users
[Top][All Lists]
Advanced

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

[paragui-users] ListBox bug ?


From: Admin
Subject: [paragui-users] ListBox bug ?
Date: Thu, 15 Dec 2005 14:48:04 +0200 (EET)

 I need to a .jpg file to appear in a definite place on the screen.
> Does anybody know how to do that? I've read some docs about PG_Image,
> but I don't have a code example. If you can, give me the example please. 
The solution we have always used is to place a PG_ThemeWidget with the
correct measures at the place and set the image as background.

> 2. I add lines in ListBox using AddItem. I use UP/Down to navigate
> through this ListBox (SelectNextItem SelectPrevItem). When the are a
> lot of lines and some of them are out of the visible zone, scroll bar
> appears in ListBox. But, I cannot scroll the text using Up/ Down keys.
> Where is the problem? 
And dif you click on the scrollbars everything works fine? Then it is a
bug.

I have an exam on Friday. If you could send me a reminder then that I am
going to fix this problem, I would (hopefully) spend some part of my
weekend on this. Does this sound OK?


cu,
Ulf


==============================================================
==============================================================

class MyApplication : public PG_Application, public PG_Navigator {
protected:
        bool eventKeyDown(const SDL_KeyboardEvent* key);
};
bool MyApplication::eventKeyDown(const SDL_KeyboardEvent* key) {
        DIR * directory_songs;
        struct dirent * ent_songs;
        char path[PATH_MAX + 1] = "/";
        char song_from_add[PATH_MAX + 1] = "";  

        PG_ListBox* list_artist = static_cast<PG_ListBox*>(GetWidgetById(146));
        PG_ListBox* list_songs = static_cast<PG_ListBox*>(GetWidgetById(145));
        PG_ListBox* list_playlist = 
static_cast<PG_ListBox*>(GetWidgetById(147));

        PG_ListBoxBaseItem* sel_item;   
        PG_ListBoxBaseItem* cur_song;   

        
        switch(key->keysym.sym) {
                case SDLK_UP:
                        list_artist->SelectPrevItem();
                        list_artist->Update();

                        sel_item = list_artist->GetSelectedItem();      
                        strcat(path,sel_item->GetText());

                        list_songs->RemoveAll();
                        
                        directory_songs = opendir(path);
        
                        while ( (ent_songs = readdir ( directory_songs )) != 
NULL ) {
                            if (ent_songs->d_type != DT_DIR) 
                                 if(strcmp(ent_songs->d_name,".") == 0 || 
strcmp(ent_songs->d_name,"..") == 0) continue;
                                    else list_songs->AddItem(new 
PG_ListBoxItem(20,ent_songs->d_name));
                            else continue;
                        }

                        closedir(directory_songs); 
                        list_songs->SelectFirstItem();                  
                        list_songs->Update();
                        break;
                case SDLK_DOWN:
                        list_artist->SelectNextItem();
                        list_artist->Update();
                        
                        sel_item = list_artist->GetSelectedItem();      
                        strcat(path,sel_item->GetText());

                        list_songs->RemoveAll();
                        
                        directory_songs = opendir(path);
        
                        while ( (ent_songs = readdir ( directory_songs )) != 
NULL ) {
                            if (ent_songs->d_type != DT_DIR) 
                                 if(strcmp(ent_songs->d_name,".") == 0 || 
strcmp(ent_songs->d_name,"..") == 0) continue;
                                    else list_songs->AddItem(new 
PG_ListBoxItem(20,ent_songs->d_name));
                            else continue;
                        }

                        closedir(directory_songs); 
                        list_songs->SelectFirstItem();                  
                        list_songs->Update();

                        break;
                case SDLK_LEFT:
                        list_songs->SelectNextItem();
                        list_songs->Update();
                        break;
                case SDLK_RIGHT:
                        list_songs->SelectPrevItem();
                        list_songs->Update();
                        break;
                case SDLK_TAB:
                        return true;
                case SDLK_SPACE:
                        cur_song = list_songs->GetSelectedItem();       
                        list_playlist->AddItem(new 
PG_ListBoxItem(20,cur_song->GetText()));
                        list_playlist->Update();
                        return true;
                default:
                        break;
        }
        return false;
}

int main( int argc, char **argv )
{
        DIR * directory_artist;
        struct dirent * ent_artist;

        DIR * directory_songs;
        struct dirent * ent_songs;

        Uint32 flags = SDL_SWSURFACE;
        int bpp = 0;

        MyApplication app;

        app.LoadTheme( "simple" );
        
        app.InitScreen( 800, 600, 0 );
        app.SetEmergencyQuit(true);

        PG_ListBox listbox_dir(NULL, PG_Rect(10,60,380,260));
        PG_ListBox listbox_file(NULL, PG_Rect(405,60,385,260));
        PG_ListBox listbox_playlist(NULL, PG_Rect(405,330,385,125));

        PG_ThemeWidget splash(NULL, PG_Rect(10,330,380,260), true);
        splash.LoadImage("1.bmp");
        splash.Update();

        listbox_file.SetID(145);
        listbox_dir.SetID(146);
        listbox_playlist.SetID(147);

        directory_artist = opendir("/");
        
        while ( (ent_artist = readdir ( directory_artist )) != NULL ) {
            if (ent_artist->d_type == DT_DIR) 
                 if(strcmp(ent_artist->d_name,".") == 0 || 
strcmp(ent_artist->d_name,"..") == 0) continue;
                    else listbox_dir.AddItem(new 
PG_ListBoxItem(20,ent_artist->d_name));
            else continue;
        }
        closedir(directory_artist); 

        directory_songs = opendir("/root");
        
        while ( (ent_songs = readdir ( directory_songs )) != NULL ) {
            if (ent_songs->d_type != DT_DIR) 
                 if(strcmp(ent_songs->d_name,".") == 0 || 
strcmp(ent_songs->d_name,"..") == 0) continue;
                    else listbox_file.AddItem(new 
PG_ListBoxItem(20,ent_songs->d_name));
            else continue;
        }
        closedir(directory_songs); 
        
        listbox_file.SelectFirstItem();
        listbox_dir.SelectFirstItem();
        listbox_playlist.SelectFirstItem();

        listbox_file.Update();
        listbox_playlist.Update();
        listbox_dir.Update();

        listbox_dir.Show();
        listbox_file.Show();
        listbox_playlist.Show();

        splash.Show();

        listbox_file.Update();
        listbox_dir.Update();
        listbox_playlist.Update();
        
        app.Run();
        
        return 0;
}
Scroll appears in this code, but while moving down the list, the list in 
ListBox doesn&#146;t scroll. And the system hangs up after navigating down the 
listbox_dir for two times (after refreshing listbox_file for two times)

___________________________________
Новый тариф компании EXPRESS, Интернет 64k всего за 95 гривен 
http://express.net.ua







reply via email to

[Prev in Thread] Current Thread [Next in Thread]