Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Protected Attributes
nsFilePanelBeOS Class Reference

#include <nsFilePicker.h>

List of all members.

Public Types

enum  { NOT_SELECTED = 0, OPEN_SELECTED = 1, SAVE_SELECTED = 2, CANCEL_SELECTED = 3 }

Public Member Functions

 nsFilePanelBeOS (file_panel_mode mode, uint32 node_flavors, bool allow_multiple_selection, bool modal, bool hide_when_done)
virtual ~nsFilePanelBeOS ()
virtual void MessageReceived (BMessage *message)
virtual bool SelectionDone ()
virtual void SelectionChanged ()
virtual bool IsOpenSelected ()
virtual bool IsSaveSelected ()
virtual bool IsCancelSelected ()
virtual uint32 SelectedActivity ()
virtual BList * OpenRefs ()
virtual BString SaveFileName ()
virtual entry_ref SaveDirRef ()

Protected Attributes

BButton * mDirectoryButton
uint32 mSelectedActivity
bool mIsSelected
BString mSaveFileName
entry_ref mSaveDirRef
BList mOpenRefs

Detailed Description

Definition at line 117 of file nsFilePicker.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
NOT_SELECTED 
OPEN_SELECTED 
SAVE_SELECTED 
CANCEL_SELECTED 

Definition at line 147 of file nsFilePicker.h.


Constructor & Destructor Documentation

nsFilePanelBeOS::nsFilePanelBeOS ( file_panel_mode  mode,
uint32  node_flavors,
bool  allow_multiple_selection,
bool  modal,
bool  hide_when_done 
)

Definition at line 427 of file nsFilePicker.cpp.

                            : BLooper("FilePickerLooper", B_DISPLAY_PRIORITY)
                            , BFilePanel(mode,
                                                 NULL, NULL,
                                                 node_flavors,
                                                 allow_multiple_selection,
                                                 NULL, NULL,
                                                 modal,
                                                 hide_when_done)
                            , mSelectedActivity(nsFilePanelBeOS::NOT_SELECTED)
                            , mIsSelected(false)
                            , mSaveFileName("")
                            , mSaveDirRef()
                            , mOpenRefs()
{
       SetTarget(BMessenger(this));

       if ( mode == B_OPEN_PANEL && node_flavors == B_DIRECTORY_NODE ) 
       {
              // Add a 'Select <dirname>' button to the open dialog
              Window()->Lock();

              BView *background = Window()->ChildAt(0); 
              entry_ref ref;
              char label[10+B_FILE_NAME_LENGTH];
              GetPanelDirectory(&ref);
              sprintf(label, "Select '%s'", ref.name);
              mDirectoryButton = new BButton(
                     BRect(113, background->Bounds().bottom-35, 269, background->Bounds().bottom-10),
                     "directoryButton", label, new BMessage(MSG_DIRECTORY), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);

              if(mDirectoryButton)
              {
                     background->AddChild(mDirectoryButton);
                     mDirectoryButton->SetTarget(Messenger());
              }
              else
                     NS_ASSERTION(false, "Out of memory: failed to create mDirectoryButton");

              SetButtonLabel(B_DEFAULT_BUTTON, "Select");

              Window()->Unlock();
       }
       else 
              mDirectoryButton = nsnull;
       this->Run();
}

Definition at line 479 of file nsFilePicker.cpp.

{
       int count = mOpenRefs.CountItems();
       for (int i=0 ; i<count ; i++)
              delete mOpenRefs.ItemAt(i);
}

Member Function Documentation

virtual bool nsFilePanelBeOS::IsCancelSelected ( ) [inline, virtual]

