Added private libtracker headers, shared with Deskbar.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12771 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-05-23 00:24:17 +00:00
parent 3dc0510487
commit c45b77186b
6 changed files with 726 additions and 0 deletions

View File

@ -0,0 +1,105 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _AUTO_LOCK_H
#define _AUTO_LOCK_H
template<class T>
class AutoLock
{
// exception safe locking mechanism, allocate on stack and have
// destructor unlock for you whenever the lock goes out of scope
public:
AutoLock(T *lock, bool lockNow = true)
// use <lockLater> for lazy locking
: fLock(lock),
fHasLock(false)
{
if (lockNow)
fHasLock = fLock->Lock();
}
AutoLock(T &lock, bool lockNow = true)
: fLock(&lock),
fHasLock(false)
{
if (lockNow)
fHasLock = fLock->Lock();
}
~AutoLock()
{
if (fHasLock)
fLock->Unlock();
}
bool operator!() const
{ return !fHasLock; }
bool IsLocked() const
{ return fHasLock; }
// explicit Lock/Unlock calls are only used in special cases
// for unlocking before lock goes out of scope and successive
// re-locking
// usually constructor/destructor locks/unlocks are sufficient
void Unlock()
{
if (fHasLock) {
fLock->Unlock();
fHasLock = false;
}
}
bool Lock()
{
if (!fHasLock)
fHasLock = fLock->Lock();
return fHasLock;
}
// convenience call used when passing the AutoLock and the locked object
// around
T *LockedItem() const
{ return fLock; }
private:
T *fLock;
bool fHasLock;
};
#endif

View File

