Merge from layout management branch.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18649 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2006-08-26 16:21:15 +00:00
parent 01595708f3
commit 9ecf9d1c1d
277 changed files with 45889 additions and 747 deletions
+6
View File
@@ -27,10 +27,16 @@ typedef unsigned long haiku_build_addr_t;
# define B_CURRENT_TEAM 0
#endif
#ifndef SYMLOOP_MAX
# define SYMLOOP_MAX (16)
#endif
#ifndef B_FIRST_REAL_TIME_PRIORITY
# define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
#endif
#ifdef __cplusplus
extern "C" {
#endif
File diff suppressed because it is too large Load Diff
+93
View File
@@ -0,0 +1,93 @@
/* expat_config.h. Generated by configure. */
/* expat_config.h.in. Generated from configure.in by autoheader. */
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#define BYTEORDER 1234
/* Define to 1 if you have the `bcopy' function. */
#define HAVE_BCOPY 1
/* Define to 1 if you have the <check.h> header file. */
/* #undef HAVE_CHECK_H */
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `getpagesize' function. */
/* #undef HAVE_GETPAGESIZE */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have a working `mmap' system call. */
/* #undef HAVE_MMAP */
/* Define to 1 if you have the <stdint.h> header file. */
/* #undef HAVE_STDINT_H */
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "[email protected]"
/* Define to the full name of this package. */
#define PACKAGE_NAME "expat"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "expat 1.95.8"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "expat"
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.95.8"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* whether byteorder is bigendian */
/* #undef WORDS_BIGENDIAN */
/* Define to specify how much context to retain around the current parse
point. */
#define XML_CONTEXT_BYTES 1024
/* Define to make parameter entity parsing functionality available. */
#define XML_DTD 1
/* Define to make XML Namespaces functionality available. */
#define XML_NS 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `long' if <sys/types.h> does not define. */
/* #undef off_t */
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */
+92
View File
@@ -0,0 +1,92 @@
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
See the file COPYING for copying permission.
*/
/* External API definitions */
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
#define XML_USE_MSC_EXTENSIONS 1
#endif
/* Expat tries very hard to make the API boundary very specifically
defined. There are two macros defined to control this boundary;
each of these can be defined before including this header to
achieve some different behavior, but doing so it not recommended or
tested frequently.
XMLCALL - The calling convention to use for all calls across the
"library boundary." This will default to cdecl, and
try really hard to tell the compiler that's what we
want.
XMLIMPORT - Whatever magic is needed to note that a function is
to be imported from a dynamically loaded library
(.dll, .so, or .sl, depending on your platform).
The XMLCALL macro was added in Expat 1.95.7. The only one which is
expected to be directly useful in client code is XMLCALL.
Note that on at least some Unix versions, the Expat library must be
compiled with the cdecl calling convention as the default since
system headers may assume the cdecl convention.
*/
#ifndef XMLCALL
#if defined(XML_USE_MSC_EXTENSIONS)
#define XMLCALL __cdecl
#elif defined(__GNUC__) && defined(__i386)
#define XMLCALL __attribute__((cdecl))
#else
/* For any platform which uses this definition and supports more than
one calling convention, we need to extend this definition to
declare the convention used on that platform, if it's possible to
do so.
If this is the case for your platform, please file a bug report
with information on how to identify your platform via the C
pre-processor and how to specify the same calling convention as the
platform's malloc() implementation.
*/
#define XMLCALL
#endif
#endif /* not defined XMLCALL */
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
#ifndef XML_BUILDING_EXPAT
/* using Expat from an application */
#ifdef XML_USE_MSC_EXTENSIONS
#define XMLIMPORT __declspec(dllimport)
#endif
#endif
#endif /* not defined XML_STATIC */
/* If we didn't define it above, define it away: */
#ifndef XMLIMPORT
#define XMLIMPORT
#endif
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XML_UNICODE_WCHAR_T
#define XML_UNICODE
#endif
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
#ifdef XML_UNICODE_WCHAR_T
typedef wchar_t XML_Char;
typedef wchar_t XML_LChar;
#else
typedef unsigned short XML_Char;
typedef char XML_LChar;
#endif /* XML_UNICODE_WCHAR_T */
#else /* Information is UTF-8 encoded. */
typedef char XML_Char;
typedef char XML_LChar;
#endif /* XML_UNICODE */
+80
View File
@@ -0,0 +1,80 @@
/*
* Copyright 2006, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
*/
#ifndef ICON_UTILS_H
#define ICON_UTILS_H
#include <Mime.h>
class BBitmap;
class BNode;
// This class is a little different from many other classes.
// You don't create an instance of it; you just call its various
// static member functions for utility-like operations.
class BIconUtils {
BIconUtils();
~BIconUtils();
BIconUtils(const BIconUtils&);
BIconUtils& operator=(const BIconUtils&);
public:
// Utility function to import an icon from the node that
// has either of the provided attribute names. Which icon type
// is preferred (vector, small or large B_CMAP8 icon) depends
// on the colorspace of the provided bitmap. If the colorspace
// is B_CMAP8, B_CMAP8 icons are preferred. If no vector icon
// is available, the bitmap size must match the provided
// icon_size "size"!
static status_t GetIcon(BNode* node,
const char* vectorIconAttrName,
const char* smallIconAttrName,
const char* largeIconAttrName,
icon_size size,
BBitmap* result);
// Utility functions to import a vector icon in "flat icon"
// format from a BNode attribute or from a flat buffer in
// memory into the preallocated BBitmap "result".
// The colorspace of result needs to be B_RGBA32 or at
// least B_RGB32 (though that makes less sense). The icon
// will be scaled from it's "native" size of 64x64 to the
// size of the bitmap, the scale is derived from the bitmap
// width, the bitmap should have square dimension, or the
// icon will be cut off at the bottom (or have room left).
static status_t GetVectorIcon(BNode* node,
const char* attrName,
BBitmap* result);
static status_t GetVectorIcon(const uint8* buffer,
size_t size,
BBitmap* result);
// Utility function to import an "old" BeOS icon in B_CMAP8
// colorspace from either the small icon attribute or the
// large icon attribute as given in "smallIconAttrName" and
// "largeIconAttrName". Which icon is loaded depends on
// the given "size".
static status_t GetCMAP8Icon(BNode* node,
const char* smallIconAttrName,
const char* largeIconAttrName,
icon_size size,
BBitmap* icon);
// Utility functions to convert from old icon colorspace
// into colorspace of BBitmap "result" (should be B_RGBA32
// to make any sense).
static status_t ConvertFromCMAP8(BBitmap* source,
BBitmap* result);
static status_t ConvertFromCMAP8(const uint8* data,
uint32 width, uint32 height,
uint32 bytesPerRow,
BBitmap* result);
};
#endif // ICON_UTILS_H
+1
View File
@@ -50,6 +50,7 @@ enum {
B_KEY_UP = '_KYU',
B_UNMAPPED_KEY_DOWN = '_UKD',
B_UNMAPPED_KEY_UP = '_UKU',
B_LAYOUT_WINDOW = '_LAY',
B_MODIFIERS_CHANGED = '_MCH',
B_MINIMIZE = '_WMN',
B_MOUSE_DOWN = '_MDN',
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _ABSTRACT_LAYOUT_ITEM_H
#define _ABSTRACT_LAYOUT_ITEM_H
#include <Alignment.h>
#include <LayoutItem.h>
#include <Size.h>
class BAbstractLayoutItem : public BLayoutItem {
public:
BAbstractLayoutItem();
virtual ~BAbstractLayoutItem();
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual BAlignment Alignment();
virtual void SetExplicitMinSize(BSize size);
virtual void SetExplicitMaxSize(BSize size);
virtual void SetExplicitPreferredSize(BSize size);
virtual void SetExplicitAlignment(BAlignment alignment);
virtual BSize BaseMinSize();
virtual BSize BaseMaxSize();
virtual BSize BasePreferredSize();
virtual BAlignment BaseAlignment();
private:
BSize fMinSize;
BSize fMaxSize;
BSize fPreferredSize;
BAlignment fAlignment;
};
#endif // _ABSTRACT_LAYOUT_ITEM_H
+128
View File
@@ -0,0 +1,128 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _ALIGNMENT_H
#define _ALIGNMENT_H
#include <InterfaceDefs.h>
class BAlignment {
public:
alignment horizontal;
vertical_alignment vertical;
inline BAlignment();
inline BAlignment(const BAlignment& other);
inline BAlignment(alignment horizontal,
vertical_alignment vertical);
inline alignment Horizontal() const;
inline vertical_alignment Vertical() const;
float RelativeHorizontal() const;
float RelativeVertical() const;
inline void SetHorizontal(alignment horizontal);
inline void SetVertical(vertical_alignment vertical);
inline bool IsHorizontalSet() const;
inline bool IsVerticalSet() const;
inline bool operator==(const BAlignment& other) const;
inline bool operator!=(const BAlignment& other) const;
inline BAlignment& operator=(const BAlignment& other);
};
// constructor
inline
BAlignment::BAlignment()
: horizontal(B_ALIGN_HORIZONTAL_UNSET),
vertical(B_ALIGN_VERTICAL_UNSET)
{
}
// copy constructor
inline
BAlignment::BAlignment(const BAlignment& other)
: horizontal(other.horizontal),
vertical(other.vertical)
{
}
// constructor
inline
BAlignment::BAlignment(alignment horizontal, vertical_alignment vertical)
: horizontal(horizontal),
vertical(vertical)
{
}
// Horizontal
inline alignment
BAlignment::Horizontal() const
{
return horizontal;
}
// Vertical
inline vertical_alignment
BAlignment::Vertical() const
{
return vertical;
}
// SetHorizontal
inline void
BAlignment::SetHorizontal(alignment horizontal)
{
this->horizontal = horizontal;
}
// SetVertical
inline void
BAlignment::SetVertical(vertical_alignment vertical)
{
this->vertical = vertical;
}
// IsHorizontalSet
inline bool
BAlignment::IsHorizontalSet() const
{
return (horizontal != B_ALIGN_HORIZONTAL_UNSET);
}
// IsVerticalSet
inline bool
BAlignment::IsVerticalSet() const
{
return (vertical != B_ALIGN_VERTICAL_UNSET);
}
// ==
inline bool
BAlignment::operator==(const BAlignment& other) const
{
return (horizontal == other.horizontal && vertical == other.vertical);
}
// !=
inline bool
BAlignment::operator!=(const BAlignment& other) const
{
return !(*this == other);
}
// =
inline BAlignment&
BAlignment::operator=(const BAlignment& other)
{
horizontal = other.horizontal;
vertical = other.vertical;
return *this;
}
#endif // _ALIGNMENT_H
+7
View File
@@ -52,6 +52,10 @@ public:
BMessage *message,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BButton(const char* name, const char* label,
BMessage *message,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BButton(const char* label, BMessage *message);
virtual ~BButton();
@@ -92,6 +96,9 @@ virtual BHandler *ResolveSpecifier(BMessage *message,
virtual status_t GetSupportedSuites(BMessage *message);
virtual status_t Perform(perform_code d, void *arg);
virtual BSize MaxSize();
private:
virtual void _ReservedButton1();
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _CARD_LAYOUT_H
#define _CARD_LAYOUT_H
#include <Layout.h>
class BCardLayout : public BLayout {
public:
BCardLayout();
virtual ~BCardLayout();
BLayoutItem* VisibleItem() const;
int32 VisibleIndex() const;
void SetVisibleItem(int32 index);
void SetVisibleItem(BLayoutItem* item);
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual BAlignment Alignment();
virtual bool HasHeightForWidth();
virtual void GetHeightForWidth(float width, float* min,
float* max, float* preferred);
virtual void InvalidateLayout();
virtual void LayoutView();
protected:
virtual void ItemAdded(BLayoutItem* item);
virtual void ItemRemoved(BLayoutItem* item);
private:
BSize fMin;
BSize fMax;
BSize fPreferred;
BLayoutItem* fVisibleItem;
bool fMinMaxValid;
void _ValidateMinMax();
};
#endif // _CARD_LAYOUT_H
+2
View File
@@ -33,6 +33,8 @@ class BColorControl : public BControl {
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive, bool deep = true) const;
virtual void SetLayout(BLayout* layout);
virtual void SetValue(int32 color_value);
void SetValue(rgb_color color);
rgb_color ValueAsColor();
+95
View File
@@ -0,0 +1,95 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _GRID_LAYOUT_H
#define _GRID_LAYOUT_H
#include <TwoDimensionalLayout.h>
class BGridLayout : public BTwoDimensionalLayout {
public:
BGridLayout(float horizontal = 0.0f,
float vertical = 0.0f);
virtual ~BGridLayout();
float HorizontalSpacing() const;
float VerticalSpacing() const;
void SetHorizontalSpacing(float spacing);
void SetVerticalSpacing(float spacing);
void SetSpacing(float horizontal, float vertical);
float ColumnWeight(int32 column) const;
void SetColumnWeight(int32 column, float weight);
float MinColumnWidth(int32 column) const;
void SetMinColumnWidth(int32 column, float width);
float MaxColumnWidth(int32 column) const;
void SetMaxColumnWidth(int32 column, float width);
float RowWeight(int32 row) const;
void SetRowWeight(int32 row, float weight);
float MinRowHeight(int row) const;
void SetMinRowHeight(int32 row, float height);
float MaxRowHeight(int32 row) const;
void SetMaxRowHeight(int32 row, float height);
virtual BLayoutItem* AddView(BView* child);
virtual BLayoutItem* AddView(int32 index, BView* child);
virtual BLayoutItem* AddView(BView* child, int32 column, int32 row,
int32 columnCount = 1, int32 rowCount = 1);
virtual bool AddItem(BLayoutItem* item);
virtual bool AddItem(int32 index, BLayoutItem* item);
virtual bool AddItem(BLayoutItem* item, int32 column,
int32 row, int32 columnCount = 1,
int32 rowCount = 1);
protected:
virtual void ItemAdded(BLayoutItem* item);
virtual void ItemRemoved(BLayoutItem* item);
virtual bool HasMultiColumnItems();
virtual bool HasMultiRowItems();
virtual int32 InternalCountColumns();
virtual int32 InternalCountRows();
virtual void GetColumnRowConstraints(
enum orientation orientation,
int32 index,
ColumnRowConstraints* constraints);
virtual void GetItemDimensions(BLayoutItem* item,
Dimensions* dimensions);
private:
class DummyLayoutItem;
class RowInfoArray;
struct ItemLayoutData;
bool _IsGridCellEmpty(int32 column, int32 row);
bool _AreGridCellsEmpty(int32 column, int32 row,
int32 columnCount, int32 rowCount);
bool _ResizeGrid(int32 columnCount, int32 rowCount);
ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const;
private:
BLayoutItem*** fGrid;
int32 fColumnCount;
int32 fRowCount;
RowInfoArray* fRowInfos;
RowInfoArray* fColumnInfos;
int32 fMultiColumnItems;
int32 fMultiRowItems;
};
#endif // _GRID_LAYOUT_H
+38
View File
@@ -0,0 +1,38 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _GRID_LAYOUT_BUILDER_H
#define _GRID_LAYOUT_BUILDER_H
#include <GridView.h>
class BGridLayoutBuilder {
public:
BGridLayoutBuilder(
float horizontalSpacing = 0.0f,
float verticalSpacing = 0.0f);
BGridLayoutBuilder(BGridLayout* layout);
BGridLayoutBuilder(BGridView* view);
BGridLayout* GridLayout() const;
BView* View() const;
BGridLayoutBuilder& GetGridLayout(BGridLayout** _layout);
BGridLayoutBuilder& GetView(BView** _view);
BGridLayoutBuilder& Add(BView* view, int32 column, int32 row,
int32 columnCount = 1, int32 rowCount = 1);
BGridLayoutBuilder& Add(BLayoutItem* item, int32 column, int32 row,
int32 columnCount = 1, int32 rowCount = 1);
BGridLayoutBuilder& SetColumnWeight(int32 column, float weight);
BGridLayoutBuilder& SetRowWeight(int32 row, float weight);
operator BGridLayout*();
operator BView*();
private:
BGridLayout* fLayout;
};
#endif // _GRID_LAYOUT_BUILDER_H
+24
View File
@@ -0,0 +1,24 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _GRID_VIEW_H
#define _GRID_VIEW_H
#include <GridLayout.h>
#include <View.h>
class BGridView : public BView {
public:
BGridView(float horizontalSpacing = 0.0f,
float verticalSpacing = 0.0f);
virtual ~BGridView();
virtual void SetLayout(BLayout* layout);
BGridLayout* GridLayout() const;
};
#endif // _GRID_VIEW_H
+61
View File
@@ -0,0 +1,61 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _GROUP_LAYOUT_H
#define _GROUP_LAYOUT_H
#include <TwoDimensionalLayout.h>
class BGroupLayout : public BTwoDimensionalLayout {
public:
BGroupLayout(enum orientation orientation,
float spacing = 0.0f);
virtual ~BGroupLayout();
float Spacing() const;
void SetSpacing(float spacing);
orientation Orientation() const;
void SetOrientation(enum orientation orientation);
float ItemWeight(int32 index) const;
void SetItemWeight(int32 index, float weight);
virtual BLayoutItem* AddView(BView* child);
virtual BLayoutItem* AddView(int32 index, BView* child);
virtual BLayoutItem* AddView(BView* child, float weight);
virtual BLayoutItem* AddView(int32 index, BView* child,
float weight);
virtual bool AddItem(BLayoutItem* item);
virtual bool AddItem(int32 index, BLayoutItem* item);
virtual bool AddItem(BLayoutItem* item, float weight);
virtual bool AddItem(int32 index, BLayoutItem* item,
float weight);
protected:
virtual void ItemAdded(BLayoutItem* item);
virtual void ItemRemoved(BLayoutItem* item);
virtual void PrepareItems(enum orientation orientation);
virtual int32 InternalCountColumns();
virtual int32 InternalCountRows();
virtual void GetColumnRowConstraints(
enum orientation orientation,
int32 index,
ColumnRowConstraints* constraints);
virtual void GetItemDimensions(BLayoutItem* item,
Dimensions* dimensions);
private:
struct ItemLayoutData;
ItemLayoutData* _LayoutDataForItem(BLayoutItem* item) const;
orientation fOrientation;
BList fVisibleItems;
};
#endif // _GROUP_LAYOUT_H
+49
View File
@@ -0,0 +1,49 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _GROUP_LAYOUT_BUILDER_H
#define _GROUP_LAYOUT_BUILDER_H
#include <GroupLayout.h>
#include <GroupView.h>
#include <List.h>
class BGroupLayoutBuilder {
public:
BGroupLayoutBuilder(
enum orientation orientation = B_HORIZONTAL,
float spacing = 0.0f);
BGroupLayoutBuilder(BGroupLayout* layout);
BGroupLayoutBuilder(BGroupView* view);
BGroupLayout* RootLayout() const;
BGroupLayout* TopLayout() const;
BGroupLayoutBuilder& GetTopLayout(BGroupLayout** _layout);
BGroupLayoutBuilder& GetTopView(BView** _view);
BGroupLayoutBuilder& Add(BView* view);
BGroupLayoutBuilder& Add(BView* view, float weight);
BGroupLayoutBuilder& Add(BLayoutItem* item);
BGroupLayoutBuilder& Add(BLayoutItem* item, float weight);
BGroupLayoutBuilder& AddGroup(enum orientation orientation,
float spacing = 0.0f, float weight = 1.0f);
BGroupLayoutBuilder& End();
BGroupLayoutBuilder& AddGlue(float weight = 1.0f);
BGroupLayoutBuilder& AddStrut(float size);
operator BGroupLayout*();
operator BView*();
private:
bool _PushLayout(BGroupLayout* layout);
void _PopLayout();
private:
BGroupLayout* fRootLayout;
BList fLayoutStack;
};
#endif // _GROUP_LAYOUT_BUILDER_H
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _GROUP_VIEW_H
#define _GROUP_VIEW_H
#include <GroupLayout.h>
#include <View.h>
class BGroupView : public BView {
public:
BGroupView(
enum orientation orientation = B_HORIZONTAL,
float spacing = 0.0f);
virtual ~BGroupView();
virtual void SetLayout(BLayout* layout);
BGroupLayout* GroupLayout() const;
};
#endif // _GROUP_VIEW_H
+12 -2
View File
@@ -179,14 +179,24 @@ struct scroll_bar_info {
enum alignment {
B_ALIGN_LEFT,
B_ALIGN_RIGHT,
B_ALIGN_CENTER
B_ALIGN_CENTER,
B_ALIGN_HORIZONTAL_CENTER = B_ALIGN_CENTER,
B_ALIGN_HORIZONTAL_UNSET = -1L,
B_ALIGN_USE_FULL_WIDTH = -2L,
};
enum vertical_alignment {
B_ALIGN_TOP = 0x10L,
B_ALIGN_MIDDLE = 0x20,
B_ALIGN_BOTTOM = 0x30,
B_ALIGN_NO_VERTICAL = -1L
B_ALIGN_VERTICAL_CENTER = B_ALIGN_MIDDLE,
B_ALIGN_VERTICAL_UNSET = -1L,
B_ALIGN_NO_VERTICAL = B_ALIGN_VERTICAL_UNSET,
B_ALIGN_USE_FULL_HEIGHT = -2L,
};
/*----------------------------------------------------------------*/
+67
View File
@@ -0,0 +1,67 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _LAYOUT_H
#define _LAYOUT_H
#include <Alignment.h>
#include <List.h>
#include <Size.h>
class BLayoutItem;
class BView;
class BLayout {
public:
BLayout();
virtual ~BLayout();
BView* View() const;
virtual BLayoutItem* AddView(BView* child);
virtual BLayoutItem* AddView(int32 index, BView* child);
virtual bool AddItem(BLayoutItem* item);
virtual bool AddItem(int32 index, BLayoutItem* item);
virtual bool RemoveView(BView* child);
virtual bool RemoveItem(BLayoutItem* item);
virtual BLayoutItem* RemoveItem(int32 index);
BLayoutItem* ItemAt(int32 index) const;
int32 CountItems() const;
int32 IndexOfItem(BLayoutItem* item) const;
int32 IndexOfView(BView* child) const;
virtual BSize MinSize() = 0;
virtual BSize MaxSize() = 0;
virtual BSize PreferredSize() = 0;
virtual BAlignment Alignment() = 0;
virtual bool HasHeightForWidth() = 0;
virtual void GetHeightForWidth(float width, float* min,
float* max, float* preferred) = 0;
virtual void InvalidateLayout();
virtual void LayoutView() = 0;
protected:
// TODO: Since memory allocations can fail, we should return a bool and
// undo the addition, if false.
virtual void ItemAdded(BLayoutItem* item);
virtual void ItemRemoved(BLayoutItem* item);
private:
friend class BView;
void SetView(BView* view);
BView* fView;
BList fItems;
};
#endif // _LAYOUT_H
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _LAYOUT_CONTEXT_H
#define _LAYOUT_CONTEXT_H
#include <List.h>
class BLayoutContext;
class BLayoutContextListener {
public:
BLayoutContextListener();
virtual ~BLayoutContextListener();
virtual void LayoutContextLeft(BLayoutContext* context) = 0;
};
class BLayoutContext {
public:
BLayoutContext();
~BLayoutContext();
void AddListener(BLayoutContextListener* listener);
void RemoveListener(
BLayoutContextListener* listener);
private:
BList fListeners;
};
#endif // _LAYOUT_CONTEXT_H
+60
View File
@@ -0,0 +1,60 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _LAYOUT_ITEM_H
#define _LAYOUT_ITEM_H
#include <Alignment.h>
#include <Rect.h>
#include <Size.h>
class BLayout;
class BView;
class BLayoutItem {
public:
BLayoutItem();
virtual ~BLayoutItem();
BLayout* Layout() const;
virtual BSize MinSize() = 0;
virtual BSize MaxSize() = 0;
virtual BSize PreferredSize() = 0;
virtual BAlignment Alignment() = 0;
virtual void SetExplicitMinSize(BSize size) = 0;
virtual void SetExplicitMaxSize(BSize size) = 0;
virtual void SetExplicitPreferredSize(BSize size) = 0;
virtual void SetExplicitAlignment(BAlignment alignment) = 0;
virtual bool IsVisible() = 0;
virtual void SetVisible(bool visible) = 0;
virtual BRect Frame() = 0;
virtual void SetFrame(BRect frame) = 0;
virtual bool HasHeightForWidth();
virtual void GetHeightForWidth(float width, float* min,
float* max, float* preferred);
virtual BView* View();
virtual void InvalidateLayout();
void* LayoutData() const;
void SetLayoutData(void* data);
void AlignInFrame(BRect frame);
private:
friend class BLayout;
void SetLayout(BLayout* layout);
BLayout* fLayout;
void* fLayoutData;
};
#endif // _LAYOUT_ITEM_H
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _LAYOUT_UTILS_H
#define _LAYOUT_UTILS_H
#include <Alignment.h>
#include <Rect.h>
#include <Size.h>
class BView;
class BLayoutUtils {
public:
// static float AddSizesFloat(float a, float b);
// static float AddSizesFloat(float a, float b, float c);
static float AddDistances(float a, float b);
static float AddDistances(float a, float b, float c);
static int32 AddSizesInt32(int32 a, int32 b);
static int32 AddSizesInt32(int32 a, int32 b, int32 c);
// static float SubtractSizesFloat(float a, float b);
static int32 SubtractSizesInt32(int32 a, int32 b);
static float SubtractDistances(float a, float b);
static BSize ComposeSize(BSize size, BSize layoutSize);
static BAlignment ComposeAlignment(BAlignment alignment,
BAlignment layoutAlignment);
static BRect AlignInFrame(BRect frame, BSize maxSize,
BAlignment alignment);
static void AlignInFrame(BView* view, BRect frame);
};
#endif // _LAYOUT_UTILS_H
+3
View File
@@ -126,6 +126,9 @@ class BListView : public BView, public BInvoker
virtual void AllAttached();
virtual void AllDetached();
virtual BSize MinSize();
virtual BSize PreferredSize();
protected:
enum MiscCode { B_NO_OP, B_REPLACE_OP, B_MOVE_OP, B_SWAP_OP };
union MiscData {
+66 -62
View File
@@ -36,82 +36,86 @@ class BMenuField;
class BMenuBar : public BMenu
{
public:
BMenuBar( BRect frame,
const char *title,
uint32 resizeMask =
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
menu_layout layout = B_ITEMS_IN_ROW,
bool resizeToFit = true);
BMenuBar(BMessage *data);
virtual ~BMenuBar();
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
BMenuBar( BRect frame,
const char *title,
uint32 resizeMask =
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
menu_layout layout = B_ITEMS_IN_ROW,
bool resizeToFit = true);
BMenuBar(BMessage *data);
virtual ~BMenuBar();
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void SetBorder(menu_bar_border border);
menu_bar_border Border() const;
virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void MessageReceived(BMessage *msg);
virtual void MouseDown(BPoint where);
virtual void WindowActivated(bool state);
virtual void MouseUp(BPoint where);
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual void SetBorder(menu_bar_border border);
menu_bar_border Border() const;
virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void MessageReceived(BMessage *msg);
virtual void MouseDown(BPoint where);
virtual void WindowActivated(bool state);
virtual void MouseUp(BPoint where);
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual void Show();
virtual void Hide();
virtual void Show();
virtual void Hide();
virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height);
virtual void MakeFocus(bool state = true);
virtual void AllAttached();
virtual void AllDetached();
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height);
virtual void MakeFocus(bool state = true);
virtual void AllAttached();
virtual void AllDetached();
// layout related
virtual BSize MaxSize();
/*----- Private or reserved -----------------------------------------*/
virtual status_t Perform(perform_code d, void *arg);
virtual status_t Perform(perform_code d, void *arg);
private:
friend class BWindow;
friend class BMenuItem;
friend class BMenuField;
friend class BMenu;
friend class BWindow;
friend class BMenuItem;
friend class BMenuField;
friend class BMenu;
virtual void _ReservedMenuBar1();
virtual void _ReservedMenuBar2();
virtual void _ReservedMenuBar3();
virtual void _ReservedMenuBar4();
virtual void _ReservedMenuBar1();
virtual void _ReservedMenuBar2();
virtual void _ReservedMenuBar3();
virtual void _ReservedMenuBar4();
BMenuBar &operator=(const BMenuBar &);
BMenuBar &operator=(const BMenuBar &);
void StartMenuBar( int32 menuIndex,
bool sticky = true,
bool show_menu = false,
BRect *special_rect = NULL);
static long TrackTask(void *arg);
BMenuItem *Track( int32 *action,
int32 startIndex = -1,
bool showMenu = false);
void StealFocus();
void RestoreFocus();
void InitData(menu_layout layout);
void StartMenuBar( int32 menuIndex,
bool sticky = true,
bool show_menu = false,
BRect *special_rect = NULL);
static long TrackTask(void *arg);
BMenuItem *Track( int32 *action,
int32 startIndex = -1,
bool showMenu = false);
void StealFocus();
void RestoreFocus();
void InitData(menu_layout layout);
menu_bar_border fBorder;
thread_id fTrackingPID;
int32 fPrevFocusToken;
sem_id fMenuSem;
BRect* fLastBounds;
uint32 _reserved[2]; // was 3
menu_bar_border fBorder;
thread_id fTrackingPID;
int32 fPrevFocusToken;
sem_id fMenuSem;
BRect* fLastBounds;
uint32 _reserved[2]; // was 3
bool fTracking;
bool fTracking;
};
/*-------------------------------------------------------------*/
+103 -99
View File
@@ -1,13 +1,7 @@
/*******************************************************************************
/
/ File: MenuField.h
/
/ Description: BMenuField displays a labeled pop-up menu.
/
/ Copyright 1994-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _MENU_FIELD_H
#define _MENU_FIELD_H
@@ -18,108 +12,118 @@
class BMenuBar;
/*----------------------------------------------------------------*/
/*----- BMenuField class -----------------------------------------*/
class BMenuField : public BView {
public:
BMenuField(BRect frame, const char* name,
const char* label, BMenu* menu,
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField(BRect frame, const char* name,
const char* label, BMenu* menu,
bool fixed_size,
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField(const char* name,
const char* label, BMenu* menu,
BMessage* message,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField(const char* label,
BMenu* menu, BMessage* message);
BMenuField(BMessage* data);
virtual ~BMenuField();
class BMenuField : public BView
{
public:
BMenuField( BRect frame,
const char *name,
const char *label,
BMenu *menu,
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField( BRect frame,
const char *name,
const char *label,
BMenu *menu,
bool fixed_size,
uint32 resize = B_FOLLOW_LEFT|B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BMenuField(BMessage *data);
virtual ~BMenuField();
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive, bool deep = true) const;
virtual void Draw(BRect update);
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void MouseDown(BPoint where);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MakeFocus(bool state);
virtual void MessageReceived(BMessage *msg);
virtual void WindowActivated(bool state);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual void Draw(BRect update);
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void MouseDown(BPoint where);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void MakeFocus(bool state);
virtual void MessageReceived(BMessage* message);
virtual void WindowActivated(bool state);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 code,
const BMessage* dragMessage);
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
BMenu *Menu() const;
BMenuBar *MenuBar() const;
BMenuItem *MenuItem() const;
BMenu* Menu() const;
BMenuBar* MenuBar() const;
BMenuItem* MenuItem() const;
virtual void SetLabel(const char *label);
const char *Label() const;
virtual void SetLabel(const char* label);
const char* Label() const;
virtual void SetEnabled(bool on);
bool IsEnabled() const;
virtual void SetEnabled(bool on);
bool IsEnabled() const;
virtual void SetAlignment(alignment label);
alignment Alignment() const;
virtual void SetDivider(float dividing_line);
float Divider() const;
virtual void SetAlignment(alignment label);
alignment Alignment() const;
virtual void SetDivider(float dividing_line);
float Divider() const;
void ShowPopUpMarker();
void HidePopUpMarker();
void ShowPopUpMarker();
void HidePopUpMarker();
virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage* specifier,
int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* width, float* height);
BLayoutItem* CreateLabelLayoutItem();
BLayoutItem* CreateMenuBarLayoutItem();
/*----- Private or reserved -----------------------------------------*/
virtual status_t Perform(perform_code d, void* arg);
private:
class LabelLayoutItem;
class MenuBarLayoutItem;
friend class _BMCMenuBar_;
friend class LabelLayoutItem;
friend class MenuBarLayoutItem;
virtual void _ReservedMenuField1();
virtual void _ReservedMenuField2();
virtual void _ReservedMenuField3();
BMenuField &operator=(const BMenuField&);
/*----- Private or reserved -----------------------------------------*/
virtual status_t Perform(perform_code d, void *arg);
void InitObject(const char* label);
void InitObject2();
void DrawLabel(BRect bounds, BRect update);
static void InitMenu(BMenu* menu);
static long MenuTask(void* arg);
void _UpdateFrame();
void _InitMenuBar(BMenu* menu,
BRect frame, bool fixedSize);
private:
friend class _BMCMenuBar_;
char* fLabel;
BMenu* fMenu;
BMenuBar* fMenuBar;
alignment fAlign;
float fDivider;
float fStringWidth;
bool fEnabled;
bool fSelected;
bool fTransition;
bool fFixedSizeMB;
thread_id fMenuTaskID;
virtual void _ReservedMenuField1();
virtual void _ReservedMenuField2();
virtual void _ReservedMenuField3();
BLayoutItem* fLabelLayoutItem;
BLayoutItem* fMenuBarLayoutItem;
BMenuField &operator=(const BMenuField &);
void InitObject(const char *label);
void InitObject2();
void DrawLabel(BRect bounds, BRect update);
static void InitMenu(BMenu *menu);
static long MenuTask(void *arg);
char *fLabel;
BMenu *fMenu;
BMenuBar *fMenuBar;
alignment fAlign;
float fDivider;
float fStringWidth;
bool fEnabled;
bool fSelected;
bool fTransition;
bool fFixedSizeMB;
thread_id fMenuTaskID;
uint32 _reserved[3];
uint32 _reserved[1];
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _MENU_FIELD_H */
#endif // _MENU_FIELD_H
+9
View File
@@ -54,6 +54,12 @@ public:
BMessage *message,
uint32 resizMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BRadioButton(const char *name,
const char *label,
BMessage *message,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BRadioButton(const char *label,
BMessage *message);
BRadioButton(BMessage *archive);
virtual ~BRadioButton();
@@ -91,6 +97,9 @@ virtual status_t GetSupportedSuites(BMessage *message);
virtual status_t Perform(perform_code d, void *arg);
virtual BSize MaxSize();
private:
friend status_t _init_interface_kit_();
+3
View File
@@ -60,6 +60,9 @@ class BScrollView : public BView {
virtual void MakeFocus(bool state = true);
virtual status_t GetSupportedSuites(BMessage *data);
virtual BSize MinSize();
virtual BSize PreferredSize();
// private or reserved methods are following
virtual status_t Perform(perform_code d, void *arg);
+158
View File
@@ -0,0 +1,158 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _SIZE_H
#define _SIZE_H
#include <limits.h>
#include <Rect.h>
#include <SupportDefs.h>
enum {
B_SIZE_UNSET = -1,
B_SIZE_UNLIMITED = 1024 * 1024 * 1024,
};
class BSize {
public:
float width;
float height;
inline BSize();
inline BSize(const BSize& other);
inline BSize(float width, float height);
inline BSize(const BRect& rect);
inline float Width() const;
inline float Height() const;
inline void SetWidth(float width);
inline void SetHeight(float height);
inline int32 IntegerWidth() const;
inline int32 IntegerHeight() const;
inline bool IsWidthSet() const;
inline bool IsHeightSet() const;
inline bool operator==(const BSize& other) const;
inline bool operator!=(const BSize& other) const;
inline BSize& operator=(const BSize& other);
};
// constructor
inline
BSize::BSize()
: width(B_SIZE_UNSET),
height(B_SIZE_UNSET)
{
}
// copy constructor
inline
BSize::BSize(const BSize& other)
: width(other.width),
height(other.height)
{
}
// constructor
inline
BSize::BSize(float width, float height)
: width(width),
height(height)
{
}
// constructor
inline
BSize::BSize(const BRect& rect)
: width(rect.Width()),
height(rect.Height())
{
}
// Width
inline float
BSize::Width() const
{
return width;
}
// Height
inline float
BSize::Height() const
{
return height;
}
// SetWidth
inline void
BSize::SetWidth(float width)
{
this->width = width;
}
// SetHeight
inline void
BSize::SetHeight(float height)
{
this->height = height;
}
// IntegerWidth
inline int32
BSize::IntegerWidth() const
{
return (int32)width;
}
// IntegerHeight
inline int32
BSize::IntegerHeight() const
{
return (int32)height;
}
// IsWidthSet
inline bool
BSize::IsWidthSet() const
{
return width != B_SIZE_UNSET;
}
// IsHeightSet
inline bool
BSize::IsHeightSet() const
{
return height != B_SIZE_UNSET;
}
// ==
inline bool
BSize::operator==(const BSize& other) const
{
return (width == other.width && height == other.height);
}
// !=
inline bool
BSize::operator!=(const BSize& other) const
{
return !(*this == other);
}
// =
inline BSize&
BSize::operator=(const BSize& other)
{
width = other.width;
height = other.height;
return *this;
}
#endif // _SIZE_H
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _SPACE_LAYOUT_ITEM_H
#define _SPACE_LAYOUT_ITEM_H
#include <LayoutItem.h>
class BSpaceLayoutItem : public BLayoutItem {
public:
BSpaceLayoutItem(BSize minSize, BSize maxSize,
BSize preferredSize, BAlignment alignment);
virtual ~BSpaceLayoutItem();
static BSpaceLayoutItem* CreateGlue();
static BSpaceLayoutItem* CreateHorizontalStrut(float width);
static BSpaceLayoutItem* CreateVerticalStrut(float height);
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual BAlignment Alignment();
virtual void SetExplicitMinSize(BSize size);
virtual void SetExplicitMaxSize(BSize size);
virtual void SetExplicitPreferredSize(BSize size);
virtual void SetExplicitAlignment(BAlignment alignment);
virtual bool IsVisible();
virtual void SetVisible(bool visible);
virtual BRect Frame();
virtual void SetFrame(BRect frame);
private:
BRect fFrame;
BSize fMinSize;
BSize fMaxSize;
BSize fPreferredSize;
BAlignment fAlignment;
bool fVisible;
};
#endif // _SPACE_LAYOUT_ITEM_H
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _SPLIT_LAYOUT_BUILDER_H
#define _SPLIT_LAYOUT_BUILDER_H
#include <SplitView.h>
class BSplitLayoutBuilder {
public:
BSplitLayoutBuilder(
enum orientation orientation = B_HORIZONTAL,
float spacing = 0.0f);
BSplitLayoutBuilder(BSplitView* view);
BSplitView* SplitView() const;
BSplitLayoutBuilder& GetSplitView(BSplitView** view);
BSplitLayoutBuilder& Add(BView* view);
BSplitLayoutBuilder& Add(BView* view, float weight);
BSplitLayoutBuilder& Add(BLayoutItem* item);
BSplitLayoutBuilder& Add(BLayoutItem* item, float weight);
BSplitLayoutBuilder& SetCollapsible(bool collapsible);
operator BSplitView*();
private:
BSplitView* fView;
};
#endif // _SPLIT_LAYOUT_BUILDER_H
+69
View File
@@ -0,0 +1,69 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _SPLIT_VIEW_H
#define _SPLIT_VIEW_H
#include <View.h>
class BSplitLayout;
class BSplitView : public BView {
public:
BSplitView(
enum orientation orientation = B_HORIZONTAL,
float spacing = 0.0f);
virtual ~BSplitView();
float Spacing() const;
void SetSpacing(float spacing);
orientation Orientation() const;
void SetOrientation(enum orientation orientation);
float SplitterSize() const;
void SetSplitterSize(float size);
void SetCollapsible(bool collapsible);
void SetCollapsible(int32 index, bool collapsible);
void SetCollapsible(int32 first, int32 last,
bool collapsible);
// void AddChild(BView* child);
void AddChild(BView* child, BView* sibling = NULL);
bool AddChild(BView* child, float weight);
bool AddChild(int32 index, BView* child,
float weight);
bool AddChild(BLayoutItem* child);
bool AddChild(BLayoutItem* child, float weight);
bool AddChild(int32 index, BLayoutItem* child,
float weight);
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint where, uint32 transit,
const BMessage* message);
virtual void SetLayout(BLayout* layout);
// overridden to avoid use
protected:
virtual void DrawSplitter(BRect frame,
enum orientation orientation, bool pressed);
private:
static void _DrawDefaultSplitter(BView* view, BRect frame,
enum orientation orientation, bool pressed);
private:
BSplitLayout* fSplitLayout;
};
#endif // _SPLIT_VIEW_H
+2
View File
@@ -53,6 +53,8 @@ class BStringView : public BView{
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage* data);
virtual BSize MaxSize();
private:
virtual status_t Perform(perform_code d, void* arg);
virtual void _ReservedStringView1();
+21 -1
View File
@@ -9,6 +9,7 @@
#include <Control.h>
#include <TextView.h>
class BLayoutItem;
class _BTextInput_;
@@ -19,6 +20,13 @@ class BTextControl : public BControl {
BMessage* message,
uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BTextControl(const char* name,
const char* label, const char* initialText,
BMessage* message,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BTextControl(const char* label,
const char* initialText,
BMessage* message);
virtual ~BTextControl();
BTextControl(BMessage* archive);
@@ -68,8 +76,16 @@ class BTextControl : public BControl {
virtual status_t GetSupportedSuites(BMessage* data);
virtual void SetFlags(uint32 flags);
BLayoutItem* CreateLabelLayoutItem();
BLayoutItem* CreateTextViewLayoutItem();
private:
class LabelLayoutItem;
class TextViewLayoutItem;
friend class _BTextInput_;
friend class LabelLayoutItem;
friend class TextViewLayoutItem;
virtual status_t Perform(perform_code d, void* arg);
@@ -84,6 +100,8 @@ class BTextControl : public BControl {
void _UpdateTextViewColors(bool enabled);
void _InitData(const char* label, const char* initialText,
BMessage* archive = NULL);
void _ValidateLayout();
void _UpdateFrame();
private:
_BTextInput_* fText;
@@ -93,8 +111,10 @@ class BTextControl : public BControl {
float fDivider;
float fPreviousWidth;
float fPreviousHeight;
BLayoutItem* fLabelLayoutItem;
BLayoutItem* fTextViewLayoutItem;
uint32 _reserved[6];
uint32 _reserved[4];
bool fClean;
bool fSkipSetFlags;
@@ -0,0 +1,93 @@
/*
* Copyright 2006, Haiku Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _TWO_DIMENSIONAL_LAYOUT_H
#define _TWO_DIMENSIONAL_LAYOUT_H
#include <Layout.h>
class BLayoutContext;
class BTwoDimensionalLayout : public BLayout {
public:
BTwoDimensionalLayout();
virtual ~BTwoDimensionalLayout();
void SetInsets(float left, float top, float right,
float bottom);
void GetInsets(float* left, float* top, float* right,
float* bottom);
void AlignLayoutWith(BTwoDimensionalLayout* other,
enum orientation orientation);
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual BAlignment Alignment();
virtual bool HasHeightForWidth();
virtual void GetHeightForWidth(float width, float* min,
float* max, float* preferred);
virtual void InvalidateLayout();
virtual void LayoutView();
protected:
struct ColumnRowConstraints {
float weight;
float min;
float max;
};
struct Dimensions {
int32 x;
int32 y;
int32 width;
int32 height;
};
BSize AddInsets(BSize size);
void AddInsets(float* minHeight, float* maxHeight,
float* preferredHeight);
BSize SubtractInsets(BSize size);
virtual void PrepareItems(enum orientation orientation);
virtual bool HasMultiColumnItems();
virtual bool HasMultiRowItems();
virtual int32 InternalCountColumns() = 0;
virtual int32 InternalCountRows() = 0;
virtual void GetColumnRowConstraints(
enum orientation orientation,
int32 index,
ColumnRowConstraints* constraints) = 0;
virtual void GetItemDimensions(BLayoutItem* item,
Dimensions* dimensions) = 0;
private:
class CompoundLayouter;
class LocalLayouter;
class VerticalCompoundLayouter;
friend class LocalLayouter;
void _ValidateMinMax();
BLayoutContext* _CurrentLayoutContext();
protected:
float fLeftInset;
float fRightInset;
float fTopInset;
float fBottomInset;
float fHSpacing;
float fVSpacing;
private:
LocalLayouter* fLocalLayouter;
};
#endif // _TWO_DIMENSIONAL_LAYOUT_H
+64 -15
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -9,11 +9,13 @@
#define _VIEW_H
#include <Alignment.h>
#include <BeBuild.h>
#include <Font.h>
#include <Handler.h>
#include <InterfaceDefs.h>
#include <Rect.h>
#include <Size.h>
// mouse button
@@ -74,6 +76,8 @@ const uint32 B_SUBPIXEL_PRECISE = 0x01000000UL; /* 24 */
const uint32 B_DRAW_ON_CHILDREN = 0x00800000UL; /* 23 */
const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL; /* 23 */
const uint32 _B_RESERVED7_ = 0x00200000UL; /* 22 */
const uint32 B_SUPPORTS_LAYOUT = 0x00100000UL; /* 21 */
const uint32 B_INVALIDATE_AFTER_LAYOUT = 0x00080000UL; /* 20 */
#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE | _B_RESERVED1_ | B_WILL_DRAW \
| B_PULSE_NEEDED | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE \
@@ -104,6 +108,9 @@ inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4)
class BBitmap;
class BCursor;
class BLayout;
class BLayoutContext;
class BLayoutItem;
class BMessage;
class BPicture;
class BPolygon;
@@ -125,6 +132,8 @@ namespace BPrivate {
class BView : public BHandler {
public:
BView(const char* name, uint32 flags,
BLayout* layout = NULL);
BView(BRect frame, const char* name,
uint32 resizeMask, uint32 flags);
virtual ~BView();
@@ -141,6 +150,7 @@ public:
virtual void MessageReceived(BMessage* msg);
void AddChild(BView* child, BView* before = NULL);
bool AddChild(BLayoutItem* child);
bool RemoveChild(BView* child);
int32 CountChildren() const;
BView* ChildAt(int32 index) const;
@@ -490,31 +500,64 @@ public:
bool IsPrinting() const;
void SetScale(float scale) const;
float Scale() const;
// new for Haiku
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
virtual void DrawAfterChildren(BRect r);
float Scale() const;
// new for Haiku
// layout related
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual BAlignment Alignment();
void SetExplicitMinSize(BSize size);
void SetExplicitMaxSize(BSize size);
void SetExplicitPreferredSize(BSize size);
void SetExplicitAlignment(BAlignment alignment);
BSize ExplicitMinSize() const;
BSize ExplicitMaxSize() const;
BSize ExplicitPreferredSize() const;
BAlignment ExplicitAlignment() const;
virtual bool HasHeightForWidth();
virtual void GetHeightForWidth(float width, float* min,
float* max, float* preferred);
virtual void SetLayout(BLayout* layout);
BLayout* GetLayout() const;
void InvalidateLayout(bool descendants = false);
void EnableLayoutInvalidation();
void DisableLayoutInvalidation();
BLayoutContext* LayoutContext() const;
void Layout(bool force);
void Relayout();
protected:
virtual void DoLayout();
private:
friend class BScrollBar;
friend class BWindow;
void _Layout(bool force, BLayoutContext* context);
private:
struct LayoutData;
friend class BBitmap;
friend class BLayout;
friend class BPrintJob;
friend class BScrollBar;
friend class BShelf;
friend class BTabView;
friend class BWindow;
virtual void _ReservedView2();
virtual void _ReservedView3();
virtual void _ReservedView4();
virtual void _ReservedView5();
virtual void _ReservedView6();
virtual void _ReservedView7();
virtual void _ReservedView8();
virtual void _ReservedView9();
virtual void _ReservedView10();
virtual void _ReservedView11();
virtual void _ReservedView12();
@@ -571,6 +614,9 @@ private:
bool _AddChildToList(BView* child, BView* before = NULL);
bool _RemoveChildFromList(BView* child);
bool _AddChild(BView *child, BView *before);
bool _RemoveSelf();
// Debugging methods
void PrintToStream();
void PrintTree();
@@ -601,7 +647,10 @@ private:
BShelf* fShelf;
uint32 fEventMask;
uint32 fEventOptions;
uint32 _reserved[9];
LayoutData* fLayoutData;
uint32 _reserved[8];
};
+6
View File
@@ -81,6 +81,7 @@ enum {
B_ASYNCHRONOUS_CONTROLS = 0x00080000,
B_QUIT_ON_WINDOW_CLOSE = 0x00100000,
B_SAME_POSITION_IN_ALL_WORKSPACES = 0x00200000,
B_AUTO_UPDATE_SIZE_LIMITS = 0x00400000,
};
#define B_CURRENT_WORKSPACE 0
@@ -257,6 +258,11 @@ public:
virtual bool QuitRequested();
virtual thread_id Run();
virtual void SetLayout(BLayout* layout);
BLayout* GetLayout() const;
void InvalidateLayout(bool descendants = false);
private:
typedef BLooper inherited;
struct unpack_cookie;
+2 -2
View File
@@ -43,8 +43,8 @@ public:
/* Adding and removing items. */
bool AddItem(void *item, int32 index);
bool AddItem(void *item);
bool AddList(BList *list, int32 index);
bool AddList(BList *list);
bool AddList(const BList *list, int32 index);
bool AddList(const BList *list);
bool RemoveItem(void *item);
void *RemoveItem(int32 index);
bool RemoveItems(int32 index, int32 count);
@@ -28,6 +28,7 @@ extern const std::string kApplicationDatabaseDir;
// Attribute Prefixes
extern const char *kMiniIconAttrPrefix;
extern const char *kLargeIconAttrPrefix;
extern const char *kIconAttrPrefix;
// Attribute names
extern const char *kFileTypeAttr;
@@ -39,6 +40,7 @@ extern const char *kLongDescriptionAttr;
extern const char *kFileExtensionsAttr;
extern const char *kMiniIconAttr;
extern const char *kLargeIconAttr;
extern const char *kIconAttr;
extern const char *kPreferredAppAttr;
extern const char *kSnifferRuleAttr;
extern const char *kSupportedTypesAttr;
@@ -53,6 +55,7 @@ extern const int32 kLongDescriptionType;
extern const int32 kFileExtensionsType;
extern const int32 kMiniIconType;
extern const int32 kLargeIconType;
extern const int32 kIconType;
extern const int32 kPreferredAppType;
extern const int32 kSnifferRuleType;
extern const int32 kSupportedTypesType;