/*
* Copyright (c)1998 by Angry Red Planet.
*
* This code is distributed under a modified form of the
* Artistic License. A copy of this license should have
* been included with it; if this wasn't the case, the
* entire package can be obtained at
* .
*
* A logical GUI layout engine: the programmer describes
* high-level relationships between the different user interface
* object through formal container classes, which then take care
* of their physical placement. The system is completely
* font-sensitive and resizeable.
*
* ----------------------------------------------------------------------
*
* ViewStubs.h
*
* Interfaces to various Be UI objects that need a bit
* of extra help...
*
* ----------------------------------------------------------------------
*
* Known Bugs
* ~~~~~~~~~~
*
* • ArpListView and ArpOutlineListView currently set their
* preferred height to the total height of the text in the
* list view. This is wrong -- it should probably place some
* limit on this height, such as no more than six lines.
*
* ----------------------------------------------------------------------
*
* To Do
* ~~~~~
*
* • All of these should provide an ArpLayoutable parameters
* interface for setting their associated object's values.
*
* • It would probably be good to split this out into separate
* files.
*
* ----------------------------------------------------------------------
*
* History
* ~~~~~~~
*
* Dec 6, 1998:
* First public release.
*
* May 5, 1999:
* - ArpBox was not correctly propagating its child's maximum
* dimensions up to itself.
* - Added special magic to ArpMenuBar to correctly redraw the
* menu when resizing, without using B_FULL_UPDATE_ON_RESIZE.
*
*/
#ifndef ARPLAYOUT_VIEWSTUBS_H
#define ARPLAYOUT_VIEWSTUBS_H
#ifndef ARPLAYOUT_ARPVIEWWRAPPER_H
#include
#endif
#ifndef _VIEW_H
#include
#endif
#ifndef _MENUBAR_H
#include
#endif
#ifndef _BOX_H
#include
#endif
#ifndef _BUTTON_H
#include
#endif
#ifndef _COLORCONTROL_H
#include
#endif
#ifndef _LISTVIEW_H
#include
#endif
#ifndef _OUTLINELISTVIEW_H
#include
#endif
#ifndef _MENUBAR_H
#include
#endif
#ifndef _MENUFIELD_H
#include
#endif
#ifndef _TEXTCONTROL_H
#include
#endif
/* -----------------------------------------------------------
* ArpBox: Interface to BBox.
*
* Addresses the following problems:
*
* • Need to place proper space between box and child.
*/
#define IS_BOX 1
class ArpBox :
#ifdef IS_BOX
public BBox, public ArpViewWrapper {
private:
typedef BBox inherited;
#else
public ArpLayoutable {
private:
typedef ArpLayoutable inherited;
#endif
public:
ArpBox(const char* name, const char* label,
border_style border = B_FANCY_BORDER);
ArpBox(BMessage* data);
static ArpBox* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
#ifdef IS_BOX
void Draw(BRect updateRect);
#endif
protected:
void ComputeDimens(void);
void Layout(void);
private:
float indent_l, indent_t, indent_r, indent_b;
};
/* -----------------------------------------------------------
* ArpButton: Interface to BButton.
*
* Addresses the following problems:
*
* • Needs to have B_FULL_UPDATE_ON_RESIZE set to correctly
* resize itself.
* • BButton does not completely see a font change until
* its SetLabel() function is called.
*/
class ArpButton : public BButton, public ArpViewWrapper {
public:
ArpButton(const char* name, const char* label,
BMessage* message);
ArpButton(BMessage* data);
static ArpButton* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
protected:
void ComputeDimens(void);
private:
typedef ArpButton inherited;
};
/* -----------------------------------------------------------
* ArpListView: Interface to BListView.
*
* Addresses the following problems:
*
* • BListView does not return any useful preferred size.
*/
class ArpListView : public BListView, public ArpViewWrapper {
private:
typedef ArpViewWrapper inherited;
public:
ArpListView(const char* name,
list_view_type type=B_SINGLE_SELECTION_LIST);
ArpListView(BMessage* data);
static ArpListView* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
void GetPreferredSize(float* w, float* h);
virtual void MakeFocus(bool focusState = true);
protected:
void ComputeDimens(void);
};
/* -----------------------------------------------------------
* ArpOutlineListView: Interface to BOutlineListView.
*
* Addresses the following problems:
*
* • BOutlineListView does not return any useful preferred size.
*
* Remaining problems:
*
* • Font changes do not change the spacing of its items --
* but the items in a sub-hierarchy will be re-spaced if
* they are collapsed and then expanded again.
*/
class ArpOutlineListView : public BOutlineListView,
public ArpViewWrapper {
private:
typedef ArpViewWrapper inherited;
public:
ArpOutlineListView(const char* name,
list_view_type type=B_SINGLE_SELECTION_LIST);
ArpOutlineListView(BMessage* data);
static ArpOutlineListView* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
void GetPreferredSize(float* w, float* h);
virtual void MakeFocus(bool focusState = true);
protected:
void ComputeDimens(void);
};
/* -----------------------------------------------------------
* ArpMenuBar: Interface to BMenuBar.
*
* Addresses the following problems:
*
* • BMenuBar does not always return sane GetPreferredSize()
* values, unless some special magic is performed.
* • Need to distribute font changes to menu children.
*
*/
class ArpMenuBar : public BMenuBar, public ArpViewWrapper {
private:
typedef ArpViewWrapper inherited;
public:
ArpMenuBar(const char* title,
menu_layout layout = B_ITEMS_IN_ROW,
bool resizeToFit = true);
ArpMenuBar(BMessage* data);
static ArpMenuBar* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
virtual void FrameResized(float new_width, float new_height);
protected:
void ComputeDimens(void);
private:
void copy_font(BMenu* menu, BFont* font);
BRect mLastFrame;
};
/* -----------------------------------------------------------
* ArpMenuField: Interface to BMenuField.
*
* Addresses the following problems:
*
* • BMenuField does not seem to return anything useful
* from GetPreferredSize().
* • Need to correctly manage SetDivider().
* • Need to distribute font changes to menu children.
* • Add parameters to control font of menu.
*
*/
class ArpMenuField : public BMenuField, public ArpViewWrapper {
private:
typedef ArpViewWrapper inherited;
public:
ArpMenuField(const char* name, const char* label,
BMenu* menu, bool fixed_size=false);
ArpMenuField(BMessage* data);
static ArpMenuField* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
virtual void FrameResized(float new_width, float new_height);
static const char* MenuFontP;
static const char* MenuBackColorP;
static const char* MenuForeColorP;
protected:
virtual void DoSetParams(const ArpMessage* g,
const ArpMessage* p);
virtual bool DoParams(ArpMessage& p, const char* name);
void ComputeDimens(void);
ArpString PG_MenuFont;
ArpString PG_MenuBackColor;
ArpString PG_MenuForeColor;
BFont PV_MenuFont;
rgb_color PV_MenuBackColor;
rgb_color PV_MenuForeColor;
private:
void copy_attrs(BMenu* menu);
float mLabelWidth;
};
/* -----------------------------------------------------------
* ArpTextControl: Interface to BTextControl.
*
* Addresses the following problems:
*
* • Need to distribute font changes to text child.
* • Add parameters to control fill color of child.
* • Need more control over min/pref/max dimensions.
*/
class ArpTextControl : public BTextControl, public ArpViewWrapper {
private:
typedef ArpViewWrapper inherited;
public:
ArpTextControl(const char* name, const char* label,
const char* text, BMessage* message);
ArpTextControl(BMessage* data);
static ArpTextControl* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* data, bool deep=true);
virtual void AttachedToWindow(void);
static const char* FillBackColorP;
static const char* FillForeColorP;
static const char* FillFontP;
static const char* MinTextStringP;
static const char* PrefTextStringP;
static const char* MaxTextStringP;
protected:
virtual void DoSetParams(const ArpMessage* g,
const ArpMessage* p);
virtual bool DoParams(ArpMessage& p, const char* name);
void ComputeDimens(void);
ArpString PG_FillBackColor;
ArpString PG_FillForeColor;
ArpString PG_FillFont;
rgb_color PV_FillBackColor;
rgb_color PV_FillForeColor;
BFont PV_FillFont;
ArpString PV_MinTextString;
ArpString PV_PrefTextString;
ArpString PV_MaxTextString;
private:
void copy_colors(BView* v);
void copy_font(BView* v);
};
#endif