23#ifndef BAGEL_BOFLIB_GUI_WINDOW_H
24#define BAGEL_BOFLIB_GUI_WINDOW_H
26#include "common/list.h"
27#include "common/events.h"
28#include "bagel/spacebar/boflib/array.h"
29#include "bagel/boflib/stdinc.h"
30#include "bagel/boflib/error.h"
31#include "bagel/boflib/object.h"
32#include "bagel/boflib/point.h"
33#include "bagel/boflib/rect.h"
34#include "bagel/boflib/size.h"
35#include "bagel/spacebar/boflib/timer.h"
36#include "bagel/boflib/llist.h"
37#include "bagel/spacebar/boflib/gfx/bitmap.h"
38#include "bagel/boflib/palette.h"
39#include "bagel/spacebar/boflib/gfx/text.h"
48#define USE_DEFAULT (-1)
58 uint32 _lastLButtonTime = 0, _lastRButtonTime = 0;
94 static ErrorCode initialize();
95 static ErrorCode shutdown();
109 virtual ErrorCode
create(
const char *pszName,
int x,
int y,
int nWidth,
int nHeight,
CBofWindow *pParent, uint32 nControlID = 0);
125 virtual void destroyWindow() {
152 void move(
int x,
int y,
bool bRepaint =
false);
161 virtual ErrorCode close() {
173 void postMessage(uint32 nMessage, uint32 lParam1, uint32 lParam2);
186 void setTimer(uint32 nID, uint32 nInterval, BofCallback pCallBack =
nullptr);
213 return _pActiveWindow;
217 _pActiveWindow =
this;
224 CBofRect getWindowRect()
const {
227 CBofRect getClientRect();
229 CBofRect getRect()
const {
234 return _cRect.width();
237 return _cRect.height();
240 void screenToClient(CBofPoint *pPoint);
262 ErrorCode
setBackdrop(
const char *pszFileName,
bool bRefresh =
false);
264 void clearBackdrop() {
265 _pBackdrop =
nullptr;
272 bool hasBackdrop()
const {
273 return _pBackdrop !=
nullptr;
289 void setControlID(uint32 nID) {
292 uint32 getControlID()
const {
296 void setBkColor(COLORREF cColor) {
299 COLORREF getBkColor()
const {
303 void setFgColor(COLORREF cColor) {
306 COLORREF getFgColor()
const {
310 void setPrevMouseDown(CBofPoint p) {
313 CBofPoint getPrevMouseDown()
const {
314 return _cPrevMouseDown;
347 void flushAllMessages();
361 virtual void onBofButton(
CBofObject *pButton,
int nExtraInfo);
362 virtual void onBofScrollBar(
CBofObject *pButton,
int nNewPos);
363 virtual void onBofListBox(
CBofObject *pListBox,
int nItemIndex);
364 virtual void onMainLoop();
366 virtual void onSoundNotify(
CBofObject *pObject, uint32 lParam2);
367 virtual void onMovieNotify(uint32 lParam1, uint32 lParam2);
369 virtual void onMCINotify(uint32 wParam, uint32 lParam);
371 virtual void onTimer(uint32 nTimerId);
381 bool isCreated()
const {
382 return _surface !=
nullptr;
385 virtual void enable() {
389 virtual void disable() {
393 bool isVisible()
const {
396 bool isEnabled()
const {
409 virtual void onKeyHit(uint32 lKey, uint32 lRepCount);
410 void fillWindow(
byte iColor);
411 void fillRect(
CBofRect *pRect,
byte iColor);
413 ErrorCode paintBeveledText(
CBofRect *rect,
const CBofString &
string,
int size,
int weight, COLORREF color,
int justify, uint32 format);
420 virtual void onMouseMove(uint32 nFlags,
CBofPoint *pPoint,
void * =
nullptr);
421 virtual void onLButtonDown(uint32 nFlags,
CBofPoint *pPoint,
void * =
nullptr);
422 virtual void onLButtonUp(uint32 nFlags,
CBofPoint *pPoint,
void * =
nullptr);
423 virtual void onLButtonDblClk(uint32 nFlags,
CBofPoint *pPoint);
425 virtual void onRButtonDown(uint32 nFlags,
CBofPoint *pPoint);
426 virtual void onRButtonUp(uint32 nFlags,
CBofPoint *pPoint);
427 virtual void onRButtonDblClk(uint32 nFlags,
CBofPoint *pPoint);
429 virtual void onReSize(
CBofSize *pSize);
430 virtual void onPaint(
CBofRect *pRect);
431 virtual void onClose();
433 virtual void onUserMessage(uint32 nMessage, uint32 lParam);
435 virtual void onActivate();
436 virtual void onDeActivate();
439 char _szTitle[MAX_TITLE] = { 0 };
445 COLORREF _cBkColor = RGB(255, 255, 255);
446 COLORREF _cFgColor = RGB(0, 0, 0);
448 bool _bCaptured =
false;
470 BofCallback _pCallBack;
CBofWindow(const char *pszName, int x, int y, int nWidth, int nHeight, CBofWindow *pParent)
void reSize(CBofRect *pRect, bool bRepaint=false)
virtual ErrorCode create(const char *pszName, CBofRect *pRect, CBofWindow *pParent, uint32 nControlID=0)
void postUserMessage(uint32 lMessage, uint32 lExtraInfo)
void killTimer(uint32 nID)
void postMessage(uint32 nMessage, uint32 lParam1, uint32 lParam2)
ErrorCode setBackdrop(CBofBitmap *pNewBitmap, bool bRefresh=false)
void move(int x, int y, bool bRepaint=false)
ErrorCode setBackdrop(const char *pszFileName, bool bRefresh=false)
void setTimer(uint32 nID, uint32 nInterval, BofCallback pCallBack=nullptr)
virtual ErrorCode create(const char *pszName, int x, int y, int nWidth, int nHeight, CBofWindow *pParent, uint32 nControlID=0)
void validateRect(const CBofRect *pRect)
void validateAnscestors(CBofRect *pRect=nullptr)
virtual void handleEvent(const Common::Event &event)
void selectPalette(CBofPalette *pPal)
void invalidateRect(const CBofRect *pRect)
CBofWindow * getParent() const
Definition: window.h:202
ErrorCode paintBackdrop(CBofRect *pRect=nullptr, int nTransparentColor=-1)
Definition: managed_surface.h:51