#ifndef WINDOW_LAYER_H
#define WINDOW_LAYER_H
#include <List.h>
#include <Looper.h>
#include <Region.h>
#include <String.h>
#include "ViewLayer.h"
class ClientLooper;
class Desktop;
class DrawingEngine;
enum {
MSG_REDRAW = 'rdrw',
MSG_BEGIN_UPDATE = 'bgud',
MSG_END_UPDATE = 'edud',
MSG_DRAWING_COMMAND = 'draw',
MSG_SHOW = 'show',
MSG_INVALIDATE_VIEW = 'invl',
MSG_DRAW_POLYGON = 'drwp',
};
class UpdateSession {
public:
UpdateSession();
virtual ~UpdateSession();
void Include(BRegion* additionalDirty);
void Exclude(BRegion* dirtyInNextSession);
inline BRegion& DirtyRegion()
{ return fDirtyRegion; }
void MoveBy(int32 x, int32 y);
void SetUsed(bool used);
inline bool IsUsed() const
{ return fInUse; }
UpdateSession& operator=(const UpdateSession& other);
private:
BRegion fDirtyRegion;
bool fInUse;
};
class WindowLayer : public BLooper {
public:
WindowLayer(BRect frame, const char* name,
DrawingEngine* drawingEngine,
Desktop* desktop);
virtual ~WindowLayer();
virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested();
inline BRect Frame() const
{ return fFrame; }
void SetClipping(BRegion* stillAvailableOnScreen);
inline BRegion& VisibleRegion()
{ return fVisibleRegion; }
BRegion& VisibleContentRegion();
void GetFullRegion(BRegion* region) const;
void GetBorderRegion(BRegion* region);
void GetContentRegion(BRegion* region);
void SetFocus(bool focus);
void MoveBy(int32 x, int32 y);
void ResizeBy(int32 x, int32 y, BRegion* dirtyRegion);
void ScrollViewBy(ViewLayer* view, int32 dx, int32 dy);
void AddChild(ViewLayer* layer);
ViewLayer* ViewAt(const BPoint& where);
void SetHidden(bool hidden);
inline bool IsHidden() const
{ return fHidden; }
void MarkDirty(BRegion* regionOnScreen);
void MarkContentDirty(BRegion* regionOnScreen);
void InvalidateView(int32 token);
void ProcessDirtyRegion(BRegion* region);
DrawingEngine* GetDrawingEngine() const
{ return fDrawingEngine; }
void CopyContents(BRegion* region,
int32 xOffset, int32 yOffset);
private:
void _ShiftPartOfRegion(BRegion* region, BRegion* regionToShift,
int32 xOffset, int32 yOffset);
void _TriggerContentRedraw();
void _DrawClient(int32 token);
void _DrawClientPolygon(int32 token, BPoint polygon[4]);
void _DrawBorder();
void _MarkContentDirty(BRegion* contentDirtyRegion);
void _BeginUpdate();
void _EndUpdate();
void _UpdateContentRegion();
BRect fFrame;
BRegion fVisibleRegion;
BRegion fVisibleContentRegion;
bool fVisibleContentRegionValid;
BRegion fDirtyRegion;
BRegion fBorderRegion;
bool fBorderRegionValid;
BRegion fContentRegion;
bool fContentRegionValid;
BRegion fEffectiveDrawingRegion;
bool fEffectiveDrawingRegionValid;
bool fFocus;
ViewLayer* fTopLayer;
bool fHidden;
DrawingEngine* fDrawingEngine;
Desktop* fDesktop;
BList fTokenViewMap;
ClientLooper* fClient;
UpdateSession fCurrentUpdateSession;
UpdateSession fPendingUpdateSession;
bool fUpdateRequested;
bool fInUpdate;
};
#endif