@ -0,0 +1,275 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef FAVORITES_CONFIG_H
#define FAVORITES_CONFIG_H
#include <Control.h>
#include <Window.h>
#include "Model.h"
class BBox;
class BButton;
class BCheckBox;
class BFilePanel;
class BMenuField;
class BPopUpMenu;
class BTextControl;
class BMessageRunner;
namespace BPrivate {
const uint32 kConfigShow = 'show';
const uint32 kConfigClose = 'canc';
//
// your app will get one of these messages when
// the count has changed
// FindInt32("count", &count)
//
const uint32 kUpdateAppsCount = 'upac';
const uint32 kUpdateDocsCount = 'updc';
const uint32 kUpdateFolderCount = 'upfl';
class NameItemPanel : public BWindow {
public:
NameItemPanel(BWindow *parent, const char *initialText);
virtual ~NameItemPanel();
virtual void MessageReceived(BMessage *);
private:
void AddParts(const char *initialText);
BWindow *fParent;
BBox *fBG;
BTextControl *fNameFld;
BButton *fCancelBtn;
BButton *fDoneBtn;
};
class TDraggableIconButton : public BControl {
public:
TDraggableIconButton(BRect , const char *label, BMessage *,
uint32 resizemask, uint32 flags);
virtual ~TDraggableIconButton();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect);
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint);
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
virtual void GetPreferredSize(float *, float *);
virtual void ResizeToPreferred();
private:
bool fDragging;
BRect fInitialClickRect;
BBitmap *fIcon;
BRect fIconRect;
BRect fLabelRect;
};
class TScrollerButton : public BControl {
public:
TScrollerButton(BRect , BMessage *, bool direction);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect);
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint);
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
private:
bool fDirection;
rgb_color fSelectedColor;
BRect fHiliteFrame;
BMessageRunner *fTicker;
};
class TContentsMenu : public BControl {
public:
TContentsMenu(BRect , BMessage *singleClick, BMessage *doubleClick,
int32 visibleItemCount, const entry_ref *startRef);
virtual ~TContentsMenu();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void Draw(BRect );
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MessageReceived(BMessage *);
virtual void MouseDown(BPoint );
virtual void MouseUp(BPoint );
virtual void MouseMoved(BPoint , uint32 , const BMessage *);
virtual void GetPreferredSize(float *, float *);
virtual void ResizeToPreferred();
void StartTracking(BPoint);
void StopTracking();
#ifdef ITEM_EDIT
void BeginItemEdit(BPoint);
void StopItemEdit();
#endif
void SetStartRef(const entry_ref *);
void FillMenu(const entry_ref *);
void EmptyMenu();
bool ItemFrame(int32 index, BRect *iconFrame, BRect *textFrame, BRect *itemFrame) const;
void InvalidateItem(int32 index);
void InvalidateAbsoluteItem(int32 index);
int32 ItemAt(BPoint, BRect *textFrame, BRect *itemFrame, BRect *iconFrame);
const Model *ItemAt(int32) const;
void SelectItemAt(BPoint where);
void Select(const entry_ref *);
void OpenItem(int32);
int32 ItemCount() const;
void RemoveItem(int32);
void AddTempItem(BPoint where);
private:
void UpdateScrollers();
void Scroll(bool);
BMessage *fDoubleClickMessage;
int32 fVisibleItemCount;
entry_ref fStartRef;
BFont *fMenuFont;
float fFontHeight;
float fItemHeight;
rgb_color fHiliteColor;
BRect fInitialClickRect;
bigtime_t fInitialClickTime;
#ifdef ITEM_EDIT
BPoint fInitialClickLoc;
bool fEditingItem;
BTextView *fEditingFld;
int32 fItemIndex;
#endif
int32 fFirstItem;
BObjectList<Model> *fContentsList;
BBitmap *fSmallGroupIcon;
BBitmap *fSymlinkIcon;
TScrollerButton *fUpBtn;
TScrollerButton *fDownBtn;
};
// pass -1 to max apps/docs/folders to not have it show
class TFavoritesConfigWindow : public BWindow {
public:
TFavoritesConfigWindow(BRect frame, const char *title,
bool modal, uint32 filePanelNodeFlavors,
BMessenger parent, const entry_ref *startRef,
int32 maxApps = -1, int32 maxDocs = -1, int32 maxFolders = -1);
~TFavoritesConfigWindow();
void MessageReceived(BMessage *);
bool QuitRequested();
void AddNewGroup();
void AddRefs(BMessage *);
private:
void AddParts(int32 maxApps, int32 maxDocs, int32 maxFolders);
void AddBeMenuPane(int32 maxApps, int32 maxDocs, int32 maxFolders);
void OpenGroup(const entry_ref *);
void ShowGroup(const entry_ref *);
void PromptForAdd();
void UpdateButtons();
void UpdateFoldersCount(int32 = -1, bool notifyTracker = true);
void UpdateDocsCount(int32 = -1, bool notifyTracker = true);
void UpdateAppsCount(int32 = -1, bool notifyTracker = true);
static void BuildCommon(BRect *frame, int32 count, const char *string, uint32 btnWhat,
uint32 fldWhat, BCheckBox **button, BTextControl **field, BBox *parent);
static void AddNewGroup(entry_ref *, entry_ref *);
static void AddSymLink(const entry_ref *, const entry_ref *);
uint32 fFilePanelNodeFlavors;
BMessenger fParent;
entry_ref fCurrentRef;
BFilePanel *fAddPanel;
// Favorites Menu Config controls
BBox *fBeMenuPaneBG;
BPopUpMenu *fGroupMenu;
BMenuField *fGroupBtn;
BPopUpMenu *fSortMenu;
BMenuField *fSortBtn;
TDraggableIconButton *fNewGroupBtn;
BCheckBox *fRecentAppsBtn;
BTextControl *fRecentAppsFld;
BCheckBox *fRecentFoldersBtn;
BTextControl *fRecentFoldersFld;
BCheckBox *fRecentDocsBtn;
BTextControl *fRecentDocsFld;
TContentsMenu *fMenuThing;
BButton *fAddBtn;
BButton *fRemoveBtn;
BButton *fEditBtn;
BButton *fOpenBtn;
};
} // namespace BPrivate
using namespace BPrivate;
#endif

View File

@ -0,0 +1,170 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
// NavMenu is a hierarchical menu of volumes, folders, files and queries
// displays icons, uses the SlowMenu API for full interruptability
#ifndef NAV_MENU_H
#define NAV_MENU_H
#include <Messenger.h>
#include <StorageDefs.h>
#include <Entry.h>
#include "SlowMenu.h"
template<class T> class BObjectList;
class BMenuItem;
namespace BPrivate {
class Model;
class BContainerWindow;
class ModelMenuItem;
class EntryListBase;
class TrackingHookData {
public:
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 BObjectList<BString> *list = NULL);
BNavMenu(const char* title, uint32 message, const BMessenger &,
BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL);
// parentWindow, if specified, will be closed if nav menu item invoked
// with option held down
virtual ~BNavMenu();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
void SetNavDir(const entry_ref *);
void ForceRebuild();
bool NeedsToRebuild() const;
// will cause menu to get rebuilt next time it is shown
virtual void ResetTargets();
void SetTarget(const BMessenger &);
BMessenger Target();
void SetTypesList(const BObjectList<BString> *list);
const BObjectList<BString> *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 BObjectList<BString> *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 AddRootItemsIfNeeded();
static void SetTrackingHookDeep(BMenu *, bool (*)(BMenu *, void *), void *);
entry_ref fNavDir;
BMessage fMessage;
BMessenger fMessenger;
BWindow *fParentWindow;
// menu building state
uint8 fFlags;
BObjectList<BMenuItem> *fItemList;
EntryListBase *fContainer;
bool fIteratingDesktop;
const BObjectList<BString> *fTypesList;
TrackingHookData fTrackingHook;
};
// Spring Loaded Folder convenience routines
// used in both Tracker and Deskbar
#if B_BEOS_VERSION_DANO
#define _IMPEXP_TRACKER
#endif
_IMPEXP_TRACKER bool SpringLoadedFolderCompareMessages(const BMessage *incoming,
const BMessage *dragmessage);
_IMPEXP_TRACKER void SpringLoadedFolderSetMenuStates(const BMenu *menu,
const BObjectList<BString> *typeslist);
_IMPEXP_TRACKER void SpringLoadedFolderAddUniqueTypeToList(entry_ref *ref,
BObjectList<BString> *typeslist);
_IMPEXP_TRACKER void SpringLoadedFolderCacheDragData(const BMessage *incoming,
BMessage **, BObjectList<BString> **typeslist);
#if B_BEOS_VERSION_DANO
#undef _IMPEXP_TRACKER
#endif
} // namespace BPrivate
using namespace BPrivate;
#endif