Definition at line 138 of file nsFilePicker.h.

                                  {
    return (SelectedActivity() == CANCEL_SELECTED);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool nsFilePanelBeOS::IsOpenSelected ( ) [inline, virtual]

Definition at line 132 of file nsFilePicker.h.

                                {
    return (SelectedActivity() == OPEN_SELECTED);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool nsFilePanelBeOS::IsSaveSelected ( ) [inline, virtual]

Definition at line 135 of file nsFilePicker.h.

                                {
    return (SelectedActivity() == SAVE_SELECTED);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFilePanelBeOS::MessageReceived ( BMessage *  message) [virtual]

Definition at line 486 of file nsFilePicker.cpp.

{
       switch ( msg->what )
       {
       case B_REFS_RECEIVED: // open
              int32 count;
              type_code code;
              msg->GetInfo("refs", &code, &count);
              if (code == B_REF_TYPE)
              {
                     for (int i=0 ; i<count ; i++)
                     {
                            // XXX change - adding BPaths * to list instead entry_refs,
                            // entry_refs are too unsafe objects in our case.
                            entry_ref ref;
                            if (msg->FindRef("refs", i, &ref) == B_OK)
                            {
                                   BPath *path = new BPath(&ref);
                                   mOpenRefs.AddItem((void *) path);
                            }
                     }
              }
              else
              {
                     printf("nsFilePanelBeOS::MessageReceived() no ref!\n");
              }
              mSelectedActivity = OPEN_SELECTED;
              mIsSelected = true;
              break;
       
       case MSG_DIRECTORY: // Directory selected
       {
              entry_ref ref;
              GetPanelDirectory(&ref);
              BPath *path = new BPath(&ref);
              mOpenRefs.AddItem((void *) path);
              mSelectedActivity = OPEN_SELECTED;
              mIsSelected = true;
              break;
       }

       case B_SAVE_REQUESTED: // save
              msg->FindString("name", &mSaveFileName);
              msg->FindRef("directory", &mSaveDirRef);
              mSelectedActivity = SAVE_SELECTED;
              mIsSelected = true;
              break;

       case B_CANCEL: // cancel
              if (mIsSelected) break;
              mSelectedActivity = CANCEL_SELECTED;
              mIsSelected = true;
              break;
       default:
              break;
       }
}
virtual BList* nsFilePanelBeOS::OpenRefs ( ) [inline, virtual]

Definition at line 143 of file nsFilePicker.h.

{ return &mOpenRefs; }

Here is the caller graph for this function:

virtual entry_ref nsFilePanelBeOS::SaveDirRef ( ) [inline, virtual]

Definition at line 145 of file nsFilePicker.h.

{ return mSaveDirRef; }

Here is the caller graph for this function:

virtual BString nsFilePanelBeOS::SaveFileName ( ) [inline, virtual]

Definition at line 144 of file nsFilePicker.h.

{ return mSaveFileName; }

Here is the caller graph for this function:

Definition at line 549 of file nsFilePicker.cpp.

{
       uint32 result = 0;
       result = mSelectedActivity;

       return result;
}

Here is the caller graph for this function:

Definition at line 557 of file nsFilePicker.cpp.

{
       if(mDirectoryButton)
       {
              //Update the 'Select <dir>' button
              entry_ref ref;
              char label[50];
              GetPanelDirectory(&ref);
              Window()->Lock();
              sprintf(label, "Select '%s'", ref.name);
              mDirectoryButton->SetLabel(label);
              Window()->Unlock();
       }
       BFilePanel::SelectionChanged();
}

Definition at line 544 of file nsFilePicker.cpp.

{
       return mIsSelected;
}

Here is the caller graph for this function:


Member Data Documentation

BButton* nsFilePanelBeOS::mDirectoryButton [protected]

Definition at line 155 of file nsFilePicker.h.

Definition at line 157 of file nsFilePicker.h.

BList nsFilePanelBeOS::mOpenRefs [protected]

Definition at line 160 of file nsFilePicker.h.

entry_ref nsFilePanelBeOS::mSaveDirRef [protected]

Definition at line 159 of file nsFilePicker.h.

BString nsFilePanelBeOS::mSaveFileName [protected]

Definition at line 158 of file nsFilePicker.h.

Definition at line 156 of file nsFilePicker.h.


The documentation for this class was generated from the following files: