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:
@@ -38,7 +38,7 @@ BEOS_BIN = addattr alert basename beep cat catattr chgrp chmod chop chown clear
|
|||||||
BEOS_APPS = Terminal Expander People ShowImage Clock Pulse ProcessController
|
BEOS_APPS = Terminal Expander People ShowImage Clock Pulse ProcessController
|
||||||
Playground SoundRecorder BitmapDrawing Magnify DiskProbe AboutHaiku
|
Playground SoundRecorder BitmapDrawing Magnify DiskProbe AboutHaiku
|
||||||
StyledEdit Installer Chart Workspaces $(X86_ONLY)Cortex $(X86_ONLY)CortexAddOnHost $(X86_ONLY)GLTeapot
|
StyledEdit Installer Chart Workspaces $(X86_ONLY)Cortex $(X86_ONLY)CortexAddOnHost $(X86_ONLY)GLTeapot
|
||||||
MediaPlayer DeskCalc MidiPlayer
|
MediaPlayer DeskCalc MidiPlayer Icon-O-Matic
|
||||||
;
|
;
|
||||||
BEOS_PREFERENCES = Backgrounds DataTranslations FileTypes Fonts Media Menu
|
BEOS_PREFERENCES = Backgrounds DataTranslations FileTypes Fonts Media Menu
|
||||||
Mouse Keyboard Keymap Screen ScreenSaver Sounds Time VirtualMemory
|
Mouse Keyboard Keymap Screen ScreenSaver Sounds Time VirtualMemory
|
||||||
@@ -47,7 +47,7 @@ BEOS_SYSTEM_LIB = libbe.so $(HAIKU_LIBSTDC++) libmedia.so libtracker.so
|
|||||||
libtranslation.so libnetwork.so libdebug.so libbsd.so
|
libtranslation.so libnetwork.so libdebug.so libbsd.so
|
||||||
libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so
|
libtextencoding.so libz.so libfreetype.so libpng.so libmidi.so libmidi2.so
|
||||||
libdevice.so libgame.so libscreensaver.so libroot.so $(X86_ONLY)libGL.so
|
libdevice.so libgame.so libscreensaver.so libroot.so $(X86_ONLY)libGL.so
|
||||||
libfluidsynth.so
|
libfluidsynth.so libqoca.so
|
||||||
;
|
;
|
||||||
BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server
|
BEOS_SYSTEM_SERVERS = registrar debug_server syslog_daemon media_server
|
||||||
media_addon_server input_server app_server fake_app_server midi_server
|
media_addon_server input_server app_server fake_app_server midi_server
|
||||||
|
|||||||
@@ -27,10 +27,16 @@ typedef unsigned long haiku_build_addr_t;
|
|||||||
# define B_CURRENT_TEAM 0
|
# define B_CURRENT_TEAM 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SYMLOOP_MAX
|
||||||
|
# define SYMLOOP_MAX (16)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef B_FIRST_REAL_TIME_PRIORITY
|
#ifndef B_FIRST_REAL_TIME_PRIORITY
|
||||||
# define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
|
# define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||||
@@ -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 */
|
||||||
@@ -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
|
||||||
@@ -50,6 +50,7 @@ enum {
|
|||||||
B_KEY_UP = '_KYU',
|
B_KEY_UP = '_KYU',
|
||||||
B_UNMAPPED_KEY_DOWN = '_UKD',
|
B_UNMAPPED_KEY_DOWN = '_UKD',
|
||||||
B_UNMAPPED_KEY_UP = '_UKU',
|
B_UNMAPPED_KEY_UP = '_UKU',
|
||||||
|
B_LAYOUT_WINDOW = '_LAY',
|
||||||
B_MODIFIERS_CHANGED = '_MCH',
|
B_MODIFIERS_CHANGED = '_MCH',
|
||||||
B_MINIMIZE = '_WMN',
|
B_MINIMIZE = '_WMN',
|
||||||
B_MOUSE_DOWN = '_MDN',
|
B_MOUSE_DOWN = '_MDN',
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -52,6 +52,10 @@ public:
|
|||||||
BMessage *message,
|
BMessage *message,
|
||||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
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();
|
virtual ~BButton();
|
||||||
|
|
||||||
@@ -92,6 +96,9 @@ virtual BHandler *ResolveSpecifier(BMessage *message,
|
|||||||
virtual status_t GetSupportedSuites(BMessage *message);
|
virtual status_t GetSupportedSuites(BMessage *message);
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
virtual status_t Perform(perform_code d, void *arg);
|
||||||
|
|
||||||
|
virtual BSize MaxSize();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
virtual void _ReservedButton1();
|
virtual void _ReservedButton1();
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -33,6 +33,8 @@ class BColorControl : public BControl {
|
|||||||
static BArchivable* Instantiate(BMessage* archive);
|
static BArchivable* Instantiate(BMessage* archive);
|
||||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||||
|
|
||||||
|
virtual void SetLayout(BLayout* layout);
|
||||||
|
|
||||||
virtual void SetValue(int32 color_value);
|
virtual void SetValue(int32 color_value);
|
||||||
void SetValue(rgb_color color);
|
void SetValue(rgb_color color);
|
||||||
rgb_color ValueAsColor();
|
rgb_color ValueAsColor();
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -179,14 +179,24 @@ struct scroll_bar_info {
|
|||||||
enum alignment {
|
enum alignment {
|
||||||
B_ALIGN_LEFT,
|
B_ALIGN_LEFT,
|
||||||
B_ALIGN_RIGHT,
|
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 {
|
enum vertical_alignment {
|
||||||
B_ALIGN_TOP = 0x10L,
|
B_ALIGN_TOP = 0x10L,
|
||||||
B_ALIGN_MIDDLE = 0x20,
|
B_ALIGN_MIDDLE = 0x20,
|
||||||
B_ALIGN_BOTTOM = 0x30,
|
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -126,6 +126,9 @@ class BListView : public BView, public BInvoker
|
|||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void AllDetached();
|
virtual void AllDetached();
|
||||||
|
|
||||||
|
virtual BSize MinSize();
|
||||||
|
virtual BSize PreferredSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum MiscCode { B_NO_OP, B_REPLACE_OP, B_MOVE_OP, B_SWAP_OP };
|
enum MiscCode { B_NO_OP, B_REPLACE_OP, B_MOVE_OP, B_SWAP_OP };
|
||||||
union MiscData {
|
union MiscData {
|
||||||
|
|||||||
@@ -36,82 +36,86 @@ class BMenuField;
|
|||||||
class BMenuBar : public BMenu
|
class BMenuBar : public BMenu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BMenuBar( BRect frame,
|
BMenuBar( BRect frame,
|
||||||
const char *title,
|
const char *title,
|
||||||
uint32 resizeMask =
|
uint32 resizeMask =
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
||||||
menu_layout layout = B_ITEMS_IN_ROW,
|
menu_layout layout = B_ITEMS_IN_ROW,
|
||||||
bool resizeToFit = true);
|
bool resizeToFit = true);
|
||||||
BMenuBar(BMessage *data);
|
BMenuBar(BMessage *data);
|
||||||
virtual ~BMenuBar();
|
virtual ~BMenuBar();
|
||||||
static BArchivable *Instantiate(BMessage *data);
|
static BArchivable *Instantiate(BMessage *data);
|
||||||
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
virtual status_t Archive(BMessage *data, bool deep = true) const;
|
||||||
|
|
||||||
virtual void SetBorder(menu_bar_border border);
|
virtual void SetBorder(menu_bar_border border);
|
||||||
menu_bar_border Border() const;
|
menu_bar_border Border() const;
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void WindowActivated(bool state);
|
virtual void WindowActivated(bool state);
|
||||||
virtual void MouseUp(BPoint where);
|
virtual void MouseUp(BPoint where);
|
||||||
virtual void FrameMoved(BPoint new_position);
|
virtual void FrameMoved(BPoint new_position);
|
||||||
virtual void FrameResized(float new_width, float new_height);
|
virtual void FrameResized(float new_width, float new_height);
|
||||||
|
|
||||||
virtual void Show();
|
virtual void Show();
|
||||||
virtual void Hide();
|
virtual void Hide();
|
||||||
|
|
||||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
||||||
int32 index,
|
int32 index,
|
||||||
BMessage *specifier,
|
BMessage *specifier,
|
||||||
int32 form,
|
int32 form,
|
||||||
const char *property);
|
const char *property);
|
||||||
virtual status_t GetSupportedSuites(BMessage *data);
|
virtual status_t GetSupportedSuites(BMessage *data);
|
||||||
|
|
||||||
virtual void ResizeToPreferred();
|
virtual void ResizeToPreferred();
|
||||||
virtual void GetPreferredSize(float *width, float *height);
|
virtual void GetPreferredSize(float *width, float *height);
|
||||||
virtual void MakeFocus(bool state = true);
|
virtual void MakeFocus(bool state = true);
|
||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void AllDetached();
|
virtual void AllDetached();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// layout related
|
||||||
|
virtual BSize MaxSize();
|
||||||
|
|
||||||
/*----- Private or reserved -----------------------------------------*/
|
/*----- Private or reserved -----------------------------------------*/
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
virtual status_t Perform(perform_code d, void *arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class BWindow;
|
friend class BWindow;
|
||||||
friend class BMenuItem;
|
friend class BMenuItem;
|
||||||
friend class BMenuField;
|
friend class BMenuField;
|
||||||
friend class BMenu;
|
friend class BMenu;
|
||||||
|
|
||||||
virtual void _ReservedMenuBar1();
|
virtual void _ReservedMenuBar1();
|
||||||
virtual void _ReservedMenuBar2();
|
virtual void _ReservedMenuBar2();
|
||||||
virtual void _ReservedMenuBar3();
|
virtual void _ReservedMenuBar3();
|
||||||
virtual void _ReservedMenuBar4();
|
virtual void _ReservedMenuBar4();
|
||||||
|
|
||||||
BMenuBar &operator=(const BMenuBar &);
|
BMenuBar &operator=(const BMenuBar &);
|
||||||
|
|
||||||
void StartMenuBar( int32 menuIndex,
|
void StartMenuBar( int32 menuIndex,
|
||||||
bool sticky = true,
|
bool sticky = true,
|
||||||
bool show_menu = false,
|
bool show_menu = false,
|
||||||
BRect *special_rect = NULL);
|
BRect *special_rect = NULL);
|
||||||
static long TrackTask(void *arg);
|
static long TrackTask(void *arg);
|
||||||
BMenuItem *Track( int32 *action,
|
BMenuItem *Track( int32 *action,
|
||||||
int32 startIndex = -1,
|
int32 startIndex = -1,
|
||||||
bool showMenu = false);
|
bool showMenu = false);
|
||||||
void StealFocus();
|
void StealFocus();
|
||||||
void RestoreFocus();
|
void RestoreFocus();
|
||||||
void InitData(menu_layout layout);
|
void InitData(menu_layout layout);
|
||||||
|
|
||||||
menu_bar_border fBorder;
|
menu_bar_border fBorder;
|
||||||
thread_id fTrackingPID;
|
thread_id fTrackingPID;
|
||||||
int32 fPrevFocusToken;
|
int32 fPrevFocusToken;
|
||||||
sem_id fMenuSem;
|
sem_id fMenuSem;
|
||||||
BRect* fLastBounds;
|
BRect* fLastBounds;
|
||||||
uint32 _reserved[2]; // was 3
|
uint32 _reserved[2]; // was 3
|
||||||
|
|
||||||
bool fTracking;
|
bool fTracking;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
/*-------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||||
/ File: MenuField.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: BMenuField displays a labeled pop-up menu.
|
|
||||||
/
|
|
||||||
/ Copyright 1994-98, Be Incorporated, All Rights Reserved
|
|
||||||
/
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MENU_FIELD_H
|
#ifndef _MENU_FIELD_H
|
||||||
#define _MENU_FIELD_H
|
#define _MENU_FIELD_H
|
||||||
@@ -18,108 +12,118 @@
|
|||||||
|
|
||||||
class BMenuBar;
|
class BMenuBar;
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
class BMenuField : public BView {
|
||||||
/*----- BMenuField class -----------------------------------------*/
|
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
|
static BArchivable* Instantiate(BMessage* archive);
|
||||||
{
|
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||||
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;
|
|
||||||
|
|
||||||
virtual void Draw(BRect update);
|
virtual void Draw(BRect update);
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
virtual void MakeFocus(bool state);
|
virtual void MakeFocus(bool state);
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void WindowActivated(bool state);
|
virtual void WindowActivated(bool state);
|
||||||
virtual void MouseUp(BPoint pt);
|
virtual void MouseUp(BPoint pt);
|
||||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
virtual void MouseMoved(BPoint pt, uint32 code,
|
||||||
virtual void DetachedFromWindow();
|
const BMessage* dragMessage);
|
||||||
virtual void AllDetached();
|
virtual void DetachedFromWindow();
|
||||||
virtual void FrameMoved(BPoint new_position);
|
virtual void AllDetached();
|
||||||
virtual void FrameResized(float new_width, float new_height);
|
virtual void FrameMoved(BPoint new_position);
|
||||||
|
virtual void FrameResized(float new_width, float new_height);
|
||||||
|
|
||||||
BMenu *Menu() const;
|
BMenu* Menu() const;
|
||||||
BMenuBar *MenuBar() const;
|
BMenuBar* MenuBar() const;
|
||||||
BMenuItem *MenuItem() const;
|
BMenuItem* MenuItem() const;
|
||||||
|
|
||||||
virtual void SetLabel(const char *label);
|
virtual void SetLabel(const char* label);
|
||||||
const char *Label() const;
|
const char* Label() const;
|
||||||
|
|
||||||
virtual void SetEnabled(bool on);
|
virtual void SetEnabled(bool on);
|
||||||
bool IsEnabled() const;
|
bool IsEnabled() const;
|
||||||
|
|
||||||
virtual void SetAlignment(alignment label);
|
virtual void SetAlignment(alignment label);
|
||||||
alignment Alignment() const;
|
alignment Alignment() const;
|
||||||
virtual void SetDivider(float dividing_line);
|
virtual void SetDivider(float dividing_line);
|
||||||
float Divider() const;
|
float Divider() const;
|
||||||
|
|
||||||
void ShowPopUpMarker();
|
void ShowPopUpMarker();
|
||||||
void HidePopUpMarker();
|
void HidePopUpMarker();
|
||||||
|
|
||||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
virtual BHandler* ResolveSpecifier(BMessage* message,
|
||||||
int32 index,
|
int32 index, BMessage* specifier,
|
||||||
BMessage *specifier,
|
int32 form, const char* property);
|
||||||
int32 form,
|
virtual status_t GetSupportedSuites(BMessage* data);
|
||||||
const char *property);
|
|
||||||
virtual status_t GetSupportedSuites(BMessage *data);
|
|
||||||
|
|
||||||
virtual void ResizeToPreferred();
|
virtual void ResizeToPreferred();
|
||||||
virtual void GetPreferredSize(float *width, float *height);
|
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 -----------------------------------------*/
|
void InitObject(const char* label);
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
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:
|
char* fLabel;
|
||||||
friend class _BMCMenuBar_;
|
BMenu* fMenu;
|
||||||
|
BMenuBar* fMenuBar;
|
||||||
|
alignment fAlign;
|
||||||
|
float fDivider;
|
||||||
|
float fStringWidth;
|
||||||
|
bool fEnabled;
|
||||||
|
bool fSelected;
|
||||||
|
bool fTransition;
|
||||||
|
bool fFixedSizeMB;
|
||||||
|
thread_id fMenuTaskID;
|
||||||
|
|
||||||
virtual void _ReservedMenuField1();
|
BLayoutItem* fLabelLayoutItem;
|
||||||
virtual void _ReservedMenuField2();
|
BLayoutItem* fMenuBarLayoutItem;
|
||||||
virtual void _ReservedMenuField3();
|
|
||||||
|
|
||||||
BMenuField &operator=(const BMenuField &);
|
uint32 _reserved[1];
|
||||||
|
|
||||||
|
|
||||||
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];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-------------------------------------------------------------*/
|
#endif // _MENU_FIELD_H
|
||||||
/*-------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#endif /* _MENU_FIELD_H */
|
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ public:
|
|||||||
BMessage *message,
|
BMessage *message,
|
||||||
uint32 resizMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
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);
|
BRadioButton(BMessage *archive);
|
||||||
virtual ~BRadioButton();
|
virtual ~BRadioButton();
|
||||||
@@ -91,6 +97,9 @@ virtual status_t GetSupportedSuites(BMessage *message);
|
|||||||
|
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
virtual status_t Perform(perform_code d, void *arg);
|
||||||
|
|
||||||
|
virtual BSize MaxSize();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend status_t _init_interface_kit_();
|
friend status_t _init_interface_kit_();
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,9 @@ class BScrollView : public BView {
|
|||||||
virtual void MakeFocus(bool state = true);
|
virtual void MakeFocus(bool state = true);
|
||||||
virtual status_t GetSupportedSuites(BMessage *data);
|
virtual status_t GetSupportedSuites(BMessage *data);
|
||||||
|
|
||||||
|
virtual BSize MinSize();
|
||||||
|
virtual BSize PreferredSize();
|
||||||
|
|
||||||
// private or reserved methods are following
|
// private or reserved methods are following
|
||||||
|
|
||||||
virtual status_t Perform(perform_code d, void *arg);
|
virtual status_t Perform(perform_code d, void *arg);
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -53,6 +53,8 @@ class BStringView : public BView{
|
|||||||
virtual void AllDetached();
|
virtual void AllDetached();
|
||||||
virtual status_t GetSupportedSuites(BMessage* data);
|
virtual status_t GetSupportedSuites(BMessage* data);
|
||||||
|
|
||||||
|
virtual BSize MaxSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual status_t Perform(perform_code d, void* arg);
|
virtual status_t Perform(perform_code d, void* arg);
|
||||||
virtual void _ReservedStringView1();
|
virtual void _ReservedStringView1();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <Control.h>
|
#include <Control.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
|
class BLayoutItem;
|
||||||
class _BTextInput_;
|
class _BTextInput_;
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +20,13 @@ class BTextControl : public BControl {
|
|||||||
BMessage* message,
|
BMessage* message,
|
||||||
uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resizeMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
|
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();
|
virtual ~BTextControl();
|
||||||
|
|
||||||
BTextControl(BMessage* archive);
|
BTextControl(BMessage* archive);
|
||||||
@@ -68,8 +76,16 @@ class BTextControl : public BControl {
|
|||||||
virtual status_t GetSupportedSuites(BMessage* data);
|
virtual status_t GetSupportedSuites(BMessage* data);
|
||||||
virtual void SetFlags(uint32 flags);
|
virtual void SetFlags(uint32 flags);
|
||||||
|
|
||||||
|
BLayoutItem* CreateLabelLayoutItem();
|
||||||
|
BLayoutItem* CreateTextViewLayoutItem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class LabelLayoutItem;
|
||||||
|
class TextViewLayoutItem;
|
||||||
|
|
||||||
friend class _BTextInput_;
|
friend class _BTextInput_;
|
||||||
|
friend class LabelLayoutItem;
|
||||||
|
friend class TextViewLayoutItem;
|
||||||
|
|
||||||
virtual status_t Perform(perform_code d, void* arg);
|
virtual status_t Perform(perform_code d, void* arg);
|
||||||
|
|
||||||
@@ -84,6 +100,8 @@ class BTextControl : public BControl {
|
|||||||
void _UpdateTextViewColors(bool enabled);
|
void _UpdateTextViewColors(bool enabled);
|
||||||
void _InitData(const char* label, const char* initialText,
|
void _InitData(const char* label, const char* initialText,
|
||||||
BMessage* archive = NULL);
|
BMessage* archive = NULL);
|
||||||
|
void _ValidateLayout();
|
||||||
|
void _UpdateFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
_BTextInput_* fText;
|
_BTextInput_* fText;
|
||||||
@@ -93,8 +111,10 @@ class BTextControl : public BControl {
|
|||||||
float fDivider;
|
float fDivider;
|
||||||
float fPreviousWidth;
|
float fPreviousWidth;
|
||||||
float fPreviousHeight;
|
float fPreviousHeight;
|
||||||
|
BLayoutItem* fLabelLayoutItem;
|
||||||
|
BLayoutItem* fTextViewLayoutItem;
|
||||||
|
|
||||||
uint32 _reserved[6];
|
uint32 _reserved[4];
|
||||||
|
|
||||||
bool fClean;
|
bool fClean;
|
||||||
bool fSkipSetFlags;
|
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
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2005, Haiku.
|
* Copyright 2001-2006, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -9,11 +9,13 @@
|
|||||||
#define _VIEW_H
|
#define _VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <Alignment.h>
|
||||||
#include <BeBuild.h>
|
#include <BeBuild.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
#include <Handler.h>
|
#include <Handler.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
#include <Size.h>
|
||||||
|
|
||||||
|
|
||||||
// mouse button
|
// mouse button
|
||||||
@@ -74,6 +76,8 @@ const uint32 B_SUBPIXEL_PRECISE = 0x01000000UL; /* 24 */
|
|||||||
const uint32 B_DRAW_ON_CHILDREN = 0x00800000UL; /* 23 */
|
const uint32 B_DRAW_ON_CHILDREN = 0x00800000UL; /* 23 */
|
||||||
const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL; /* 23 */
|
const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL; /* 23 */
|
||||||
const uint32 _B_RESERVED7_ = 0x00200000UL; /* 22 */
|
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 \
|
#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE | _B_RESERVED1_ | B_WILL_DRAW \
|
||||||
| B_PULSE_NEEDED | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE \
|
| 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 BBitmap;
|
||||||
class BCursor;
|
class BCursor;
|
||||||
|
class BLayout;
|
||||||
|
class BLayoutContext;
|
||||||
|
class BLayoutItem;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class BPicture;
|
class BPicture;
|
||||||
class BPolygon;
|
class BPolygon;
|
||||||
@@ -125,6 +132,8 @@ namespace BPrivate {
|
|||||||
|
|
||||||
class BView : public BHandler {
|
class BView : public BHandler {
|
||||||
public:
|
public:
|
||||||
|
BView(const char* name, uint32 flags,
|
||||||
|
BLayout* layout = NULL);
|
||||||
BView(BRect frame, const char* name,
|
BView(BRect frame, const char* name,
|
||||||
uint32 resizeMask, uint32 flags);
|
uint32 resizeMask, uint32 flags);
|
||||||
virtual ~BView();
|
virtual ~BView();
|
||||||
@@ -141,6 +150,7 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* msg);
|
virtual void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
void AddChild(BView* child, BView* before = NULL);
|
void AddChild(BView* child, BView* before = NULL);
|
||||||
|
bool AddChild(BLayoutItem* child);
|
||||||
bool RemoveChild(BView* child);
|
bool RemoveChild(BView* child);
|
||||||
int32 CountChildren() const;
|
int32 CountChildren() const;
|
||||||
BView* ChildAt(int32 index) const;
|
BView* ChildAt(int32 index) const;
|
||||||
@@ -490,31 +500,64 @@ public:
|
|||||||
|
|
||||||
bool IsPrinting() const;
|
bool IsPrinting() const;
|
||||||
void SetScale(float scale) 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 status_t Perform(perform_code d, void* arg);
|
||||||
|
|
||||||
virtual void DrawAfterChildren(BRect r);
|
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:
|
private:
|
||||||
friend class BScrollBar;
|
void _Layout(bool force, BLayoutContext* context);
|
||||||
friend class BWindow;
|
|
||||||
|
private:
|
||||||
|
struct LayoutData;
|
||||||
|
|
||||||
friend class BBitmap;
|
friend class BBitmap;
|
||||||
|
friend class BLayout;
|
||||||
friend class BPrintJob;
|
friend class BPrintJob;
|
||||||
|
friend class BScrollBar;
|
||||||
friend class BShelf;
|
friend class BShelf;
|
||||||
friend class BTabView;
|
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 _ReservedView10();
|
||||||
virtual void _ReservedView11();
|
virtual void _ReservedView11();
|
||||||
virtual void _ReservedView12();
|
virtual void _ReservedView12();
|
||||||
@@ -571,6 +614,9 @@ private:
|
|||||||
bool _AddChildToList(BView* child, BView* before = NULL);
|
bool _AddChildToList(BView* child, BView* before = NULL);
|
||||||
bool _RemoveChildFromList(BView* child);
|
bool _RemoveChildFromList(BView* child);
|
||||||
|
|
||||||
|
bool _AddChild(BView *child, BView *before);
|
||||||
|
bool _RemoveSelf();
|
||||||
|
|
||||||
// Debugging methods
|
// Debugging methods
|
||||||
void PrintToStream();
|
void PrintToStream();
|
||||||
void PrintTree();
|
void PrintTree();
|
||||||
@@ -601,7 +647,10 @@ private:
|
|||||||
BShelf* fShelf;
|
BShelf* fShelf;
|
||||||
uint32 fEventMask;
|
uint32 fEventMask;
|
||||||
uint32 fEventOptions;
|
uint32 fEventOptions;
|
||||||
uint32 _reserved[9];
|
|
||||||
|
LayoutData* fLayoutData;
|
||||||
|
|
||||||
|
uint32 _reserved[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ enum {
|
|||||||
B_ASYNCHRONOUS_CONTROLS = 0x00080000,
|
B_ASYNCHRONOUS_CONTROLS = 0x00080000,
|
||||||
B_QUIT_ON_WINDOW_CLOSE = 0x00100000,
|
B_QUIT_ON_WINDOW_CLOSE = 0x00100000,
|
||||||
B_SAME_POSITION_IN_ALL_WORKSPACES = 0x00200000,
|
B_SAME_POSITION_IN_ALL_WORKSPACES = 0x00200000,
|
||||||
|
B_AUTO_UPDATE_SIZE_LIMITS = 0x00400000,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define B_CURRENT_WORKSPACE 0
|
#define B_CURRENT_WORKSPACE 0
|
||||||
@@ -257,6 +258,11 @@ public:
|
|||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual thread_id Run();
|
virtual thread_id Run();
|
||||||
|
|
||||||
|
virtual void SetLayout(BLayout* layout);
|
||||||
|
BLayout* GetLayout() const;
|
||||||
|
|
||||||
|
void InvalidateLayout(bool descendants = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BLooper inherited;
|
typedef BLooper inherited;
|
||||||
struct unpack_cookie;
|
struct unpack_cookie;
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ public:
|
|||||||
/* Adding and removing items. */
|
/* Adding and removing items. */
|
||||||
bool AddItem(void *item, int32 index);
|
bool AddItem(void *item, int32 index);
|
||||||
bool AddItem(void *item);
|
bool AddItem(void *item);
|
||||||
bool AddList(BList *list, int32 index);
|
bool AddList(const BList *list, int32 index);
|
||||||
bool AddList(BList *list);
|
bool AddList(const BList *list);
|
||||||
bool RemoveItem(void *item);
|
bool RemoveItem(void *item);
|
||||||
void *RemoveItem(int32 index);
|
void *RemoveItem(int32 index);
|
||||||
bool RemoveItems(int32 index, int32 count);
|
bool RemoveItems(int32 index, int32 count);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ extern const std::string kApplicationDatabaseDir;
|
|||||||
// Attribute Prefixes
|
// Attribute Prefixes
|
||||||
extern const char *kMiniIconAttrPrefix;
|
extern const char *kMiniIconAttrPrefix;
|
||||||
extern const char *kLargeIconAttrPrefix;
|
extern const char *kLargeIconAttrPrefix;
|
||||||
|
extern const char *kIconAttrPrefix;
|
||||||
|
|
||||||
// Attribute names
|
// Attribute names
|
||||||
extern const char *kFileTypeAttr;
|
extern const char *kFileTypeAttr;
|
||||||
@@ -39,6 +40,7 @@ extern const char *kLongDescriptionAttr;
|
|||||||
extern const char *kFileExtensionsAttr;
|
extern const char *kFileExtensionsAttr;
|
||||||
extern const char *kMiniIconAttr;
|
extern const char *kMiniIconAttr;
|
||||||
extern const char *kLargeIconAttr;
|
extern const char *kLargeIconAttr;
|
||||||
|
extern const char *kIconAttr;
|
||||||
extern const char *kPreferredAppAttr;
|
extern const char *kPreferredAppAttr;
|
||||||
extern const char *kSnifferRuleAttr;
|
extern const char *kSnifferRuleAttr;
|
||||||
extern const char *kSupportedTypesAttr;
|
extern const char *kSupportedTypesAttr;
|
||||||
@@ -53,6 +55,7 @@ extern const int32 kLongDescriptionType;
|
|||||||
extern const int32 kFileExtensionsType;
|
extern const int32 kFileExtensionsType;
|
||||||
extern const int32 kMiniIconType;
|
extern const int32 kMiniIconType;
|
||||||
extern const int32 kLargeIconType;
|
extern const int32 kLargeIconType;
|
||||||
|
extern const int32 kIconType;
|
||||||
extern const int32 kPreferredAppType;
|
extern const int32 kPreferredAppType;
|
||||||
extern const int32 kSnifferRuleType;
|
extern const int32 kSnifferRuleType;
|
||||||
extern const int32 kSupportedTypesType;
|
extern const int32 kSupportedTypesType;
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ SharedLibrary libbe.so :
|
|||||||
<libbe>storage_diskdevice_kit.o
|
<libbe>storage_diskdevice_kit.o
|
||||||
<libbe>support_kit.o
|
<libbe>support_kit.o
|
||||||
|
|
||||||
|
libqoca.so
|
||||||
|
|
||||||
|
libicon.a
|
||||||
|
libagg.a
|
||||||
|
|
||||||
libroot.so # make sure it links against our libroot.so
|
libroot.so # make sure it links against our libroot.so
|
||||||
$(TARGET_LIBSTDC++)
|
$(TARGET_LIBSTDC++)
|
||||||
;
|
;
|
||||||
@@ -64,6 +69,11 @@ SharedLibrary libbe_haiku.so :
|
|||||||
<libbe>storage_kit.o
|
<libbe>storage_kit.o
|
||||||
<libbe>support_kit.o
|
<libbe>support_kit.o
|
||||||
|
|
||||||
|
libqoca.so
|
||||||
|
|
||||||
|
libicon.a
|
||||||
|
libagg.a
|
||||||
|
|
||||||
libbeadapter.so
|
libbeadapter.so
|
||||||
net
|
net
|
||||||
$(TARGET_LIBSTDC++)
|
$(TARGET_LIBSTDC++)
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <DesktopLink.h>
|
#include <DesktopLink.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
|
||||||
|
|||||||
@@ -275,8 +275,9 @@ BDirectWindow::SetFullScreen(bool enable)
|
|||||||
fLink->Attach<bool>(enable);
|
fLink->Attach<bool>(enable);
|
||||||
|
|
||||||
if (fLink->FlushWithReply(status) == B_OK
|
if (fLink->FlushWithReply(status) == B_OK
|
||||||
&& status == B_OK)
|
&& status == B_OK) {
|
||||||
fIsFullScreen = enable;
|
fIsFullScreen = enable;
|
||||||
|
}
|
||||||
Unlock();
|
Unlock();
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
@@ -303,6 +304,8 @@ BDirectWindow::SupportsWindowMode(screen_id id)
|
|||||||
// TODO: Apparently, the above is false for the vesa driver,
|
// TODO: Apparently, the above is false for the vesa driver,
|
||||||
// but enabling it doesn't do any harm... maybe we should just return always true.
|
// but enabling it doesn't do any harm... maybe we should just return always true.
|
||||||
// At least, I can't see why window mode shouldn't be supported.
|
// At least, I can't see why window mode shouldn't be supported.
|
||||||
|
// additional NOTE: it probably depends on wether hardware cursor is supported or
|
||||||
|
// not
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AbstractLayoutItem.h>
|
||||||
|
|
||||||
|
#include <LayoutUtils.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BAbstractLayoutItem::BAbstractLayoutItem()
|
||||||
|
: fMinSize(),
|
||||||
|
fMaxSize(),
|
||||||
|
fPreferredSize(),
|
||||||
|
fAlignment()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BAbstractLayoutItem::~BAbstractLayoutItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinSize
|
||||||
|
BSize
|
||||||
|
BAbstractLayoutItem::MinSize()
|
||||||
|
{
|
||||||
|
return BLayoutUtils::ComposeSize(fMinSize, BaseMinSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSize
|
||||||
|
BSize
|
||||||
|
BAbstractLayoutItem::MaxSize()
|
||||||
|
{
|
||||||
|
return BLayoutUtils::ComposeSize(fMaxSize, BaseMaxSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferredSize
|
||||||
|
BSize
|
||||||
|
BAbstractLayoutItem::PreferredSize()
|
||||||
|
{
|
||||||
|
return BLayoutUtils::ComposeSize(fMaxSize, BaseMaxSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alignment
|
||||||
|
BAlignment
|
||||||
|
BAbstractLayoutItem::Alignment()
|
||||||
|
{
|
||||||
|
return BLayoutUtils::ComposeAlignment(fAlignment, BaseAlignment());
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitMinSize
|
||||||
|
void
|
||||||
|
BAbstractLayoutItem::SetExplicitMinSize(BSize size)
|
||||||
|
{
|
||||||
|
fMinSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitMaxSize
|
||||||
|
void
|
||||||
|
BAbstractLayoutItem::SetExplicitMaxSize(BSize size)
|
||||||
|
{
|
||||||
|
fMaxSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitPreferredSize
|
||||||
|
void
|
||||||
|
BAbstractLayoutItem::SetExplicitPreferredSize(BSize size)
|
||||||
|
{
|
||||||
|
fPreferredSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitAlignment
|
||||||
|
void
|
||||||
|
BAbstractLayoutItem::SetExplicitAlignment(BAlignment alignment)
|
||||||
|
{
|
||||||
|
fAlignment = alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseMinSize
|
||||||
|
BSize
|
||||||
|
BAbstractLayoutItem::BaseMinSize()
|
||||||
|
{
|
||||||
|
return BSize(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseMaxSize
|
||||||
|
BSize
|
||||||
|
BAbstractLayoutItem::BaseMaxSize()
|
||||||
|
{
|
||||||
|
return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BasePreferredSize
|
||||||
|
BSize
|
||||||
|
BAbstractLayoutItem::BasePreferredSize()
|
||||||
|
{
|
||||||
|
return BSize(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BaseAlignment
|
||||||
|
BAlignment
|
||||||
|
BAbstractLayoutItem::BaseAlignment()
|
||||||
|
{
|
||||||
|
return BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Alignment.h>
|
||||||
|
|
||||||
|
// RelativeHorizontal
|
||||||
|
float
|
||||||
|
BAlignment::RelativeHorizontal() const
|
||||||
|
{
|
||||||
|
switch (horizontal) {
|
||||||
|
case B_ALIGN_LEFT:
|
||||||
|
return 0;
|
||||||
|
case B_ALIGN_RIGHT:
|
||||||
|
return 1;
|
||||||
|
case B_ALIGN_HORIZONTAL_CENTER:
|
||||||
|
return 0.5f;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (float)horizontal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RelativeVertical
|
||||||
|
float
|
||||||
|
BAlignment::RelativeVertical() const
|
||||||
|
{
|
||||||
|
switch (vertical) {
|
||||||
|
case B_ALIGN_TOP:
|
||||||
|
return 0;
|
||||||
|
case B_ALIGN_BOTTOM:
|
||||||
|
return 1;
|
||||||
|
case B_ALIGN_VERTICAL_CENTER:
|
||||||
|
return 0.5f;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (float)vertical;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
|
#include <LayoutUtils.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -31,6 +33,35 @@ BButton::BButton(BRect frame, const char *name, const char *label, BMessage *mes
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BButton::BButton(const char* name, const char* label, BMessage *message,
|
||||||
|
uint32 flags)
|
||||||
|
: BControl(BRect(0, 0, -1, -1), name, label, message, B_FOLLOW_NONE,
|
||||||
|
flags | B_WILL_DRAW | B_SUPPORTS_LAYOUT),
|
||||||
|
fDrawAsDefault(false)
|
||||||
|
{
|
||||||
|
// Resize to minimum height if needed
|
||||||
|
font_height fh;
|
||||||
|
GetFontHeight(&fh);
|
||||||
|
float minHeight = 12.0f + (float)ceil(fh.ascent + fh.descent);
|
||||||
|
if (Bounds().Height() < minHeight)
|
||||||
|
ResizeTo(Bounds().Width(), minHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BButton::BButton(const char* label, BMessage *message)
|
||||||
|
: BControl(BRect(0, 0, -1, -1), NULL, label, message, B_FOLLOW_NONE,
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE | B_SUPPORTS_LAYOUT),
|
||||||
|
fDrawAsDefault(false)
|
||||||
|
{
|
||||||
|
// Resize to minimum height if needed
|
||||||
|
font_height fh;
|
||||||
|
GetFontHeight(&fh);
|
||||||
|
float minHeight = 12.0f + (float)ceil(fh.ascent + fh.descent);
|
||||||
|
if (Bounds().Height() < minHeight)
|
||||||
|
ResizeTo(Bounds().Width(), minHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BButton::~BButton()
|
BButton::~BButton()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -690,6 +721,16 @@ BButton::Perform(perform_code d, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BButton::MaxSize()
|
||||||
|
{
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), BSize(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BButton::_ReservedButton1() {}
|
void BButton::_ReservedButton1() {}
|
||||||
void BButton::_ReservedButton2() {}
|
void BButton::_ReservedButton2() {}
|
||||||
void BButton::_ReservedButton3() {}
|
void BButton::_ReservedButton3() {}
|
||||||
|
|||||||
@@ -0,0 +1,236 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <CardLayout.h>
|
||||||
|
|
||||||
|
#include <LayoutItem.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BCardLayout::BCardLayout()
|
||||||
|
: BLayout(),
|
||||||
|
fMin(0, 0),
|
||||||
|
fMax(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED),
|
||||||
|
fPreferred(0, 0),
|
||||||
|
fVisibleItem(NULL),
|
||||||
|
fMinMaxValid(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BCardLayout::~BCardLayout()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// VisibleItem
|
||||||
|
BLayoutItem*
|
||||||
|
BCardLayout::VisibleItem() const
|
||||||
|
{
|
||||||
|
return fVisibleItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VisibleIndex
|
||||||
|
int32
|
||||||
|
BCardLayout::VisibleIndex() const
|
||||||
|
{
|
||||||
|
return IndexOfItem(fVisibleItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetVisibleItem
|
||||||
|
void
|
||||||
|
BCardLayout::SetVisibleItem(int32 index)
|
||||||
|
{
|
||||||
|
SetVisibleItem(ItemAt(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetVisibleItem
|
||||||
|
void
|
||||||
|
BCardLayout::SetVisibleItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
if (item == fVisibleItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (item != NULL && IndexOfItem(item) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fVisibleItem != NULL)
|
||||||
|
fVisibleItem->SetVisible(false);
|
||||||
|
|
||||||
|
fVisibleItem = item;
|
||||||
|
|
||||||
|
if (fVisibleItem != NULL) {
|
||||||
|
fVisibleItem->SetVisible(true);
|
||||||
|
|
||||||
|
LayoutView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinSize
|
||||||
|
BSize
|
||||||
|
BCardLayout::MinSize()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
return fMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSize
|
||||||
|
BSize
|
||||||
|
BCardLayout::MaxSize()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
return fMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferredSize
|
||||||
|
BSize
|
||||||
|
BCardLayout::PreferredSize()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
return fPreferred;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alignment
|
||||||
|
BAlignment
|
||||||
|
BCardLayout::Alignment()
|
||||||
|
{
|
||||||
|
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasHeightForWidth
|
||||||
|
bool
|
||||||
|
BCardLayout::HasHeightForWidth()
|
||||||
|
{
|
||||||
|
int32 count = CountItems();
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
if (ItemAt(i)->HasHeightForWidth())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHeightForWidth
|
||||||
|
void
|
||||||
|
BCardLayout::GetHeightForWidth(float width, float* min, float* max,
|
||||||
|
float* preferred)
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
|
||||||
|
// init with useful values
|
||||||
|
float minHeight = fMin.height;
|
||||||
|
float maxHeight = fMax.height;
|
||||||
|
float preferredHeight = fPreferred.height;
|
||||||
|
|
||||||
|
// apply the items' constraints
|
||||||
|
int32 count = CountItems();
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
BLayoutItem* item = ItemAt(i);
|
||||||
|
if (item->HasHeightForWidth()) {
|
||||||
|
float itemMinHeight;
|
||||||
|
float itemMaxHeight;
|
||||||
|
float itemPreferredHeight;
|
||||||
|
item->GetHeightForWidth(width, &itemMinHeight, &itemMaxHeight,
|
||||||
|
&itemPreferredHeight);
|
||||||
|
minHeight = max_c(minHeight, itemMinHeight);
|
||||||
|
maxHeight = min_c(maxHeight, itemMaxHeight);
|
||||||
|
preferredHeight = min_c(preferredHeight, itemPreferredHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// adjust max and preferred, if necessary
|
||||||
|
maxHeight = max_c(maxHeight, minHeight);
|
||||||
|
preferredHeight = max_c(preferredHeight, minHeight);
|
||||||
|
preferredHeight = min_c(preferredHeight, maxHeight);
|
||||||
|
|
||||||
|
if (min)
|
||||||
|
*min = minHeight;
|
||||||
|
if (max)
|
||||||
|
*max = maxHeight;
|
||||||
|
if (preferred)
|
||||||
|
*preferred = preferredHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidateLayout
|
||||||
|
void
|
||||||
|
BCardLayout::InvalidateLayout()
|
||||||
|
{
|
||||||
|
BLayout::InvalidateLayout();
|
||||||
|
|
||||||
|
fMinMaxValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// LayoutView
|
||||||
|
void
|
||||||
|
BCardLayout::LayoutView()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
|
||||||
|
BSize size = BSize(View()->Bounds());
|
||||||
|
size.width = max_c(size.width, fMin.width);
|
||||||
|
size.height = max_c(size.height, fMin.height);
|
||||||
|
|
||||||
|
if (fVisibleItem != NULL)
|
||||||
|
fVisibleItem->AlignInFrame(BRect(0, 0, size.width, size.height));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemAdded
|
||||||
|
void
|
||||||
|
BCardLayout::ItemAdded(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
item->SetVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemRemoved
|
||||||
|
void
|
||||||
|
BCardLayout::ItemRemoved(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
if (fVisibleItem == item) {
|
||||||
|
BLayoutItem* newVisibleItem = NULL;
|
||||||
|
SetVisibleItem(newVisibleItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _ValidateMinMax
|
||||||
|
void
|
||||||
|
BCardLayout::_ValidateMinMax()
|
||||||
|
{
|
||||||
|
if (fMinMaxValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fMin.width = 0;
|
||||||
|
fMin.height = 0;
|
||||||
|
fMax.width = B_SIZE_UNLIMITED;
|
||||||
|
fMax.height = B_SIZE_UNLIMITED;
|
||||||
|
fPreferred.width = 0;
|
||||||
|
fPreferred.height = 0;
|
||||||
|
|
||||||
|
int32 itemCount = CountItems();
|
||||||
|
for (int32 i = 0; i < itemCount; i++) {
|
||||||
|
BLayoutItem* item = ItemAt(i);
|
||||||
|
|
||||||
|
BSize min = item->MinSize();
|
||||||
|
BSize max = item->MaxSize();
|
||||||
|
BSize preferred = item->PreferredSize();
|
||||||
|
|
||||||
|
fMin.width = max_c(fMin.width, min.width);
|
||||||
|
fMin.height = max_c(fMin.height, min.height);
|
||||||
|
|
||||||
|
fMax.width = min_c(fMax.width, max.width);
|
||||||
|
fMax.height = min_c(fMax.height, max.height);
|
||||||
|
|
||||||
|
fPreferred.width = max_c(fPreferred.width, preferred.width);
|
||||||
|
fPreferred.height = max_c(fPreferred.height, preferred.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
fMax.width = max_c(fMax.width, fMin.width);
|
||||||
|
fMax.height = max_c(fMax.height, fMin.height);
|
||||||
|
|
||||||
|
fPreferred.width = max_c(fPreferred.width, fMin.width);
|
||||||
|
fPreferred.height = max_c(fPreferred.height, fMin.height);
|
||||||
|
fPreferred.width = min_c(fPreferred.width, fMax.width);
|
||||||
|
fPreferred.height = min_c(fPreferred.height, fMax.height);
|
||||||
|
|
||||||
|
fMinMaxValid = true;
|
||||||
|
}
|
||||||
@@ -200,6 +200,15 @@ BColorControl::Archive(BMessage *archive, bool deep) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BColorControl::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
// We need to implement this method, since we have another SetLayout()
|
||||||
|
// method and C++ has this special method hiding "feature".
|
||||||
|
BControl::SetLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BColorControl::SetValue(int32 value)
|
BColorControl::SetValue(int32 value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ BControl::SetLabel(const char *label)
|
|||||||
free(fLabel);
|
free(fLabel);
|
||||||
fLabel = label ? strdup(label) : NULL;
|
fLabel = label ? strdup(label) : NULL;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,586 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GridLayout.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include <LayoutItem.h>
|
||||||
|
#include <List.h>
|
||||||
|
|
||||||
|
#include "ViewLayoutItem.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MAX_COLUMN_ROW_COUNT = 1024,
|
||||||
|
};
|
||||||
|
|
||||||
|
// a placeholder we put in our grid array to make a cell occupied
|
||||||
|
static BLayoutItem* const OCCUPIED_GRID_CELL = (BLayoutItem*)0x1;
|
||||||
|
|
||||||
|
|
||||||
|
// ItemLayoutData
|
||||||
|
struct BGridLayout::ItemLayoutData {
|
||||||
|
Dimensions dimensions;
|
||||||
|
|
||||||
|
ItemLayoutData()
|
||||||
|
{
|
||||||
|
dimensions.x = 0;
|
||||||
|
dimensions.y = 0;
|
||||||
|
dimensions.width = 1;
|
||||||
|
dimensions.height = 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// RowInfoArray
|
||||||
|
class BGridLayout::RowInfoArray {
|
||||||
|
public:
|
||||||
|
|
||||||
|
RowInfoArray()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~RowInfoArray()
|
||||||
|
{
|
||||||
|
for (int32 i = 0; Info* info = (Info*)fInfos.ItemAt(i); i++)
|
||||||
|
delete info;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Count() const
|
||||||
|
{
|
||||||
|
return fInfos.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
float Weight(int32 index) const
|
||||||
|
{
|
||||||
|
if (Info* info = _InfoAt(index))
|
||||||
|
return info->weight;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetWeight(int32 index, float weight)
|
||||||
|
{
|
||||||
|
if (Info* info = _InfoAt(index, true))
|
||||||
|
info->weight = weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
float MinSize(int32 index) const
|
||||||
|
{
|
||||||
|
if (Info* info = _InfoAt(index))
|
||||||
|
return info->minSize;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMinSize(int32 index, float size)
|
||||||
|
{
|
||||||
|
if (Info* info = _InfoAt(index, true))
|
||||||
|
info->minSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
float MaxSize(int32 index) const
|
||||||
|
{
|
||||||
|
if (Info* info = _InfoAt(index))
|
||||||
|
return info->maxSize;
|
||||||
|
return B_SIZE_UNLIMITED;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMaxSize(int32 index, float size)
|
||||||
|
{
|
||||||
|
if (Info* info = _InfoAt(index, true))
|
||||||
|
info->maxSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Info {
|
||||||
|
float weight;
|
||||||
|
float minSize;
|
||||||
|
float maxSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
Info* _InfoAt(int32 index) const
|
||||||
|
{
|
||||||
|
return (Info*)fInfos.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info* _InfoAt(int32 index, bool resize)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= MAX_COLUMN_ROW_COUNT)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
// resize, if necessary and desired
|
||||||
|
int32 count = Count();
|
||||||
|
if (index >= count) {
|
||||||
|
if (!resize)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (int32 i = count; i <= index; i++) {
|
||||||
|
Info* info = new Info;
|
||||||
|
info->weight = 1;
|
||||||
|
info->minSize = 0;
|
||||||
|
info->maxSize = B_SIZE_UNLIMITED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _InfoAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
BList fInfos;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGridLayout::BGridLayout(float horizontal, float vertical)
|
||||||
|
: fGrid(NULL),
|
||||||
|
fColumnCount(0),
|
||||||
|
fRowCount(0),
|
||||||
|
fRowInfos(new RowInfoArray),
|
||||||
|
fColumnInfos(new RowInfoArray),
|
||||||
|
fMultiColumnItems(0),
|
||||||
|
fMultiRowItems(0)
|
||||||
|
{
|
||||||
|
SetSpacing(horizontal, vertical);
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BGridLayout::~BGridLayout()
|
||||||
|
{
|
||||||
|
delete fRowInfos;
|
||||||
|
delete fColumnInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// HorizontalSpacing
|
||||||
|
float
|
||||||
|
BGridLayout::HorizontalSpacing() const
|
||||||
|
{
|
||||||
|
return fHSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VerticalSpacing
|
||||||
|
float
|
||||||
|
BGridLayout::VerticalSpacing() const
|
||||||
|
{
|
||||||
|
return fVSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetHorizontalSpacing
|
||||||
|
void
|
||||||
|
BGridLayout::SetHorizontalSpacing(float spacing)
|
||||||
|
{
|
||||||
|
if (spacing != fHSpacing) {
|
||||||
|
fHSpacing = spacing;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetVerticalSpacing
|
||||||
|
void
|
||||||
|
BGridLayout::SetVerticalSpacing(float spacing)
|
||||||
|
{
|
||||||
|
if (spacing != fVSpacing) {
|
||||||
|
fVSpacing = spacing;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpacing
|
||||||
|
void
|
||||||
|
BGridLayout::SetSpacing(float horizontal, float vertical)
|
||||||
|
{
|
||||||
|
if (horizontal != fHSpacing || vertical != fVSpacing) {
|
||||||
|
fHSpacing = horizontal;
|
||||||
|
fVSpacing = vertical;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ColumnWeight
|
||||||
|
float
|
||||||
|
BGridLayout::ColumnWeight(int32 column) const
|
||||||
|
{
|
||||||
|
return fColumnInfos->Weight(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetColumnWeight
|
||||||
|
void
|
||||||
|
BGridLayout::SetColumnWeight(int32 column, float weight)
|
||||||
|
{
|
||||||
|
fColumnInfos->SetWeight(column, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinColumnWidth
|
||||||
|
float
|
||||||
|
BGridLayout::MinColumnWidth(int32 column) const
|
||||||
|
{
|
||||||
|
return fColumnInfos->MinSize(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMinColumnWidth
|
||||||
|
void
|
||||||
|
BGridLayout::SetMinColumnWidth(int32 column, float width)
|
||||||
|
{
|
||||||
|
fColumnInfos->SetMinSize(column, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxColumnWidth
|
||||||
|
float
|
||||||
|
BGridLayout::MaxColumnWidth(int32 column) const
|
||||||
|
{
|
||||||
|
return fColumnInfos->MaxSize(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMaxColumnWidth
|
||||||
|
void
|
||||||
|
BGridLayout::SetMaxColumnWidth(int32 column, float width)
|
||||||
|
{
|
||||||
|
fColumnInfos->SetMaxSize(column, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RowWeight
|
||||||
|
float
|
||||||
|
BGridLayout::RowWeight(int32 row) const
|
||||||
|
{
|
||||||
|
return fRowInfos->Weight(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRowWeight
|
||||||
|
void
|
||||||
|
BGridLayout::SetRowWeight(int32 row, float weight)
|
||||||
|
{
|
||||||
|
fRowInfos->SetWeight(row, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinRowHeight
|
||||||
|
float
|
||||||
|
BGridLayout::MinRowHeight(int row) const
|
||||||
|
{
|
||||||
|
return fRowInfos->MinSize(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMinRowHeight
|
||||||
|
void
|
||||||
|
BGridLayout::SetMinRowHeight(int32 row, float height)
|
||||||
|
{
|
||||||
|
fRowInfos->SetMinSize(row, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxRowHeight
|
||||||
|
float
|
||||||
|
BGridLayout::MaxRowHeight(int32 row) const
|
||||||
|
{
|
||||||
|
return fRowInfos->MaxSize(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMaxRowHeight
|
||||||
|
void
|
||||||
|
BGridLayout::SetMaxRowHeight(int32 row, float height)
|
||||||
|
{
|
||||||
|
fRowInfos->SetMaxSize(row, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGridLayout::AddView(BView* child)
|
||||||
|
{
|
||||||
|
return BTwoDimensionalLayout::AddView(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGridLayout::AddView(int32 index, BView* child)
|
||||||
|
{
|
||||||
|
return BTwoDimensionalLayout::AddView(index, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGridLayout::AddView(BView* child, int32 column, int32 row, int32 columnCount,
|
||||||
|
int32 rowCount)
|
||||||
|
{
|
||||||
|
if (!child)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
BLayoutItem* item = new BViewLayoutItem(child);
|
||||||
|
if (!AddItem(item, column, row, columnCount, rowCount)) {
|
||||||
|
delete item;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGridLayout::AddItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
// find a free spot
|
||||||
|
for (int32 row = 0; row < fRowCount; row++) {
|
||||||
|
for (int32 column = 0; column < fColumnCount; column++) {
|
||||||
|
if (_IsGridCellEmpty(row, column))
|
||||||
|
return AddItem(item, column, row, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// no free spot, start a new column
|
||||||
|
return AddItem(item, fColumnCount, 0, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGridLayout::AddItem(int32 index, BLayoutItem* item)
|
||||||
|
{
|
||||||
|
return AddItem(index, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGridLayout::AddItem(BLayoutItem* item, int32 column, int32 row,
|
||||||
|
int32 columnCount, int32 rowCount)
|
||||||
|
{
|
||||||
|
if (!_AreGridCellsEmpty(column, row, columnCount, rowCount))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool success = BTwoDimensionalLayout::AddItem(-1, item);
|
||||||
|
if (!success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// set item dimensions
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(item)) {
|
||||||
|
data->dimensions.x = column;
|
||||||
|
data->dimensions.y = row;
|
||||||
|
data->dimensions.width = columnCount;
|
||||||
|
data->dimensions.height = rowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resize the grid, if necessary
|
||||||
|
int32 newColumnCount = max_c(fColumnCount, column + columnCount);
|
||||||
|
int32 newRowCount = max_c(fRowCount, row + rowCount);
|
||||||
|
if (newColumnCount > fColumnCount || newRowCount > fRowCount) {
|
||||||
|
if (!_ResizeGrid(newColumnCount, newRowCount)) {
|
||||||
|
RemoveItem(item);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// enter the item in the grid
|
||||||
|
for (int32 x = 0; x < columnCount; x++) {
|
||||||
|
for (int32 y = 0; y < rowCount; y++) {
|
||||||
|
if (x == 0 && y == 0)
|
||||||
|
fGrid[column + x][row + y] = item;
|
||||||
|
else
|
||||||
|
fGrid[column + x][row + y] = OCCUPIED_GRID_CELL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (columnCount > 1)
|
||||||
|
fMultiColumnItems++;
|
||||||
|
if (rowCount > 1)
|
||||||
|
fMultiRowItems++;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemAdded
|
||||||
|
void
|
||||||
|
BGridLayout::ItemAdded(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
item->SetLayoutData(new ItemLayoutData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemRemoved
|
||||||
|
void
|
||||||
|
BGridLayout::ItemRemoved(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
ItemLayoutData* data = _LayoutDataForItem(item);
|
||||||
|
// TODO: Once ItemAdded() returns a bool, we can remove this check.
|
||||||
|
if (!data)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dimensions itemDimensions = data->dimensions;
|
||||||
|
item->SetLayoutData(NULL);
|
||||||
|
delete data;
|
||||||
|
|
||||||
|
if (itemDimensions.width > 1)
|
||||||
|
fMultiColumnItems--;
|
||||||
|
if (itemDimensions.height > 1)
|
||||||
|
fMultiRowItems--;
|
||||||
|
|
||||||
|
// remove the item from the grid
|
||||||
|
for (int x = 0; x < itemDimensions.width; x++) {
|
||||||
|
for (int y = 0; y < itemDimensions.height; y++)
|
||||||
|
fGrid[itemDimensions.x + x][itemDimensions.y + y] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check whether we can shrink the grid
|
||||||
|
if (itemDimensions.x + itemDimensions.width == fColumnCount
|
||||||
|
|| itemDimensions.y + itemDimensions.height == fRowCount) {
|
||||||
|
int32 columnCount = fColumnCount;
|
||||||
|
int32 rowCount = fRowCount;
|
||||||
|
|
||||||
|
// check for empty columns
|
||||||
|
bool empty = false;
|
||||||
|
for (; columnCount > 0; columnCount--) {
|
||||||
|
for (int32 row = 0; empty && row < rowCount; row++)
|
||||||
|
empty &= (fGrid[columnCount - 1][row] == NULL);
|
||||||
|
|
||||||
|
if (!empty)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for empty rows
|
||||||
|
empty = false;
|
||||||
|
for (; rowCount > 0; rowCount--) {
|
||||||
|
for (int32 column = 0; empty && column < columnCount; column++)
|
||||||
|
empty &= (fGrid[column][rowCount - 1] == NULL);
|
||||||
|
|
||||||
|
if (!empty)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resize the grid
|
||||||
|
if (columnCount != fColumnCount || rowCount != fRowCount)
|
||||||
|
_ResizeGrid(columnCount, rowCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasMultiColumnItems
|
||||||
|
bool
|
||||||
|
BGridLayout::HasMultiColumnItems()
|
||||||
|
{
|
||||||
|
return (fMultiColumnItems > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasMultiRowItems
|
||||||
|
bool
|
||||||
|
BGridLayout::HasMultiRowItems()
|
||||||
|
{
|
||||||
|
return (fMultiRowItems > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// InternalCountColumns
|
||||||
|
int32
|
||||||
|
BGridLayout::InternalCountColumns()
|
||||||
|
{
|
||||||
|
return fColumnCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// InternalCountRows
|
||||||
|
int32
|
||||||
|
BGridLayout::InternalCountRows()
|
||||||
|
{
|
||||||
|
return fRowCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetColumnRowConstraints
|
||||||
|
void
|
||||||
|
BGridLayout::GetColumnRowConstraints(enum orientation orientation, int32 index,
|
||||||
|
ColumnRowConstraints* constraints)
|
||||||
|
{
|
||||||
|
if (orientation == B_HORIZONTAL) {
|
||||||
|
constraints->min = MinColumnWidth(index);
|
||||||
|
constraints->max = MaxColumnWidth(index);
|
||||||
|
constraints->weight = ColumnWeight(index);
|
||||||
|
} else {
|
||||||
|
constraints->min = MinRowHeight(index);
|
||||||
|
constraints->max = MaxRowHeight(index);
|
||||||
|
constraints->weight = RowWeight(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetItemDimensions
|
||||||
|
void
|
||||||
|
BGridLayout::GetItemDimensions(BLayoutItem* item, Dimensions* dimensions)
|
||||||
|
{
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||||
|
*dimensions = data->dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// _IsGridCellEmpty
|
||||||
|
bool
|
||||||
|
BGridLayout::_IsGridCellEmpty(int32 column, int32 row)
|
||||||
|
{
|
||||||
|
if (column < 0 || row < 0)
|
||||||
|
return false;
|
||||||
|
if (column >= fColumnCount || row >= fRowCount)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return (fGrid[column][row] == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _AreGridCellsEmpty
|
||||||
|
bool
|
||||||
|
BGridLayout::_AreGridCellsEmpty(int32 column, int32 row, int32 columnCount,
|
||||||
|
int32 rowCount)
|
||||||
|
{
|
||||||
|
if (column < 0 || row < 0)
|
||||||
|
return false;
|
||||||
|
int32 toColumn = min_c(column + columnCount, fColumnCount);
|
||||||
|
int32 toRow = min_c(row + rowCount, fRowCount);
|
||||||
|
|
||||||
|
for (int32 x = column; x < toColumn; x++) {
|
||||||
|
for (int32 y = row; y < toRow; y++) {
|
||||||
|
if (fGrid[x][y] != NULL)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// _ResizeGrid
|
||||||
|
bool
|
||||||
|
BGridLayout::_ResizeGrid(int32 columnCount, int32 rowCount)
|
||||||
|
{
|
||||||
|
if (columnCount == fColumnCount && rowCount == fRowCount)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int32 rowsToKeep = min_c(rowCount, fRowCount);
|
||||||
|
|
||||||
|
// allocate new grid
|
||||||
|
BLayoutItem*** grid = new(nothrow) BLayoutItem**[columnCount];
|
||||||
|
if (!grid)
|
||||||
|
return false;
|
||||||
|
memset(grid, 0, sizeof(BLayoutItem**) * columnCount);
|
||||||
|
|
||||||
|
bool success = true;
|
||||||
|
for (int32 i = 0; i < columnCount; i++) {
|
||||||
|
BLayoutItem** column = new(nothrow) BLayoutItem*[rowCount];
|
||||||
|
if (!column) {
|
||||||
|
success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
grid[i] = column;
|
||||||
|
|
||||||
|
memset(column, 0, sizeof(BLayoutItem*) * rowCount);
|
||||||
|
if (i < fColumnCount && rowsToKeep > 0)
|
||||||
|
memcpy(column, fGrid[i], sizeof(BLayoutItem*) * rowsToKeep);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if everything went fine, set the new grid
|
||||||
|
if (success) {
|
||||||
|
swap(grid, fGrid);
|
||||||
|
swap(columnCount, fColumnCount);
|
||||||
|
swap(rowCount, fRowCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete the old, respectively on error the partially created grid
|
||||||
|
for (int32 i = 0; i < columnCount; i++)
|
||||||
|
delete grid[i];
|
||||||
|
delete[] grid;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// _LayoutDataForItem
|
||||||
|
BGridLayout::ItemLayoutData*
|
||||||
|
BGridLayout::_LayoutDataForItem(BLayoutItem* item) const
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
return NULL;
|
||||||
|
return (ItemLayoutData*)item->LayoutData();
|
||||||
|
}
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GridLayoutBuilder.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::nothrow;
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGridLayoutBuilder::BGridLayoutBuilder(float horizontalSpacing,
|
||||||
|
float verticalSpacing)
|
||||||
|
: fLayout((new BGridView(horizontalSpacing, verticalSpacing))
|
||||||
|
->GridLayout())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGridLayoutBuilder::BGridLayoutBuilder(BGridLayout* layout)
|
||||||
|
: fLayout(layout)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGridLayoutBuilder::BGridLayoutBuilder(BGridView* view)
|
||||||
|
: fLayout(view->GridLayout())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// GridLayout
|
||||||
|
BGridLayout*
|
||||||
|
BGridLayoutBuilder::GridLayout() const
|
||||||
|
{
|
||||||
|
return fLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// View
|
||||||
|
BView*
|
||||||
|
BGridLayoutBuilder::View() const
|
||||||
|
{
|
||||||
|
return fLayout->View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGridLayout
|
||||||
|
BGridLayoutBuilder&
|
||||||
|
BGridLayoutBuilder::GetGridLayout(BGridLayout** _layout)
|
||||||
|
{
|
||||||
|
*_layout = fLayout;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetView
|
||||||
|
BGridLayoutBuilder&
|
||||||
|
BGridLayoutBuilder::GetView(BView** _view)
|
||||||
|
{
|
||||||
|
*_view = fLayout->View();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BGridLayoutBuilder&
|
||||||
|
BGridLayoutBuilder::Add(BView* view, int32 column, int32 row,
|
||||||
|
int32 columnCount, int32 rowCount)
|
||||||
|
{
|
||||||
|
fLayout->AddView(view, column, row, columnCount, rowCount);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BGridLayoutBuilder&
|
||||||
|
BGridLayoutBuilder::Add(BLayoutItem* item, int32 column, int32 row,
|
||||||
|
int32 columnCount, int32 rowCount)
|
||||||
|
{
|
||||||
|
fLayout->AddItem(item, column, row, columnCount, rowCount);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetColumnWeight
|
||||||
|
BGridLayoutBuilder&
|
||||||
|
BGridLayoutBuilder::SetColumnWeight(int32 column, float weight)
|
||||||
|
{
|
||||||
|
fLayout->SetColumnWeight(column, weight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRowWeight
|
||||||
|
BGridLayoutBuilder&
|
||||||
|
BGridLayoutBuilder::SetRowWeight(int32 row, float weight)
|
||||||
|
{
|
||||||
|
fLayout->SetRowWeight(row, weight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cast operator BGridLayout*
|
||||||
|
BGridLayoutBuilder::operator BGridLayout*()
|
||||||
|
{
|
||||||
|
return fLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cast operator BView*
|
||||||
|
BGridLayoutBuilder::operator BView*()
|
||||||
|
{
|
||||||
|
return fLayout->View();
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GridView.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGridView::BGridView(float horizontalSpacing, float verticalSpacing)
|
||||||
|
: BView(NULL, 0, new BGridLayout(horizontalSpacing, verticalSpacing))
|
||||||
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BGridView::~BGridView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLayout
|
||||||
|
void
|
||||||
|
BGridView::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
// only BGridLayouts are allowed
|
||||||
|
if (!dynamic_cast<BGridLayout*>(layout))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BView::SetLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GridLayout
|
||||||
|
BGridLayout*
|
||||||
|
BGridView::GridLayout() const
|
||||||
|
{
|
||||||
|
return dynamic_cast<BGridLayout*>(GetLayout());
|
||||||
|
}
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GroupLayout.h>
|
||||||
|
|
||||||
|
#include <LayoutItem.h>
|
||||||
|
|
||||||
|
|
||||||
|
// ItemLayoutData
|
||||||
|
struct BGroupLayout::ItemLayoutData {
|
||||||
|
float weight;
|
||||||
|
|
||||||
|
ItemLayoutData()
|
||||||
|
: weight(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGroupLayout::BGroupLayout(enum orientation orientation, float spacing)
|
||||||
|
: BTwoDimensionalLayout(),
|
||||||
|
fOrientation(orientation)
|
||||||
|
{
|
||||||
|
SetSpacing(spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BGroupLayout::~BGroupLayout()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spacing
|
||||||
|
float
|
||||||
|
BGroupLayout::Spacing() const
|
||||||
|
{
|
||||||
|
return fHSpacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpacing
|
||||||
|
void
|
||||||
|
BGroupLayout::SetSpacing(float spacing)
|
||||||
|
{
|
||||||
|
if (spacing != fHSpacing) {
|
||||||
|
fHSpacing = spacing;
|
||||||
|
fVSpacing = spacing;
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Orientation
|
||||||
|
orientation
|
||||||
|
BGroupLayout::Orientation() const
|
||||||
|
{
|
||||||
|
return fOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOrientation
|
||||||
|
void
|
||||||
|
BGroupLayout::SetOrientation(enum orientation orientation)
|
||||||
|
{
|
||||||
|
if (orientation != fOrientation) {
|
||||||
|
fOrientation = orientation;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemWeight
|
||||||
|
float
|
||||||
|
BGroupLayout::ItemWeight(int32 index) const
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= CountItems())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ItemLayoutData* data = _LayoutDataForItem(ItemAt(index));
|
||||||
|
return (data ? data->weight : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetItemWeight
|
||||||
|
void
|
||||||
|
BGroupLayout::SetItemWeight(int32 index, float weight)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= CountItems())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(ItemAt(index)))
|
||||||
|
data->weight = weight;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGroupLayout::AddView(BView* child)
|
||||||
|
{
|
||||||
|
return BTwoDimensionalLayout::AddView(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGroupLayout::AddView(int32 index, BView* child)
|
||||||
|
{
|
||||||
|
return BTwoDimensionalLayout::AddView(index, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGroupLayout::AddView(BView* child, float weight)
|
||||||
|
{
|
||||||
|
return AddView(-1, child, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BGroupLayout::AddView(int32 index, BView* child, float weight)
|
||||||
|
{
|
||||||
|
BLayoutItem* item = AddView(index, child);
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||||
|
data->weight = weight;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGroupLayout::AddItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
return BTwoDimensionalLayout::AddItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGroupLayout::AddItem(int32 index, BLayoutItem* item)
|
||||||
|
{
|
||||||
|
return BTwoDimensionalLayout::AddItem(index, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGroupLayout::AddItem(BLayoutItem* item, float weight)
|
||||||
|
{
|
||||||
|
return AddItem(-1, item, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BGroupLayout::AddItem(int32 index, BLayoutItem* item, float weight)
|
||||||
|
{
|
||||||
|
bool success = AddItem(index, item);
|
||||||
|
if (success) {
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||||
|
data->weight = weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemAdded
|
||||||
|
void
|
||||||
|
BGroupLayout::ItemAdded(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
item->SetLayoutData(new ItemLayoutData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemRemoved
|
||||||
|
void
|
||||||
|
BGroupLayout::ItemRemoved(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(item)) {
|
||||||
|
item->SetLayoutData(NULL);
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrepareItems
|
||||||
|
void
|
||||||
|
BGroupLayout::PrepareItems(enum orientation orientation)
|
||||||
|
{
|
||||||
|
// filter the visible items
|
||||||
|
fVisibleItems.MakeEmpty();
|
||||||
|
int32 itemCount = CountItems();
|
||||||
|
for (int i = 0; i < itemCount; i++) {
|
||||||
|
BLayoutItem* item = ItemAt(i);
|
||||||
|
if (item->IsVisible())
|
||||||
|
fVisibleItems.AddItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InternalCountColumns
|
||||||
|
int32
|
||||||
|
BGroupLayout::InternalCountColumns()
|
||||||
|
{
|
||||||
|
return (fOrientation == B_HORIZONTAL ? fVisibleItems.CountItems() : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// InternalCountRows
|
||||||
|
int32
|
||||||
|
BGroupLayout::InternalCountRows()
|
||||||
|
{
|
||||||
|
return (fOrientation == B_VERTICAL ? fVisibleItems.CountItems() : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetColumnRowConstraints
|
||||||
|
void
|
||||||
|
BGroupLayout::GetColumnRowConstraints(enum orientation orientation, int32 index,
|
||||||
|
ColumnRowConstraints* constraints)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < fVisibleItems.CountItems()) {
|
||||||
|
BLayoutItem* item = (BLayoutItem*)fVisibleItems.ItemAt(index);
|
||||||
|
constraints->min = -1;
|
||||||
|
constraints->max = B_SIZE_UNLIMITED;
|
||||||
|
if (ItemLayoutData* data = _LayoutDataForItem(item))
|
||||||
|
constraints->weight = data->weight;
|
||||||
|
else
|
||||||
|
constraints->weight = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemDimensions
|
||||||
|
void
|
||||||
|
BGroupLayout::GetItemDimensions(BLayoutItem* item, Dimensions* dimensions)
|
||||||
|
{
|
||||||
|
int32 index = fVisibleItems.IndexOf(item);
|
||||||
|
if (index < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fOrientation == B_HORIZONTAL) {
|
||||||
|
dimensions->x = index;
|
||||||
|
dimensions->y = 0;
|
||||||
|
dimensions->width = 1;
|
||||||
|
dimensions->height = 1;
|
||||||
|
} else {
|
||||||
|
dimensions->x = 0;
|
||||||
|
dimensions->y = index;
|
||||||
|
dimensions->width = 1;
|
||||||
|
dimensions->height = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _LayoutDataForItem
|
||||||
|
BGroupLayout::ItemLayoutData*
|
||||||
|
BGroupLayout::_LayoutDataForItem(BLayoutItem* item) const
|
||||||
|
{
|
||||||
|
if (!item)
|
||||||
|
return NULL;
|
||||||
|
return (ItemLayoutData*)item->LayoutData();
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::nothrow;
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGroupLayoutBuilder::BGroupLayoutBuilder(enum orientation orientation,
|
||||||
|
float spacing)
|
||||||
|
: fRootLayout((new BGroupView(orientation, spacing))->GroupLayout())
|
||||||
|
{
|
||||||
|
_PushLayout(fRootLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGroupLayoutBuilder::BGroupLayoutBuilder(BGroupLayout* layout)
|
||||||
|
: fRootLayout(layout)
|
||||||
|
{
|
||||||
|
_PushLayout(fRootLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGroupLayoutBuilder::BGroupLayoutBuilder(BGroupView* view)
|
||||||
|
: fRootLayout(view->GroupLayout())
|
||||||
|
{
|
||||||
|
_PushLayout(fRootLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RootLayout
|
||||||
|
BGroupLayout*
|
||||||
|
BGroupLayoutBuilder::RootLayout() const
|
||||||
|
{
|
||||||
|
return fRootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TopLayout
|
||||||
|
BGroupLayout*
|
||||||
|
BGroupLayoutBuilder::TopLayout() const
|
||||||
|
{
|
||||||
|
int32 count = fLayoutStack.CountItems();
|
||||||
|
return (count > 0
|
||||||
|
? (BGroupLayout*)fLayoutStack.ItemAt(count - 1) : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTopLayout
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::GetTopLayout(BGroupLayout** _layout)
|
||||||
|
{
|
||||||
|
*_layout = TopLayout();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetTopView
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::GetTopView(BView** _view)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout())
|
||||||
|
*_view = layout->View();
|
||||||
|
else
|
||||||
|
*_view = NULL;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::Add(BView* view)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout())
|
||||||
|
layout->AddView(view);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::Add(BView* view, float weight)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout())
|
||||||
|
layout->AddView(view, weight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::Add(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout())
|
||||||
|
layout->AddItem(item);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::Add(BLayoutItem* item, float weight)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout())
|
||||||
|
layout->AddItem(item, weight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddGroup
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::AddGroup(enum orientation orientation,
|
||||||
|
float spacing = 0.0f, float weight = 1.0f)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout()) {
|
||||||
|
BGroupView* group = new(nothrow) BGroupView(orientation, spacing);
|
||||||
|
if (group) {
|
||||||
|
if (layout->AddView(group, weight))
|
||||||
|
_PushLayout(group->GroupLayout());
|
||||||
|
else
|
||||||
|
delete group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// End
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::End()
|
||||||
|
{
|
||||||
|
_PopLayout();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddGlue
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::AddGlue(float weight = 1.0f)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout())
|
||||||
|
layout->AddItem(BSpaceLayoutItem::CreateGlue(), weight);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddStrut
|
||||||
|
BGroupLayoutBuilder&
|
||||||
|
BGroupLayoutBuilder::AddStrut(float size)
|
||||||
|
{
|
||||||
|
if (BGroupLayout* layout = TopLayout()) {
|
||||||
|
if (layout->Orientation() == B_HORIZONTAL)
|
||||||
|
layout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(size));
|
||||||
|
else
|
||||||
|
layout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(size));
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cast operator BGroupLayout*
|
||||||
|
BGroupLayoutBuilder::operator BGroupLayout*()
|
||||||
|
{
|
||||||
|
return fRootLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cast operator BView*
|
||||||
|
BGroupLayoutBuilder::operator BView*()
|
||||||
|
{
|
||||||
|
return fRootLayout->View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// _PushLayout
|
||||||
|
bool
|
||||||
|
BGroupLayoutBuilder::_PushLayout(BGroupLayout* layout)
|
||||||
|
{
|
||||||
|
return fLayoutStack.AddItem(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _PopLayout
|
||||||
|
void
|
||||||
|
BGroupLayoutBuilder::_PopLayout()
|
||||||
|
{
|
||||||
|
int32 count = fLayoutStack.CountItems();
|
||||||
|
if (count > 0)
|
||||||
|
fLayoutStack.RemoveItem(count - 1);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <GroupView.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BGroupView::BGroupView(enum orientation orientation, float spacing)
|
||||||
|
: BView(NULL, 0, new BGroupLayout(orientation, spacing))
|
||||||
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BGroupView::~BGroupView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLayout
|
||||||
|
void
|
||||||
|
BGroupView::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
// only BGroupLayouts are allowed
|
||||||
|
if (!dynamic_cast<BGroupLayout*>(layout))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BView::SetLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupLayout
|
||||||
|
BGroupLayout*
|
||||||
|
BGroupView::GroupLayout() const
|
||||||
|
{
|
||||||
|
return dynamic_cast<BGroupLayout*>(GetLayout());
|
||||||
|
}
|
||||||
@@ -27,14 +27,23 @@ SetSubDirSupportedPlatforms haiku libbe_test ;
|
|||||||
|
|
||||||
UsePrivateHeaders app input interface shared tracker ;
|
UsePrivateHeaders app input interface shared tracker ;
|
||||||
|
|
||||||
|
# qoca headers
|
||||||
|
SubDirSysHdrs $(SUBDIR) ;
|
||||||
|
SubDirHdrs [ FDirName $(SUBDIR) qoca ] ;
|
||||||
|
|
||||||
|
|
||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) BTextView ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) BTextView ] ;
|
||||||
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
|
||||||
|
|
||||||
MergeObject <libbe>interface_kit.o :
|
MergeObject <libbe>interface_kit.o :
|
||||||
|
AbstractLayoutItem.cpp
|
||||||
Alert.cpp
|
Alert.cpp
|
||||||
|
Alignment.cpp
|
||||||
Bitmap.cpp
|
Bitmap.cpp
|
||||||
BMCPrivate.cpp
|
BMCPrivate.cpp
|
||||||
Box.cpp
|
Box.cpp
|
||||||
Button.cpp
|
Button.cpp
|
||||||
|
CardLayout.cpp
|
||||||
ChannelControl.cpp
|
ChannelControl.cpp
|
||||||
ChannelSlider.cpp
|
ChannelSlider.cpp
|
||||||
CheckBox.cpp
|
CheckBox.cpp
|
||||||
@@ -48,8 +57,18 @@ MergeObject <libbe>interface_kit.o :
|
|||||||
Dragger.cpp
|
Dragger.cpp
|
||||||
Font.cpp
|
Font.cpp
|
||||||
GraphicsDefs.cpp
|
GraphicsDefs.cpp
|
||||||
|
GridLayout.cpp
|
||||||
|
GridLayoutBuilder.cpp
|
||||||
|
GridView.cpp
|
||||||
|
GroupLayout.cpp
|
||||||
|
GroupLayoutBuilder.cpp
|
||||||
|
GroupView.cpp
|
||||||
Input.cpp
|
Input.cpp
|
||||||
InterfaceDefs.cpp
|
InterfaceDefs.cpp
|
||||||
|
Layout.cpp
|
||||||
|
LayoutContext.cpp
|
||||||
|
LayoutItem.cpp
|
||||||
|
LayoutUtils.cpp
|
||||||
ListItem.cpp
|
ListItem.cpp
|
||||||
ListView.cpp
|
ListView.cpp
|
||||||
Menu.cpp
|
Menu.cpp
|
||||||
@@ -77,14 +96,21 @@ MergeObject <libbe>interface_kit.o :
|
|||||||
SeparatorItem.cpp
|
SeparatorItem.cpp
|
||||||
Shape.cpp
|
Shape.cpp
|
||||||
Shelf.cpp
|
Shelf.cpp
|
||||||
|
Size.cpp
|
||||||
Slider.cpp
|
Slider.cpp
|
||||||
|
SpaceLayoutItem.cpp
|
||||||
|
SplitLayout.cpp
|
||||||
|
SplitLayoutBuilder.cpp
|
||||||
|
SplitView.cpp
|
||||||
StatusBar.cpp
|
StatusBar.cpp
|
||||||
StringView.cpp
|
StringView.cpp
|
||||||
TabView.cpp
|
TabView.cpp
|
||||||
TextControl.cpp
|
TextControl.cpp
|
||||||
TextInput.cpp
|
TextInput.cpp
|
||||||
TPicture.cpp
|
TPicture.cpp
|
||||||
|
TwoDimensionalLayout.cpp
|
||||||
View.cpp
|
View.cpp
|
||||||
|
ViewLayoutItem.cpp
|
||||||
Window.cpp
|
Window.cpp
|
||||||
ZombieReplicantView.cpp
|
ZombieReplicantView.cpp
|
||||||
|
|
||||||
@@ -96,4 +122,12 @@ MergeObject <libbe>interface_kit.o :
|
|||||||
TextView.cpp
|
TextView.cpp
|
||||||
UndoBuffer.cpp
|
UndoBuffer.cpp
|
||||||
WidthBuffer.cpp
|
WidthBuffer.cpp
|
||||||
|
|
||||||
|
# layouter
|
||||||
|
ConstraintSolverLayouter.cpp
|
||||||
|
Layouter.cpp
|
||||||
|
OneElementLayouter.cpp
|
||||||
|
SimpleLayouter.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SubInclude HAIKU_TOP src kits interface qoca ;
|
||||||
|
|||||||
@@ -0,0 +1,204 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Layout.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
#include "ViewLayoutItem.h"
|
||||||
|
|
||||||
|
using std::nothrow;
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BLayout::BLayout()
|
||||||
|
: fView(NULL),
|
||||||
|
fItems(20)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BLayout::~BLayout()
|
||||||
|
{
|
||||||
|
// this deletes all items
|
||||||
|
SetView(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// View
|
||||||
|
BView*
|
||||||
|
BLayout::View() const
|
||||||
|
{
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BLayout::AddView(BView* child)
|
||||||
|
{
|
||||||
|
return AddView(-1, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddView
|
||||||
|
BLayoutItem*
|
||||||
|
BLayout::AddView(int32 index, BView* child)
|
||||||
|
{
|
||||||
|
if (BViewLayoutItem* item = new(nothrow) BViewLayoutItem(child)) {
|
||||||
|
if (AddItem(index, item))
|
||||||
|
return item;
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BLayout::AddItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
return AddItem(-1, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddItem
|
||||||
|
bool
|
||||||
|
BLayout::AddItem(int32 index, BLayoutItem* item)
|
||||||
|
{
|
||||||
|
if (!fView || !item || fItems.HasItem(item))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// if the item refers to a BView, we make sure, it is added to the parent
|
||||||
|
// view
|
||||||
|
BView* view = item->View();
|
||||||
|
if (view && view->fParent != fView && !fView->_AddChild(view, NULL))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// validate the index
|
||||||
|
if (index < 0 || index > fItems.CountItems())
|
||||||
|
index = fItems.CountItems();
|
||||||
|
|
||||||
|
fItems.AddItem(item, index);
|
||||||
|
ItemAdded(item);
|
||||||
|
item->SetLayout(this);
|
||||||
|
InvalidateLayout();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveView
|
||||||
|
bool
|
||||||
|
BLayout::RemoveView(BView* child)
|
||||||
|
{
|
||||||
|
int32 index = IndexOfView(child);
|
||||||
|
if (index >= 0) {
|
||||||
|
if (BLayoutItem* item = RemoveItem(index)) {
|
||||||
|
delete item;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveItem
|
||||||
|
bool
|
||||||
|
BLayout::RemoveItem(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
int32 index = IndexOfItem(item);
|
||||||
|
return (index >= 0 ? RemoveItem(index) : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveItem
|
||||||
|
BLayoutItem*
|
||||||
|
BLayout::RemoveItem(int32 index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= fItems.CountItems())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
BLayoutItem* item = (BLayoutItem*)fItems.RemoveItem(index);
|
||||||
|
|
||||||
|
// if the item refers to a BView, we make sure, it is removed from the
|
||||||
|
// parent view
|
||||||
|
BView* view = item->View();
|
||||||
|
if (view && view->fParent == fView)
|
||||||
|
view->_RemoveSelf();
|
||||||
|
|
||||||
|
item->SetLayout(NULL);
|
||||||
|
ItemRemoved(item);
|
||||||
|
InvalidateLayout();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemAt
|
||||||
|
BLayoutItem*
|
||||||
|
BLayout::ItemAt(int32 index) const
|
||||||
|
{
|
||||||
|
return (BLayoutItem*)fItems.ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountItems
|
||||||
|
int32
|
||||||
|
BLayout::CountItems() const
|
||||||
|
{
|
||||||
|
return fItems.CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
// IndexOfItem
|
||||||
|
int32
|
||||||
|
BLayout::IndexOfItem(BLayoutItem* item) const
|
||||||
|
{
|
||||||
|
return fItems.IndexOf(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IndexOfView
|
||||||
|
int32
|
||||||
|
BLayout::IndexOfView(BView* child) const
|
||||||
|
{
|
||||||
|
int itemCount = fItems.CountItems();
|
||||||
|
for (int32 i = 0; i < itemCount; i++) {
|
||||||
|
BLayoutItem* item = (BLayoutItem*)fItems.ItemAt(i);
|
||||||
|
if (dynamic_cast<BViewLayoutItem*>(item) && item->View() == child)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidateLayout
|
||||||
|
void
|
||||||
|
BLayout::InvalidateLayout()
|
||||||
|
{
|
||||||
|
if (fView)
|
||||||
|
fView->InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemAdded
|
||||||
|
void
|
||||||
|
BLayout::ItemAdded(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ItemRemoved
|
||||||
|
void
|
||||||
|
BLayout::ItemRemoved(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetView
|
||||||
|
void
|
||||||
|
BLayout::SetView(BView* view)
|
||||||
|
{
|
||||||
|
if (view != fView) {
|
||||||
|
fView = NULL;
|
||||||
|
|
||||||
|
// remove and delete all items
|
||||||
|
for (int32 i = CountItems() - 1; i >= 0; i--)
|
||||||
|
delete RemoveItem(i);
|
||||||
|
|
||||||
|
fView = view;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LayoutContext.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BLayoutContextListener::BLayoutContextListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BLayoutContextListener::~BLayoutContextListener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BLayoutContext::BLayoutContext()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BLayoutContext::~BLayoutContext()
|
||||||
|
{
|
||||||
|
// notify the listeners
|
||||||
|
for (int32 i = 0;
|
||||||
|
BLayoutContextListener* listener
|
||||||
|
= (BLayoutContextListener*)fListeners.ItemAt(i);
|
||||||
|
i++) {
|
||||||
|
listener->LayoutContextLeft(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddListener
|
||||||
|
void
|
||||||
|
BLayoutContext::AddListener(BLayoutContextListener* listener)
|
||||||
|
{
|
||||||
|
if (listener)
|
||||||
|
fListeners.AddItem(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveListener
|
||||||
|
void
|
||||||
|
BLayoutContext::RemoveListener(BLayoutContextListener* listener)
|
||||||
|
{
|
||||||
|
if (listener)
|
||||||
|
fListeners.RemoveItem(listener);
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LayoutItem.h>
|
||||||
|
|
||||||
|
#include <Layout.h>
|
||||||
|
#include <LayoutUtils.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BLayoutItem::BLayoutItem()
|
||||||
|
: fLayout(NULL),
|
||||||
|
fLayoutData(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BLayoutItem::~BLayoutItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Layout
|
||||||
|
BLayout*
|
||||||
|
BLayoutItem::Layout() const
|
||||||
|
{
|
||||||
|
return fLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasHeightForWidth
|
||||||
|
bool
|
||||||
|
BLayoutItem::HasHeightForWidth()
|
||||||
|
{
|
||||||
|
// no "height for width" by default
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHeightForWidth
|
||||||
|
void
|
||||||
|
BLayoutItem::GetHeightForWidth(float width, float* min, float* max,
|
||||||
|
float* preferred)
|
||||||
|
{
|
||||||
|
// no "height for width" by default
|
||||||
|
}
|
||||||
|
|
||||||
|
// View
|
||||||
|
BView*
|
||||||
|
BLayoutItem::View()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidateLayout
|
||||||
|
void
|
||||||
|
BLayoutItem::InvalidateLayout()
|
||||||
|
{
|
||||||
|
if (fLayout)
|
||||||
|
fLayout->InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// LayoutData
|
||||||
|
void*
|
||||||
|
BLayoutItem::LayoutData() const
|
||||||
|
{
|
||||||
|
return fLayoutData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLayoutData
|
||||||
|
void
|
||||||
|
BLayoutItem::SetLayoutData(void* data)
|
||||||
|
{
|
||||||
|
fLayoutData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlignInFrame
|
||||||
|
void
|
||||||
|
BLayoutItem::AlignInFrame(BRect frame)
|
||||||
|
{
|
||||||
|
BSize maxSize = MaxSize();
|
||||||
|
BAlignment alignment = Alignment();
|
||||||
|
|
||||||
|
if (HasHeightForWidth()) {
|
||||||
|
// The item has height for width, so we do the horizontal alignment
|
||||||
|
// ourselves and restrict the height max constraint respectively.
|
||||||
|
if (maxSize.width < frame.Width()
|
||||||
|
&& alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
|
||||||
|
frame.left += (int)((frame.Width() - maxSize.width)
|
||||||
|
* alignment.horizontal);
|
||||||
|
frame.right = frame.left + maxSize.width;
|
||||||
|
}
|
||||||
|
alignment.horizontal = B_ALIGN_USE_FULL_WIDTH;
|
||||||
|
|
||||||
|
float minHeight;
|
||||||
|
GetHeightForWidth(frame.Width(), &minHeight, NULL, NULL);
|
||||||
|
|
||||||
|
frame.bottom = frame.top + max_c(frame.Height(), minHeight);
|
||||||
|
maxSize.height = minHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFrame(BLayoutUtils::AlignInFrame(frame, maxSize, alignment));
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLayout
|
||||||
|
void
|
||||||
|
BLayoutItem::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
fLayout = layout;
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LayoutUtils.h>
|
||||||
|
|
||||||
|
|
||||||
|
// // AddSizesFloat
|
||||||
|
// float
|
||||||
|
// BLayoutUtils::AddSizesFloat(float a, float b)
|
||||||
|
// {
|
||||||
|
// float sum = a + b + 1;
|
||||||
|
// if (sum >= B_SIZE_UNLIMITED)
|
||||||
|
// return B_SIZE_UNLIMITED;
|
||||||
|
//
|
||||||
|
// return sum;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // AddSizesFloat
|
||||||
|
// float
|
||||||
|
// BLayoutUtils::AddSizesFloat(float a, float b, float c)
|
||||||
|
// {
|
||||||
|
// return AddSizesFloat(AddSizesFloat(a, b), c);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// AddSizesInt32
|
||||||
|
int32
|
||||||
|
BLayoutUtils::AddSizesInt32(int32 a, int32 b)
|
||||||
|
{
|
||||||
|
if (a >= B_SIZE_UNLIMITED - b)
|
||||||
|
return B_SIZE_UNLIMITED;
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSizesInt32
|
||||||
|
int32
|
||||||
|
BLayoutUtils::AddSizesInt32(int32 a, int32 b, int32 c)
|
||||||
|
{
|
||||||
|
return AddSizesInt32(AddSizesInt32(a, b), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDistances
|
||||||
|
float
|
||||||
|
BLayoutUtils::AddDistances(float a, float b)
|
||||||
|
{
|
||||||
|
float sum = a + b + 1;
|
||||||
|
if (sum >= B_SIZE_UNLIMITED)
|
||||||
|
return B_SIZE_UNLIMITED;
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddDistances
|
||||||
|
float
|
||||||
|
BLayoutUtils::AddDistances(float a, float b, float c)
|
||||||
|
{
|
||||||
|
return AddDistances(AddDistances(a, b), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// // SubtractSizesFloat
|
||||||
|
// float
|
||||||
|
// BLayoutUtils::SubtractSizesFloat(float a, float b)
|
||||||
|
// {
|
||||||
|
// if (a < b)
|
||||||
|
// return -1;
|
||||||
|
// return a - b - 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// SubtractSizesInt32
|
||||||
|
int32
|
||||||
|
BLayoutUtils::SubtractSizesInt32(int32 a, int32 b)
|
||||||
|
{
|
||||||
|
if (a < b)
|
||||||
|
return 0;
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubtractDistances
|
||||||
|
float
|
||||||
|
BLayoutUtils::SubtractDistances(float a, float b)
|
||||||
|
{
|
||||||
|
if (a < b)
|
||||||
|
return -1;
|
||||||
|
return a - b - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComposeSize
|
||||||
|
BSize
|
||||||
|
BLayoutUtils::ComposeSize(BSize size, BSize layoutSize)
|
||||||
|
{
|
||||||
|
if (!size.IsWidthSet())
|
||||||
|
size.width = layoutSize.width;
|
||||||
|
if (!size.IsHeightSet())
|
||||||
|
size.height = layoutSize.height;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComposeAlignment
|
||||||
|
BAlignment
|
||||||
|
BLayoutUtils::ComposeAlignment(BAlignment alignment, BAlignment layoutAlignment)
|
||||||
|
{
|
||||||
|
if (!alignment.IsHorizontalSet())
|
||||||
|
alignment.horizontal = layoutAlignment.horizontal;
|
||||||
|
if (!alignment.IsVerticalSet())
|
||||||
|
alignment.vertical = layoutAlignment.vertical;
|
||||||
|
|
||||||
|
return alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlignInFrame
|
||||||
|
BRect
|
||||||
|
BLayoutUtils::AlignInFrame(BRect frame, BSize maxSize, BAlignment alignment)
|
||||||
|
{
|
||||||
|
// align according to the given alignment
|
||||||
|
if (maxSize.width < frame.Width()
|
||||||
|
&& alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
|
||||||
|
frame.left += (int)((frame.Width() - maxSize.width)
|
||||||
|
* alignment.RelativeHorizontal());
|
||||||
|
frame.right = frame.left + maxSize.width;
|
||||||
|
}
|
||||||
|
if (maxSize.height < frame.Height()
|
||||||
|
&& alignment.vertical != B_ALIGN_USE_FULL_HEIGHT) {
|
||||||
|
frame.top += (int)((frame.Height() - maxSize.height)
|
||||||
|
* alignment.RelativeVertical());
|
||||||
|
frame.bottom = frame.top + maxSize.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AlignInFrame
|
||||||
|
void
|
||||||
|
BLayoutUtils::AlignInFrame(BView* view, BRect frame)
|
||||||
|
{
|
||||||
|
// TODO:...
|
||||||
|
// BSize maxSize = view->MaxSize();
|
||||||
|
// BAlignment alignment = view->Alignment();
|
||||||
|
//
|
||||||
|
// if (view->HasHeightForWidth()) {
|
||||||
|
// // The view has height for width, so we do the horizontal alignment
|
||||||
|
// // ourselves and restrict the height max constraint respectively.
|
||||||
|
//
|
||||||
|
// if (maxSize.width < frame.width
|
||||||
|
// && alignment.horizontal != B_ALIGN_USE_FULL_WIDTH) {
|
||||||
|
// frame.x += (int)((frame.width - maxSize.width)
|
||||||
|
// * alignment.RelativeHorizontal());
|
||||||
|
// frame.width = maxSize.width;
|
||||||
|
// }
|
||||||
|
// alignment.horizontal = BAlignment.B_ALIGN_USE_FULL_WIDTH;
|
||||||
|
//
|
||||||
|
// float minHeight;
|
||||||
|
// float maxHeight;
|
||||||
|
// float preferredHeight;
|
||||||
|
// view->GetHeightForWidth(frame.width, &minHeight, &maxHeight,
|
||||||
|
// &preferredHeight);
|
||||||
|
//
|
||||||
|
// frame.height = max_c(frame.height, info.min);
|
||||||
|
// maxSize.height = minHeight;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// frame = AlignInFrame(frame, maxSize, alignment);
|
||||||
|
// view->SetLocation(frame.x, frame.y);
|
||||||
|
// view->SetSize(frame.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
#include <LayoutUtils.h>
|
||||||
#include <PropertyInfo.h>
|
#include <PropertyInfo.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
@@ -1092,6 +1093,24 @@ BListView::AllDetached()
|
|||||||
BView::AllDetached();
|
BView::AllDetached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BListView::MinSize()
|
||||||
|
{
|
||||||
|
// We need a stable min size: the BView implementation uses
|
||||||
|
// GetPreferredSize(), which by default just returns the current size.
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMinSize(), BSize(10, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BListView::PreferredSize()
|
||||||
|
{
|
||||||
|
// We need a stable preferred size: the BView implementation uses
|
||||||
|
// GetPreferredSize(), which by default just returns the current size.
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), BSize(100, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// DoMiscellaneous
|
// DoMiscellaneous
|
||||||
bool
|
bool
|
||||||
BListView::DoMiscellaneous(MiscCode code, MiscData *data)
|
BListView::DoMiscellaneous(MiscCode code, MiscData *data)
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
* Stefano Ceccherini (burton666@libero.it)
|
* Stefano Ceccherini (burton666@libero.it)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <MenuBar.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <MenuBar.h>
|
#include <LayoutUtils.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -297,6 +299,21 @@ BMenuBar::Perform(perform_code d, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuBar::MaxSize()
|
||||||
|
{
|
||||||
|
// TODO: cache the result
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
|
||||||
|
BSize(B_SIZE_UNLIMITED, height));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
void BMenuBar::_ReservedMenuBar1() {}
|
void BMenuBar::_ReservedMenuBar1() {}
|
||||||
void BMenuBar::_ReservedMenuBar2() {}
|
void BMenuBar::_ReservedMenuBar2() {}
|
||||||
void BMenuBar::_ReservedMenuBar3() {}
|
void BMenuBar::_ReservedMenuBar3() {}
|
||||||
|
|||||||
@@ -5,11 +5,14 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Marc Flerackers (mflerackers@androme.be)
|
* Marc Flerackers (mflerackers@androme.be)
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <AbstractLayoutItem.h>
|
||||||
|
#include <LayoutUtils.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
@@ -17,6 +20,55 @@
|
|||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BMenuField::LabelLayoutItem : public BAbstractLayoutItem {
|
||||||
|
public:
|
||||||
|
LabelLayoutItem(BMenuField* parent);
|
||||||
|
|
||||||
|
virtual bool IsVisible();
|
||||||
|
virtual void SetVisible(bool visible);
|
||||||
|
|
||||||
|
virtual BRect Frame();
|
||||||
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual BSize BaseMinSize();
|
||||||
|
virtual BSize BaseMaxSize();
|
||||||
|
virtual BSize BasePreferredSize();
|
||||||
|
virtual BAlignment BaseAlignment();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BMenuField* fParent;
|
||||||
|
BRect fFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BMenuField::MenuBarLayoutItem : public BAbstractLayoutItem {
|
||||||
|
public:
|
||||||
|
MenuBarLayoutItem(BMenuField* parent);
|
||||||
|
|
||||||
|
virtual bool IsVisible();
|
||||||
|
virtual void SetVisible(bool visible);
|
||||||
|
|
||||||
|
virtual BRect Frame();
|
||||||
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual BSize BaseMinSize();
|
||||||
|
virtual BSize BaseMaxSize();
|
||||||
|
virtual BSize BasePreferredSize();
|
||||||
|
virtual BAlignment BaseAlignment();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BMenuField* fParent;
|
||||||
|
BRect fFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
static float kVMargin = 2.0f;
|
static float kVMargin = 2.0f;
|
||||||
|
|
||||||
|
|
||||||
@@ -25,19 +77,9 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
|
|||||||
: BView(frame, name, resize, flags)
|
: BView(frame, name, resize, flags)
|
||||||
{
|
{
|
||||||
InitObject(label);
|
InitObject(label);
|
||||||
SetFont(be_plain_font);
|
|
||||||
fMenu = menu;
|
|
||||||
InitMenu(menu);
|
|
||||||
|
|
||||||
frame.OffsetTo(B_ORIGIN);
|
frame.OffsetTo(B_ORIGIN);
|
||||||
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 1,
|
_InitMenuBar(menu, frame, false);
|
||||||
frame.top + kVMargin, frame.right, frame.bottom - kVMargin),
|
|
||||||
false, this);
|
|
||||||
|
|
||||||
AddChild(fMenuBar);
|
|
||||||
fMenuBar->AddItem(menu);
|
|
||||||
|
|
||||||
fMenuBar->SetFont(be_plain_font);
|
|
||||||
|
|
||||||
InitObject2();
|
InitObject2();
|
||||||
}
|
}
|
||||||
@@ -48,21 +90,37 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
|
|||||||
: BView(frame, name, resize, flags)
|
: BView(frame, name, resize, flags)
|
||||||
{
|
{
|
||||||
InitObject(label);
|
InitObject(label);
|
||||||
SetFont(be_plain_font);
|
|
||||||
fMenu = menu;
|
|
||||||
InitMenu(menu);
|
|
||||||
|
|
||||||
fFixedSizeMB = fixedSize;
|
fFixedSizeMB = fixedSize;
|
||||||
|
|
||||||
frame.OffsetTo(B_ORIGIN);
|
frame.OffsetTo(B_ORIGIN);
|
||||||
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 1,
|
_InitMenuBar(menu, frame, fixedSize);
|
||||||
frame.top + kVMargin, frame.right, frame.bottom - kVMargin),
|
|
||||||
fixedSize, this);
|
|
||||||
|
|
||||||
AddChild(fMenuBar);
|
InitObject2();
|
||||||
fMenuBar->AddItem(menu);
|
}
|
||||||
|
|
||||||
fMenuBar->SetFont(be_plain_font);
|
|
||||||
|
BMenuField::BMenuField(const char* name, const char* label, BMenu* menu,
|
||||||
|
BMessage* message, uint32 flags)
|
||||||
|
: BView(BRect(0, 0, -1, -1), name, B_FOLLOW_NONE,
|
||||||
|
flags | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||||
|
{
|
||||||
|
InitObject(label);
|
||||||
|
|
||||||
|
_InitMenuBar(menu, BRect(0, 0, 100, 15), false);
|
||||||
|
|
||||||
|
InitObject2();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMenuField::BMenuField(const char* label,
|
||||||
|
BMenu* menu, BMessage* message)
|
||||||
|
: BView(BRect(0, 0, -1, -1), NULL, B_FOLLOW_NONE,
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||||
|
{
|
||||||
|
InitObject(label);
|
||||||
|
|
||||||
|
_InitMenuBar(menu, BRect(0, 0, 100, 15), false);
|
||||||
|
|
||||||
InitObject2();
|
InitObject2();
|
||||||
}
|
}
|
||||||
@@ -371,6 +429,8 @@ BMenuField::SetLabel(const char *label)
|
|||||||
if (fLabel)
|
if (fLabel)
|
||||||
fStringWidth = StringWidth(fLabel);
|
fStringWidth = StringWidth(fLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -430,8 +490,23 @@ BMenuField::SetDivider(float divider)
|
|||||||
|
|
||||||
fDivider = divider;
|
fDivider = divider;
|
||||||
|
|
||||||
MenuBar()->MoveBy(-dx, 0.0f);
|
BRect dirty(fMenuBar->Frame());
|
||||||
MenuBar()->ResizeBy(dx, 0.0f);
|
|
||||||
|
fMenuBar->MoveTo(fDivider + 1, kVMargin);
|
||||||
|
|
||||||
|
if (fFixedSizeMB) {
|
||||||
|
fMenuBar->ResizeTo(Bounds().Width() - fDivider + 1 - 2,
|
||||||
|
dirty.Height());
|
||||||
|
}
|
||||||
|
|
||||||
|
dirty = dirty | fMenuBar->Frame();
|
||||||
|
|
||||||
|
dirty.left -= 1;
|
||||||
|
dirty.top -= 1;
|
||||||
|
dirty.right += 2;
|
||||||
|
dirty.bottom += 2;
|
||||||
|
|
||||||
|
Invalidate(dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -525,6 +600,24 @@ BMenuField::GetPreferredSize(float *_width, float *_height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayoutItem*
|
||||||
|
BMenuField::CreateLabelLayoutItem()
|
||||||
|
{
|
||||||
|
if (!fLabelLayoutItem)
|
||||||
|
fLabelLayoutItem = new LabelLayoutItem(this);
|
||||||
|
return fLabelLayoutItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayoutItem*
|
||||||
|
BMenuField::CreateMenuBarLayoutItem()
|
||||||
|
{
|
||||||
|
if (!fMenuBarLayoutItem)
|
||||||
|
fMenuBarLayoutItem = new MenuBarLayoutItem(this);
|
||||||
|
return fMenuBarLayoutItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMenuField::Perform(perform_code d, void *arg)
|
BMenuField::Perform(perform_code d, void *arg)
|
||||||
{
|
{
|
||||||
@@ -557,6 +650,8 @@ BMenuField::InitObject(const char *label)
|
|||||||
fTransition = false;
|
fTransition = false;
|
||||||
fFixedSizeMB = false;
|
fFixedSizeMB = false;
|
||||||
fMenuTaskID = -1;
|
fMenuTaskID = -1;
|
||||||
|
fLabelLayoutItem = NULL;
|
||||||
|
fMenuBarLayoutItem = NULL;
|
||||||
|
|
||||||
SetLabel(label);
|
SetLabel(label);
|
||||||
|
|
||||||
@@ -662,3 +757,206 @@ BMenuField::MenuTask(void *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenuField::_UpdateFrame()
|
||||||
|
{
|
||||||
|
if (fLabelLayoutItem && fMenuBarLayoutItem) {
|
||||||
|
BRect labelFrame = fLabelLayoutItem->Frame();
|
||||||
|
BRect menuFrame = fMenuBarLayoutItem->Frame();
|
||||||
|
MoveTo(labelFrame.left, labelFrame.top);
|
||||||
|
ResizeTo(menuFrame.left + menuFrame.Width() - labelFrame.left,
|
||||||
|
menuFrame.top + menuFrame.Height() - labelFrame.top);
|
||||||
|
SetDivider(menuFrame.left - labelFrame.left);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenuField::_InitMenuBar(BMenu* menu, BRect frame, bool fixedSize)
|
||||||
|
{
|
||||||
|
fMenu = menu;
|
||||||
|
InitMenu(menu);
|
||||||
|
|
||||||
|
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 1,
|
||||||
|
frame.top + kVMargin, frame.right, frame.bottom - kVMargin),
|
||||||
|
fixedSize, this);
|
||||||
|
|
||||||
|
AddChild(fMenuBar);
|
||||||
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
|
fMenuBar->SetFont(be_plain_font);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BMenuField::LabelLayoutItem::LabelLayoutItem(BMenuField* parent)
|
||||||
|
: fParent(parent),
|
||||||
|
fFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BMenuField::LabelLayoutItem::IsVisible()
|
||||||
|
{
|
||||||
|
return !fParent->IsHidden(fParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenuField::LabelLayoutItem::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
// not allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BMenuField::LabelLayoutItem::Frame()
|
||||||
|
{
|
||||||
|
return fFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenuField::LabelLayoutItem::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fFrame = frame;
|
||||||
|
fParent->_UpdateFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView*
|
||||||
|
BMenuField::LabelLayoutItem::View()
|
||||||
|
{
|
||||||
|
return fParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuField::LabelLayoutItem::BaseMinSize()
|
||||||
|
{
|
||||||
|
// TODO: Cache the info. Might be too expensive for this call.
|
||||||
|
const char* label = fParent->Label();
|
||||||
|
if (!label)
|
||||||
|
return BSize(-1, -1);
|
||||||
|
|
||||||
|
BSize size;
|
||||||
|
fParent->GetPreferredSize(NULL, &size.height);
|
||||||
|
|
||||||
|
size.width = fParent->StringWidth(label) + 2 * 3 - 1;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuField::LabelLayoutItem::BaseMaxSize()
|
||||||
|
{
|
||||||
|
return BaseMinSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuField::LabelLayoutItem::BasePreferredSize()
|
||||||
|
{
|
||||||
|
return BaseMinSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BMenuField::LabelLayoutItem::BaseAlignment()
|
||||||
|
{
|
||||||
|
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BMenuField::MenuBarLayoutItem::MenuBarLayoutItem(BMenuField* parent)
|
||||||
|
: fParent(parent),
|
||||||
|
fFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BMenuField::MenuBarLayoutItem::IsVisible()
|
||||||
|
{
|
||||||
|
return !fParent->IsHidden(fParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenuField::MenuBarLayoutItem::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
// not allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BMenuField::MenuBarLayoutItem::Frame()
|
||||||
|
{
|
||||||
|
return fFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BMenuField::MenuBarLayoutItem::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fFrame = frame;
|
||||||
|
fParent->_UpdateFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView*
|
||||||
|
BMenuField::MenuBarLayoutItem::View()
|
||||||
|
{
|
||||||
|
return fParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuField::MenuBarLayoutItem::BaseMinSize()
|
||||||
|
{
|
||||||
|
// TODO: Cache the info. Might be too expensive for this call.
|
||||||
|
BSize size;
|
||||||
|
fParent->fMenuBar->GetPreferredSize(&size.width, &size.height);
|
||||||
|
|
||||||
|
// BMenuField draws additional lines around BMenuBar,
|
||||||
|
// one line on left and top side, two on right and bottom
|
||||||
|
size.width += 3;
|
||||||
|
size.height += 3;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuField::MenuBarLayoutItem::BaseMaxSize()
|
||||||
|
{
|
||||||
|
BSize size(BaseMinSize());
|
||||||
|
size.width = B_SIZE_UNLIMITED;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BMenuField::MenuBarLayoutItem::BasePreferredSize()
|
||||||
|
{
|
||||||
|
BSize size(BaseMinSize());
|
||||||
|
// puh, no idea...
|
||||||
|
size.width = 100;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BMenuField::MenuBarLayoutItem::BaseAlignment()
|
||||||
|
{
|
||||||
|
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,11 @@
|
|||||||
"multiple choice" control.
|
"multiple choice" control.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <RadioButton.h>
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <RadioButton.h>
|
#include <LayoutUtils.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -35,6 +36,35 @@ BRadioButton::BRadioButton(BRect frame, const char *name, const char *label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRadioButton::BRadioButton(const char *name, const char *label,
|
||||||
|
BMessage *message, uint32 flags)
|
||||||
|
: BControl(BRect(0, 0, -1, -1), name, label, message, B_FOLLOW_NONE,
|
||||||
|
flags | B_SUPPORTS_LAYOUT),
|
||||||
|
fOutlined(false)
|
||||||
|
{
|
||||||
|
// Resize to minimum height if needed
|
||||||
|
font_height fontHeight;
|
||||||
|
GetFontHeight(&fontHeight);
|
||||||
|
float minHeight = ceilf(6.0f + fontHeight.ascent + fontHeight.descent);
|
||||||
|
if (Bounds().Height() < minHeight)
|
||||||
|
ResizeTo(Bounds().Width(), minHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRadioButton::BRadioButton(const char *label, BMessage *message)
|
||||||
|
: BControl(BRect(0, 0, -1, -1), NULL, label, message, B_FOLLOW_NONE,
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE | B_SUPPORTS_LAYOUT),
|
||||||
|
fOutlined(false)
|
||||||
|
{
|
||||||
|
// Resize to minimum height if needed
|
||||||
|
font_height fontHeight;
|
||||||
|
GetFontHeight(&fontHeight);
|
||||||
|
float minHeight = ceilf(6.0f + fontHeight.ascent + fontHeight.descent);
|
||||||
|
if (Bounds().Height() < minHeight)
|
||||||
|
ResizeTo(Bounds().Width(), minHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BRadioButton::BRadioButton(BMessage *archive)
|
BRadioButton::BRadioButton(BMessage *archive)
|
||||||
: BControl(archive),
|
: BControl(archive),
|
||||||
fOutlined(false)
|
fOutlined(false)
|
||||||
@@ -466,6 +496,19 @@ BRadioButton::Perform(perform_code d, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BRadioButton::MaxSize()
|
||||||
|
{
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
|
||||||
|
BSize(B_SIZE_UNLIMITED, height));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BRadioButton::_ReservedRadioButton1() {}
|
void BRadioButton::_ReservedRadioButton1() {}
|
||||||
void BRadioButton::_ReservedRadioButton2() {}
|
void BRadioButton::_ReservedRadioButton2() {}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <LayoutUtils.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
@@ -594,6 +595,44 @@ BScrollView::GetSupportedSuites(BMessage *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BScrollView::MinSize()
|
||||||
|
{
|
||||||
|
// TODO: This is not yet correct.
|
||||||
|
BSize size = (fTarget ? fTarget->MinSize() : BSize(-1, -1));
|
||||||
|
|
||||||
|
if (fVerticalScrollBar)
|
||||||
|
size.width += B_V_SCROLL_BAR_WIDTH;
|
||||||
|
if (fHorizontalScrollBar)
|
||||||
|
size.height += B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
|
float borderSize = BorderSize(fBorder);
|
||||||
|
size.width += 2 * borderSize;
|
||||||
|
size.height += 2 * borderSize;
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BScrollView::PreferredSize()
|
||||||
|
{
|
||||||
|
// TODO: This is not yet correct.
|
||||||
|
BSize size = (fTarget ? fTarget->PreferredSize() : BSize(-1, -1));
|
||||||
|
|
||||||
|
if (fVerticalScrollBar)
|
||||||
|
size.width += B_V_SCROLL_BAR_WIDTH;
|
||||||
|
if (fHorizontalScrollBar)
|
||||||
|
size.height += B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
|
float borderSize = BorderSize(fBorder);
|
||||||
|
size.width += 2 * borderSize;
|
||||||
|
size.height += 2 * borderSize;
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BScrollView::Perform(perform_code d, void *arg)
|
BScrollView::Perform(perform_code d, void *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Size.h>
|
||||||
|
|
||||||
|
// completely implemented inline
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <SpaceLayoutItem.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BSpaceLayoutItem::BSpaceLayoutItem(BSize minSize, BSize maxSize,
|
||||||
|
BSize preferredSize, BAlignment alignment)
|
||||||
|
: fFrame(),
|
||||||
|
fMinSize(minSize),
|
||||||
|
fMaxSize(maxSize),
|
||||||
|
fPreferredSize(preferredSize),
|
||||||
|
fAlignment(alignment),
|
||||||
|
fVisible(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BSpaceLayoutItem::~BSpaceLayoutItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateGlue
|
||||||
|
BSpaceLayoutItem*
|
||||||
|
BSpaceLayoutItem::CreateGlue() {
|
||||||
|
return new BSpaceLayoutItem(
|
||||||
|
BSize(-1, -1),
|
||||||
|
BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED),
|
||||||
|
BSize(-1, -1),
|
||||||
|
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateHorizontalStrut
|
||||||
|
BSpaceLayoutItem*
|
||||||
|
BSpaceLayoutItem::CreateHorizontalStrut(float width) {
|
||||||
|
return new BSpaceLayoutItem(
|
||||||
|
BSize(width, -1),
|
||||||
|
BSize(width, B_SIZE_UNLIMITED),
|
||||||
|
BSize(width, -1),
|
||||||
|
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateVerticalStrut
|
||||||
|
BSpaceLayoutItem*
|
||||||
|
BSpaceLayoutItem::CreateVerticalStrut(float height) {
|
||||||
|
return new BSpaceLayoutItem(
|
||||||
|
BSize(-1, height),
|
||||||
|
BSize(B_SIZE_UNLIMITED, height),
|
||||||
|
BSize(-1, height),
|
||||||
|
BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinSize
|
||||||
|
BSize
|
||||||
|
BSpaceLayoutItem::MinSize()
|
||||||
|
{
|
||||||
|
return fMinSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSize
|
||||||
|
BSize
|
||||||
|
BSpaceLayoutItem::MaxSize()
|
||||||
|
{
|
||||||
|
return fMaxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferredSize
|
||||||
|
BSize
|
||||||
|
BSpaceLayoutItem::PreferredSize()
|
||||||
|
{
|
||||||
|
return fPreferredSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alignment
|
||||||
|
BAlignment
|
||||||
|
BSpaceLayoutItem::Alignment()
|
||||||
|
{
|
||||||
|
return fAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitMinSize
|
||||||
|
void
|
||||||
|
BSpaceLayoutItem::SetExplicitMinSize(BSize size)
|
||||||
|
{
|
||||||
|
if (size.IsWidthSet())
|
||||||
|
fMinSize.width = size.width;
|
||||||
|
if (size.IsHeightSet())
|
||||||
|
fMinSize.height = size.height;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitMaxSize
|
||||||
|
void
|
||||||
|
BSpaceLayoutItem::SetExplicitMaxSize(BSize size)
|
||||||
|
{
|
||||||
|
if (size.IsWidthSet())
|
||||||
|
fMaxSize.width = size.width;
|
||||||
|
if (size.IsHeightSet())
|
||||||
|
fMaxSize.height = size.height;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitPreferredSize
|
||||||
|
void
|
||||||
|
BSpaceLayoutItem::SetExplicitPreferredSize(BSize size)
|
||||||
|
{
|
||||||
|
if (size.IsWidthSet())
|
||||||
|
fPreferredSize.width = size.width;
|
||||||
|
if (size.IsHeightSet())
|
||||||
|
fPreferredSize.height = size.height;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitAlignment
|
||||||
|
void
|
||||||
|
BSpaceLayoutItem::SetExplicitAlignment(BAlignment alignment)
|
||||||
|
{
|
||||||
|
if (alignment.IsHorizontalSet())
|
||||||
|
fAlignment.horizontal = alignment.horizontal;
|
||||||
|
if (alignment.IsVerticalSet())
|
||||||
|
fAlignment.vertical = alignment.vertical;
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVisible
|
||||||
|
bool
|
||||||
|
BSpaceLayoutItem::IsVisible()
|
||||||
|
{
|
||||||
|
return fVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetVisible
|
||||||
|
void
|
||||||
|
BSpaceLayoutItem::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
fVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Frame
|
||||||
|
BRect
|
||||||
|
BSpaceLayoutItem::Frame()
|
||||||
|
{
|
||||||
|
return fFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetFrame
|
||||||
|
void
|
||||||
|
BSpaceLayoutItem::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fFrame = frame;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _SPLIT_LAYOUT_H
|
||||||
|
#define _SPLIT_LAYOUT_H
|
||||||
|
|
||||||
|
#include <Layout.h>
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
namespace Layout {
|
||||||
|
class Layouter;
|
||||||
|
class LayoutInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using BPrivate::Layout::Layouter;
|
||||||
|
using BPrivate::Layout::LayoutInfo;
|
||||||
|
|
||||||
|
|
||||||
|
class BSplitLayout : public BLayout {
|
||||||
|
public:
|
||||||
|
BSplitLayout(enum orientation orientation,
|
||||||
|
float spacing = 0.0f);
|
||||||
|
virtual ~BSplitLayout();
|
||||||
|
|
||||||
|
void SetInsets(float left, float top, float right,
|
||||||
|
float bottom);
|
||||||
|
void GetInsets(float* left, float* top, float* right,
|
||||||
|
float* bottom);
|
||||||
|
|
||||||
|
float Spacing() const;
|
||||||
|
void SetSpacing(float spacing);
|
||||||
|
|
||||||
|
orientation Orientation() const;
|
||||||
|
void SetOrientation(enum orientation orientation);
|
||||||
|
|
||||||
|
float SplitterSize() const;
|
||||||
|
void SetSplitterSize(float size);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
float ItemWeight(int32 index) const;
|
||||||
|
float ItemWeight(BLayoutItem* item) const;
|
||||||
|
void SetItemWeight(int32 index, float weight,
|
||||||
|
bool invalidateLayout);
|
||||||
|
void SetItemWeight(BLayoutItem* item, float weight);
|
||||||
|
|
||||||
|
void SetCollapsible(bool collapsible);
|
||||||
|
void SetCollapsible(int32 index, bool collapsible);
|
||||||
|
void SetCollapsible(int32 first, int32 last,
|
||||||
|
bool collapsible);
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
// interface for BSplitView
|
||||||
|
BRect SplitterItemFrame(int32 index) const;
|
||||||
|
|
||||||
|
bool StartDraggingSplitter(BPoint point);
|
||||||
|
bool DragSplitter(BPoint point);
|
||||||
|
bool StopDraggingSplitter();
|
||||||
|
int32 DraggedSplitter() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void ItemAdded(BLayoutItem* item);
|
||||||
|
virtual void ItemRemoved(BLayoutItem* item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ItemLayoutInfo;
|
||||||
|
class ValueRange;
|
||||||
|
class SplitterItem;
|
||||||
|
|
||||||
|
void _InvalidateLayout(bool invalidateView);
|
||||||
|
void _InvalidateCachedHeightForWidth();
|
||||||
|
|
||||||
|
SplitterItem* _SplitterItemAt(int32 index) const;
|
||||||
|
|
||||||
|
void _GetSplitterValueRange(int32 index,
|
||||||
|
ValueRange& range);
|
||||||
|
int32 _SplitterValue(int32 index) const;
|
||||||
|
|
||||||
|
void _LayoutItem(BLayoutItem* item, BRect frame,
|
||||||
|
bool visible);
|
||||||
|
void _LayoutItem(BLayoutItem* item,
|
||||||
|
ItemLayoutInfo* info);
|
||||||
|
|
||||||
|
bool _SetSplitterValue(int32 index, int32 value);
|
||||||
|
|
||||||
|
ItemLayoutInfo* _ItemLayoutInfo(BLayoutItem* item) const;
|
||||||
|
|
||||||
|
|
||||||
|
void _UpdateSplitterWeights();
|
||||||
|
|
||||||
|
void _ValidateMinMax();
|
||||||
|
|
||||||
|
void _InternalGetHeightForWidth(float width,
|
||||||
|
bool realLayout, float* minHeight,
|
||||||
|
float* maxHeight, float* preferredHeight);
|
||||||
|
|
||||||
|
float _SplitterSpace() const;
|
||||||
|
|
||||||
|
BSize _AddInsets(BSize size);
|
||||||
|
void _AddInsets(float* minHeight, float* maxHeight,
|
||||||
|
float* preferredHeight);
|
||||||
|
BSize _SubtractInsets(BSize size);
|
||||||
|
|
||||||
|
private:
|
||||||
|
orientation fOrientation;
|
||||||
|
float fLeftInset;
|
||||||
|
float fRightInset;
|
||||||
|
float fTopInset;
|
||||||
|
float fBottomInset;
|
||||||
|
float fSplitterSize;
|
||||||
|
float fSpacing;
|
||||||
|
|
||||||
|
BList fSplitterItems;
|
||||||
|
BList fVisibleItems;
|
||||||
|
|
||||||
|
BSize fMin;
|
||||||
|
BSize fMax;
|
||||||
|
BSize fPreferred;
|
||||||
|
|
||||||
|
Layouter* fHorizontalLayouter;
|
||||||
|
Layouter* fVerticalLayouter;
|
||||||
|
|
||||||
|
LayoutInfo* fHorizontalLayoutInfo;
|
||||||
|
LayoutInfo* fVerticalLayoutInfo;
|
||||||
|
|
||||||
|
BList fHeightForWidthItems;
|
||||||
|
// Incorporates the children's height for width constraints for a
|
||||||
|
// concrete width. Cloned lazily from fVerticalLayout when needed.
|
||||||
|
Layouter* fHeightForWidthVerticalLayouter;
|
||||||
|
LayoutInfo* fHeightForWidthHorizontalLayoutInfo;
|
||||||
|
// for computing height for width info
|
||||||
|
|
||||||
|
bool fLayoutValid;
|
||||||
|
|
||||||
|
float fCachedHeightForWidthWidth;
|
||||||
|
float fHeightForWidthVerticalLayouterWidth;
|
||||||
|
float fCachedMinHeightForWidth;
|
||||||
|
float fCachedMaxHeightForWidth;
|
||||||
|
float fCachedPreferredHeightForWidth;
|
||||||
|
|
||||||
|
BPoint fDraggingStartPoint;
|
||||||
|
int32 fDraggingStartValue;
|
||||||
|
int32 fDraggingCurrentValue;
|
||||||
|
int32 fDraggingSplitterIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _SPLIT_LAYOUT_H
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <SplitLayoutBuilder.h>
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
|
||||||
|
using std::nothrow;
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BSplitLayoutBuilder::BSplitLayoutBuilder(enum orientation orientation,
|
||||||
|
float spacing)
|
||||||
|
: fView(new BSplitView(orientation, spacing))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BSplitLayoutBuilder::BSplitLayoutBuilder(BSplitView* view)
|
||||||
|
: fView(view)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// SplitView
|
||||||
|
BSplitView*
|
||||||
|
BSplitLayoutBuilder::SplitView() const
|
||||||
|
{
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSplitView
|
||||||
|
BSplitLayoutBuilder&
|
||||||
|
BSplitLayoutBuilder::GetSplitView(BSplitView** view)
|
||||||
|
{
|
||||||
|
*view = fView;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BSplitLayoutBuilder&
|
||||||
|
BSplitLayoutBuilder::Add(BView* view)
|
||||||
|
{
|
||||||
|
fView->AddChild(view);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BSplitLayoutBuilder&
|
||||||
|
BSplitLayoutBuilder::Add(BView* view, float weight)
|
||||||
|
{
|
||||||
|
fView->AddChild(view, weight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BSplitLayoutBuilder&
|
||||||
|
BSplitLayoutBuilder::Add(BLayoutItem* item)
|
||||||
|
{
|
||||||
|
fView->AddChild(item);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add
|
||||||
|
BSplitLayoutBuilder&
|
||||||
|
BSplitLayoutBuilder::Add(BLayoutItem* item, float weight)
|
||||||
|
{
|
||||||
|
fView->AddChild(item, weight);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCollapsible
|
||||||
|
BSplitLayoutBuilder&
|
||||||
|
BSplitLayoutBuilder::SetCollapsible(bool collapsible)
|
||||||
|
{
|
||||||
|
int32 count = fView->CountChildren();
|
||||||
|
if (count > 0)
|
||||||
|
fView->SetCollapsible(count - 1, collapsible);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cast operator BSplitView*
|
||||||
|
BSplitLayoutBuilder::operator BSplitView*()
|
||||||
|
{
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <SplitView.h>
|
||||||
|
|
||||||
|
#include "SplitLayout.h"
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BSplitView::BSplitView(enum orientation orientation, float spacing)
|
||||||
|
: BView(NULL,
|
||||||
|
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_INVALIDATE_AFTER_LAYOUT,
|
||||||
|
fSplitLayout = new BSplitLayout(orientation, spacing))
|
||||||
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BSplitView::~BSplitView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spacing
|
||||||
|
float
|
||||||
|
BSplitView::Spacing() const
|
||||||
|
{
|
||||||
|
return fSplitLayout->Spacing();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSpacing
|
||||||
|
void
|
||||||
|
BSplitView::SetSpacing(float spacing)
|
||||||
|
{
|
||||||
|
fSplitLayout->SetSpacing(spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Orientation
|
||||||
|
orientation
|
||||||
|
BSplitView::Orientation() const
|
||||||
|
{
|
||||||
|
return fSplitLayout->Orientation();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOrientation
|
||||||
|
void
|
||||||
|
BSplitView::SetOrientation(enum orientation orientation)
|
||||||
|
{
|
||||||
|
fSplitLayout->SetOrientation(orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SplitterSize
|
||||||
|
float
|
||||||
|
BSplitView::SplitterSize() const
|
||||||
|
{
|
||||||
|
return fSplitLayout->SplitterSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSplitterSize
|
||||||
|
void
|
||||||
|
BSplitView::SetSplitterSize(float size)
|
||||||
|
{
|
||||||
|
fSplitLayout->SetSplitterSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCollapsible
|
||||||
|
void
|
||||||
|
BSplitView::SetCollapsible(bool collapsible)
|
||||||
|
{
|
||||||
|
fSplitLayout->SetCollapsible(collapsible);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCollapsible
|
||||||
|
void
|
||||||
|
BSplitView::SetCollapsible(int32 index, bool collapsible)
|
||||||
|
{
|
||||||
|
fSplitLayout->SetCollapsible(index, collapsible);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCollapsible
|
||||||
|
void
|
||||||
|
BSplitView::SetCollapsible(int32 first, int32 last, bool collapsible)
|
||||||
|
{
|
||||||
|
fSplitLayout->SetCollapsible(first, last, collapsible);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild
|
||||||
|
void
|
||||||
|
BSplitView::AddChild(BView* child, BView* sibling)
|
||||||
|
{
|
||||||
|
BView::AddChild(child, sibling);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild
|
||||||
|
bool
|
||||||
|
BSplitView::AddChild(BView* child, float weight)
|
||||||
|
{
|
||||||
|
return fSplitLayout->AddView(child, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild
|
||||||
|
bool
|
||||||
|
BSplitView::AddChild(int32 index, BView* child, float weight)
|
||||||
|
{
|
||||||
|
return fSplitLayout->AddView(index, child, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild
|
||||||
|
bool
|
||||||
|
BSplitView::AddChild(BLayoutItem* child)
|
||||||
|
{
|
||||||
|
return fSplitLayout->AddItem(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild
|
||||||
|
bool
|
||||||
|
BSplitView::AddChild(BLayoutItem* child, float weight)
|
||||||
|
{
|
||||||
|
return fSplitLayout->AddItem(child, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddChild
|
||||||
|
bool
|
||||||
|
BSplitView::AddChild(int32 index, BLayoutItem* child, float weight)
|
||||||
|
{
|
||||||
|
return fSplitLayout->AddItem(index, child, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
void
|
||||||
|
BSplitView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
// draw the splitters
|
||||||
|
int32 draggedSplitterIndex = fSplitLayout->DraggedSplitter();
|
||||||
|
int32 count = fSplitLayout->CountItems();
|
||||||
|
for (int32 i = 0; i < count - 1; i++) {
|
||||||
|
BRect frame = fSplitLayout->SplitterItemFrame(i);
|
||||||
|
DrawSplitter(frame, Orientation(), draggedSplitterIndex == i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MouseDown
|
||||||
|
void
|
||||||
|
BSplitView::MouseDown(BPoint where)
|
||||||
|
{
|
||||||
|
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||||
|
|
||||||
|
if (fSplitLayout->StartDraggingSplitter(where))
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// MouseUp
|
||||||
|
void
|
||||||
|
BSplitView::MouseUp(BPoint where)
|
||||||
|
{
|
||||||
|
if (fSplitLayout->StopDraggingSplitter()) {
|
||||||
|
Relayout();
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MouseMoved
|
||||||
|
void
|
||||||
|
BSplitView::MouseMoved(BPoint where, uint32 transit, const BMessage* message)
|
||||||
|
{
|
||||||
|
int32 splitterIndex = fSplitLayout->DraggedSplitter();
|
||||||
|
if (splitterIndex >= 0) {
|
||||||
|
BRect oldFrame = fSplitLayout->SplitterItemFrame(splitterIndex);
|
||||||
|
if (fSplitLayout->DragSplitter(where)) {
|
||||||
|
Invalidate(oldFrame);
|
||||||
|
Invalidate(fSplitLayout->SplitterItemFrame(splitterIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLayout
|
||||||
|
void
|
||||||
|
BSplitView::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
// not allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
// DrawSplitter
|
||||||
|
void
|
||||||
|
BSplitView::DrawSplitter(BRect frame, enum orientation orientation,
|
||||||
|
bool pressed)
|
||||||
|
{
|
||||||
|
rgb_color black = { 0, 0, 0, 255 };
|
||||||
|
rgb_color white = { 255, 255, 255, 255 };
|
||||||
|
|
||||||
|
SetHighColor(pressed ? white : black);
|
||||||
|
|
||||||
|
FillRect(frame);
|
||||||
|
}
|
||||||
@@ -9,8 +9,10 @@
|
|||||||
/** BStringView draw a non-editable text string */
|
/** BStringView draw a non-editable text string */
|
||||||
|
|
||||||
|
|
||||||
#include <Message.h>
|
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
|
||||||
|
#include <LayoutUtils.h>
|
||||||
|
#include <Message.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -265,6 +267,16 @@ BStringView::GetSupportedSuites(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BStringView::MaxSize()
|
||||||
|
{
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), BSize(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BStringView::Perform(perform_code d, void* arg)
|
BStringView::Perform(perform_code d, void* arg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Frans van Nispen (xlr8@tref.nl)
|
* Frans van Nispen (xlr8@tref.nl)
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** BTextControl displays text that can act like a control. */
|
/** BTextControl displays text that can act like a control. */
|
||||||
@@ -12,6 +13,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <AbstractLayoutItem.h>
|
||||||
|
#include <LayoutUtils.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
@@ -20,23 +23,83 @@
|
|||||||
#include "TextInput.h"
|
#include "TextInput.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BTextControl::LabelLayoutItem : public BAbstractLayoutItem {
|
||||||
|
public:
|
||||||
|
LabelLayoutItem(BTextControl* parent);
|
||||||
|
|
||||||
|
virtual bool IsVisible();
|
||||||
|
virtual void SetVisible(bool visible);
|
||||||
|
|
||||||
|
virtual BRect Frame();
|
||||||
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual BSize BaseMinSize();
|
||||||
|
virtual BSize BaseMaxSize();
|
||||||
|
virtual BSize BasePreferredSize();
|
||||||
|
virtual BAlignment BaseAlignment();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BTextControl* fParent;
|
||||||
|
BRect fFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class BTextControl::TextViewLayoutItem : public BAbstractLayoutItem {
|
||||||
|
public:
|
||||||
|
TextViewLayoutItem(BTextControl* parent);
|
||||||
|
|
||||||
|
virtual bool IsVisible();
|
||||||
|
virtual void SetVisible(bool visible);
|
||||||
|
|
||||||
|
virtual BRect Frame();
|
||||||
|
virtual void SetFrame(BRect frame);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual BSize BaseMinSize();
|
||||||
|
virtual BSize BaseMaxSize();
|
||||||
|
virtual BSize BasePreferredSize();
|
||||||
|
virtual BAlignment BaseAlignment();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BTextControl* fParent;
|
||||||
|
BRect fFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BTextControl::BTextControl(BRect frame, const char *name, const char *label,
|
BTextControl::BTextControl(BRect frame, const char *name, const char *label,
|
||||||
const char *text, BMessage *message, uint32 mask,
|
const char *text, BMessage *message, uint32 mask,
|
||||||
uint32 flags)
|
uint32 flags)
|
||||||
: BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
|
: BControl(frame, name, label, message, mask, flags | B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
_InitData(label, text);
|
_InitData(label, text);
|
||||||
|
_ValidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
float height;
|
|
||||||
BTextControl::GetPreferredSize(NULL, &height);
|
|
||||||
|
|
||||||
ResizeTo(Bounds().Width(), height);
|
BTextControl::BTextControl(const char *name, const char *label,
|
||||||
|
const char *text, BMessage *message,
|
||||||
|
uint32 flags)
|
||||||
|
: BControl(BRect(0, 0, -1, -1), name, label, message, B_FOLLOW_NONE,
|
||||||
|
flags | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||||
|
{
|
||||||
|
_InitData(label, text);
|
||||||
|
_ValidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
float lineHeight = ceil(fText->LineHeight(0));
|
|
||||||
fText->ResizeTo(fText->Bounds().Width(), lineHeight);
|
|
||||||
fText->MoveTo(fText->Frame().left, (height - lineHeight) / 2);
|
|
||||||
|
|
||||||
fPreviousHeight = Bounds().Height();
|
BTextControl::BTextControl(const char *label,
|
||||||
|
const char *text, BMessage *message)
|
||||||
|
: BControl(BRect(0, 0, -1, -1), NULL, label, message, B_FOLLOW_NONE,
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT)
|
||||||
|
{
|
||||||
|
_InitData(label, text);
|
||||||
|
_ValidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -566,6 +629,24 @@ BTextControl::Perform(perform_code d, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayoutItem*
|
||||||
|
BTextControl::CreateLabelLayoutItem()
|
||||||
|
{
|
||||||
|
if (!fLabelLayoutItem)
|
||||||
|
fLabelLayoutItem = new LabelLayoutItem(this);
|
||||||
|
return fLabelLayoutItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayoutItem*
|
||||||
|
BTextControl::CreateTextViewLayoutItem()
|
||||||
|
{
|
||||||
|
if (!fTextViewLayoutItem)
|
||||||
|
fTextViewLayoutItem = new TextViewLayoutItem(this);
|
||||||
|
return fTextViewLayoutItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BTextControl::_ReservedTextControl1() {}
|
void BTextControl::_ReservedTextControl1() {}
|
||||||
void BTextControl::_ReservedTextControl2() {}
|
void BTextControl::_ReservedTextControl2() {}
|
||||||
void BTextControl::_ReservedTextControl3() {}
|
void BTextControl::_ReservedTextControl3() {}
|
||||||
@@ -627,6 +708,8 @@ BTextControl::_InitData(const char* label, const char* initialText,
|
|||||||
fDivider = 0.0f;
|
fDivider = 0.0f;
|
||||||
fPreviousWidth = bounds.Width();
|
fPreviousWidth = bounds.Width();
|
||||||
fPreviousHeight = bounds.Height();
|
fPreviousHeight = bounds.Height();
|
||||||
|
fLabelLayoutItem = NULL;
|
||||||
|
fTextViewLayoutItem = NULL;
|
||||||
fSkipSetFlags = false;
|
fSkipSetFlags = false;
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
@@ -672,3 +755,204 @@ BTextControl::_InitData(const char* label, const char* initialText,
|
|||||||
fText->AlignTextRect();
|
fText->AlignTextRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::_ValidateLayout()
|
||||||
|
{
|
||||||
|
float height;
|
||||||
|
BTextControl::GetPreferredSize(NULL, &height);
|
||||||
|
|
||||||
|
ResizeTo(Bounds().Width(), height);
|
||||||
|
|
||||||
|
float lineHeight = ceil(fText->LineHeight(0));
|
||||||
|
fText->ResizeTo(fText->Bounds().Width(), lineHeight);
|
||||||
|
fText->MoveTo(fText->Frame().left, (height - lineHeight) / 2);
|
||||||
|
|
||||||
|
fPreviousHeight = Bounds().Height();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::_UpdateFrame()
|
||||||
|
{
|
||||||
|
if (fLabelLayoutItem && fTextViewLayoutItem) {
|
||||||
|
BRect labelFrame = fLabelLayoutItem->Frame();
|
||||||
|
BRect textFrame = fTextViewLayoutItem->Frame();
|
||||||
|
MoveTo(labelFrame.left, labelFrame.top);
|
||||||
|
ResizeTo(textFrame.left + textFrame.Width() - labelFrame.left,
|
||||||
|
textFrame.top + textFrame.Height() - labelFrame.top);
|
||||||
|
SetDivider(textFrame.left - labelFrame.left);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BTextControl::LabelLayoutItem::LabelLayoutItem(BTextControl* parent)
|
||||||
|
: fParent(parent),
|
||||||
|
fFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BTextControl::LabelLayoutItem::IsVisible()
|
||||||
|
{
|
||||||
|
return !fParent->IsHidden(fParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::LabelLayoutItem::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
// not allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BTextControl::LabelLayoutItem::Frame()
|
||||||
|
{
|
||||||
|
return fFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::LabelLayoutItem::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fFrame = frame;
|
||||||
|
fParent->_UpdateFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView*
|
||||||
|
BTextControl::LabelLayoutItem::View()
|
||||||
|
{
|
||||||
|
return fParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BTextControl::LabelLayoutItem::BaseMinSize()
|
||||||
|
{
|
||||||
|
// TODO: Cache the info. Might be too expensive for this call.
|
||||||
|
const char* label = fParent->Label();
|
||||||
|
if (!label)
|
||||||
|
return BSize(-1, -1);
|
||||||
|
|
||||||
|
BSize size;
|
||||||
|
fParent->GetPreferredSize(NULL, &size.height);
|
||||||
|
|
||||||
|
size.width = fParent->StringWidth(label) + 2 * 3 - 1;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BTextControl::LabelLayoutItem::BaseMaxSize()
|
||||||
|
{
|
||||||
|
return BaseMinSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BTextControl::LabelLayoutItem::BasePreferredSize()
|
||||||
|
{
|
||||||
|
return BaseMinSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BTextControl::LabelLayoutItem::BaseAlignment()
|
||||||
|
{
|
||||||
|
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
BTextControl::TextViewLayoutItem::TextViewLayoutItem(BTextControl* parent)
|
||||||
|
: fParent(parent),
|
||||||
|
fFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BTextControl::TextViewLayoutItem::IsVisible()
|
||||||
|
{
|
||||||
|
return !fParent->IsHidden(fParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::TextViewLayoutItem::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
// not allowed
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BTextControl::TextViewLayoutItem::Frame()
|
||||||
|
{
|
||||||
|
return fFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BTextControl::TextViewLayoutItem::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fFrame = frame;
|
||||||
|
fParent->_UpdateFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView*
|
||||||
|
BTextControl::TextViewLayoutItem::View()
|
||||||
|
{
|
||||||
|
return fParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BTextControl::TextViewLayoutItem::BaseMinSize()
|
||||||
|
{
|
||||||
|
// TODO: Cache the info. Might be too expensive for this call.
|
||||||
|
BSize size;
|
||||||
|
fParent->GetPreferredSize(NULL, &size.height);
|
||||||
|
|
||||||
|
// mmh, some arbitrary minimal width
|
||||||
|
size.width = 30;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BTextControl::TextViewLayoutItem::BaseMaxSize()
|
||||||
|
{
|
||||||
|
BSize size(BaseMinSize());
|
||||||
|
size.width = B_SIZE_UNLIMITED;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BTextControl::TextViewLayoutItem::BasePreferredSize()
|
||||||
|
{
|
||||||
|
BSize size(BaseMinSize());
|
||||||
|
// puh, no idea...
|
||||||
|
size.width = 100;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BTextControl::TextViewLayoutItem::BaseAlignment()
|
||||||
|
{
|
||||||
|
return BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+397
-18
@@ -6,6 +6,7 @@
|
|||||||
* Adrian Oanca <adioanca@cotty.iren.ro>
|
* Adrian Oanca <adioanca@cotty.iren.ro>
|
||||||
* Axel Dörfler, axeld@pinc-software.de
|
* Axel Dörfler, axeld@pinc-software.de
|
||||||
* Stephan Aßmus <superstippi@gmx.de>
|
* Stephan Aßmus <superstippi@gmx.de>
|
||||||
|
* Ingo Weinhold <bonefish@cs.tu-berlin.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -24,6 +25,9 @@
|
|||||||
#include <Cursor.h>
|
#include <Cursor.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
#include <Layout.h>
|
||||||
|
#include <LayoutContext.h>
|
||||||
|
#include <LayoutUtils.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <MessageQueue.h>
|
#include <MessageQueue.h>
|
||||||
@@ -310,6 +314,43 @@ ViewState::UpdateFrom(BPrivate::PortLink &link)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
struct BView::LayoutData {
|
||||||
|
|
||||||
|
LayoutData()
|
||||||
|
: fMinSize(),
|
||||||
|
fMaxSize(),
|
||||||
|
fPreferredSize(),
|
||||||
|
fAlignment(),
|
||||||
|
fLayoutInvalidationDisabled(0),
|
||||||
|
fLayout(NULL),
|
||||||
|
fLayoutContext(NULL),
|
||||||
|
fLayoutValid(true), // <- TODO: Rethink this!
|
||||||
|
fLayoutInProgress(false),
|
||||||
|
fNeedsRelayout(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BSize fMinSize;
|
||||||
|
BSize fMaxSize;
|
||||||
|
BSize fPreferredSize;
|
||||||
|
BAlignment fAlignment;
|
||||||
|
int fLayoutInvalidationDisabled;
|
||||||
|
BLayout* fLayout;
|
||||||
|
BLayoutContext* fLayoutContext;
|
||||||
|
bool fLayoutValid;
|
||||||
|
bool fLayoutInProgress;
|
||||||
|
bool fNeedsRelayout;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
BView::BView(const char* name, uint32 flags, BLayout* layout)
|
||||||
|
{
|
||||||
|
_InitData(BRect(0, 0, 0, 0), name, B_FOLLOW_NONE,
|
||||||
|
flags | B_SUPPORTS_LAYOUT);
|
||||||
|
SetLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BView::BView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
|
BView::BView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
|
||||||
: BHandler(name)
|
: BHandler(name)
|
||||||
{
|
{
|
||||||
@@ -531,7 +572,7 @@ BView::~BView()
|
|||||||
RemoveSelf();
|
RemoveSelf();
|
||||||
|
|
||||||
// TODO: see about BShelf! must I delete it here? is it deleted by the window?
|
// TODO: see about BShelf! must I delete it here? is it deleted by the window?
|
||||||
|
|
||||||
// we also delete all our children
|
// we also delete all our children
|
||||||
|
|
||||||
BView *child = fFirstChild;
|
BView *child = fFirstChild;
|
||||||
@@ -542,6 +583,10 @@ BView::~BView()
|
|||||||
child = nextChild;
|
child = nextChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete the layout and the layout data
|
||||||
|
delete fLayoutData->fLayout;
|
||||||
|
delete fLayoutData;
|
||||||
|
|
||||||
if (fVerScroller)
|
if (fVerScroller)
|
||||||
fVerScroller->SetTarget((BView*)NULL);
|
fVerScroller->SetTarget((BView*)NULL);
|
||||||
if (fHorScroller)
|
if (fHorScroller)
|
||||||
@@ -837,6 +882,9 @@ BView::Hide()
|
|||||||
fOwner->fLink->StartMessage(AS_LAYER_HIDE);
|
fOwner->fLink->StartMessage(AS_LAYER_HIDE);
|
||||||
}
|
}
|
||||||
fShowLevel++;
|
fShowLevel++;
|
||||||
|
|
||||||
|
if (fShowLevel == 1 && fParent)
|
||||||
|
fParent->InvalidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -848,6 +896,9 @@ BView::Show()
|
|||||||
check_lock();
|
check_lock();
|
||||||
fOwner->fLink->StartMessage(AS_LAYER_SHOW);
|
fOwner->fLink->StartMessage(AS_LAYER_SHOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fShowLevel == 0 && fParent)
|
||||||
|
fParent->InvalidateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3255,11 +3306,34 @@ BView::AddChild(BView *child, BView *before)
|
|||||||
child && child->Name() ? child->Name(): "NULL",
|
child && child->Name() ? child->Name(): "NULL",
|
||||||
before && before->Name() ? before->Name(): "NULL"));
|
before && before->Name() ? before->Name(): "NULL"));
|
||||||
|
|
||||||
if (!child)
|
if (!_AddChild(child, before))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (child->fParent != NULL)
|
if (fLayoutData->fLayout)
|
||||||
|
fLayoutData->fLayout->AddView(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BView::AddChild(BLayoutItem* child)
|
||||||
|
{
|
||||||
|
if (!fLayoutData->fLayout)
|
||||||
|
return false;
|
||||||
|
return fLayoutData->fLayout->AddItem(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BView::_AddChild(BView *child, BView *before)
|
||||||
|
{
|
||||||
|
if (!child)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (child->fParent != NULL) {
|
||||||
|
printf("BView::_AddChild(): child %p already has parent %p\n", child , child->fParent);
|
||||||
debugger("AddChild failed - the view already has a parent.");
|
debugger("AddChild failed - the view already has a parent.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool lockedOwner = false;
|
bool lockedOwner = false;
|
||||||
if (fOwner && !fOwner->IsLocked()) {
|
if (fOwner && !fOwner->IsLocked()) {
|
||||||
@@ -3267,8 +3341,12 @@ BView::AddChild(BView *child, BView *before)
|
|||||||
lockedOwner = true;
|
lockedOwner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_AddChildToList(child, before))
|
if (!_AddChildToList(child, before)) {
|
||||||
debugger("AddChild failed!");
|
debugger("AddChild failed!");
|
||||||
|
if (lockedOwner)
|
||||||
|
fOwner->Unlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (fOwner) {
|
if (fOwner) {
|
||||||
check_lock();
|
check_lock();
|
||||||
@@ -3280,6 +3358,10 @@ BView::AddChild(BView *child, BView *before)
|
|||||||
if (lockedOwner)
|
if (lockedOwner)
|
||||||
fOwner->Unlock();
|
fOwner->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3294,7 +3376,6 @@ BView::RemoveChild(BView *child)
|
|||||||
return child->RemoveSelf();
|
return child->RemoveSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BView::CountChildren() const
|
BView::CountChildren() const
|
||||||
{
|
{
|
||||||
@@ -3342,6 +3423,16 @@ BView::PreviousSibling() const
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
BView::RemoveSelf()
|
BView::RemoveSelf()
|
||||||
|
{
|
||||||
|
if (fParent && fParent->fLayoutData->fLayout)
|
||||||
|
return fParent->fLayoutData->fLayout->RemoveView(this);
|
||||||
|
else
|
||||||
|
return _RemoveSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BView::_RemoveSelf()
|
||||||
{
|
{
|
||||||
STRACE(("BView(%s)::RemoveSelf()...\n", Name()));
|
STRACE(("BView(%s)::RemoveSelf()...\n", Name()));
|
||||||
|
|
||||||
@@ -3355,7 +3446,8 @@ BView::RemoveSelf()
|
|||||||
_Detach();
|
_Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fParent || !fParent->_RemoveChildFromList(this))
|
BView* parent = fParent;
|
||||||
|
if (!parent || !parent->_RemoveChildFromList(this))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (owner != NULL && !fTopLevelView) {
|
if (owner != NULL && !fTopLevelView) {
|
||||||
@@ -3364,6 +3456,8 @@ BView::RemoveSelf()
|
|||||||
owner->fLink->Attach<int32>(_get_object_token_(this));
|
owner->fLink->Attach<int32>(_get_object_token_(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent->InvalidateLayout();
|
||||||
|
|
||||||
STRACE(("DONE: BView(%s)::RemoveSelf()\n", Name()));
|
STRACE(("DONE: BView(%s)::RemoveSelf()\n", Name()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -3725,6 +3819,285 @@ BView::Perform(perform_code d, void* arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - Layout Functions
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BView::MinSize()
|
||||||
|
{
|
||||||
|
// TODO: make sure this works correctly when some methods are overridden
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(fLayoutData->fMinSize,
|
||||||
|
(fLayoutData->fLayout ? fLayoutData->fLayout->MinSize()
|
||||||
|
: BSize(width, height)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BView::MaxSize()
|
||||||
|
{
|
||||||
|
return BLayoutUtils::ComposeSize(fLayoutData->fMaxSize,
|
||||||
|
(fLayoutData->fLayout ? fLayoutData->fLayout->MaxSize()
|
||||||
|
: BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BView::PreferredSize()
|
||||||
|
{
|
||||||
|
// TODO: make sure this works correctly when some methods are overridden
|
||||||
|
float width, height;
|
||||||
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
|
return BLayoutUtils::ComposeSize(fLayoutData->fPreferredSize,
|
||||||
|
(fLayoutData->fLayout ? fLayoutData->fLayout->PreferredSize()
|
||||||
|
: BSize(width, height)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BView::Alignment()
|
||||||
|
{
|
||||||
|
return BLayoutUtils::ComposeAlignment(fLayoutData->fAlignment,
|
||||||
|
(fLayoutData->fLayout ? fLayoutData->fLayout->Alignment()
|
||||||
|
: BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::SetExplicitMinSize(BSize size)
|
||||||
|
{
|
||||||
|
fLayoutData->fMinSize = size;
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::SetExplicitMaxSize(BSize size)
|
||||||
|
{
|
||||||
|
fLayoutData->fMaxSize = size;
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::SetExplicitPreferredSize(BSize size)
|
||||||
|
{
|
||||||
|
fLayoutData->fPreferredSize = size;
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::SetExplicitAlignment(BAlignment alignment)
|
||||||
|
{
|
||||||
|
fLayoutData->fAlignment = alignment;
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BView::ExplicitMinSize() const
|
||||||
|
{
|
||||||
|
return fLayoutData->fMinSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BView::ExplicitMaxSize() const
|
||||||
|
{
|
||||||
|
return fLayoutData->fMaxSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BSize
|
||||||
|
BView::ExplicitPreferredSize() const
|
||||||
|
{
|
||||||
|
return fLayoutData->fPreferredSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BAlignment
|
||||||
|
BView::ExplicitAlignment() const
|
||||||
|
{
|
||||||
|
return fLayoutData->fAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BView::HasHeightForWidth()
|
||||||
|
{
|
||||||
|
return (fLayoutData->fLayout
|
||||||
|
? fLayoutData->fLayout->HasHeightForWidth() : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::GetHeightForWidth(float width, float* min, float* max, float* preferred)
|
||||||
|
{
|
||||||
|
if (fLayoutData->fLayout)
|
||||||
|
fLayoutData->fLayout->GetHeightForWidth(width, min, max, preferred);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
if (layout == fLayoutData->fLayout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fFlags |= B_SUPPORTS_LAYOUT;
|
||||||
|
|
||||||
|
// unset and delete the old layout
|
||||||
|
if (fLayoutData->fLayout) {
|
||||||
|
fLayoutData->fLayout->SetView(NULL);
|
||||||
|
delete fLayoutData->fLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
fLayoutData->fLayout = layout;
|
||||||
|
|
||||||
|
if (fLayoutData->fLayout) {
|
||||||
|
fLayoutData->fLayout->SetView(this);
|
||||||
|
|
||||||
|
// add all children
|
||||||
|
int count = CountChildren();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
fLayoutData->fLayout->AddView(ChildAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
InvalidateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayout*
|
||||||
|
BView::GetLayout() const
|
||||||
|
{
|
||||||
|
return fLayoutData->fLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::InvalidateLayout(bool descendants)
|
||||||
|
{
|
||||||
|
if (fLayoutData->fLayoutValid && !fLayoutData->fLayoutInProgress
|
||||||
|
&& fLayoutData->fLayoutInvalidationDisabled == 0) {
|
||||||
|
if (fParent && fParent->fLayoutData->fLayoutValid)
|
||||||
|
fParent->InvalidateLayout(false);
|
||||||
|
|
||||||
|
fLayoutData->fLayoutValid = false;
|
||||||
|
|
||||||
|
if (fLayoutData->fLayout)
|
||||||
|
fLayoutData->fLayout->InvalidateLayout();
|
||||||
|
|
||||||
|
if (descendants) {
|
||||||
|
int count = CountChildren();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
ChildAt(i)->InvalidateLayout(descendants);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fTopLevelView) {
|
||||||
|
// trigger layout process
|
||||||
|
if (fOwner)
|
||||||
|
fOwner->PostMessage(B_LAYOUT_WINDOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::EnableLayoutInvalidation()
|
||||||
|
{
|
||||||
|
if (fLayoutData->fLayoutInvalidationDisabled > 0)
|
||||||
|
fLayoutData->fLayoutInvalidationDisabled--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::DisableLayoutInvalidation()
|
||||||
|
{
|
||||||
|
fLayoutData->fLayoutInvalidationDisabled++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayoutContext*
|
||||||
|
BView::LayoutContext() const
|
||||||
|
{
|
||||||
|
return fLayoutData->fLayoutContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::Layout(bool force)
|
||||||
|
{
|
||||||
|
BLayoutContext context;
|
||||||
|
_Layout(force, &context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::Relayout()
|
||||||
|
{
|
||||||
|
if (fLayoutData->fLayoutValid && !fLayoutData->fLayoutInProgress) {
|
||||||
|
fLayoutData->fNeedsRelayout = true;
|
||||||
|
|
||||||
|
// Layout() is recursive, that is if the parent view is currently laid
|
||||||
|
// out, we don't call layout() on this view, but wait for the parent's
|
||||||
|
// Layout() to do that for us.
|
||||||
|
if (!fParent || !fParent->fLayoutData->fLayoutInProgress)
|
||||||
|
Layout(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::DoLayout()
|
||||||
|
{
|
||||||
|
if (fLayoutData->fLayout)
|
||||||
|
fLayoutData->fLayout->LayoutView();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::_Layout(bool force, BLayoutContext* context)
|
||||||
|
{
|
||||||
|
//printf("%p->BView::_Layout(%d, %p)\n", this, force, context);
|
||||||
|
//printf(" fNeedsRelayout: %d, fLayoutValid: %d, fLayoutInProgress: %d\n",
|
||||||
|
//fLayoutData->fNeedsRelayout, fLayoutData->fLayoutValid, fLayoutData->fLayoutInProgress);
|
||||||
|
if (fLayoutData->fNeedsRelayout || !fLayoutData->fLayoutValid || force) {
|
||||||
|
fLayoutData->fLayoutValid = false;
|
||||||
|
|
||||||
|
if (fLayoutData->fLayoutInProgress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BLayoutContext* oldContext = fLayoutData->fLayoutContext;
|
||||||
|
fLayoutData->fLayoutContext = context;
|
||||||
|
|
||||||
|
fLayoutData->fLayoutInProgress = true;
|
||||||
|
DoLayout();
|
||||||
|
fLayoutData->fLayoutInProgress = false;
|
||||||
|
|
||||||
|
fLayoutData->fLayoutValid = true;
|
||||||
|
fLayoutData->fNeedsRelayout = false;
|
||||||
|
|
||||||
|
// layout children
|
||||||
|
int32 childCount = CountChildren();
|
||||||
|
for (int32 i = 0; i < childCount; i++) {
|
||||||
|
BView* child = ChildAt(i);
|
||||||
|
if (!child->IsHidden(child))
|
||||||
|
child->_Layout(force, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
fLayoutData->fLayoutContext = oldContext;
|
||||||
|
|
||||||
|
// invalidate the drawn content, if requested
|
||||||
|
if (fFlags & B_INVALIDATE_AFTER_LAYOUT)
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
// Private Functions
|
// Private Functions
|
||||||
|
|
||||||
@@ -3772,6 +4145,8 @@ BView::_InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flag
|
|||||||
|
|
||||||
fEventMask = 0;
|
fEventMask = 0;
|
||||||
fEventOptions = 0;
|
fEventOptions = 0;
|
||||||
|
|
||||||
|
fLayoutData = new LayoutData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4010,8 +4385,12 @@ BView::_ResizeBy(int32 deltaWidth, int32 deltaHeight)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// layout the children
|
// layout the children
|
||||||
for (BView* child = fFirstChild; child; child = child->fNextSibling)
|
if (fFlags & B_SUPPORTS_LAYOUT) {
|
||||||
child->_ParentResizedBy(deltaWidth, deltaHeight);
|
Relayout();
|
||||||
|
} else {
|
||||||
|
for (BView* child = fFirstChild; child; child = child->fNextSibling)
|
||||||
|
child->_ParentResizedBy(deltaWidth, deltaHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if (fFlags & B_FRAME_EVENTS) {
|
if (fFlags & B_FRAME_EVENTS) {
|
||||||
BMessage resized(B_VIEW_RESIZED);
|
BMessage resized(B_VIEW_RESIZED);
|
||||||
@@ -4383,15 +4762,15 @@ BView::do_owner_check_no_pick() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void _ReservedView1__5BView() {}
|
||||||
void BView::_ReservedView2(){}
|
extern "C" void _ReservedView2__5BView() {}
|
||||||
void BView::_ReservedView3(){}
|
extern "C" void _ReservedView3__5BView() {}
|
||||||
void BView::_ReservedView4(){}
|
extern "C" void _ReservedView4__5BView() {}
|
||||||
void BView::_ReservedView5(){}
|
extern "C" void _ReservedView5__5BView() {}
|
||||||
void BView::_ReservedView6(){}
|
extern "C" void _ReservedView6__5BView() {}
|
||||||
void BView::_ReservedView7(){}
|
extern "C" void _ReservedView7__5BView() {}
|
||||||
void BView::_ReservedView8(){}
|
extern "C" void _ReservedView8__5BView() {}
|
||||||
void BView::_ReservedView9(){}
|
extern "C" void _ReservedView9__5BView() {}
|
||||||
void BView::_ReservedView10(){}
|
void BView::_ReservedView10(){}
|
||||||
void BView::_ReservedView11(){}
|
void BView::_ReservedView11(){}
|
||||||
void BView::_ReservedView12(){}
|
void BView::_ReservedView12(){}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ViewLayoutItem.h"
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
BViewLayoutItem::BViewLayoutItem(BView* view)
|
||||||
|
: fView(view)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
BViewLayoutItem::~BViewLayoutItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinSize
|
||||||
|
BSize
|
||||||
|
BViewLayoutItem::MinSize()
|
||||||
|
{
|
||||||
|
return fView->MinSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSize
|
||||||
|
BSize
|
||||||
|
BViewLayoutItem::MaxSize()
|
||||||
|
{
|
||||||
|
return fView->MaxSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferredSize
|
||||||
|
BSize
|
||||||
|
BViewLayoutItem::PreferredSize()
|
||||||
|
{
|
||||||
|
return fView->PreferredSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alignment
|
||||||
|
BAlignment
|
||||||
|
BViewLayoutItem::Alignment()
|
||||||
|
{
|
||||||
|
return fView->Alignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitMinSize
|
||||||
|
void
|
||||||
|
BViewLayoutItem::SetExplicitMinSize(BSize size)
|
||||||
|
{
|
||||||
|
fView->SetExplicitMinSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitMaxSize
|
||||||
|
void
|
||||||
|
BViewLayoutItem::SetExplicitMaxSize(BSize size)
|
||||||
|
{
|
||||||
|
fView->SetExplicitMaxSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitPreferredSize
|
||||||
|
void
|
||||||
|
BViewLayoutItem::SetExplicitPreferredSize(BSize size)
|
||||||
|
{
|
||||||
|
fView->SetExplicitPreferredSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExplicitAlignment
|
||||||
|
void
|
||||||
|
BViewLayoutItem::SetExplicitAlignment(BAlignment alignment)
|
||||||
|
{
|
||||||
|
fView->SetExplicitAlignment(alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsVisible
|
||||||
|
bool
|
||||||
|
BViewLayoutItem::IsVisible()
|
||||||
|
{
|
||||||
|
return !fView->IsHidden(fView);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetVisible
|
||||||
|
void
|
||||||
|
BViewLayoutItem::SetVisible(bool visible)
|
||||||
|
{
|
||||||
|
if (visible != IsVisible()) {
|
||||||
|
if (visible)
|
||||||
|
fView->Show();
|
||||||
|
else
|
||||||
|
fView->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Frame
|
||||||
|
BRect
|
||||||
|
BViewLayoutItem::Frame()
|
||||||
|
{
|
||||||
|
return fView->Frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetFrame
|
||||||
|
void
|
||||||
|
BViewLayoutItem::SetFrame(BRect frame)
|
||||||
|
{
|
||||||
|
fView->MoveTo(frame.LeftTop());
|
||||||
|
fView->ResizeTo(frame.Width(), frame.Height());
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasHeightForWidth
|
||||||
|
bool
|
||||||
|
BViewLayoutItem::HasHeightForWidth()
|
||||||
|
{
|
||||||
|
return fView->HasHeightForWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHeightForWidth
|
||||||
|
void
|
||||||
|
BViewLayoutItem::GetHeightForWidth(float width, float* min, float* max,
|
||||||
|
float* preferred)
|
||||||
|
{
|
||||||
|
fView->GetHeightForWidth(width, min, max, preferred);
|
||||||
|
}
|
||||||
|
|
||||||
|
// View
|
||||||
|
BView*
|
||||||
|
BViewLayoutItem::View()
|
||||||
|
{
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidateLayout
|
||||||
|
void
|
||||||
|
BViewLayoutItem::InvalidateLayout()
|
||||||
|
{
|
||||||
|
fView->InvalidateLayout();
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _VIEW_LAYOUT_ITEM_H
|
||||||
|
#define _VIEW_LAYOUT_ITEM_H
|
||||||
|
|
||||||
|
#include <LayoutItem.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BViewLayoutItem : public BLayoutItem {
|
||||||
|
public:
|
||||||
|
BViewLayoutItem(BView* view);
|
||||||
|
virtual ~BViewLayoutItem();
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
virtual bool HasHeightForWidth();
|
||||||
|
virtual void GetHeightForWidth(float width, float* min,
|
||||||
|
float* max, float* preferred);
|
||||||
|
|
||||||
|
virtual BView* View();
|
||||||
|
|
||||||
|
virtual void InvalidateLayout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BView* fView;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _VIEW_LAYOUT_ITEM_H
|
||||||
@@ -1150,6 +1150,23 @@ FrameMoved(origin);
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case B_LAYOUT_WINDOW:
|
||||||
|
{
|
||||||
|
if (fFlags & B_AUTO_UPDATE_SIZE_LIMITS) {
|
||||||
|
// Get min/max constraints of the top view and enforce window
|
||||||
|
// size limits respectively.
|
||||||
|
BSize minSize = fTopView->MinSize();
|
||||||
|
BSize maxSize = fTopView->MaxSize();
|
||||||
|
SetSizeLimits(minSize.width, maxSize.width,
|
||||||
|
minSize.height, maxSize.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// do the actual layout
|
||||||
|
fTopView->Layout(false);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BLooper::DispatchMessage(msg, target);
|
BLooper::DispatchMessage(msg, target);
|
||||||
break;
|
break;
|
||||||
@@ -2214,6 +2231,27 @@ BWindow::Run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BWindow::SetLayout(BLayout* layout)
|
||||||
|
{
|
||||||
|
fTopView->SetLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BLayout*
|
||||||
|
BWindow::GetLayout() const
|
||||||
|
{
|
||||||
|
return fTopView->GetLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BWindow::InvalidateLayout(bool descendants)
|
||||||
|
{
|
||||||
|
fTopView->InvalidateLayout(descendants);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BWindow::GetSupportedSuites(BMessage *data)
|
BWindow::GetSupportedSuites(BMessage *data)
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef CONSTRAINT_SOLVER_LAYOUTER_H
|
||||||
|
#define CONSTRAINT_SOLVER_LAYOUTER_H
|
||||||
|
|
||||||
|
#include "Layouter.h"
|
||||||
|
|
||||||
|
#include <List.h>
|
||||||
|
|
||||||
|
class QcLinInEqSolver;
|
||||||
|
class QcConstraint;
|
||||||
|
class QcConstraint;
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
namespace Layout {
|
||||||
|
|
||||||
|
class ConstraintSolverLayouter : public Layouter {
|
||||||
|
public:
|
||||||
|
ConstraintSolverLayouter(int32 elementCount,
|
||||||
|
int32 spacing);
|
||||||
|
virtual ~ConstraintSolverLayouter();
|
||||||
|
|
||||||
|
virtual void AddConstraints(int32 element, int32 length,
|
||||||
|
float min, float max, float preferred);
|
||||||
|
virtual void SetWeight(int32 element, float weight);
|
||||||
|
|
||||||
|
virtual float MinSize();
|
||||||
|
virtual float MaxSize();
|
||||||
|
virtual float PreferredSize();
|
||||||
|
|
||||||
|
virtual LayoutInfo* CreateLayoutInfo();
|
||||||
|
|
||||||
|
virtual void Layout(LayoutInfo* layoutInfo, float size);
|
||||||
|
|
||||||
|
virtual Layouter* CloneLayouter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Set;
|
||||||
|
|
||||||
|
class Variable;
|
||||||
|
class Constraint;
|
||||||
|
class MinConstraint;
|
||||||
|
class MaxConstraint;
|
||||||
|
class MinMaxEntry;
|
||||||
|
class MinMaxMatrix;
|
||||||
|
class MyLayoutInfo;
|
||||||
|
|
||||||
|
friend class Constraint;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MIN_CONSTRAINT = 0,
|
||||||
|
MAX_CONSTRAINT = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void _ValidateMinMax();
|
||||||
|
|
||||||
|
void _AddMinConstraint(int32 first, int32 last,
|
||||||
|
int32 value);
|
||||||
|
void _AddMaxConstraint(int32 first, int32 last,
|
||||||
|
int32 value);
|
||||||
|
|
||||||
|
int32 _ComputeMin();
|
||||||
|
int32 _ComputeMax();
|
||||||
|
bool _ComputeSolution(int32 size);
|
||||||
|
|
||||||
|
bool _FindIntegerSolution(int32 size);
|
||||||
|
bool _FindIntegerSolution(const Set& nonIntVariables,
|
||||||
|
const BList& minConstraints,
|
||||||
|
const BList& maxConstraints,
|
||||||
|
int32 sizeDiff);
|
||||||
|
|
||||||
|
Constraint* _CreateConstraint(int32 type, int32 first,
|
||||||
|
int32 last, int32 value);
|
||||||
|
void _SetConstraint(int32 type,
|
||||||
|
Constraint** constraints,
|
||||||
|
int32 element, int32 value, bool restrict);
|
||||||
|
void _SetConstraint(int32 type,
|
||||||
|
BList& constraints,
|
||||||
|
int32 first, int32 last, int32 value,
|
||||||
|
bool restrict);
|
||||||
|
int _IndexOfConstraint(BList& constraints,
|
||||||
|
int32 first, int32 last);
|
||||||
|
bool _AddSetSizeConstraint(int32 size);
|
||||||
|
|
||||||
|
void _AddConstraints();
|
||||||
|
void _AddConstraints(const BList& constraints);
|
||||||
|
void _RemoveSetSizeConstraint();
|
||||||
|
void _RemoveConstraints();
|
||||||
|
void _RemoveConstraint(Constraint* constraint);
|
||||||
|
void _GetInvolvedConstraints(
|
||||||
|
const BList& constraints,
|
||||||
|
const BList& variables,
|
||||||
|
BList& filteredConstraints);
|
||||||
|
void _GetViolatedConstraints(
|
||||||
|
const BList& constraints,
|
||||||
|
BList& violatedConstraints);
|
||||||
|
void _FilterVariablesByMaxConstraints(
|
||||||
|
const BList& variables,
|
||||||
|
const BList& constraints,
|
||||||
|
Set& filteredVars);
|
||||||
|
|
||||||
|
static int _CompareVariables(const void* a, const void* b);
|
||||||
|
static int _CompareConstraintsByLength(const void* a,
|
||||||
|
const void* b);
|
||||||
|
static int _CompareConstraintsBySatisfactionDistance(
|
||||||
|
const void* a, const void* b);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fElementCount;
|
||||||
|
float* fWeights;
|
||||||
|
|
||||||
|
Constraint** fBasicMinConstraints;
|
||||||
|
Constraint** fBasicMaxConstraints;
|
||||||
|
|
||||||
|
BList fComplexMinConstraints;
|
||||||
|
BList fComplexMaxConstraints;
|
||||||
|
|
||||||
|
Variable* fVariables;
|
||||||
|
Variable* fSizeVariable;
|
||||||
|
|
||||||
|
QcLinInEqSolver* fSolver;
|
||||||
|
QcConstraint* fSizeSumConstraint;
|
||||||
|
QcConstraint* fSetSizeConstraint;
|
||||||
|
|
||||||
|
bool fConstraintsAdded;
|
||||||
|
bool fSetSizeConstraintAdded;
|
||||||
|
|
||||||
|
int32 fSpacing;
|
||||||
|
int32 fMin;
|
||||||
|
int32 fMax;
|
||||||
|
bool fMinMaxValid;
|
||||||
|
|
||||||
|
MyLayoutInfo* fLayoutInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Layout
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
using BPrivate::Layout::ConstraintSolverLayouter;
|
||||||
|
|
||||||
|
#endif // CONSTRAINT_SOLVER_LAYOUTER_H
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Layouter.h"
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
LayoutInfo::LayoutInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
LayoutInfo::~LayoutInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ElementRangeSize
|
||||||
|
float
|
||||||
|
LayoutInfo::ElementRangeSize(int32 position, int32 length)
|
||||||
|
{
|
||||||
|
if (length == 1)
|
||||||
|
return ElementSize(position);
|
||||||
|
|
||||||
|
int lastIndex = position + length - 1;
|
||||||
|
return ElementLocation(lastIndex) + ElementSize(lastIndex)
|
||||||
|
- ElementLocation(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
Layouter::Layouter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
Layouter::~Layouter()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef LAYOUTER_H
|
||||||
|
#define LAYOUTER_H
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
namespace Layout {
|
||||||
|
|
||||||
|
class LayoutInfo {
|
||||||
|
public:
|
||||||
|
LayoutInfo();
|
||||||
|
virtual ~LayoutInfo();
|
||||||
|
|
||||||
|
virtual float ElementLocation(int32 element) = 0;
|
||||||
|
virtual float ElementSize(int32 element) = 0;
|
||||||
|
|
||||||
|
virtual float ElementRangeSize(int32 position, int32 length);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Layouter {
|
||||||
|
public:
|
||||||
|
Layouter();
|
||||||
|
virtual ~Layouter();
|
||||||
|
|
||||||
|
virtual void AddConstraints(int32 element, int32 length,
|
||||||
|
float min, float max, float preferred) = 0;
|
||||||
|
virtual void SetWeight(int32 element, float weight) = 0;
|
||||||
|
|
||||||
|
virtual float MinSize() = 0;
|
||||||
|
virtual float MaxSize() = 0;
|
||||||
|
virtual float PreferredSize() = 0;
|
||||||
|
|
||||||
|
virtual LayoutInfo* CreateLayoutInfo() = 0;
|
||||||
|
|
||||||
|
virtual void Layout(LayoutInfo* layoutInfo, float size) = 0;
|
||||||
|
|
||||||
|
virtual Layouter* CloneLayouter() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Layout
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
using BPrivate::Layout::LayoutInfo;
|
||||||
|
using BPrivate::Layout::Layouter;
|
||||||
|
|
||||||
|
#endif // LAYOUTER_H
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "OneElementLayouter.h"
|
||||||
|
|
||||||
|
#include <Size.h>
|
||||||
|
|
||||||
|
|
||||||
|
class OneElementLayouter::MyLayoutInfo : public LayoutInfo {
|
||||||
|
public:
|
||||||
|
float fSize;
|
||||||
|
|
||||||
|
MyLayoutInfo()
|
||||||
|
: fSize(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual float ElementLocation(int32 element)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual float ElementSize(int32 element)
|
||||||
|
{
|
||||||
|
return fSize;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
OneElementLayouter::OneElementLayouter()
|
||||||
|
: fMin(-1),
|
||||||
|
fMax(B_SIZE_UNLIMITED),
|
||||||
|
fPreferred(-1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
OneElementLayouter::~OneElementLayouter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddConstraints
|
||||||
|
void
|
||||||
|
OneElementLayouter::AddConstraints(int32 element, int32 length,
|
||||||
|
float min, float max, float preferred)
|
||||||
|
{
|
||||||
|
fMin = max_c(fMin, min);
|
||||||
|
fMax = min_c(fMax, max);
|
||||||
|
fMax = max_c(fMax, fMin);
|
||||||
|
fPreferred = max_c(fPreferred, preferred);
|
||||||
|
fPreferred = max_c(fPreferred, fMin);
|
||||||
|
fPreferred = min_c(fPreferred, fMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetWeight
|
||||||
|
void
|
||||||
|
OneElementLayouter::SetWeight(int32 element, float weight)
|
||||||
|
{
|
||||||
|
// not needed
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinSize
|
||||||
|
float
|
||||||
|
OneElementLayouter::MinSize()
|
||||||
|
{
|
||||||
|
return fMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSize
|
||||||
|
float
|
||||||
|
OneElementLayouter::MaxSize()
|
||||||
|
{
|
||||||
|
return fMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferredSize
|
||||||
|
float
|
||||||
|
OneElementLayouter::PreferredSize()
|
||||||
|
{
|
||||||
|
return fPreferred;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateLayoutInfo
|
||||||
|
LayoutInfo*
|
||||||
|
OneElementLayouter::CreateLayoutInfo()
|
||||||
|
{
|
||||||
|
return new MyLayoutInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Layout
|
||||||
|
void
|
||||||
|
OneElementLayouter::Layout(LayoutInfo* layoutInfo, float size)
|
||||||
|
{
|
||||||
|
((MyLayoutInfo*)layoutInfo)->fSize = max_c(size, fMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloneLayouter
|
||||||
|
Layouter*
|
||||||
|
OneElementLayouter::CloneLayouter()
|
||||||
|
{
|
||||||
|
OneElementLayouter* layouter = new OneElementLayouter;
|
||||||
|
layouter->fMin = fMin;
|
||||||
|
layouter->fMax = fMax;
|
||||||
|
layouter->fPreferred = fPreferred;
|
||||||
|
|
||||||
|
return layouter;
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef ONE_ELEMENT_LAYOUTER_H
|
||||||
|
#define ONE_ELEMENT_LAYOUTER_H
|
||||||
|
|
||||||
|
#include "Layouter.h"
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
namespace Layout {
|
||||||
|
|
||||||
|
class OneElementLayouter : public Layouter {
|
||||||
|
public:
|
||||||
|
OneElementLayouter();
|
||||||
|
virtual ~OneElementLayouter();
|
||||||
|
|
||||||
|
virtual void AddConstraints(int32 element, int32 length,
|
||||||
|
float min, float max, float preferred);
|
||||||
|
virtual void SetWeight(int32 element, float weight);
|
||||||
|
|
||||||
|
virtual float MinSize();
|
||||||
|
virtual float MaxSize();
|
||||||
|
virtual float PreferredSize();
|
||||||
|
|
||||||
|
virtual LayoutInfo* CreateLayoutInfo();
|
||||||
|
|
||||||
|
virtual void Layout(LayoutInfo* layoutInfo, float size);
|
||||||
|
|
||||||
|
virtual Layouter* CloneLayouter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class MyLayoutInfo;
|
||||||
|
|
||||||
|
float fMin;
|
||||||
|
float fMax;
|
||||||
|
float fPreferred;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Layout
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
using BPrivate::Layout::OneElementLayouter;
|
||||||
|
|
||||||
|
#endif // ONE_ELEMENT_LAYOUTER_H
|
||||||
@@ -0,0 +1,457 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SimpleLayouter.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <LayoutUtils.h>
|
||||||
|
#include <List.h>
|
||||||
|
#include <Size.h>
|
||||||
|
|
||||||
|
|
||||||
|
// no lround() under BeOS R5 x86
|
||||||
|
#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
|
||||||
|
# define lround(x) (long)floor((x) + 0.5)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// ElementLayoutInfo
|
||||||
|
class SimpleLayouter::ElementLayoutInfo {
|
||||||
|
public:
|
||||||
|
int32 size;
|
||||||
|
int32 location;
|
||||||
|
|
||||||
|
ElementLayoutInfo()
|
||||||
|
: size(0),
|
||||||
|
location(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ElementInfo
|
||||||
|
class SimpleLayouter::ElementInfo {
|
||||||
|
public:
|
||||||
|
int32 index;
|
||||||
|
int32 min;
|
||||||
|
int32 max;
|
||||||
|
int32 preferred;
|
||||||
|
float weight;
|
||||||
|
int64 tempWeight;
|
||||||
|
|
||||||
|
ElementInfo()
|
||||||
|
: index(0),
|
||||||
|
min(0),
|
||||||
|
max(B_SIZE_UNLIMITED),
|
||||||
|
preferred(0),
|
||||||
|
weight(1),
|
||||||
|
tempWeight(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementInfo(int index)
|
||||||
|
: index(index),
|
||||||
|
min(0),
|
||||||
|
max(B_SIZE_UNLIMITED),
|
||||||
|
preferred(0),
|
||||||
|
weight(1),
|
||||||
|
tempWeight(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Assign(const ElementInfo& info)
|
||||||
|
{
|
||||||
|
min = info.min;
|
||||||
|
max = info.max;
|
||||||
|
preferred = info.preferred;
|
||||||
|
weight = info.weight;
|
||||||
|
tempWeight = info.tempWeight;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// MyLayoutInfo
|
||||||
|
class SimpleLayouter::MyLayoutInfo : public LayoutInfo {
|
||||||
|
public:
|
||||||
|
int32 fSize;
|
||||||
|
ElementLayoutInfo* fElements;
|
||||||
|
int32 fElementCount;
|
||||||
|
|
||||||
|
MyLayoutInfo(int32 elementCount)
|
||||||
|
: fSize(0),
|
||||||
|
fElementCount(elementCount)
|
||||||
|
{
|
||||||
|
fElements = new ElementLayoutInfo[elementCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~MyLayoutInfo()
|
||||||
|
{
|
||||||
|
delete[] fElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual float ElementLocation(int32 element)
|
||||||
|
{
|
||||||
|
if (element < 0 || element >= fElementCount) {
|
||||||
|
// error
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fElements[element].location;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual float ElementSize(int32 element)
|
||||||
|
{
|
||||||
|
if (element < 0 || element >= fElementCount) {
|
||||||
|
// error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fElements[element].size - 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
SimpleLayouter::SimpleLayouter(int32 elementCount, int32 spacing)
|
||||||
|
: fElementCount(elementCount),
|
||||||
|
fSpacing(spacing),
|
||||||
|
fMin(0),
|
||||||
|
fMax(B_SIZE_UNLIMITED),
|
||||||
|
fPreferred(0),
|
||||||
|
fMinMaxValid(false),
|
||||||
|
fLayoutInfo(NULL)
|
||||||
|
{
|
||||||
|
fElements = new ElementInfo[elementCount];
|
||||||
|
for (int i = 0; i < elementCount; i++)
|
||||||
|
fElements[i].index = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
SimpleLayouter::~SimpleLayouter()
|
||||||
|
{
|
||||||
|
delete[] fElements;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddConstraints
|
||||||
|
void
|
||||||
|
SimpleLayouter::AddConstraints(int32 element, int32 length,
|
||||||
|
float _min, float _max, float _preferred)
|
||||||
|
{
|
||||||
|
if (element < 0 || element >= fElementCount) {
|
||||||
|
// error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (length != 1) {
|
||||||
|
// error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 min = (int32)_min + 1;
|
||||||
|
int32 max = (int32)_max + 1;
|
||||||
|
// int32 preferred = (int32)_preferred + 1;
|
||||||
|
|
||||||
|
ElementInfo& info = fElements[element];
|
||||||
|
info.min = max_c(info.min, min);
|
||||||
|
info.max = min_c(info.max, max);
|
||||||
|
info.preferred = max_c(info.min, min);
|
||||||
|
|
||||||
|
fMinMaxValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetWeight
|
||||||
|
void
|
||||||
|
SimpleLayouter::SetWeight(int32 element, float weight)
|
||||||
|
{
|
||||||
|
if (element < 0 || element >= fElementCount) {
|
||||||
|
// error
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fElements[element].weight = weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MinSize
|
||||||
|
float
|
||||||
|
SimpleLayouter::MinSize()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
return fMin - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSize
|
||||||
|
float
|
||||||
|
SimpleLayouter::MaxSize()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
return fMax - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PreferredSize
|
||||||
|
float
|
||||||
|
SimpleLayouter::PreferredSize()
|
||||||
|
{
|
||||||
|
_ValidateMinMax();
|
||||||
|
return fPreferred - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateLayoutInfo
|
||||||
|
LayoutInfo*
|
||||||
|
SimpleLayouter::CreateLayoutInfo()
|
||||||
|
{
|
||||||
|
return new MyLayoutInfo(fElementCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Layout
|
||||||
|
void
|
||||||
|
SimpleLayouter::Layout(LayoutInfo* layoutInfo, float _size)
|
||||||
|
{
|
||||||
|
int32 size = int32(_size + 1);
|
||||||
|
|
||||||
|
fLayoutInfo = (MyLayoutInfo*)layoutInfo;
|
||||||
|
|
||||||
|
_ValidateMinMax();
|
||||||
|
|
||||||
|
if (fElementCount == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fLayoutInfo->fSize = max_c(size, fMin);
|
||||||
|
|
||||||
|
// layout the elements
|
||||||
|
if (fLayoutInfo->fSize >= fMax)
|
||||||
|
_LayoutMax();
|
||||||
|
else
|
||||||
|
_LayoutStandard();
|
||||||
|
|
||||||
|
// set locations
|
||||||
|
int location = 0;
|
||||||
|
for (int i = 0; i < fElementCount; i++) {
|
||||||
|
fLayoutInfo->fElements[i].location = location;
|
||||||
|
location += fSpacing + fLayoutInfo->fElements[i].size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloneLayouter
|
||||||
|
Layouter*
|
||||||
|
SimpleLayouter::CloneLayouter()
|
||||||
|
{
|
||||||
|
SimpleLayouter* layouter = new SimpleLayouter(fElementCount, fSpacing);
|
||||||
|
|
||||||
|
for (int i = 0; i < fElementCount; i++)
|
||||||
|
layouter->fElements[i].Assign(fElements[i]);
|
||||||
|
|
||||||
|
layouter->fMin = fMin;
|
||||||
|
layouter->fMax = fMax;
|
||||||
|
layouter->fPreferred = fPreferred;
|
||||||
|
|
||||||
|
return layouter;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DistributeSize
|
||||||
|
void
|
||||||
|
SimpleLayouter::DistributeSize(int32 size, float weights[], int32 sizes[],
|
||||||
|
int32 count)
|
||||||
|
{
|
||||||
|
// create element infos
|
||||||
|
BList elementInfos(count);
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
ElementInfo* info = new ElementInfo(i);
|
||||||
|
info->weight = weights[i];
|
||||||
|
elementInfos.AddItem(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute integer weights
|
||||||
|
int64 sumWeight = _CalculateSumWeight(elementInfos);
|
||||||
|
|
||||||
|
// distribute the size
|
||||||
|
int64 weight = 0;
|
||||||
|
int32 sumSize = 0;
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
|
||||||
|
weight += info->tempWeight;
|
||||||
|
int32 oldSumSize = sumSize;
|
||||||
|
sumSize = (int32)(size * weight / sumWeight);
|
||||||
|
sizes[i] = sumSize - oldSumSize;
|
||||||
|
|
||||||
|
delete info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _CalculateSumWeight
|
||||||
|
long
|
||||||
|
SimpleLayouter::_CalculateSumWeight(BList& elementInfos)
|
||||||
|
{
|
||||||
|
if (elementInfos.IsEmpty())
|
||||||
|
return 0;
|
||||||
|
int32 count = elementInfos.CountItems();
|
||||||
|
|
||||||
|
// sum up the floating point weight, so we get a scale
|
||||||
|
double scale = 0;
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
|
||||||
|
scale += info->weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 weight = 0;
|
||||||
|
|
||||||
|
if (scale == 0) {
|
||||||
|
// The weight sum is 0: We assign each info a temporary weight of 1.
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
|
||||||
|
info->tempWeight = 1;
|
||||||
|
weight += info->tempWeight;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// We scale the weights so that their sum is about 100000. This should
|
||||||
|
// give us ample resolution. If possible make the scale integer, so that
|
||||||
|
// integer weights will produce exact results.
|
||||||
|
if (scale >= 1 && scale <= 100000)
|
||||||
|
scale = lround(100000 / scale);
|
||||||
|
else
|
||||||
|
scale = 100000 / scale;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
ElementInfo* info = (ElementInfo*)elementInfos.ItemAt(i);
|
||||||
|
info->tempWeight = (int64)(info->weight * scale);
|
||||||
|
weight += info->tempWeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// _ValidateMinMax
|
||||||
|
void
|
||||||
|
SimpleLayouter::_ValidateMinMax()
|
||||||
|
{
|
||||||
|
if (fMinMaxValid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fMinMaxValid = true;
|
||||||
|
|
||||||
|
if (fElementCount == 0) {
|
||||||
|
fMin = 0;
|
||||||
|
fMax = B_SIZE_UNLIMITED;
|
||||||
|
fPreferred = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int spacing = (fElementCount - 1) * fSpacing;
|
||||||
|
fMin = spacing;
|
||||||
|
fMax = spacing;
|
||||||
|
fPreferred = spacing;
|
||||||
|
|
||||||
|
for (int i = 0; i < fElementCount; i++) {
|
||||||
|
ElementInfo& info = fElements[i];
|
||||||
|
|
||||||
|
// correct the preferred and maximum sizes
|
||||||
|
if (info.max < info.min)
|
||||||
|
info.max = info.min;
|
||||||
|
if (info.preferred < info.min)
|
||||||
|
info.preferred = info.min;
|
||||||
|
else if (info.preferred > info.max)
|
||||||
|
info.preferred = info.max;
|
||||||
|
|
||||||
|
// sum up
|
||||||
|
fMin += info.min;
|
||||||
|
fMax = BLayoutUtils::AddSizesInt32(fMax, info.max);
|
||||||
|
fPreferred = BLayoutUtils::AddSizesInt32(fPreferred, info.preferred);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _LayoutMax
|
||||||
|
void
|
||||||
|
SimpleLayouter::_LayoutMax()
|
||||||
|
{
|
||||||
|
ElementInfo* infos = fElements;
|
||||||
|
int32 count = fElementCount;
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 additionalSpace = fLayoutInfo->fSize - fMax;
|
||||||
|
|
||||||
|
// layout to the maximum first
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
fLayoutInfo->fElements[infos[i].index].size = infos[i].max;
|
||||||
|
|
||||||
|
// Mmh, distributing according to the weights doesn't look that good.
|
||||||
|
// // Now distribute the additional space according to the weights.
|
||||||
|
// int64 sumWeight = calculateSumWeight(Arrays.asList(infos));
|
||||||
|
// int64 weight = 0;
|
||||||
|
// int64 sumSize = 0;
|
||||||
|
// for (int i = 0; i < infos.length; i++) {
|
||||||
|
// weight += infos[i].tempWeight;
|
||||||
|
// int64 oldSumSize = sumSize;
|
||||||
|
// sumSize = (int)(additionalSpace * weight / sumWeight);
|
||||||
|
// fLayoutInfo.fElements[infos[i].index].size += sumSize - oldSumSize;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// distribute the additional space equally
|
||||||
|
int64 sumSize = 0;
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
int64 oldSumSize = sumSize;
|
||||||
|
sumSize = additionalSpace * (i + 1) / count;
|
||||||
|
fLayoutInfo->fElements[infos[i].index].size
|
||||||
|
+= int32(sumSize - oldSumSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _LayoutStandard
|
||||||
|
void
|
||||||
|
SimpleLayouter::_LayoutStandard()
|
||||||
|
{
|
||||||
|
int32 space = fLayoutInfo->fSize - (fElementCount - 1) * fSpacing;
|
||||||
|
|
||||||
|
BList infosToLayout(fElementCount);
|
||||||
|
for (int i = 0; i < fElementCount; i++) {
|
||||||
|
infosToLayout.AddItem(&fElements[i]);
|
||||||
|
fLayoutInfo->fElements[i].size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BList infosUnderMax(fElementCount);
|
||||||
|
BList infosOverMin(fElementCount);
|
||||||
|
while (infosToLayout.CountItems() > 0) {
|
||||||
|
int32 remainingSpace = 0;
|
||||||
|
int32 infoCount = infosToLayout.CountItems();
|
||||||
|
int64 sumWeight = _CalculateSumWeight(infosToLayout);
|
||||||
|
int64 assignedWeight = 0;
|
||||||
|
int32 assignedSize = 0;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < infoCount; i++) {
|
||||||
|
ElementInfo* info = (ElementInfo*)infosToLayout.ItemAt(i);
|
||||||
|
ElementLayoutInfo& layoutInfo = fLayoutInfo->fElements[info->index];
|
||||||
|
// The simple algorithm is this:
|
||||||
|
// info.size += (int)(space * info.tempWeight / sumWeight);
|
||||||
|
// I.e. we simply assign space according to the weight. To avoid the
|
||||||
|
// rounding problematic, we make it a bit more complicated. We
|
||||||
|
// assign the difference of total assignment for all infos including
|
||||||
|
// the current one minus the total excluding the current one.
|
||||||
|
assignedWeight += info->tempWeight;
|
||||||
|
int32 oldAssignedSize = assignedSize;
|
||||||
|
assignedSize = (int32)(space * assignedWeight / sumWeight);
|
||||||
|
layoutInfo.size += assignedSize - oldAssignedSize;
|
||||||
|
|
||||||
|
if (layoutInfo.size < info->min) {
|
||||||
|
remainingSpace += layoutInfo.size - info->min;
|
||||||
|
layoutInfo.size = info->min;
|
||||||
|
} else if (layoutInfo.size > info->max) {
|
||||||
|
remainingSpace += layoutInfo.size - info->max;
|
||||||
|
layoutInfo.size = info->max;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (layoutInfo.size > info->min)
|
||||||
|
infosOverMin.AddItem(info);
|
||||||
|
if (layoutInfo.size < info->max)
|
||||||
|
infosUnderMax.AddItem(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
infosToLayout.MakeEmpty();
|
||||||
|
if (remainingSpace > 0)
|
||||||
|
infosToLayout.AddList(&infosUnderMax);
|
||||||
|
else if (remainingSpace < 0)
|
||||||
|
infosToLayout.AddList(&infosOverMin);
|
||||||
|
infosUnderMax.MakeEmpty();
|
||||||
|
infosOverMin.MakeEmpty();
|
||||||
|
space = remainingSpace;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2006, Haiku Inc.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef SIMPLE_LAYOUTER_H
|
||||||
|
#define SIMPLE_LAYOUTER_H
|
||||||
|
|
||||||
|
#include "Layouter.h"
|
||||||
|
|
||||||
|
class BList;
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
namespace Layout {
|
||||||
|
|
||||||
|
class SimpleLayouter : public Layouter {
|
||||||
|
public:
|
||||||
|
SimpleLayouter(int32 elementCount,
|
||||||
|
int32 spacing);
|
||||||
|
virtual ~SimpleLayouter();
|
||||||
|
|
||||||
|
virtual void AddConstraints(int32 element, int32 length,
|
||||||
|
float min, float max, float preferred);
|
||||||
|
virtual void SetWeight(int32 element, float weight);
|
||||||
|
|
||||||
|
virtual float MinSize();
|
||||||
|
virtual float MaxSize();
|
||||||
|
virtual float PreferredSize();
|
||||||
|
|
||||||
|
virtual LayoutInfo* CreateLayoutInfo();
|
||||||
|
|
||||||
|
virtual void Layout(LayoutInfo* layoutInfo, float size);
|
||||||
|
|
||||||
|
virtual Layouter* CloneLayouter();
|
||||||
|
|
||||||
|
static void DistributeSize(int32 size, float weights[],
|
||||||
|
int32 sizes[], int32 count);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static long _CalculateSumWeight(BList& elementInfos);
|
||||||
|
|
||||||
|
void _ValidateMinMax();
|
||||||
|
void _LayoutMax();
|
||||||
|
void _LayoutStandard();
|
||||||
|
|
||||||
|
private:
|
||||||
|
class ElementLayoutInfo;
|
||||||
|
class ElementInfo;
|
||||||
|
class MyLayoutInfo;
|
||||||
|
|
||||||
|
int32 fElementCount;
|
||||||
|
int32 fSpacing;
|
||||||
|
ElementInfo* fElements;
|
||||||
|
|
||||||
|
int32 fMin;
|
||||||
|
int32 fMax;
|
||||||
|
int32 fPreferred;
|
||||||
|
|
||||||
|
bool fMinMaxValid;
|
||||||
|
|
||||||
|
MyLayoutInfo* fLayoutInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Layout
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
using BPrivate::Layout::SimpleLayouter;
|
||||||
|
|
||||||
|
#endif // SIMPLE_LAYOUTER_H
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
2000-10-16 Peter Moulder <[email protected]>
|
||||||
|
|
||||||
|
* QcConstraintRep.hh (isSatisfied): Compile in unconditionally.
|
||||||
|
|
||||||
|
2000-08-14 Peter Moulder <[email protected]>
|
||||||
|
|
||||||
|
|
||||||
|
* QcBiMap.hh (class QcBiMap): Remove unused methods ChangeIndex, EraseByIdentifier.
|
||||||
|
* QcBiMapNotifier.hh (class QcBiMapNotifier): Remove unused method ChangeConstraint.
|
||||||
|
|
||||||
|
* QcSolver and all derived classes (EndAddConstraint): return a
|
||||||
|
bool indicating success.
|
||||||
|
|
||||||
|
2000-07-21 Peter Moulder <[email protected]>
|
||||||
|
|
||||||
|
* QcFloat.hh (GetValue): New method.
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
SubDir HAIKU_TOP src kits interface qoca ;
|
||||||
|
|
||||||
|
# Don't compile qoca with debugging. Debug/non-debug versions are
|
||||||
|
# incompatible.
|
||||||
|
DEBUG = 0 ;
|
||||||
|
|
||||||
|
SetSubDirSupportedPlatforms haiku libbe_test ;
|
||||||
|
|
||||||
|
{
|
||||||
|
local defines = [ FDefines HAVE_RINT=1 QOCA_INTERNALS ] ;
|
||||||
|
SubDirCcFlags $(defines) ;
|
||||||
|
SubDirC++Flags $(defines) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) ] ;
|
||||||
|
|
||||||
|
SharedLibrary libqoca.so :
|
||||||
|
QcCassSolver.cc
|
||||||
|
QcCompPivotSystem.cc
|
||||||
|
QcCompPivotTableau.cc
|
||||||
|
QcConstraintRep.cc
|
||||||
|
QcCoreTableau.cc
|
||||||
|
QcDelCoreTableau.cc
|
||||||
|
QcDelLinEqTableau.cc
|
||||||
|
QcDelLinInEqTableau.cc
|
||||||
|
QcDenseMatrix.cc
|
||||||
|
QcFixedFloatRep.cc
|
||||||
|
QcFloatRep.cc
|
||||||
|
QcIneqSolverBase.cc
|
||||||
|
QcLinEqSolver.cc
|
||||||
|
QcLinEqSystem.cc
|
||||||
|
QcLinEqTableau.cc
|
||||||
|
QcLinInEqSolver.cc
|
||||||
|
QcLinInEqSystem.cc
|
||||||
|
QcLinInEqTableau.cc
|
||||||
|
QcLinPoly.cc
|
||||||
|
QcLinEqColStateVector.cc
|
||||||
|
QcLinEqRowStateVector.cc
|
||||||
|
QcLinInEqColStateVector.cc
|
||||||
|
QcLinInEqRowColStateVector.cc
|
||||||
|
QcNlpSolver.cc
|
||||||
|
QcNomadicFloatRep.cc
|
||||||
|
QcOrigRowStateVector.cc
|
||||||
|
QcQuasiRowColStateVector.cc
|
||||||
|
QcQuasiRowStateVector.cc
|
||||||
|
QcSolver.cc
|
||||||
|
QcSparseMatrix.cc
|
||||||
|
QcVarStow.cc
|
||||||
|
QcVariableBiMap.cc
|
||||||
|
:
|
||||||
|
$(TARGET_LIBSTDC++)
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
# also install in app_server test environment
|
||||||
|
if ( $(TARGET_PLATFORM) = libbe_test ) {
|
||||||
|
HaikuInstall install-test-apps : $(HAIKU_APP_TEST_LIB_DIR)
|
||||||
|
: libqoca.so
|
||||||
|
: tests!apps ;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef KeyIteratorHH
|
||||||
|
#define KeyIteratorHH
|
||||||
|
|
||||||
|
template <class Iterator, class Key>
|
||||||
|
class KeyIterator
|
||||||
|
: public Iterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KeyIterator (Iterator i)
|
||||||
|
: Iterator (i)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Key const & operator* () const
|
||||||
|
{
|
||||||
|
return (*((Iterator const *) this))->first;
|
||||||
|
}
|
||||||
|
|
||||||
|
Key const * operator->() const
|
||||||
|
{
|
||||||
|
return &(*((Iterator const *) this))->first;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !KeyIteratorHH */
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
$(srcdir)/Makefile.am: Makefile.am.m4
|
||||||
|
rm -f $(srcdir)/$(@F)
|
||||||
|
m4 -P $(srcdir)/$(<F) > $(srcdir)/$(@F)
|
||||||
|
# AFAIK, this has to be in srcdir (as opposed to bsrcdir).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##bsrcdir = $(srcdir)
|
||||||
|
bsrcdir = .
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.ch.cc: $(CH2XX)
|
||||||
|
@rm -f $(bsrcdir)/$(*F).cc && if echo "$(CH2XX) -c $< > $(bsrcdir)/$(*F).cc" \
|
||||||
|
&& $(CH2XX) -c $< > $(bsrcdir)/$(*F).cc; \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(*F).cc; exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(*F).cc; exit 1; fi
|
||||||
|
|
||||||
|
.ch.hh: $(CH2XX)
|
||||||
|
@rm -f $(bsrcdir)/$(*F).hh && if echo "$(CH2XX) -i $< > $(bsrcdir)/$(*F).hh" \
|
||||||
|
&& $(CH2XX) -i $< > $(bsrcdir)/$(*F).hh; \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(*F).hh; exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(*F).hh; exit 1; fi
|
||||||
|
|
||||||
|
.ch.H: $(CH2XX)
|
||||||
|
@rm -f $(bsrcdir)/$(*F).H && if echo "$(CH2XX) -d $< > $(bsrcdir)/$(*F).H" \
|
||||||
|
&& $(CH2XX) -d $< > $(bsrcdir)/$(*F).H; \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(*F).H; exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(*F).H; exit 1; fi
|
||||||
|
|
||||||
|
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DEP_FILES = .deps/QcCassSolver.P .deps/QcCompPivotSystem.P .deps/QcCompPivotTableau.P .deps/QcConstraintRep.P .deps/QcCoreTableau.P .deps/QcDelCoreTableau.P .deps/QcDelLinEqTableau.P .deps/QcDelLinInEqTableau.P .deps/QcDenseMatrix.P .deps/QcFixedFloatRep.P .deps/QcFloatRep.P .deps/QcIneqSolverBase.P .deps/QcLinEqSolver.P .deps/QcLinEqSystem.P .deps/QcLinEqTableau.P .deps/QcLinInEqSolver.P .deps/QcLinInEqSystem.P .deps/QcLinInEqTableau.P .deps/QcLinPoly.P .deps/QcLinEqColStateVector.P .deps/QcLinEqRowStateVector.P .deps/QcLinInEqColStateVector.P .deps/QcLinInEqRowColStateVector.P .deps/QcNlpSolver.P .deps/QcNomadicFloatRep.P .deps/QcOrigRowStateVector.P .deps/QcQuasiRowColStateVector.P .deps/QcQuasiRowStateVector.P .deps/QcSolver.P .deps/QcSparseMatrix.P .deps/QcVarStow.P .deps/QcVariableBiMap.P
|
||||||
|
|
||||||
|
|
||||||
|
-include $(DEP_FILES)
|
||||||
|
|
||||||
|
.cc.ii0:
|
||||||
|
@rm -f $(bsrcdir)/$(@F) && if echo "$(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F)" \
|
||||||
|
&& $(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F); \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(@F); exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(@F); exit 1; fi
|
||||||
|
@rm -f .deps/$(*F).P
|
||||||
|
@-sed 's/\.o/.ii0/g' < .deps/$(*F).pp > .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
||||||
|
|
||||||
|
CXXFLAGS = @CXXFLAGS@
|
||||||
|
CXXLD = $(CXX)
|
||||||
|
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||||
|
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
|
libqoca_la_myOBJECTS = QcCassSolver.lo QcCompPivotSystem.lo QcCompPivotTableau.lo QcConstraintRep.lo QcCoreTableau.lo QcDelCoreTableau.lo QcDelLinEqTableau.lo QcDelLinInEqTableau.lo QcDenseMatrix.lo QcFixedFloatRep.lo QcFloatRep.lo QcIneqSolverBase.lo QcLinEqSolver.lo QcLinEqSystem.lo QcLinEqTableau.lo QcLinInEqSolver.lo QcLinInEqSystem.lo QcLinInEqTableau.lo QcLinPoly.lo QcLinEqColStateVector.lo QcLinEqRowStateVector.lo QcLinInEqColStateVector.lo QcLinInEqRowColStateVector.lo QcNlpSolver.lo QcNomadicFloatRep.lo QcOrigRowStateVector.lo QcQuasiRowColStateVector.lo QcQuasiRowStateVector.lo QcSolver.lo QcSparseMatrix.lo QcVarStow.lo QcVariableBiMap.lo
|
||||||
|
|
||||||
|
ii0_files = QcCassSolver.ii0 QcCompPivotSystem.ii0 QcCompPivotTableau.ii0 QcConstraintRep.ii0 QcCoreTableau.ii0 QcDelCoreTableau.ii0 QcDelLinEqTableau.ii0 QcDelLinInEqTableau.ii0 QcDenseMatrix.ii0 QcFixedFloatRep.ii0 QcFloatRep.ii0 QcIneqSolverBase.ii0 QcLinEqSolver.ii0 QcLinEqSystem.ii0 QcLinEqTableau.ii0 QcLinInEqSolver.ii0 QcLinInEqSystem.ii0 QcLinInEqTableau.ii0 QcLinPoly.ii0 QcLinEqColStateVector.ii0 QcLinEqRowStateVector.ii0 QcLinInEqColStateVector.ii0 QcLinInEqRowColStateVector.ii0 QcNlpSolver.ii0 QcNomadicFloatRep.ii0 QcOrigRowStateVector.ii0 QcQuasiRowColStateVector.ii0 QcQuasiRowStateVector.ii0 QcSolver.ii0 QcSparseMatrix.ii0 QcVarStow.ii0 QcVariableBiMap.ii0
|
||||||
|
|
||||||
|
libqoca.la: $(ii0_files) $(libqoca_la_myOBJECTS) $(libqoca_la_DEPENDENCIES)
|
||||||
|
$(CXXLINK) -rpath $(libdir) $(libqoca_la_LDFLAGS) $(libqoca_la_myOBJECTS) $(libqoca_la_LIBADD) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
.ii0.o:
|
||||||
|
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
|
||||||
|
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
|
||||||
|
echo "$(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& $(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.ii0.lo:
|
||||||
|
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
|
||||||
|
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
|
||||||
|
echo "$(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& $(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Note that we must start off with no .deps files.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cc = cc
|
||||||
|
BUILT_SOURCES = arith.H QcAliasedBiMap.H QcAliasedBiMap.hh QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcBiMap.H QcBiMap.hh QcFloatRep.H QcFloatRep.hh QcFloatRep.$(cc) QcFixedFloatRep.H QcFixedFloatRep.hh QcFixedFloatRep.$(cc) QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.H QcNomadicFloatRep.hh QcNomadicFloatRep.$(cc) QcNullIterator.H QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.$(cc) QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.$(cc) QcSolver.H QcSolver.hh QcSolver.$(cc) QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc)
|
||||||
|
|
||||||
|
SUFFIXES = .ch .cc .hh .H .ii0
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libqoca.la
|
||||||
|
# Version info is `CURRENT[:REVISION[:AGE]]': *see (libtool)Versioning,
|
||||||
|
# in the libtool info page.
|
||||||
|
libqoca_la_LDFLAGS = -version-info 0:0:0
|
||||||
|
libqoca_la_LIBADD = -lstdc++ $(lwn) $(lgmp)
|
||||||
|
|
||||||
|
# Package visibility is implemented in C++ as `#ifdef QOCA_INTERNALS'.
|
||||||
|
# N.B. This is only for methods; for vars, make the var itself private
|
||||||
|
# and provide package-visible inline access methods.
|
||||||
|
# N.B.2: Also be careful of the needs of inline functions.
|
||||||
|
INCLUDES = -DQOCA_INTERNALS -I.. -I$(top_srcdir)/cxx
|
||||||
|
|
||||||
|
# Things needed by user programs. User programs #include only Qc.h, but Qc.h
|
||||||
|
# #includes the rest of these.
|
||||||
|
pkginclude_HEADERS = arith.H KeyIterator.hh QcASetSolver.H QcAliasedBiMap.H QcAliasedBiMap.hh QcFloat.hh QcFixedFloat.hh QcConstraint.hh QcBasicnessVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcCassSolver.hh QcLinEqSolver.hh QcLinInEqSolver.hh QcUtility.hh QcDefines.hh QcEnables.H QcFixedFloatRep.H QcFixedFloatRep.hh QcFloatRep.H QcFloatRep.hh QcCassConstraint.hh QcDelLinEqSystem.hh QcDesireValueStore.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraintRep.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcException.hh QcIneqSolverBase.H QcLinEqSystem.hh QcLinInEqSystem.hh QcLinPoly.hh QcBiMapNotifier.hh QcDelLinInEqTableau.hh QcLinEqTableau.hh QcLinInEqTableau.hh QcLinPolyTerm.hh QcSolver.H QcSolver.hh QcSparseCoeff.hh QcConstraintBiMap.hh QcDelCoreTableau.hh QcLinEqRowColStateVector.hh QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcRowAdaptor.hh QcTableau.hh QcVariableBiMap.H QcVariableBiMap.hh QcCoreTableau.hh QcDenseMatrix.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcSparseMatrixColIterator.hh QcTableauRowIterator.hh QcLinEqColState.hh QcLinEqRowState.hh QcLinInEqColState.hh QcMatrix.hh QcNlpSolver.H QcNlpSolver.hh QcNomadicFloatRep.H QcNomadicFloatRep.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcQuasiColStateVector.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcSolvedFormMatrix.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcMatrixIterator.hh QcOrigRowState.hh QcQuasiColState.hh QcQuasiRowState.hh QcSparseMatrix.hh QcStateVector.hh QcIterator.hh QcSparseMatrixElement.hh QcState.hh QcUnsortedListSet.hh QcVarStow.H
|
||||||
|
|
||||||
|
dist_libqoca_sources = QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcCassSolver.cc QcCompPivotSystem.cc QcCompPivotTableau.cc QcConstraintRep.cc QcCoreTableau.cc QcDelCoreTableau.cc QcDelLinEqTableau.cc QcDelLinInEqTableau.cc QcDenseMatrix.cc QcFloatRep.cc QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqSolver.cc QcLinEqSystem.cc QcLinEqTableau.cc QcLinInEqSolver.cc QcLinInEqSystem.cc QcLinInEqTableau.cc QcLinPoly.cc QcSolver.cc QcSparseMatrix.cc KeyIterator.hh QcAliasedBiMap.H QcAliasedBiMap.hh QcBasicnessVarIndexIterator.hh QcBasicVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcBiMapNotifier.hh QcCassConstraint.hh QcCassSolver.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraint.hh QcConstraintBiMap.hh QcConstraintIndexIterator.hh QcConstraintRep.hh QcCoreTableau.hh QcDefines.hh QcDelCoreTableau.hh QcDelLinEqSystem.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcDelLinInEqTableau.hh QcDenseMatrix.hh QcDenseMatrixColIterator.hh QcDenseMatrixIterator.hh QcDenseMatrixRowIterator.hh QcDenseTableauColIterator.hh QcDenseTableauIterator.hh QcDenseTableauRowIterator.hh QcDesireValueStore.hh QcException.hh QcFixedFloat.hh QcFixedFloatRep.cc QcFixedFloatRep.hh QcFloat.hh QcFloatRep.hh QcIterator.hh QcLinEqColState.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowColStateVector.hh QcLinEqRowState.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinEqSolver.hh QcLinEqSystem.hh QcLinEqTableau.hh QcLinInEqColState.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcLinInEqSolver.hh QcLinInEqSystem.hh QcLinInEqTableau.hh QcLinPoly.hh QcLinPolyTerm.hh QcMatrix.hh QcMatrixIterator.hh QcOrigRowState.hh QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.cc QcNomadicFloatRep.hh QcNullIterator.H QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.cc QcParamVarIndexIterator.hh QcQuasiColState.hh QcQuasiColStateVector.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcRowAdaptor.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.cc QcQuasiRowState.hh QcSolvedFormMatrix.hh QcSolver.hh QcSparseCoeff.hh QcSparseMatrix.hh QcSparseMatrixColIterator.hh QcSparseMatrixElement.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcState.hh QcStateVector.hh QcStructVarIndexIterator.hh QcTableau.hh QcTableauColIterator.hh QcTableauRowIterator.hh QcUnsortedListSet.hh QcUtility.hh QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc) QcVariableIndexIterator.hh arith.H
|
||||||
|
|
||||||
|
ch_files = QcAliasedBiMap.ch QcASetSolver.ch QcBiMap.ch QcFixedFloatRep.ch QcFloatRep.ch QcIneqSolverBase.ch QcLinEqColStateVector.ch QcLinEqRowStateVector.ch QcLinInEqColStateVector.ch QcLinInEqRowColStateVector.ch QcNlpSolver.ch QcNomadicFloatRep.ch QcNullIterator.ch QcOrigRowStateVector.ch QcQuasiRowColStateVector.ch QcQuasiRowStateVector.ch QcSolver.ch QcVariableBiMap.ch QcVarStow.ch arith.ch
|
||||||
|
|
||||||
|
libqoca_la_SOURCES =
|
||||||
|
# Rationale for emptiness: If it has any .cc files, then automake
|
||||||
|
# produces .cc.o rules, which stuffs things up (because make sometimes
|
||||||
|
# tries to use them directly instead of using the .ii0.o rule). If it
|
||||||
|
# had .ii0 files, then the .ii0 files would be put into distdir, which
|
||||||
|
# is wrong because .ii0 files contain system header file contents.
|
||||||
|
|
||||||
|
EXTRA_DIST = $(dist_libqoca_sources) Makefile.am.m4 $(ch_files)
|
||||||
|
|
||||||
|
CLEANFILES = *.ii *.ii0
|
||||||
|
|
||||||
|
DISTCLEANFILES = -r .deps
|
||||||
|
|
||||||
|
dist-hook:
|
||||||
|
@rm -f $(distdir)/Makefile.tmp
|
||||||
|
grep -v '^-include ' < $(distdir)/Makefile.in > $(distdir)/Makefile.tmp
|
||||||
|
mv $(distdir)/Makefile.tmp $(distdir)/Makefile.in
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
$(srcdir)/Makefile.am: Makefile.am.m4
|
||||||
|
rm -f $(srcdir)/$(@F)
|
||||||
|
m4 -P $(srcdir)/$(<F) > $(srcdir)/$(@F)
|
||||||
|
# AFAIK, this has to be in srcdir (as opposed to bsrcdir).
|
||||||
|
|
||||||
|
m4_changequote([[, ]])m4_dnl
|
||||||
|
|
||||||
|
m4_define([[m4_echodo]], [[echo "m4_patsubst([[$1]], [[["\\`]\|\$\$]], [[\\\&]])" \
|
||||||
|
&& $1]])
|
||||||
|
|
||||||
|
m4_define([[m4_outputas]],
|
||||||
|
[[@rm -f $2 && if m4_echodo([[$1 > $2]]); \
|
||||||
|
then :; \
|
||||||
|
else m4_echodo([[rm -f $2; exit 1]]); fi]])
|
||||||
|
|
||||||
|
##bsrcdir = $(srcdir)
|
||||||
|
bsrcdir = .
|
||||||
|
|
||||||
|
m4_define([[m4_ch2xx_rule]],
|
||||||
|
[[.ch.$2: $(CH2XX)
|
||||||
|
m4_outputas([[$(CH2XX) $1 $<]], [[$(bsrcdir)/$(*F).$2]])]])
|
||||||
|
|
||||||
|
m4_ch2xx_rule(-c, cc)
|
||||||
|
|
||||||
|
m4_ch2xx_rule(-i, hh)
|
||||||
|
|
||||||
|
m4_ch2xx_rule(-d, H)
|
||||||
|
|
||||||
|
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||||
|
|
||||||
|
m4_dnl Like: tr -s ' \t\n' ' '
|
||||||
|
m4_define([[m4u_white]], [[m4_patsubst([[$1]], [[[
|
||||||
|
]+]], [[ ]])]])
|
||||||
|
|
||||||
|
m4_define(m4_libqoca_la_OBJECTS, m4u_white([[
|
||||||
|
QcCassSolver.lo QcCompPivotSystem.lo QcCompPivotTableau.lo
|
||||||
|
QcConstraintRep.lo QcCoreTableau.lo QcDelCoreTableau.lo
|
||||||
|
QcDelLinEqTableau.lo QcDelLinInEqTableau.lo QcDenseMatrix.lo
|
||||||
|
QcFixedFloatRep.lo
|
||||||
|
QcFloatRep.lo
|
||||||
|
QcIneqSolverBase.lo
|
||||||
|
QcLinEqSolver.lo QcLinEqSystem.lo QcLinEqTableau.lo
|
||||||
|
QcLinInEqSolver.lo QcLinInEqSystem.lo QcLinInEqTableau.lo
|
||||||
|
QcLinPoly.lo
|
||||||
|
QcLinEqColStateVector.lo
|
||||||
|
QcLinEqRowStateVector.lo
|
||||||
|
QcLinInEqColStateVector.lo
|
||||||
|
QcLinInEqRowColStateVector.lo
|
||||||
|
QcNlpSolver.lo
|
||||||
|
QcNomadicFloatRep.lo
|
||||||
|
QcOrigRowStateVector.lo
|
||||||
|
QcQuasiRowColStateVector.lo
|
||||||
|
QcQuasiRowStateVector.lo
|
||||||
|
QcSolver.lo QcSparseMatrix.lo
|
||||||
|
QcVarStow.lo
|
||||||
|
QcVariableBiMap.lo]]))m4_dnl
|
||||||
|
|
||||||
|
DEP_FILES = m4_patsubst(m4_libqoca_la_OBJECTS, [[\(\w*\)\.lo]], [[.deps/\1.P]])
|
||||||
|
|
||||||
|
|
||||||
|
-include $(DEP_FILES)
|
||||||
|
|
||||||
|
.cc.ii0:
|
||||||
|
m4_outputas([[$(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $<]],
|
||||||
|
[[$(bsrcdir)/$(@F)]])
|
||||||
|
@rm -f .deps/$(*F).P
|
||||||
|
@-sed 's/\.o/.ii0/g' < .deps/$(*F).pp > .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
||||||
|
|
||||||
|
CXXFLAGS = @CXXFLAGS@
|
||||||
|
CXXLD = $(CXX)
|
||||||
|
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||||
|
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
|
libqoca_la_myOBJECTS = m4_libqoca_la_OBJECTS
|
||||||
|
|
||||||
|
ii0_files = m4_patsubst(m4_libqoca_la_OBJECTS, \.lo, .ii0)
|
||||||
|
|
||||||
|
libqoca.la: $(ii0_files) $(libqoca_la_myOBJECTS) $(libqoca_la_DEPENDENCIES)
|
||||||
|
$(CXXLINK) -rpath $(libdir) $(libqoca_la_LDFLAGS) $(libqoca_la_myOBJECTS) $(libqoca_la_LIBADD) $(LIBS)
|
||||||
|
|
||||||
|
m4_define([[m4_compile]],
|
||||||
|
[[.ii0.$1:
|
||||||
|
@if test -f [[$]]@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
|
||||||
|
m4_echodo([[cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii]]) && \
|
||||||
|
m4_echodo([[$($2[[]]CXXCOMPILE) -c $(bsrcdir)/$(*F).ii]]); \
|
||||||
|
fi
|
||||||
|
]])m4_dnl
|
||||||
|
|
||||||
|
m4_compile(o,)
|
||||||
|
m4_compile(lo,LT)
|
||||||
|
|
||||||
|
# Note that we must start off with no .deps files.
|
||||||
|
|
||||||
|
m4_dnl Expand `foo' to `foo.H foo.hh foo.$(cc)'.
|
||||||
|
m4_define([[m4u_Hhc]], [[m4_patsubst(.H .hh .$(cc), \., $1.)]])
|
||||||
|
m4_define([[m4u_Hh]], [[m4_patsubst(.H .hh, \., $1.)]])
|
||||||
|
|
||||||
|
cc = cc
|
||||||
|
BUILT_SOURCES = m4u_white([[
|
||||||
|
arith.H
|
||||||
|
m4u_Hh(QcAliasedBiMap)
|
||||||
|
m4u_Hhc(QcASetSolver)
|
||||||
|
m4u_Hh(QcBiMap)
|
||||||
|
m4u_Hhc(QcFloatRep)
|
||||||
|
m4u_Hhc(QcFixedFloatRep)
|
||||||
|
m4u_Hhc(QcIneqSolverBase)
|
||||||
|
m4u_Hhc(QcLinEqColStateVector)
|
||||||
|
m4u_Hhc(QcLinEqRowStateVector)
|
||||||
|
m4u_Hhc(QcLinInEqColStateVector)
|
||||||
|
m4u_Hhc(QcLinInEqRowColStateVector)
|
||||||
|
m4u_Hhc(QcNlpSolver)
|
||||||
|
m4u_Hhc(QcNomadicFloatRep)
|
||||||
|
QcNullIterator.H
|
||||||
|
m4u_Hhc(QcOrigRowStateVector)
|
||||||
|
m4u_Hhc(QcQuasiRowColStateVector)
|
||||||
|
m4u_Hhc(QcQuasiRowStateVector)
|
||||||
|
m4u_Hhc(QcSolver)
|
||||||
|
m4u_Hhc(QcVarStow)
|
||||||
|
m4u_Hhc(QcVariableBiMap)
|
||||||
|
]])
|
||||||
|
m4_dnl m4_patsubst(m4_libqoca_la_OBJECTS, \.lo, .ii0)
|
||||||
|
|
||||||
|
SUFFIXES = .ch .cc .hh .H .ii0
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libqoca.la
|
||||||
|
# Version info is `CURRENT[:REVISION[:AGE]]': *see (libtool)Versioning,
|
||||||
|
# in the libtool info page.
|
||||||
|
libqoca_la_LDFLAGS = -version-info 0:0:0
|
||||||
|
libqoca_la_LIBADD = -lstdc++ $(lwn) $(lgmp)
|
||||||
|
|
||||||
|
# Package visibility is implemented in C++ as `#ifdef QOCA_INTERNALS'.
|
||||||
|
# N.B. This is only for methods; for vars, make the var itself private
|
||||||
|
# and provide package-visible inline access methods.
|
||||||
|
# N.B.2: Also be careful of the needs of inline functions.
|
||||||
|
INCLUDES = -DQOCA_INTERNALS -I.. -I$(top_srcdir)/cxx
|
||||||
|
|
||||||
|
# Things needed by user programs. User programs #include only Qc.h, but Qc.h
|
||||||
|
# #includes the rest of these.
|
||||||
|
pkginclude_HEADERS = m4u_white([[
|
||||||
|
arith.H KeyIterator.hh
|
||||||
|
QcASetSolver.H
|
||||||
|
m4u_Hh(QcAliasedBiMap)
|
||||||
|
QcFloat.hh QcFixedFloat.hh QcConstraint.hh
|
||||||
|
QcBasicnessVarIndexIterator.hh
|
||||||
|
m4u_Hh(QcBiMap)
|
||||||
|
QcCassSolver.hh QcLinEqSolver.hh QcLinInEqSolver.hh
|
||||||
|
QcUtility.hh QcDefines.hh
|
||||||
|
QcEnables.H
|
||||||
|
QcFixedFloatRep.H QcFixedFloatRep.hh
|
||||||
|
QcFloatRep.H QcFloatRep.hh
|
||||||
|
QcCassConstraint.hh QcDelLinEqSystem.hh QcDesireValueStore.hh
|
||||||
|
QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraintRep.hh
|
||||||
|
QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcException.hh
|
||||||
|
QcIneqSolverBase.H
|
||||||
|
QcLinEqSystem.hh QcLinInEqSystem.hh QcLinPoly.hh
|
||||||
|
QcBiMapNotifier.hh QcDelLinInEqTableau.hh QcLinEqTableau.hh
|
||||||
|
QcLinInEqTableau.hh QcLinPolyTerm.hh QcSolver.H QcSolver.hh
|
||||||
|
QcSparseCoeff.hh QcConstraintBiMap.hh QcDelCoreTableau.hh
|
||||||
|
QcLinEqRowColStateVector.hh
|
||||||
|
QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh
|
||||||
|
QcRowAdaptor.hh QcTableau.hh
|
||||||
|
m4u_Hh(QcVariableBiMap)
|
||||||
|
QcCoreTableau.hh QcDenseMatrix.hh
|
||||||
|
QcLinEqColStateVector.H QcLinEqColStateVector.hh
|
||||||
|
QcLinEqRowStateVector.H QcLinEqRowStateVector.hh
|
||||||
|
QcLinInEqColStateVector.H QcLinInEqColStateVector.hh
|
||||||
|
QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh
|
||||||
|
QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh
|
||||||
|
QcSparseMatrixColIterator.hh
|
||||||
|
QcTableauRowIterator.hh QcLinEqColState.hh QcLinEqRowState.hh
|
||||||
|
QcLinInEqColState.hh QcMatrix.hh
|
||||||
|
QcNlpSolver.H QcNlpSolver.hh
|
||||||
|
QcNomadicFloatRep.H QcNomadicFloatRep.hh
|
||||||
|
QcOrigRowStateVector.H QcOrigRowStateVector.hh
|
||||||
|
QcQuasiColStateVector.hh
|
||||||
|
QcQuasiRowStateVector.H QcQuasiRowStateVector.hh
|
||||||
|
QcSolvedFormMatrix.hh QcSparseMatrixIterator.hh
|
||||||
|
QcSparseMatrixRowIterator.hh QcMatrixIterator.hh
|
||||||
|
QcOrigRowState.hh QcQuasiColState.hh QcQuasiRowState.hh
|
||||||
|
QcSparseMatrix.hh QcStateVector.hh QcIterator.hh
|
||||||
|
QcSparseMatrixElement.hh QcState.hh QcUnsortedListSet.hh
|
||||||
|
QcVarStow.H
|
||||||
|
]])
|
||||||
|
|
||||||
|
dist_libqoca_sources = m4u_white([[
|
||||||
|
m4u_Hhc(QcASetSolver)
|
||||||
|
QcCassSolver.cc QcCompPivotSystem.cc QcCompPivotTableau.cc
|
||||||
|
QcConstraintRep.cc QcCoreTableau.cc QcDelCoreTableau.cc
|
||||||
|
QcDelLinEqTableau.cc QcDelLinInEqTableau.cc QcDenseMatrix.cc
|
||||||
|
QcFloatRep.cc
|
||||||
|
m4u_Hhc(QcIneqSolverBase)
|
||||||
|
QcLinEqSolver.cc QcLinEqSystem.cc QcLinEqTableau.cc
|
||||||
|
QcLinInEqSolver.cc QcLinInEqSystem.cc QcLinInEqTableau.cc
|
||||||
|
QcLinPoly.cc QcSolver.cc QcSparseMatrix.cc
|
||||||
|
KeyIterator.hh
|
||||||
|
m4u_Hh(QcAliasedBiMap)
|
||||||
|
QcBasicnessVarIndexIterator.hh
|
||||||
|
QcBasicVarIndexIterator.hh
|
||||||
|
m4u_Hh(QcBiMap)
|
||||||
|
QcBiMapNotifier.hh
|
||||||
|
QcCassConstraint.hh QcCassSolver.hh QcCompPivotSystem.hh
|
||||||
|
QcCompPivotTableau.hh QcConstraint.hh QcConstraintBiMap.hh
|
||||||
|
QcConstraintIndexIterator.hh QcConstraintRep.hh QcCoreTableau.hh
|
||||||
|
QcDefines.hh QcDelCoreTableau.hh QcDelLinEqSystem.hh QcDelLinEqTableau.hh
|
||||||
|
QcDelLinInEqSystem.hh QcDelLinInEqTableau.hh QcDenseMatrix.hh
|
||||||
|
QcDenseMatrixColIterator.hh QcDenseMatrixIterator.hh
|
||||||
|
QcDenseMatrixRowIterator.hh QcDenseTableauColIterator.hh
|
||||||
|
QcDenseTableauIterator.hh QcDenseTableauRowIterator.hh
|
||||||
|
QcDesireValueStore.hh QcException.hh QcFixedFloat.hh
|
||||||
|
QcFixedFloatRep.cc QcFixedFloatRep.hh
|
||||||
|
QcFloat.hh QcFloatRep.hh QcIterator.hh
|
||||||
|
QcLinEqColState.hh
|
||||||
|
m4u_Hhc(QcLinEqColStateVector)
|
||||||
|
QcLinEqRowColStateVector.hh
|
||||||
|
QcLinEqRowState.hh
|
||||||
|
m4u_Hhc(QcLinEqRowStateVector)
|
||||||
|
QcLinEqSolver.hh
|
||||||
|
QcLinEqSystem.hh QcLinEqTableau.hh QcLinInEqColState.hh
|
||||||
|
m4u_Hhc(QcLinInEqColStateVector)
|
||||||
|
m4u_Hhc(QcLinInEqRowColStateVector)
|
||||||
|
QcLinInEqSolver.hh QcLinInEqSystem.hh QcLinInEqTableau.hh QcLinPoly.hh
|
||||||
|
QcLinPolyTerm.hh QcMatrix.hh QcMatrixIterator.hh QcOrigRowState.hh
|
||||||
|
m4u_Hhc(QcNlpSolver)
|
||||||
|
QcNomadicFloatRep.cc QcNomadicFloatRep.hh
|
||||||
|
QcNullIterator.H
|
||||||
|
QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh
|
||||||
|
QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.cc
|
||||||
|
QcParamVarIndexIterator.hh QcQuasiColState.hh
|
||||||
|
QcQuasiColStateVector.hh
|
||||||
|
m4u_Hhc(QcQuasiRowColStateVector)
|
||||||
|
QcRowAdaptor.hh
|
||||||
|
QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.cc
|
||||||
|
QcQuasiRowState.hh
|
||||||
|
QcSolvedFormMatrix.hh QcSolver.hh
|
||||||
|
QcSparseCoeff.hh QcSparseMatrix.hh QcSparseMatrixColIterator.hh
|
||||||
|
QcSparseMatrixElement.hh QcSparseMatrixIterator.hh
|
||||||
|
QcSparseMatrixRowIterator.hh QcState.hh QcStateVector.hh
|
||||||
|
QcStructVarIndexIterator.hh QcTableau.hh QcTableauColIterator.hh
|
||||||
|
QcTableauRowIterator.hh QcUnsortedListSet.hh QcUtility.hh
|
||||||
|
m4u_Hhc(QcVarStow)
|
||||||
|
m4u_Hhc(QcVariableBiMap)
|
||||||
|
QcVariableIndexIterator.hh
|
||||||
|
arith.H
|
||||||
|
]])
|
||||||
|
|
||||||
|
ch_files = m4u_white([[
|
||||||
|
QcAliasedBiMap.ch
|
||||||
|
QcASetSolver.ch
|
||||||
|
QcBiMap.ch
|
||||||
|
QcFixedFloatRep.ch QcFloatRep.ch
|
||||||
|
QcIneqSolverBase.ch
|
||||||
|
QcLinEqColStateVector.ch
|
||||||
|
QcLinEqRowStateVector.ch QcLinInEqColStateVector.ch
|
||||||
|
QcLinInEqRowColStateVector.ch
|
||||||
|
QcNlpSolver.ch
|
||||||
|
QcNomadicFloatRep.ch QcNullIterator.ch
|
||||||
|
QcOrigRowStateVector.ch QcQuasiRowColStateVector.ch
|
||||||
|
QcQuasiRowStateVector.ch QcSolver.ch
|
||||||
|
QcVariableBiMap.ch
|
||||||
|
QcVarStow.ch
|
||||||
|
arith.ch
|
||||||
|
]])
|
||||||
|
|
||||||
|
libqoca_la_SOURCES =
|
||||||
|
# Rationale for emptiness: If it has any .cc files, then automake
|
||||||
|
# produces .cc.o rules, which stuffs things up (because make sometimes
|
||||||
|
# tries to use them directly instead of using the .ii0.o rule). If it
|
||||||
|
# had .ii0 files, then the .ii0 files would be put into distdir, which
|
||||||
|
# is wrong because .ii0 files contain system header file contents.
|
||||||
|
|
||||||
|
EXTRA_DIST = $(dist_libqoca_sources) Makefile.am.m4 $(ch_files)
|
||||||
|
|
||||||
|
CLEANFILES = *.ii *.ii0
|
||||||
|
|
||||||
|
DISTCLEANFILES = -r .deps
|
||||||
|
|
||||||
|
dist-hook:
|
||||||
|
@rm -f $(distdir)/Makefile.tmp
|
||||||
|
grep -v '^-include ' < $(distdir)/Makefile.in > $(distdir)/Makefile.tmp
|
||||||
|
mv $(distdir)/Makefile.tmp $(distdir)/Makefile.in
|
||||||
@@ -0,0 +1,455 @@
|
|||||||
|
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||||
|
|
||||||
|
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||||
|
# This Makefile.in is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
|
||||||
|
SHELL = @SHELL@
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
top_srcdir = @top_srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
|
||||||
|
bindir = @bindir@
|
||||||
|
sbindir = @sbindir@
|
||||||
|
libexecdir = @libexecdir@
|
||||||
|
datadir = @datadir@
|
||||||
|
sysconfdir = @sysconfdir@
|
||||||
|
sharedstatedir = @sharedstatedir@
|
||||||
|
localstatedir = @localstatedir@
|
||||||
|
libdir = @libdir@
|
||||||
|
infodir = @infodir@
|
||||||
|
mandir = @mandir@
|
||||||
|
includedir = @includedir@
|
||||||
|
oldincludedir = /usr/include
|
||||||
|
|
||||||
|
DESTDIR =
|
||||||
|
|
||||||
|
pkgdatadir = $(datadir)/@PACKAGE@
|
||||||
|
pkglibdir = $(libdir)/@PACKAGE@
|
||||||
|
pkgincludedir = $(includedir)/@PACKAGE@
|
||||||
|
|
||||||
|
top_builddir = ../..
|
||||||
|
|
||||||
|
ACLOCAL = @ACLOCAL@
|
||||||
|
AUTOCONF = @AUTOCONF@
|
||||||
|
AUTOMAKE = @AUTOMAKE@
|
||||||
|
AUTOHEADER = @AUTOHEADER@
|
||||||
|
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
|
transform = @program_transform_name@
|
||||||
|
|
||||||
|
NORMAL_INSTALL = :
|
||||||
|
PRE_INSTALL = :
|
||||||
|
POST_INSTALL = :
|
||||||
|
NORMAL_UNINSTALL = :
|
||||||
|
PRE_UNINSTALL = :
|
||||||
|
POST_UNINSTALL = :
|
||||||
|
host_alias = @host_alias@
|
||||||
|
host_triplet = @host@
|
||||||
|
AS = @AS@
|
||||||
|
CC = @CC@
|
||||||
|
CH2XX = @CH2XX@
|
||||||
|
CXX = @CXX@
|
||||||
|
CXXCPP = @CXXCPP@
|
||||||
|
DLLTOOL = @DLLTOOL@
|
||||||
|
DOCXX = @DOCXX@
|
||||||
|
JAVA = @JAVA@
|
||||||
|
JAVAC = @JAVAC@
|
||||||
|
JAVACDEFINES = @JAVACDEFINES@
|
||||||
|
JAVADOC = @JAVADOC@
|
||||||
|
JCOM = @JCOM@
|
||||||
|
LIBTOOL = @LIBTOOL@
|
||||||
|
LN_S = @LN_S@
|
||||||
|
MAKEINFO = @MAKEINFO@
|
||||||
|
MINUSDEPEND = @MINUSDEPEND@
|
||||||
|
NLPSOLVER_COM = @NLPSOLVER_COM@
|
||||||
|
NLPSOLVER_HASH = @NLPSOLVER_HASH@
|
||||||
|
OBJDUMP = @OBJDUMP@
|
||||||
|
PACKAGE = @PACKAGE@
|
||||||
|
QC_NDEBUG_COM = @QC_NDEBUG_COM@
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
VERSION = @VERSION@
|
||||||
|
lgmp = @lgmp@
|
||||||
|
lwn = @lwn@
|
||||||
|
# AFAIK, this has to be in srcdir (as opposed to bsrcdir).
|
||||||
|
|
||||||
|
bsrcdir = .
|
||||||
|
|
||||||
|
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||||
|
|
||||||
|
DEP_FILES = .deps/QcCassSolver.P .deps/QcCompPivotSystem.P .deps/QcCompPivotTableau.P .deps/QcConstraintRep.P .deps/QcCoreTableau.P .deps/QcDelCoreTableau.P .deps/QcDelLinEqTableau.P .deps/QcDelLinInEqTableau.P .deps/QcDenseMatrix.P .deps/QcFixedFloatRep.P .deps/QcFloatRep.P .deps/QcIneqSolverBase.P .deps/QcLinEqSolver.P .deps/QcLinEqSystem.P .deps/QcLinEqTableau.P .deps/QcLinInEqSolver.P .deps/QcLinInEqSystem.P .deps/QcLinInEqTableau.P .deps/QcLinPoly.P .deps/QcLinEqColStateVector.P .deps/QcLinEqRowStateVector.P .deps/QcLinInEqColStateVector.P .deps/QcLinInEqRowColStateVector.P .deps/QcNlpSolver.P .deps/QcNomadicFloatRep.P .deps/QcOrigRowStateVector.P .deps/QcQuasiRowColStateVector.P .deps/QcQuasiRowStateVector.P .deps/QcSolver.P .deps/QcSparseMatrix.P .deps/QcVarStow.P .deps/QcVariableBiMap.P
|
||||||
|
|
||||||
|
CXXFLAGS = @CXXFLAGS@
|
||||||
|
CXXLD = $(CXX)
|
||||||
|
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
|
||||||
|
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
|
libqoca_la_myOBJECTS = QcCassSolver.lo QcCompPivotSystem.lo QcCompPivotTableau.lo QcConstraintRep.lo QcCoreTableau.lo QcDelCoreTableau.lo QcDelLinEqTableau.lo QcDelLinInEqTableau.lo QcDenseMatrix.lo QcFixedFloatRep.lo QcFloatRep.lo QcIneqSolverBase.lo QcLinEqSolver.lo QcLinEqSystem.lo QcLinEqTableau.lo QcLinInEqSolver.lo QcLinInEqSystem.lo QcLinInEqTableau.lo QcLinPoly.lo QcLinEqColStateVector.lo QcLinEqRowStateVector.lo QcLinInEqColStateVector.lo QcLinInEqRowColStateVector.lo QcNlpSolver.lo QcNomadicFloatRep.lo QcOrigRowStateVector.lo QcQuasiRowColStateVector.lo QcQuasiRowStateVector.lo QcSolver.lo QcSparseMatrix.lo QcVarStow.lo QcVariableBiMap.lo
|
||||||
|
|
||||||
|
ii0_files = QcCassSolver.ii0 QcCompPivotSystem.ii0 QcCompPivotTableau.ii0 QcConstraintRep.ii0 QcCoreTableau.ii0 QcDelCoreTableau.ii0 QcDelLinEqTableau.ii0 QcDelLinInEqTableau.ii0 QcDenseMatrix.ii0 QcFixedFloatRep.ii0 QcFloatRep.ii0 QcIneqSolverBase.ii0 QcLinEqSolver.ii0 QcLinEqSystem.ii0 QcLinEqTableau.ii0 QcLinInEqSolver.ii0 QcLinInEqSystem.ii0 QcLinInEqTableau.ii0 QcLinPoly.ii0 QcLinEqColStateVector.ii0 QcLinEqRowStateVector.ii0 QcLinInEqColStateVector.ii0 QcLinInEqRowColStateVector.ii0 QcNlpSolver.ii0 QcNomadicFloatRep.ii0 QcOrigRowStateVector.ii0 QcQuasiRowColStateVector.ii0 QcQuasiRowStateVector.ii0 QcSolver.ii0 QcSparseMatrix.ii0 QcVarStow.ii0 QcVariableBiMap.ii0
|
||||||
|
|
||||||
|
# Note that we must start off with no .deps files.
|
||||||
|
|
||||||
|
cc = cc
|
||||||
|
BUILT_SOURCES = arith.H QcAliasedBiMap.H QcAliasedBiMap.hh QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcBiMap.H QcBiMap.hh QcFloatRep.H QcFloatRep.hh QcFloatRep.$(cc) QcFixedFloatRep.H QcFixedFloatRep.hh QcFixedFloatRep.$(cc) QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.H QcNomadicFloatRep.hh QcNomadicFloatRep.$(cc) QcNullIterator.H QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.$(cc) QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.$(cc) QcSolver.H QcSolver.hh QcSolver.$(cc) QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc)
|
||||||
|
|
||||||
|
SUFFIXES = .ch .cc .hh .H .ii0
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libqoca.la
|
||||||
|
# Version info is `CURRENT[:REVISION[:AGE]]': *see (libtool)Versioning,
|
||||||
|
# in the libtool info page.
|
||||||
|
libqoca_la_LDFLAGS = -version-info 0:0:0
|
||||||
|
libqoca_la_LIBADD = -lstdc++ $(lwn) $(lgmp)
|
||||||
|
|
||||||
|
# Package visibility is implemented in C++ as `#ifdef QOCA_INTERNALS'.
|
||||||
|
# N.B. This is only for methods; for vars, make the var itself private
|
||||||
|
# and provide package-visible inline access methods.
|
||||||
|
# N.B.2: Also be careful of the needs of inline functions.
|
||||||
|
INCLUDES = -DQOCA_INTERNALS -I.. -I$(top_srcdir)/cxx
|
||||||
|
|
||||||
|
# Things needed by user programs. User programs #include only Qc.h, but Qc.h
|
||||||
|
# #includes the rest of these.
|
||||||
|
pkginclude_HEADERS = arith.H KeyIterator.hh QcASetSolver.H QcAliasedBiMap.H QcAliasedBiMap.hh QcFloat.hh QcFixedFloat.hh QcConstraint.hh QcBasicnessVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcCassSolver.hh QcLinEqSolver.hh QcLinInEqSolver.hh QcUtility.hh QcDefines.hh QcEnables.H QcFixedFloatRep.H QcFixedFloatRep.hh QcFloatRep.H QcFloatRep.hh QcCassConstraint.hh QcDelLinEqSystem.hh QcDesireValueStore.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraintRep.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcException.hh QcIneqSolverBase.H QcLinEqSystem.hh QcLinInEqSystem.hh QcLinPoly.hh QcBiMapNotifier.hh QcDelLinInEqTableau.hh QcLinEqTableau.hh QcLinInEqTableau.hh QcLinPolyTerm.hh QcSolver.H QcSolver.hh QcSparseCoeff.hh QcConstraintBiMap.hh QcDelCoreTableau.hh QcLinEqRowColStateVector.hh QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcRowAdaptor.hh QcTableau.hh QcVariableBiMap.H QcVariableBiMap.hh QcCoreTableau.hh QcDenseMatrix.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcSparseMatrixColIterator.hh QcTableauRowIterator.hh QcLinEqColState.hh QcLinEqRowState.hh QcLinInEqColState.hh QcMatrix.hh QcNlpSolver.H QcNlpSolver.hh QcNomadicFloatRep.H QcNomadicFloatRep.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcQuasiColStateVector.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcSolvedFormMatrix.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcMatrixIterator.hh QcOrigRowState.hh QcQuasiColState.hh QcQuasiRowState.hh QcSparseMatrix.hh QcStateVector.hh QcIterator.hh QcSparseMatrixElement.hh QcState.hh QcUnsortedListSet.hh QcVarStow.H
|
||||||
|
|
||||||
|
dist_libqoca_sources = QcASetSolver.H QcASetSolver.hh QcASetSolver.$(cc) QcCassSolver.cc QcCompPivotSystem.cc QcCompPivotTableau.cc QcConstraintRep.cc QcCoreTableau.cc QcDelCoreTableau.cc QcDelLinEqTableau.cc QcDelLinInEqTableau.cc QcDenseMatrix.cc QcFloatRep.cc QcIneqSolverBase.H QcIneqSolverBase.hh QcIneqSolverBase.$(cc) QcLinEqSolver.cc QcLinEqSystem.cc QcLinEqTableau.cc QcLinInEqSolver.cc QcLinInEqSystem.cc QcLinInEqTableau.cc QcLinPoly.cc QcSolver.cc QcSparseMatrix.cc KeyIterator.hh QcAliasedBiMap.H QcAliasedBiMap.hh QcBasicnessVarIndexIterator.hh QcBasicVarIndexIterator.hh QcBiMap.H QcBiMap.hh QcBiMapNotifier.hh QcCassConstraint.hh QcCassSolver.hh QcCompPivotSystem.hh QcCompPivotTableau.hh QcConstraint.hh QcConstraintBiMap.hh QcConstraintIndexIterator.hh QcConstraintRep.hh QcCoreTableau.hh QcDefines.hh QcDelCoreTableau.hh QcDelLinEqSystem.hh QcDelLinEqTableau.hh QcDelLinInEqSystem.hh QcDelLinInEqTableau.hh QcDenseMatrix.hh QcDenseMatrixColIterator.hh QcDenseMatrixIterator.hh QcDenseMatrixRowIterator.hh QcDenseTableauColIterator.hh QcDenseTableauIterator.hh QcDenseTableauRowIterator.hh QcDesireValueStore.hh QcException.hh QcFixedFloat.hh QcFixedFloatRep.cc QcFixedFloatRep.hh QcFloat.hh QcFloatRep.hh QcIterator.hh QcLinEqColState.hh QcLinEqColStateVector.H QcLinEqColStateVector.hh QcLinEqColStateVector.$(cc) QcLinEqRowColStateVector.hh QcLinEqRowState.hh QcLinEqRowStateVector.H QcLinEqRowStateVector.hh QcLinEqRowStateVector.$(cc) QcLinEqSolver.hh QcLinEqSystem.hh QcLinEqTableau.hh QcLinInEqColState.hh QcLinInEqColStateVector.H QcLinInEqColStateVector.hh QcLinInEqColStateVector.$(cc) QcLinInEqRowColStateVector.H QcLinInEqRowColStateVector.hh QcLinInEqRowColStateVector.$(cc) QcLinInEqSolver.hh QcLinInEqSystem.hh QcLinInEqTableau.hh QcLinPoly.hh QcLinPolyTerm.hh QcMatrix.hh QcMatrixIterator.hh QcOrigRowState.hh QcNlpSolver.H QcNlpSolver.hh QcNlpSolver.$(cc) QcNomadicFloatRep.cc QcNomadicFloatRep.hh QcNullIterator.H QcNullableConstraint.hh QcNullableElement.hh QcNullableFloat.hh QcOrigRowStateVector.H QcOrigRowStateVector.hh QcOrigRowStateVector.cc QcParamVarIndexIterator.hh QcQuasiColState.hh QcQuasiColStateVector.hh QcQuasiRowColStateVector.H QcQuasiRowColStateVector.hh QcQuasiRowColStateVector.$(cc) QcRowAdaptor.hh QcQuasiRowStateVector.H QcQuasiRowStateVector.hh QcQuasiRowStateVector.cc QcQuasiRowState.hh QcSolvedFormMatrix.hh QcSolver.hh QcSparseCoeff.hh QcSparseMatrix.hh QcSparseMatrixColIterator.hh QcSparseMatrixElement.hh QcSparseMatrixIterator.hh QcSparseMatrixRowIterator.hh QcState.hh QcStateVector.hh QcStructVarIndexIterator.hh QcTableau.hh QcTableauColIterator.hh QcTableauRowIterator.hh QcUnsortedListSet.hh QcUtility.hh QcVarStow.H QcVarStow.hh QcVarStow.$(cc) QcVariableBiMap.H QcVariableBiMap.hh QcVariableBiMap.$(cc) QcVariableIndexIterator.hh arith.H
|
||||||
|
|
||||||
|
ch_files = QcAliasedBiMap.ch QcASetSolver.ch QcBiMap.ch QcFixedFloatRep.ch QcFloatRep.ch QcIneqSolverBase.ch QcLinEqColStateVector.ch QcLinEqRowStateVector.ch QcLinInEqColStateVector.ch QcLinInEqRowColStateVector.ch QcNlpSolver.ch QcNomadicFloatRep.ch QcNullIterator.ch QcOrigRowStateVector.ch QcQuasiRowColStateVector.ch QcQuasiRowStateVector.ch QcSolver.ch QcVariableBiMap.ch QcVarStow.ch arith.ch
|
||||||
|
|
||||||
|
libqoca_la_SOURCES =
|
||||||
|
# Rationale for emptiness: If it has any .cc files, then automake
|
||||||
|
# produces .cc.o rules, which stuffs things up (because make sometimes
|
||||||
|
# tries to use them directly instead of using the .ii0.o rule). If it
|
||||||
|
# had .ii0 files, then the .ii0 files would be put into distdir, which
|
||||||
|
# is wrong because .ii0 files contain system header file contents.
|
||||||
|
|
||||||
|
EXTRA_DIST = $(dist_libqoca_sources) Makefile.am.m4 $(ch_files)
|
||||||
|
|
||||||
|
CLEANFILES = *.ii *.ii0
|
||||||
|
|
||||||
|
DISTCLEANFILES = -r .deps
|
||||||
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||||
|
CONFIG_CLEAN_FILES = QcEnables.H
|
||||||
|
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||||
|
|
||||||
|
|
||||||
|
DEFS = @DEFS@ -I. -I$(srcdir)
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
LIBS = @LIBS@
|
||||||
|
libqoca_la_DEPENDENCIES =
|
||||||
|
libqoca_la_OBJECTS =
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
CCLD = $(CC)
|
||||||
|
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||||
|
HEADERS = $(pkginclude_HEADERS)
|
||||||
|
|
||||||
|
DIST_COMMON = ChangeLog Makefile.am Makefile.in QcEnables.H.in
|
||||||
|
|
||||||
|
|
||||||
|
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
|
|
||||||
|
TAR = gtar
|
||||||
|
GZIP_ENV = --best
|
||||||
|
SOURCES = $(libqoca_la_SOURCES)
|
||||||
|
OBJECTS = $(libqoca_la_OBJECTS)
|
||||||
|
|
||||||
|
all: all-redirect
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .H .S .c .cc .ch .hh .ii0 .lo .o .s
|
||||||
|
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||||
|
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps cxx/qoca/Makefile
|
||||||
|
|
||||||
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
|
cd $(top_builddir) \
|
||||||
|
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||||
|
|
||||||
|
QcEnables.H: $(top_builddir)/config.status QcEnables.H.in
|
||||||
|
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||||
|
|
||||||
|
mostlyclean-libLTLIBRARIES:
|
||||||
|
|
||||||
|
clean-libLTLIBRARIES:
|
||||||
|
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||||
|
|
||||||
|
distclean-libLTLIBRARIES:
|
||||||
|
|
||||||
|
maintainer-clean-libLTLIBRARIES:
|
||||||
|
|
||||||
|
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||||
|
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||||
|
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||||
|
else :; fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-libLTLIBRARIES:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||||
|
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||||
|
done
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
|
.s.o:
|
||||||
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
|
.S.o:
|
||||||
|
$(COMPILE) -c $<
|
||||||
|
|
||||||
|
mostlyclean-compile:
|
||||||
|
-rm -f *.o core *.core
|
||||||
|
|
||||||
|
clean-compile:
|
||||||
|
|
||||||
|
distclean-compile:
|
||||||
|
-rm -f *.tab.c
|
||||||
|
|
||||||
|
maintainer-clean-compile:
|
||||||
|
|
||||||
|
.c.lo:
|
||||||
|
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||||
|
|
||||||
|
.s.lo:
|
||||||
|
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||||
|
|
||||||
|
.S.lo:
|
||||||
|
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||||
|
|
||||||
|
mostlyclean-libtool:
|
||||||
|
-rm -f *.lo
|
||||||
|
|
||||||
|
clean-libtool:
|
||||||
|
-rm -rf .libs _libs
|
||||||
|
|
||||||
|
distclean-libtool:
|
||||||
|
|
||||||
|
maintainer-clean-libtool:
|
||||||
|
|
||||||
|
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
$(mkinstalldirs) $(DESTDIR)$(pkgincludedir)
|
||||||
|
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
|
||||||
|
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
|
||||||
|
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p"; \
|
||||||
|
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(pkgincludedir)/$$p; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-pkgincludeHEADERS:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
list='$(pkginclude_HEADERS)'; for p in $$list; do \
|
||||||
|
rm -f $(DESTDIR)$(pkgincludedir)/$$p; \
|
||||||
|
done
|
||||||
|
|
||||||
|
tags: TAGS
|
||||||
|
|
||||||
|
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||||
|
list='$(SOURCES) $(HEADERS)'; \
|
||||||
|
unique=`for i in $$list; do echo $$i; done | \
|
||||||
|
awk ' { files[$$0] = 1; } \
|
||||||
|
END { for (i in files) print i; }'`; \
|
||||||
|
here=`pwd` && cd $(srcdir) \
|
||||||
|
&& mkid -f$$here/ID $$unique $(LISP)
|
||||||
|
|
||||||
|
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||||
|
tags=; \
|
||||||
|
here=`pwd`; \
|
||||||
|
list='$(SOURCES) $(HEADERS)'; \
|
||||||
|
unique=`for i in $$list; do echo $$i; done | \
|
||||||
|
awk ' { files[$$0] = 1; } \
|
||||||
|
END { for (i in files) print i; }'`; \
|
||||||
|
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||||
|
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||||
|
|
||||||
|
mostlyclean-tags:
|
||||||
|
|
||||||
|
clean-tags:
|
||||||
|
|
||||||
|
distclean-tags:
|
||||||
|
-rm -f TAGS ID
|
||||||
|
|
||||||
|
maintainer-clean-tags:
|
||||||
|
|
||||||
|
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||||
|
|
||||||
|
subdir = cxx/qoca
|
||||||
|
|
||||||
|
distdir: $(DISTFILES)
|
||||||
|
@for file in $(DISTFILES); do \
|
||||||
|
d=$(srcdir); \
|
||||||
|
if test -d $$d/$$file; then \
|
||||||
|
cp -pr $$d/$$file $(distdir)/$$file; \
|
||||||
|
else \
|
||||||
|
test -f $(distdir)/$$file \
|
||||||
|
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||||
|
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook
|
||||||
|
|
||||||
|
info-am:
|
||||||
|
info: info-am
|
||||||
|
dvi-am:
|
||||||
|
dvi: dvi-am
|
||||||
|
check-am: all-am
|
||||||
|
check: check-am
|
||||||
|
installcheck-am:
|
||||||
|
installcheck: installcheck-am
|
||||||
|
install-exec-am: install-libLTLIBRARIES
|
||||||
|
install-exec: install-exec-am
|
||||||
|
|
||||||
|
install-data-am: install-pkgincludeHEADERS
|
||||||
|
install-data: install-data-am
|
||||||
|
|
||||||
|
install-am: all-am
|
||||||
|
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||||
|
install: install-am
|
||||||
|
uninstall-am: uninstall-libLTLIBRARIES uninstall-pkgincludeHEADERS
|
||||||
|
uninstall: uninstall-am
|
||||||
|
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
||||||
|
all-redirect: all-am
|
||||||
|
install-strip:
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||||
|
installdirs:
|
||||||
|
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(pkgincludedir)
|
||||||
|
|
||||||
|
|
||||||
|
mostlyclean-generic:
|
||||||
|
|
||||||
|
clean-generic:
|
||||||
|
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||||
|
|
||||||
|
distclean-generic:
|
||||||
|
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||||
|
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||||
|
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||||
|
|
||||||
|
maintainer-clean-generic:
|
||||||
|
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||||
|
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
|
||||||
|
mostlyclean-libtool mostlyclean-tags \
|
||||||
|
mostlyclean-generic
|
||||||
|
|
||||||
|
mostlyclean: mostlyclean-am
|
||||||
|
|
||||||
|
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
|
||||||
|
clean-generic mostlyclean-am
|
||||||
|
|
||||||
|
clean: clean-am
|
||||||
|
|
||||||
|
distclean-am: distclean-libLTLIBRARIES distclean-compile \
|
||||||
|
distclean-libtool distclean-tags distclean-generic \
|
||||||
|
clean-am
|
||||||
|
-rm -f libtool
|
||||||
|
|
||||||
|
distclean: distclean-am
|
||||||
|
|
||||||
|
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
|
||||||
|
maintainer-clean-compile maintainer-clean-libtool \
|
||||||
|
maintainer-clean-tags maintainer-clean-generic \
|
||||||
|
distclean-am
|
||||||
|
@echo "This command is intended for maintainers to use;"
|
||||||
|
@echo "it deletes files that may require special tools to rebuild."
|
||||||
|
|
||||||
|
maintainer-clean: maintainer-clean-am
|
||||||
|
|
||||||
|
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
|
||||||
|
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
|
||||||
|
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
|
||||||
|
distclean-compile clean-compile maintainer-clean-compile \
|
||||||
|
mostlyclean-libtool distclean-libtool clean-libtool \
|
||||||
|
maintainer-clean-libtool uninstall-pkgincludeHEADERS \
|
||||||
|
install-pkgincludeHEADERS tags mostlyclean-tags distclean-tags \
|
||||||
|
clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
|
||||||
|
check-am installcheck-am installcheck install-exec-am install-exec \
|
||||||
|
install-data-am install-data install-am install uninstall-am uninstall \
|
||||||
|
all-redirect all-am all installdirs mostlyclean-generic \
|
||||||
|
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||||
|
mostlyclean distclean maintainer-clean
|
||||||
|
|
||||||
|
|
||||||
|
$(srcdir)/Makefile.am: Makefile.am.m4
|
||||||
|
rm -f $(srcdir)/$(@F)
|
||||||
|
m4 -P $(srcdir)/$(<F) > $(srcdir)/$(@F)
|
||||||
|
|
||||||
|
.ch.cc: $(CH2XX)
|
||||||
|
@rm -f $(bsrcdir)/$(*F).cc && if echo "$(CH2XX) -c $< > $(bsrcdir)/$(*F).cc" \
|
||||||
|
&& $(CH2XX) -c $< > $(bsrcdir)/$(*F).cc; \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(*F).cc; exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(*F).cc; exit 1; fi
|
||||||
|
|
||||||
|
.ch.hh: $(CH2XX)
|
||||||
|
@rm -f $(bsrcdir)/$(*F).hh && if echo "$(CH2XX) -i $< > $(bsrcdir)/$(*F).hh" \
|
||||||
|
&& $(CH2XX) -i $< > $(bsrcdir)/$(*F).hh; \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(*F).hh; exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(*F).hh; exit 1; fi
|
||||||
|
|
||||||
|
.ch.H: $(CH2XX)
|
||||||
|
@rm -f $(bsrcdir)/$(*F).H && if echo "$(CH2XX) -d $< > $(bsrcdir)/$(*F).H" \
|
||||||
|
&& $(CH2XX) -d $< > $(bsrcdir)/$(*F).H; \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(*F).H; exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(*F).H; exit 1; fi
|
||||||
|
|
||||||
|
|
||||||
|
.cc.ii0:
|
||||||
|
@rm -f $(bsrcdir)/$(@F) && if echo "$(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F)" \
|
||||||
|
&& $(CXXCPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Wp,-MD,.deps/$(*F).pp $< > $(bsrcdir)/$(@F); \
|
||||||
|
then :; \
|
||||||
|
else echo "rm -f $(bsrcdir)/$(@F); exit 1" \
|
||||||
|
&& rm -f $(bsrcdir)/$(@F); exit 1; fi
|
||||||
|
@rm -f .deps/$(*F).P
|
||||||
|
@-sed 's/\.o/.ii0/g' < .deps/$(*F).pp > .deps/$(*F).P; \
|
||||||
|
tr ' ' '\012' < .deps/$(*F).pp \
|
||||||
|
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||||
|
>> .deps/$(*F).P; \
|
||||||
|
rm .deps/$(*F).pp
|
||||||
|
|
||||||
|
libqoca.la: $(ii0_files) $(libqoca_la_myOBJECTS) $(libqoca_la_DEPENDENCIES)
|
||||||
|
$(CXXLINK) -rpath $(libdir) $(libqoca_la_LDFLAGS) $(libqoca_la_myOBJECTS) $(libqoca_la_LIBADD) $(LIBS)
|
||||||
|
|
||||||
|
.ii0.o:
|
||||||
|
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
|
||||||
|
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
|
||||||
|
echo "$(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& $(CXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
.ii0.lo:
|
||||||
|
@if test -f $@ && cmp -s $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii 2>/dev/null; then :; else \
|
||||||
|
echo "cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& cp $(bsrcdir)/$(<F) $(bsrcdir)/$(*F).ii && \
|
||||||
|
echo "$(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii" \
|
||||||
|
&& $(LTCXXCOMPILE) -c $(bsrcdir)/$(*F).ii; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
dist-hook:
|
||||||
|
@rm -f $(distdir)/Makefile.tmp
|
||||||
|
grep -v '^-include ' < $(distdir)/Makefile.in > $(distdir)/Makefile.tmp
|
||||||
|
mv $(distdir)/Makefile.tmp $(distdir)/Makefile.in
|
||||||
|
|
||||||
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
.NOEXPORT:
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// Generated automatically from QcASetSolver.ch by /home/pmoulder/usr/local/bin/ch2xx.
|
||||||
|
#ifndef QcASetSolverDCL
|
||||||
|
#define QcASetSolverDCL
|
||||||
|
#line 1 "QcASetSolver.ch"
|
||||||
|
#include <qoca/QcSolver.H>
|
||||||
|
|
||||||
|
|
||||||
|
class QcASetSolver
|
||||||
|
: public QcSolver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
inline
|
||||||
|
QcASetSolver();
|
||||||
|
#line 15 "QcASetSolver.ch"
|
||||||
|
inline
|
||||||
|
QcASetSolver(unsigned hintNumConstraints, unsigned hintNumVariables);
|
||||||
|
#line 22 "QcASetSolver.ch"
|
||||||
|
virtual ~QcASetSolver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* !QcASetSolverDCL */
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Generated automatically from QcASetSolver.ch by /home/pmoulder/usr/local/bin/ch2xx.
|
||||||
|
#include "QcASetSolver.hh"
|
||||||
|
#line 1 "QcASetSolver.ch"
|
||||||
|
|
||||||
|
#include <qoca/QcSolver.hh>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line 29 "QcASetSolver.ch"
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
//o[d] #include <qoca/QcSolver.H>
|
||||||
|
//o[ci] #include <qoca/QcSolver.hh>
|
||||||
|
|
||||||
|
//ho class QcASetSolver
|
||||||
|
//ho : public QcSolver
|
||||||
|
//ho {
|
||||||
|
//ho public:
|
||||||
|
|
||||||
|
inline
|
||||||
|
QcASetSolver()
|
||||||
|
: QcSolver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
QcASetSolver(unsigned hintNumConstraints, unsigned hintNumVariables)
|
||||||
|
: QcSolver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//begin ho
|
||||||
|
virtual ~QcASetSolver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
//end ho
|
||||||
|
|
||||||
|
//ho };
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// Generated automatically from QcASetSolver.ch by /home/pmoulder/usr/local/bin/ch2xx.
|
||||||
|
#include "QcASetSolver.H"
|
||||||
|
#ifndef QcASetSolverIFN
|
||||||
|
#define QcASetSolverIFN
|
||||||
|
#line 1 "QcASetSolver.ch"
|
||||||
|
|
||||||
|
#include <qoca/QcSolver.hh>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
QcASetSolver::QcASetSolver()
|
||||||
|
: QcSolver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
QcASetSolver::QcASetSolver(unsigned hintNumConstraints, unsigned hintNumVariables)
|
||||||
|
: QcSolver()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#line 29 "QcASetSolver.ch"
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* !QcASetSolverIFN */
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// Generated automatically from QcAliasedBiMap.ch by /home/pmoulder/usr/local/bin/ch2xx.
|
||||||
|
#ifndef QcAliasedBiMapDCL
|
||||||
|
#define QcAliasedBiMapDCL
|
||||||
|
#line 1 "QcAliasedBiMap.ch"
|
||||||
|
|
||||||
|
#include <qoca/QcBiMap.H>
|
||||||
|
|
||||||
|
|
||||||
|
#line 11 "QcAliasedBiMap.ch"
|
||||||
|
#define TMPL template<class NullableT, class ExternalT, class PointedToT>
|
||||||
|
TMPL
|
||||||
|
class QcAliasedBiMap
|
||||||
|
: public QcBiMap<NullableT>
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
QcAliasedBiMap() { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Update(ExternalT const &ident, int index);
|
||||||
|
#line 33 "QcAliasedBiMap.ch"
|
||||||
|
inline void
|
||||||
|
Update(PointedToT *ident, int index);
|
||||||
|
#line 41 "QcAliasedBiMap.ch"
|
||||||
|
inline bool
|
||||||
|
IdentifierPresent(ExternalT const &ident) const;
|
||||||
|
#line 48 "QcAliasedBiMap.ch"
|
||||||
|
inline bool
|
||||||
|
IdentifierPtrPresent(PointedToT *ident) const;
|
||||||
|
#line 55 "QcAliasedBiMap.ch"
|
||||||
|
inline ExternalT &
|
||||||
|
Identifier(int index);
|
||||||
|
#line 67 "QcAliasedBiMap.ch"
|
||||||
|
inline ExternalT &
|
||||||
|
Identifier(char const *n);
|
||||||
|
#line 79 "QcAliasedBiMap.ch"
|
||||||
|
inline PointedToT *
|
||||||
|
getIdentifierPtr(int index);
|
||||||
|
#line 87 "QcAliasedBiMap.ch"
|
||||||
|
inline int
|
||||||
|
Index(ExternalT const &ident) const;
|
||||||
|
#line 94 "QcAliasedBiMap.ch"
|
||||||
|
inline int
|
||||||
|
Index(PointedToT *ident) const;
|
||||||
|
#line 101 "QcAliasedBiMap.ch"
|
||||||
|
inline int
|
||||||
|
safeIndex(ExternalT const &ident) const;
|
||||||
|
#line 108 "QcAliasedBiMap.ch"
|
||||||
|
inline int
|
||||||
|
safeIndex(PointedToT *ident) const;
|
||||||
|
#line 114 "QcAliasedBiMap.ch"
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef TMPL
|
||||||
|
#undef A2E
|
||||||
|
#undef const_E2A
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* !QcAliasedBiMapDCL */
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
//begin o[d]
|
||||||
|
#include <qoca/QcBiMap.H>
|
||||||
|
//end o[d]
|
||||||
|
//begin o[i]
|
||||||
|
#include <qoca/QcBiMap.hh>
|
||||||
|
|
||||||
|
#define A2E(_nkey) *((ExternalT *)((void *)&(_nkey)))
|
||||||
|
#define const_E2A(_ekey) reinterpret_cast<NullableT const &>(_ekey)
|
||||||
|
//end o[i]
|
||||||
|
|
||||||
|
#define TMPL template<class NullableT, class ExternalT, class PointedToT>
|
||||||
|
//o[d] TMPL
|
||||||
|
//o[d] class QcAliasedBiMap
|
||||||
|
//o[d] : public QcBiMap<NullableT>
|
||||||
|
//o[d] {
|
||||||
|
|
||||||
|
//$class_prefix = QcAliasedBiMap<NullableT, ExternalT, PointedToT>::
|
||||||
|
|
||||||
|
//begin o[d]
|
||||||
|
public:
|
||||||
|
QcAliasedBiMap() { }
|
||||||
|
//end o[d]
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline void
|
||||||
|
Update(ExternalT const &ident, int index)
|
||||||
|
{
|
||||||
|
qcAssertPre( ident.pointer() != 0);
|
||||||
|
QcBiMap<NullableT>::Update(const_E2A(ident), index);
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline void
|
||||||
|
Update(PointedToT *ident, int index)
|
||||||
|
{
|
||||||
|
qcAssertPre( ident != 0);
|
||||||
|
QcBiMap<NullableT>::Update( NullableT( ident), index);
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline bool
|
||||||
|
IdentifierPresent(ExternalT const &ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::IdentifierPresent(const_E2A(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline bool
|
||||||
|
IdentifierPtrPresent(PointedToT *ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::IdentifierPresent( NullableT( ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline ExternalT &
|
||||||
|
Identifier(int index)
|
||||||
|
{
|
||||||
|
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
|
||||||
|
NullableT *nidp = &nid;
|
||||||
|
void *vp = nidp;
|
||||||
|
ExternalT *ep = (ExternalT *) vp;
|
||||||
|
ExternalT &eid = *ep;
|
||||||
|
return eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline ExternalT &
|
||||||
|
Identifier(char const *n)
|
||||||
|
{
|
||||||
|
NullableT &nid = QcBiMap<NullableT>::Identifier( n);
|
||||||
|
NullableT *nidp = &nid;
|
||||||
|
void *vp = nidp;
|
||||||
|
ExternalT *ep = (ExternalT *) vp;
|
||||||
|
ExternalT &eid = *ep;
|
||||||
|
return eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline PointedToT *
|
||||||
|
getIdentifierPtr(int index)
|
||||||
|
{
|
||||||
|
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
|
||||||
|
return nid.pointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline int
|
||||||
|
Index(ExternalT const &ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::Index(const_E2A(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline int
|
||||||
|
Index(PointedToT *ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::Index( NullableT( ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline int
|
||||||
|
safeIndex(ExternalT const &ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::safeIndex(const_E2A(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[i] TMPL
|
||||||
|
inline int
|
||||||
|
safeIndex(PointedToT *ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::safeIndex( NullableT( ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
//o[d] };
|
||||||
|
|
||||||
|
#undef TMPL
|
||||||
|
#undef A2E
|
||||||
|
#undef const_E2A
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
// Generated automatically from QcAliasedBiMap.ch by /home/pmoulder/usr/local/bin/ch2xx.
|
||||||
|
#include "QcAliasedBiMap.H"
|
||||||
|
#ifndef QcAliasedBiMapIFN
|
||||||
|
#define QcAliasedBiMapIFN
|
||||||
|
#line 1 "QcAliasedBiMap.ch"
|
||||||
|
|
||||||
|
#line 5 "QcAliasedBiMap.ch"
|
||||||
|
#include <qoca/QcBiMap.hh>
|
||||||
|
|
||||||
|
#define A2E(_nkey) *((ExternalT *)((void *)&(_nkey)))
|
||||||
|
#define const_E2A(_ekey) reinterpret_cast<NullableT const &>(_ekey)
|
||||||
|
|
||||||
|
|
||||||
|
#define TMPL template<class NullableT, class ExternalT, class PointedToT>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line 24 "QcAliasedBiMap.ch"
|
||||||
|
TMPL
|
||||||
|
inline void
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Update(ExternalT const &ident, int index)
|
||||||
|
{
|
||||||
|
qcAssertPre( ident.pointer() != 0);
|
||||||
|
QcBiMap<NullableT>::Update(const_E2A(ident), index);
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline void
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Update(PointedToT *ident, int index)
|
||||||
|
{
|
||||||
|
qcAssertPre( ident != 0);
|
||||||
|
QcBiMap<NullableT>::Update( NullableT( ident), index);
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline bool
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::IdentifierPresent(ExternalT const &ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::IdentifierPresent(const_E2A(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline bool
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::IdentifierPtrPresent(PointedToT *ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::IdentifierPresent( NullableT( ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline ExternalT &
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Identifier(int index)
|
||||||
|
{
|
||||||
|
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
|
||||||
|
NullableT *nidp = &nid;
|
||||||
|
void *vp = nidp;
|
||||||
|
ExternalT *ep = (ExternalT *) vp;
|
||||||
|
ExternalT &eid = *ep;
|
||||||
|
return eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline ExternalT &
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Identifier(char const *n)
|
||||||
|
{
|
||||||
|
NullableT &nid = QcBiMap<NullableT>::Identifier( n);
|
||||||
|
NullableT *nidp = &nid;
|
||||||
|
void *vp = nidp;
|
||||||
|
ExternalT *ep = (ExternalT *) vp;
|
||||||
|
ExternalT &eid = *ep;
|
||||||
|
return eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline PointedToT *
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::getIdentifierPtr(int index)
|
||||||
|
{
|
||||||
|
NullableT &nid = QcBiMap<NullableT>::Identifier( index);
|
||||||
|
return nid.pointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline int
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Index(ExternalT const &ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::Index(const_E2A(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline int
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::Index(PointedToT *ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::Index( NullableT( ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline int
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::safeIndex(ExternalT const &ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::safeIndex(const_E2A(ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPL
|
||||||
|
inline int
|
||||||
|
QcAliasedBiMap<NullableT, ExternalT, PointedToT>::safeIndex(PointedToT *ident) const
|
||||||
|
{
|
||||||
|
return QcBiMap<NullableT>::safeIndex( NullableT( ident));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#undef TMPL
|
||||||
|
#undef A2E
|
||||||
|
#undef const_E2A
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
mode:c++
|
||||||
|
c-file-style:"gnu"
|
||||||
|
fill-column:80
|
||||||
|
End:
|
||||||
|
vim: set filetype=c++ :
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* !QcAliasedBiMapIFN */
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// $Id: QcBasicVarIndexIterator.hh,v 1.5 2000/11/29 01:58:42 pmoulder Exp $
|
||||||
|
|
||||||
|
//============================================================================//
|
||||||
|
// Written by Sitt Sen Chok //
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
// The QOCA implementation is free software, but it is Copyright (C) //
|
||||||
|
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
|
||||||
|
// General Public License. See the file COPYING for copying permission. //
|
||||||
|
// //
|
||||||
|
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
|
||||||
|
// Library General Public License. See the file COPYING.LIB for copying //
|
||||||
|
// permissions for those files. //
|
||||||
|
// //
|
||||||
|
// If those licencing arrangements are not satisfactory, please contact us! //
|
||||||
|
// We are willing to offer alternative arrangements, if the need should arise.//
|
||||||
|
// //
|
||||||
|
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
|
||||||
|
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
|
||||||
|
// //
|
||||||
|
// Permission is hereby granted to use or copy this program for any purpose, //
|
||||||
|
// provided the above notices are retained on all copies. Permission to //
|
||||||
|
// modify the code and to distribute modified code is granted, provided the //
|
||||||
|
// above notices are retained, and a notice that the code was modified is //
|
||||||
|
// included with the above copyright notice. //
|
||||||
|
//============================================================================//
|
||||||
|
|
||||||
|
#ifndef __QcBasicVarIndexIteratorH
|
||||||
|
#define __QcBasicVarIndexIteratorH
|
||||||
|
|
||||||
|
#include <qoca/QcBasicnessVarIndexIterator.hh>
|
||||||
|
|
||||||
|
class QcBasicVarIndexIterator
|
||||||
|
: public QcBasicnessVarIndexIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------//
|
||||||
|
// Constructor. //
|
||||||
|
//------------------------------------------------------------------------//
|
||||||
|
QcBasicVarIndexIterator( const QcLinEqTableau &tab)
|
||||||
|
: QcBasicnessVarIndexIterator( &tab.GetColState().fBasicHead)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
QcBasicnessVarIndexIterator::Reset();
|
||||||
|
qcAssertPost( fCurrent->isBasic());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Increment()
|
||||||
|
{
|
||||||
|
QcBasicnessVarIndexIterator::Increment();
|
||||||
|
qcAssertPost( fCurrent->isBasic());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @precondition <tt>!AtEnd()</tt>
|
||||||
|
@postcondition <tt>(int) ret</tt> ≥ 0
|
||||||
|
**/
|
||||||
|
unsigned getConstraintBasicIn() const
|
||||||
|
{
|
||||||
|
qcAssertPre (!AtEnd());
|
||||||
|
int ret = fCurrent->getConstraintBasicIn();
|
||||||
|
qcAssertPost (ret >= 0);
|
||||||
|
return (unsigned) ret;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !__QcBasicVarIndexIteratorH */
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
// $Id: QcBasicnessVarIndexIterator.hh,v 1.1 2000/11/29 01:58:42 pmoulder Exp $
|
||||||
|
|
||||||
|
//============================================================================//
|
||||||
|
// Written by Sitt Sen Chok //
|
||||||
|
//----------------------------------------------------------------------------//
|
||||||
|
// The QOCA implementation is free software, but it is Copyright (C) //
|
||||||
|
// 1994-1999 Monash University. It is distributed under the terms of the GNU //
|
||||||
|
// General Public License. See the file COPYING for copying permission. //
|
||||||
|
// //
|
||||||
|
// The QOCA toolkit and runtime are distributed under the terms of the GNU //
|
||||||
|
// Library General Public License. See the file COPYING.LIB for copying //
|
||||||
|
// permissions for those files. //
|
||||||
|
// //
|
||||||
|
// If those licencing arrangements are not satisfactory, please contact us! //
|
||||||
|
// We are willing to offer alternative arrangements, if the need should arise.//
|
||||||
|
// //
|
||||||
|
// THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR //
|
||||||
|
// IMPLIED. ANY USE IS AT YOUR OWN RISK. //
|
||||||
|
// //
|
||||||
|
// Permission is hereby granted to use or copy this program for any purpose, //
|
||||||
|
// provided the above notices are retained on all copies. Permission to //
|
||||||
|
// modify the code and to distribute modified code is granted, provided the //
|
||||||
|
// above notices are retained, and a notice that the code was modified is //
|
||||||
|
// included with the above copyright notice. //
|
||||||
|
//============================================================================//
|
||||||
|
|
||||||
|
#ifndef __QcBasicnessVarIndexIteratorH
|
||||||
|
#define __QcBasicnessVarIndexIteratorH
|
||||||
|
|
||||||
|
class QcBasicnessVarIndexIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------//
|
||||||
|
// Constructor. //
|
||||||
|
//------------------------------------------------------------------------//
|
||||||
|
QcBasicnessVarIndexIterator (QcLinEqColState const *head);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------//
|
||||||
|
// Iteration functions. //
|
||||||
|
//------------------------------------------------------------------------//
|
||||||
|
bool AtEnd() const
|
||||||
|
{
|
||||||
|
return (fCurrent == fHead);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @precondition <tt>!AtEnd()</tt>
|
||||||
|
@postcondition <tt>(int) ret</tt> ≥ 0
|
||||||
|
**/
|
||||||
|
unsigned getIndex() const
|
||||||
|
{
|
||||||
|
qcAssertPre (!AtEnd());
|
||||||
|
unsigned ret = fCurrent->fIndex;
|
||||||
|
qcAssertPost ((int) ret >= 0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Increment()
|
||||||
|
{
|
||||||
|
qcAssertPre (!AtEnd());
|
||||||
|
|
||||||
|
fCurrent = fCurrent->getNextBasicnessCol();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
fCurrent = fHead->getNextBasicnessCol();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QcLinEqColState const *fCurrent;
|
||||||
|
private:
|
||||||
|
QcLinEqColState const *fHead;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
QcBasicnessVarIndexIterator::QcBasicnessVarIndexIterator (QcLinEqColState const *head)
|
||||||
|
: fHead (head)
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !__QcBasicnessVarIndexIteratorH */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user