View File

@ -0,0 +1,100 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
/****************************************************************************
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
** **
** DANGER, WILL ROBINSON! **
** **
** The interfaces contained here are part of BeOS's **
** **
** >> PRIVATE NOT FOR PUBLIC USE << **
** **
** implementation. **
** **
** These interfaces WILL CHANGE in future releases. **
** If you use them, your app WILL BREAK at some future time. **
** **
** (And yes, this does mean that binaries built from OpenTracker will not **
** be compatible with some future releases of the OS. When that happens, **
** we will provide an updated version of this file to keep compatibility.) **
** **
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
****************************************************************************/
#ifndef _TEXTVIEWSUPPORT_H
#define _TEXTVIEWSUPPORT_H
// This is a stub of text view width buffer
// It relies on the implementation of _BWidthBuffer_ in libbe and should
// not be modified
struct _width_table_ {
#if B_BEOS_VERSION_DANO
BFont font; // corresponding font
#else
int32 fontCode; // font code
float fontSize; // font size
#endif
int32 hashCount; // number of hashed items
int32 tableCount; // size of table
void *widths; // width table
};
template<class T> class _BTextViewSupportBuffer_ {
public:
_BTextViewSupportBuffer_(int32, int32);
virtual ~_BTextViewSupportBuffer_();
protected:
int32 mExtraCount;
int32 mItemCount;
int32 mBufferCount;
T *mBuffer;
};
class _BWidthBuffer_ : public _BTextViewSupportBuffer_<_width_table_> {
public:
_BWidthBuffer_();
virtual ~_BWidthBuffer_();
float StringWidth(const char *inText, int32 fromOffset, int32 length,
const BFont *inStyle);
};
#endif /* _TEXTVIEWSUPPORT_H */

View File

@ -0,0 +1,23 @@
#ifndef _PR_SERVER_H_
#define _PR_SERVER_H_
// spool Attributes
#define PSRV_SPOOL_ATTR_MIMETYPE "_spool/MimeType"
#define PSRV_SPOOL_ATTR_PAGECOUNT "_spool/Page Count"
#define PSRV_SPOOL_ATTR_DESCRIPTION "_spool/Description"
#define PSRV_SPOOL_ATTR_PRINTER "_spool/Printer"
#define PSRV_SPOOL_ATTR_STATUS "_spool/Status"
#define PSRV_SPOOL_ATTR_ERRCODE "_spool/_errorcode"
// printer attributes
#define PSRV_PRINTER_ATTR_DRV_NAME "Driver Name"
#define PSRV_PRINTER_ATTR_PRT_NAME "Printer Name"
#define PSRV_PRINTER_ATTR_COMMENTS "Comments"
#define PSRV_PRINTER_ATTR_STATE "state"
#define PSRV_PRINTER_ATTR_TRANSPORT "transport"
#define PSRV_PRINTER_ATTR_TRANSPORT_ADDR "transport_address"
#define PSRV_PRINTER_ATTR_CNX "connection"
#define PSRV_PRINTER_ATTR_PNP "_PNP"
#define PSRV_PRINTER_ATTR_MDL "_MDL"
#endif

View File

@ -0,0 +1,53 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _TRACKER_PRIVATE_H
#define _TRACKER_PRIVATE_H
#include <BeBuild.h>
#define kTrackerSignature "application/x-vnd.Be-TRAK"
#define kTrackerSuites "suite/x-vnd.Be-TRAK"
#define kDeskbarSignature "application/x-vnd.Be-TSKB"
namespace BPrivate {
#if !B_BEOS_VERSION_DANO
_IMPEXP_TRACKER
#endif
void InitIconPreloader();
}
#endif /* _TRACKER_PRIVATE_H */