Initial checkin for Gabe Yoder.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@739 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2002-08-13 14:02:00 +00:00
parent 854fc92a7c
commit 54831cd6f1
2 changed files with 264 additions and 82 deletions
+105 -82
View File
@@ -1,82 +1,105 @@
/****************************************************************************** //------------------------------------------------------------------------------
/ // Copyright (c) 2001-2002, OpenBeOS
/ File: Clipboard.h //
/ // Permission is hereby granted, free of charge, to any person obtaining a
/ Description: BClipboard class defines clipboard functionality. // copy of this software and associated documentation files (the "Software"),
/ The global be_clipboard represents the default clipboard. // to deal in the Software without restriction, including without limitation
/ // the rights to use, copy, modify, merge, publish, distribute, sublicense,
/ Copyright 1995-98, Be Incorporated, All Rights Reserved. // 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 shall be included in
#ifndef _CLIPBOARD_H // all copies or substantial portions of the Software.
#define _CLIPBOARD_H //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#include <BeBuild.h> // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#include <Messenger.h> // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#include <Locker.h> // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
class BMessage; // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
enum { //
B_CLIPBOARD_CHANGED = 'CLCH' // File Name: Clipboard.h
}; // Author: Gabe Yoder ([email protected])
// Description: BClipboard provides an interface to a system-wide clipboard
/*------------------------------------------------------------------*/ // storage area.
/*----- BClipboard class --------------------------------------------*/ //------------------------------------------------------------------------------
class BClipboard { #ifndef _CLIPBOARD_H
public: #define _CLIPBOARD_H
BClipboard(const char *name, bool transient = false);
virtual ~BClipboard(); // Standard Includes -----------------------------------------------------------
const char *Name() const; // System Includes -------------------------------------------------------------
#include <BeBuild.h>
uint32 LocalCount() const; #include <Messenger.h>
uint32 SystemCount() const; #include <Locker.h>
status_t StartWatching(BMessenger target);
status_t StopWatching(BMessenger target); // Project Includes ------------------------------------------------------------
bool Lock(); // Local Includes --------------------------------------------------------------
void Unlock();
bool IsLocked() const; // Local Defines ---------------------------------------------------------------
status_t Clear(); // Globals ---------------------------------------------------------------------
status_t Commit(); class BMessage;
status_t Revert();
enum {
BMessenger DataSource() const; B_CLIPBOARD_CHANGED = 'CLCH'
BMessage *Data() const; };
/*----- Private or reserved -----------------------------------------*/ // BClipboard class ---------------------------------------------------------------
private: class BClipboard {
BClipboard(const BClipboard &); public:
BClipboard &operator=(const BClipboard &); BClipboard(const char *name, bool transient = false);
virtual ~BClipboard();
virtual void _ReservedClipboard1();
virtual void _ReservedClipboard2(); const char *Name() const;
virtual void _ReservedClipboard3();
uint32 LocalCount() const;
bool AssertLocked() const; uint32 SystemCount() const;
status_t DownloadFromSystem(bool force = false); status_t StartWatching(BMessenger target);
status_t UploadToSystem(); status_t StopWatching(BMessenger target);
uint32 fCount; bool Lock();
BMessage *fData; void Unlock();
BLocker fLock; bool IsLocked() const;
BMessenger fClipHandler;
BMessenger fDataSource; status_t Clear();
uint32 fSystemCount; status_t Commit();
char *fName; status_t Revert();
uint32 _reserved[4];
}; BMessenger DataSource() const;
BMessage *Data() const;
/*----------------------------------------------------------------*/
/*----- Global Clipboard -----------------------------------------*/ /*----- Private or reserved -----------------------------------------*/
private:
extern _IMPEXP_BE BClipboard *be_clipboard; BClipboard(const BClipboard &);
BClipboard &operator=(const BClipboard &);
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/ virtual void _ReservedClipboard1();
virtual void _ReservedClipboard2();
#endif /* _CLIPBOARD_H */ virtual void _ReservedClipboard3();
bool AssertLocked() const;
status_t DownloadFromSystem(bool force = false);
status_t UploadToSystem();
uint32 fCount;
BMessage *fData;
BLocker fLock;
BMessenger fClipHandler;
BMessenger fDataSource;
uint32 fSystemCount;
char *fName;
uint32 _reserved[4];
};
//----- Global Clipboard -------------------------------------------------------
extern _IMPEXP_BE BClipboard *be_clipboard;
//------------------------------------------------------------------------------
#endif // _CLIPBOARD_H
+159
View File
@@ -0,0 +1,159 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// 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 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 MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS 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.
//
// File Name: Clipboard.cpp
// Author: Gabe Yoder ([email protected])
// Description: BClipboard provides an interface to a system-wide clipboard
// storage area.
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
// System Includes -------------------------------------------------------------
#include <Clipboard.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
//------------------------------------------------------------------------------
BClipboard::BClipboard(const char *name, bool transient = false)
{
/* Not complete yet */
fName = strdup(name);
fData = new BMessage();
}
//------------------------------------------------------------------------------
BClipboard::~BClipboard()
{
/* Not complete yet? */
free(fName);
delete fData;
}
//------------------------------------------------------------------------------
const char* BClipboard::Name() const
{
return (const char*)fName;
}
//------------------------------------------------------------------------------
uint32 BClipboard::LocalCount() const
{
return fCount;
}
//------------------------------------------------------------------------------
uint32 BClipboard::SystemCount() const
{
/* Need to upload count data from app server, and update fCount */
return fCount;
}
//------------------------------------------------------------------------------
status_t BClipboard::StartWatching(BMessenger target)
{
}
//------------------------------------------------------------------------------
status_t BClipboard::StopWatching(BMessenger target)
{
}
//------------------------------------------------------------------------------
bool BClipboard::Lock()
{
bool retVal;
retVal = fLock.Lock();
/* Still need to upload clipboard data to fData */
/* Involves something with DownloadFromSystem */
return retVal;
}
//------------------------------------------------------------------------------
void BClipboard::Unlock()
{
fLock.Unlock();
}
//------------------------------------------------------------------------------
bool BClipboard::IsLocked() const
{
return fLock.IsLocked();
}
//------------------------------------------------------------------------------
status_t BClipboard::Clear()
{
}
//------------------------------------------------------------------------------
status_t BClipboard::Commit()
{
}
//------------------------------------------------------------------------------
status_t BClipboard::Revert()
{
}
//------------------------------------------------------------------------------
BMessenger BClipboard::DataSource() const
{
}
//------------------------------------------------------------------------------
BMessage* BClipboard::Data() const
{
if ( IsLocked() )
return fData;
return NULL;
}
//------------------------------------------------------------------------------
BClipboard::BClipboard(const BClipboard &)
{
}
//------------------------------------------------------------------------------
BClipboard & BClipboard::operator=(const BClipboard &)
{
}
//------------------------------------------------------------------------------
void BClipboard::_ReservedClipboard1()
{
}
//------------------------------------------------------------------------------
void BClipboard::_ReservedClipboard2()
{
}
//------------------------------------------------------------------------------
void BClipboard::_ReservedClipboard3()
{
}
//------------------------------------------------------------------------------
bool BClipboard::AssertLocked() const
{
}
//------------------------------------------------------------------------------
status_t BClipboard::DownloadFromSystem(bool force=false)
{
}
//------------------------------------------------------------------------------
status_t BClipboard::UploadToSystem()
{
}
//------------------------------------------------------------------------------