#ifndef NAV_MENU_H
#define NAV_MENU_H
#include <Messenger.h>
#include <StorageDefs.h>
#include <Entry.h>
#include "SlowMenu.h"
template<class T, bool O> class BObjectList;
class BMenuItem;
namespace BPrivate {
class Model;
class BContainerWindow;
class ModelMenuItem;
class EntryListBase;
struct TrackingHookData {
TrackingHookData()
:
fTrackingHook(NULL),
fDragMessage(NULL)
{
}
bool (*fTrackingHook)(BMenu*, void*);
BMessenger fTarget;
const BMessage* fDragMessage;
};
class BNavMenu : public BSlowMenu {
public:
BNavMenu(const char* title, uint32 message, const BHandler*,
BWindow* parentWindow = NULL, const BStringList* list = NULL);
BNavMenu(const char* title, uint32 message, const BMessenger&,
BWindow* parentWindow = NULL, const BStringList* list = NULL);
virtual ~BNavMenu();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
void SetNavDir(const entry_ref*);
void ForceRebuild();
bool NeedsToRebuild() const;
virtual void ResetTargets();
void SetTarget(const BMessenger&);
BMessenger Target();
void SetTypesList(const BStringList* list);
const BStringList* TypesList() const;
void AddNavDir(const Model* model, uint32 what, BHandler* target,
bool populateSubmenu);
void AddNavParentDir(const char* name, const Model* model, uint32 what,
BHandler* target);
void AddNavParentDir(const Model* model, uint32 what, BHandler* target);
void SetShowParent(bool show);
static int32 GetMaxMenuWidth();
static int CompareFolderNamesFirstOne(const BMenuItem*, const BMenuItem*);
static int CompareOne(const BMenuItem*, const BMenuItem*);
static ModelMenuItem* NewModelItem(Model*, const BMessage*,
const BMessenger&, bool suppressFolderHierarchy = false,
BContainerWindow* = NULL, const BStringList* typeslist = NULL,
TrackingHookData* hook = NULL);
TrackingHookData* InitTrackingHook(bool (*hookfunction)(BMenu*, void*),
const BMessenger* target, const BMessage* dragMessage);
protected:
virtual bool StartBuildingItemList();
virtual bool AddNextItem();
virtual void DoneBuildingItemList();
virtual void ClearMenuBuildingState();
void BuildVolumeMenu();
void AddOneItem(Model*);
void AddRootItem();
void AddVolumeItems();
void AddTrashItem();
static void SetTrackingHookDeep(BMenu*, bool (*)(BMenu*, void*), void*);
entry_ref fNavDir;
BMessage fMessage;
BMessenger fMessenger;
BWindow* fParentWindow;
uint8 fFlags;
BObjectList<BMenuItem, false>* fItemList;
EntryListBase* fContainer;
bool fIteratingDesktop;
BStringList* fTypesList;
TrackingHookData fTrackingHook;
};
class BPopUpNavMenu : public BNavMenu {
public:
BPopUpNavMenu(const char* title);
~BPopUpNavMenu();
void ClearMenu();
void Go(BPoint where);
bool IsShowing() const;
protected:
BPoint ScreenLocation();
private:
void _WaitForTrackThread();
static int32 _TrackThread(void* menu);
private:
BPoint fWhere;
thread_id fTrackThread;
};
#ifndef _IMPEXP_TRACKER
# define _IMPEXP_TRACKER
#endif
_IMPEXP_TRACKER bool SpringLoadedFolderCompareMessages(const BMessage *incoming,
const BMessage *dragmessage);
_IMPEXP_TRACKER void SpringLoadedFolderSetMenuStates(const BMenu *menu,
const BStringList *typeslist);
_IMPEXP_TRACKER void SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref,
BStringList *typeslist);
_IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming,
BMessage **, BStringList **typeslist);
}
using namespace BPrivate;
#endif