libui/haiku/area.cpp

86 lines
1.5 KiB
C++
Raw Normal View History

2015-11-18 22:47:20 -06:00
// 18 november 2015
#include "uipriv_haiku.hpp"
2015-11-23 17:08:34 -06:00
// TODO scrollbars
class areaView : public BView {
public:
// C++11! Inherit constructors.
using BView::BView;
uiArea *a;
virtual void Draw(BRect updateRect);
};
2015-11-18 22:47:20 -06:00
struct uiArea {
uiHaikuControl c;
2015-11-23 17:08:34 -06:00
areaView *area;
uiAreaHandler *ah;
2015-11-18 22:47:20 -06:00
};
uiHaikuDefineControl(
uiArea, // type name
uiAreaType, // type function
2015-11-23 17:08:34 -06:00
area // handle
2015-11-18 22:47:20 -06:00
)
2015-11-23 17:08:34 -06:00
void areaView::Draw(BRect updateRect)
{
uiAreaHandler *ah = this->a->ah;
uiAreaDrawParams dp;
BRect bounds;
dp.Context = newContext(this);
bounds = this->Bounds();
dp.ClientWidth = bounds.right - bounds.left;
dp.ClientHeight = bounds.bottom - bounds.top;
dp.ClipX = updateRect.left;
dp.ClipY = updateRect.top;
dp.ClipWidth = updateRect.right - updateRect.left;
dp.ClipHeight = updateRect.bottom - updateRect.top;
// TODO scroll positions
(*(ah->Draw))(ah, this->a, &dp);
freeContext(dp.Context);
}
2015-11-18 22:47:20 -06:00
void uiAreaUpdateScroll(uiArea *a)
{
// TODO
}
void uiAreaQueueRedrawAll(uiArea *a)
{
2015-11-23 17:08:34 -06:00
// TODO does this really /queue/ a redraw? or does it redraw right away, regardless of the drawing machinery?
a->area->Invalidate();
2015-11-18 22:47:20 -06:00
}
uiArea *uiNewArea(uiAreaHandler *ah)
{
uiArea *a;
a = (uiArea *) uiNewControl(uiAreaType());
2015-11-23 17:08:34 -06:00
a->ah = ah;
// TODO:
// - B_FULL_UPDATE_ON_RESIZE?
// - B_FRAME_EVENTS?
// - B_NAVIGABLE?
// - B_SUBPIXEL_PRECISE?
// - B_INVALIDATE_AFTER_LAYOUT?
a->area = new areaView(NULL,
B_WILL_DRAW | B_SUPPORTS_LAYOUT,
NULL);
a->area->a = a;
// TODO background color
2015-11-18 22:47:20 -06:00
uiHaikuFinishNewControl(a, uiArea);
return a;
}