* Copyright (c) 1999-2000, Eric Moon.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DIAGRAM_ITEM_GROUP_H
#define DIAGRAM_ITEM_GROUP_H
#include "cortex_defs.h"
#include "DiagramItem.h"
#include <List.h>
#include <Point.h>
__BEGIN_CORTEX_NAMESPACE
class DiagramItemGroup {
public:
DiagramItemGroup(uint32 acceptedTypes, bool multiSelection = true);
virtual ~DiagramItemGroup();
virtual void SelectionChanged()
{
}
uint32 CountItems(uint32 whichType = DiagramItem::M_ANY) const;
DiagramItem* ItemAt(uint32 index,
uint32 whichType = DiagramItem::M_ANY) const;
DiagramItem* ItemUnder(BPoint point);
virtual bool AddItem(DiagramItem* item);
bool RemoveItem(DiagramItem* item);
void SortItems(uint32 itemType,
int (*compareFunc)(const void *, const void *));
void DrawItems(BRect updateRect, uint32 whichType = DiagramItem::M_ANY,
BRegion *updateRegion = 0);
bool GetClippingAbove(DiagramItem* which, BRegion* outRegion);
uint32 SelectedType() const;
uint32 CountSelectedItems() const;
DiagramItem* SelectedItemAt(uint32 index) const;
bool MultipleSelection() const
{
return fMultiSelection;
}
bool SelectItem(DiagramItem* which, bool deselectOthers = true);
bool DeselectItem(DiagramItem *which);
void SortSelectedItems(int (*compareFunc)(const void *, const void *));
bool SelectAll(uint32 itemType = DiagramItem::M_ANY);
bool DeselectAll(uint32 itemType = DiagramItem::M_ANY);
void DragSelectionBy(float x, float y, BRegion *updateRegion);
void RemoveSelection();
void SetItemAlignment(float horizontal, float vertical)
{
fItemAlignment.Set(horizontal, vertical);
}
void GetItemAlignment(float *horizontal, float *vertical);
void Align(float *x, float *y) const;
BPoint Align(BPoint point) const;
protected:
function; this can be used by deriving classes to implement a
transit system
*/
DiagramItem* _LastItemUnder()
{
return fLastItemUnder;
}
void _ResetItemUnder()
{
fLastItemUnder = 0;
}
private:
BList* fBoxes;
BList* fWires;
BList* fEndPoints;
BList* fSelection;
uint32 fTypes;
BPoint fItemAlignment;
bool fMultiSelection;
DiagramItem* fLastItemUnder;
};
__END_CORTEX_NAMESPACE
#endif