This commit is contained in:
parent
c998c61655
commit
c095fb97a8
8 changed files with 125 additions and 96 deletions
|
|
@ -14,6 +14,9 @@ AllowShortIfStatementsOnASingleLine: Always
|
||||||
AllowShortBlocksOnASingleLine: Never
|
AllowShortBlocksOnASingleLine: Never
|
||||||
AllowShortFunctionsOnASingleLine: Empty
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
AllowShortLoopsOnASingleLine: true
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: true
|
||||||
SpaceBeforeParens: Never
|
SpaceBeforeParens: Never
|
||||||
AlignEscapedNewlines: DontAlign
|
AlignEscapedNewlines: DontAlign
|
||||||
SortIncludes: false
|
SortIncludes: false
|
||||||
|
|
|
||||||
2
configure
vendored
2
configure
vendored
|
|
@ -227,7 +227,7 @@ print(OUT " cp -rf include \$(DESTDIR)\$(PREFIX)/\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "format:\n");
|
print(OUT "format:\n");
|
||||||
print(OUT
|
print(OUT
|
||||||
" clang-format --verbose -i `find tools src include examples \"(\" -name \"*.c\" -or -name \"*.cxx\" -or -name \"*.h\" -or -name \"*.m\" \")\" -and -not -name \"*ttf.c\"`\n"
|
" clang-format --verbose -i `find tools src include examples \"(\" -name \"*.c\" -or -name \"*.cc\" -or -name \"*.h\" -or -name \"*.m\" \")\" -and -not -name \"*ttf.c\"`\n"
|
||||||
);
|
);
|
||||||
print(OUT
|
print(OUT
|
||||||
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl configure -name \"*.pl\"`\n"
|
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl configure -name \"*.pl\"`\n"
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class MwView : public BView {
|
||||||
MwLL handle;
|
MwLL handle;
|
||||||
BLocker* locker;
|
BLocker* locker;
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
|
BBitmap* bitmap;
|
||||||
|
|
||||||
MwView(MwLL handle, BRect rc, uint32 resizingMode, uint32 flags);
|
MwView(MwLL handle, BRect rc, uint32 resizingMode, uint32 flags);
|
||||||
~MwView();
|
~MwView();
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
#include <Picture.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#endif
|
#endif
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,15 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
GetNextEvent(everyEvent, &event);
|
GetNextEvent(everyEvent, &event);
|
||||||
|
|
||||||
switch(event.what) {
|
switch(event.what) {
|
||||||
case updateEvt: {
|
case updateEvt:
|
||||||
|
{
|
||||||
}
|
}
|
||||||
// MwLLDispatch(handle, draw, NULL);
|
// MwLLDispatch(handle, draw, NULL);
|
||||||
break;
|
break;
|
||||||
case osEvt:
|
case osEvt:
|
||||||
break;
|
break;
|
||||||
case mouseUp: {
|
case mouseUp:
|
||||||
|
{
|
||||||
// MwLLMouse m;
|
// MwLLMouse m;
|
||||||
// m.button = MwLLMouseLeft;
|
// m.button = MwLLMouseLeft;
|
||||||
// if(___curWindow->mouseButtonCallback != NULL) {
|
// if(___curWindow->mouseButtonCallback != NULL) {
|
||||||
|
|
@ -151,7 +153,8 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
case mouseDown: {
|
case mouseDown:
|
||||||
|
{
|
||||||
// // start with callback stuff
|
// // start with callback stuff
|
||||||
// if(___curWindow->mouseButtonCallback != NULL) {
|
// if(___curWindow->mouseButtonCallback != NULL) {
|
||||||
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||||
|
|
@ -174,7 +177,8 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
// event.where.v);
|
// event.where.v);
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case inGrow: {
|
case inGrow:
|
||||||
|
{
|
||||||
long growResult =
|
long growResult =
|
||||||
GrowWindow(handle->cmacos.window, event.where, &qd.screenBits.bounds);
|
GrowWindow(handle->cmacos.window, event.where, &qd.screenBits.bounds);
|
||||||
|
|
||||||
|
|
@ -201,7 +205,8 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
// }
|
// }
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case inGoAway: {
|
case inGoAway:
|
||||||
|
{
|
||||||
if(TrackGoAway(handle->cmacos.window, event.where)) {
|
if(TrackGoAway(handle->cmacos.window, event.where)) {
|
||||||
MwLLDispatch(handle, close, NULL);
|
MwLLDispatch(handle, close, NULL);
|
||||||
// if(___curWindow->windowCloseCallback != NULL) {
|
// if(___curWindow->windowCloseCallback != NULL) {
|
||||||
|
|
@ -214,7 +219,8 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
}
|
}
|
||||||
case autoKey:
|
case autoKey:
|
||||||
case keyDown:
|
case keyDown:
|
||||||
case keyUp: {
|
case keyUp:
|
||||||
|
{
|
||||||
// // key char stuff
|
// // key char stuff
|
||||||
// unsigned char ch = (event.message & charCodeMask);
|
// unsigned char ch = (event.message & charCodeMask);
|
||||||
// if(*___curWindow->charCallback != NULL) {
|
// if(*___curWindow->charCallback != NULL) {
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,8 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
|
||||||
for(i = 0; i < arrlen(self->commands); i++) {
|
for(i = 0; i < arrlen(self->commands); i++) {
|
||||||
draw_command cmd = self->commands[i];
|
draw_command cmd = self->commands[i];
|
||||||
switch(cmd.type) {
|
switch(cmd.type) {
|
||||||
case COCOA_DRAW_COMMAND_POLY: {
|
case COCOA_DRAW_COMMAND_POLY:
|
||||||
|
{
|
||||||
int n;
|
int n;
|
||||||
NSBezierPath* path = [NSBezierPath bezierPath];
|
NSBezierPath* path = [NSBezierPath bezierPath];
|
||||||
|
|
||||||
|
|
@ -156,7 +157,8 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
|
||||||
free(cmd.poly.points);
|
free(cmd.poly.points);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case COCOA_DRAW_COMMAND_LINES: {
|
case COCOA_DRAW_COMMAND_LINES:
|
||||||
|
{
|
||||||
int n;
|
int n;
|
||||||
NSBezierPath* path = [NSBezierPath bezierPath];
|
NSBezierPath* path = [NSBezierPath bezierPath];
|
||||||
|
|
||||||
|
|
@ -184,7 +186,8 @@ static void recursive_dispatch_key_released(MwLL handle, int* k) {
|
||||||
free(cmd.lines.points);
|
free(cmd.lines.points);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case COCOA_DRAW_COMMAND_PIXMAP: {
|
case COCOA_DRAW_COMMAND_PIXMAP:
|
||||||
|
{
|
||||||
NSRect rect = localRectFlip(NSMakeRect(cmd.pixmap.rect.x, cmd.pixmap.rect.y, cmd.pixmap.rect.width, cmd.pixmap.rect.height), self);
|
NSRect rect = localRectFlip(NSMakeRect(cmd.pixmap.rect.x, cmd.pixmap.rect.y, cmd.pixmap.rect.width, cmd.pixmap.rect.height), self);
|
||||||
rect.origin.x += [self bounds].origin.x;
|
rect.origin.x += [self bounds].origin.x;
|
||||||
rect.origin.y += [self bounds].origin.y;
|
rect.origin.y += [self bounds].origin.y;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../../external/stb_ds.h"
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
static void fix_point(BPoint* p, MwView* v){
|
static void fix_point(BPoint* p, MwView* v) {
|
||||||
p->x = p->x * (v->handle->haiku.width + 1) / v->handle->haiku.width;
|
p->x = p->x * (v->handle->haiku.width + 1) / v->handle->haiku.width;
|
||||||
p->y = p->y * (v->handle->haiku.height + 1) / v->handle->haiku.height;
|
p->y = p->y * (v->handle->haiku.height + 1) / v->handle->haiku.height;
|
||||||
}
|
}
|
||||||
|
|
@ -32,11 +32,13 @@ MwApplication::~MwApplication() {
|
||||||
|
|
||||||
void MwApplication::MessageReceived(BMessage* message) {
|
void MwApplication::MessageReceived(BMessage* message) {
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case BAPP_MW_DESTROY: {
|
case BAPP_MW_DESTROY:
|
||||||
|
{
|
||||||
this->Quit();
|
this->Quit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default:
|
||||||
|
{
|
||||||
BLooper::MessageReceived(message);
|
BLooper::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -51,12 +53,12 @@ MwView::MwView(MwLL handle, BRect frame, uint32 resizingMode, uint32 flags) : BV
|
||||||
this->SetDrawingMode(B_OP_OVER);
|
this->SetDrawingMode(B_OP_OVER);
|
||||||
this->SetLineMode(B_BUTT_CAP, B_BUTT_JOIN);
|
this->SetLineMode(B_BUTT_CAP, B_BUTT_JOIN);
|
||||||
|
|
||||||
this->SetViewColor(255, 0, 0);
|
this->SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
|
|
||||||
this->buttons = 0;
|
this->buttons = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwView::~MwView(){
|
MwView::~MwView() {
|
||||||
delete this->locker;
|
delete this->locker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,42 +75,44 @@ void MwView::MessageReceived(BMessage* message) {
|
||||||
this->RemoveSelf();
|
this->RemoveSelf();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BVIEW_MW_RESIZE: {
|
case BVIEW_MW_RESIZE:
|
||||||
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
if(message->FindInt32("view-width", &width) != B_OK) break;
|
if(message->FindInt32("view-width", &width) != B_OK) break;
|
||||||
if(message->FindInt32("view-height", &height) != B_OK) break;
|
if(message->FindInt32("view-height", &height) != B_OK) break;
|
||||||
|
|
||||||
if(this->handle->haiku.app == NULL){
|
if(this->handle->haiku.app == NULL) {
|
||||||
this->ResizeTo(width, height);
|
this->ResizeTo(width, height);
|
||||||
}else{
|
} else {
|
||||||
this->Window()->ResizeTo(width, height);
|
this->Window()->ResizeTo(width, height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BVIEW_MW_MOVE: {
|
case BVIEW_MW_MOVE:
|
||||||
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if(message->FindInt32("view-x", &x) != B_OK) break;
|
if(message->FindInt32("view-x", &x) != B_OK) break;
|
||||||
if(message->FindInt32("view-y", &y) != B_OK) break;
|
if(message->FindInt32("view-y", &y) != B_OK) break;
|
||||||
|
|
||||||
if(this->handle->haiku.app == NULL){
|
if(this->handle->haiku.app == NULL) {
|
||||||
this->MoveTo(x, y);
|
this->MoveTo(x, y);
|
||||||
}else{
|
} else {
|
||||||
this->Window()->MoveTo(x, y);
|
this->Window()->MoveTo(x, y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BVIEW_MW_SHOW:
|
case BVIEW_MW_SHOW:
|
||||||
{
|
{
|
||||||
if(this->Window() == NULL){
|
if(this->Window() == NULL) {
|
||||||
this->handle->haiku.parent->haiku.view->AddChild(this);
|
this->handle->haiku.parent->haiku.view->AddChild(this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BVIEW_MW_HIDE:
|
case BVIEW_MW_HIDE:
|
||||||
{
|
{
|
||||||
if(this->Window() != NULL){
|
if(this->Window() != NULL) {
|
||||||
this->RemoveSelf();
|
this->RemoveSelf();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -116,7 +120,7 @@ void MwView::MessageReceived(BMessage* message) {
|
||||||
case BVIEW_MW_SET_COLOR:
|
case BVIEW_MW_SET_COLOR:
|
||||||
{
|
{
|
||||||
int32 rgb[3];
|
int32 rgb[3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rgb[0] = rgb[1] = rgb[2] = 0;
|
rgb[0] = rgb[1] = rgb[2] = 0;
|
||||||
|
|
||||||
|
|
@ -128,11 +132,11 @@ void MwView::MessageReceived(BMessage* message) {
|
||||||
}
|
}
|
||||||
case BVIEW_MW_POLYGON:
|
case BVIEW_MW_POLYGON:
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
BPoint p;
|
BPoint p;
|
||||||
BPoint points[32];
|
BPoint points[32];
|
||||||
|
|
||||||
for(i = 0; i < 32 && message->FindPoint("view-point", i, &p) == B_OK; i++){
|
for(i = 0; i < 32 && message->FindPoint("view-point", i, &p) == B_OK; i++) {
|
||||||
points[i] = p;
|
points[i] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,11 +145,11 @@ void MwView::MessageReceived(BMessage* message) {
|
||||||
}
|
}
|
||||||
case BVIEW_MW_LINE:
|
case BVIEW_MW_LINE:
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
BPoint p;
|
BPoint p;
|
||||||
BPoint points[2];
|
BPoint points[2];
|
||||||
|
|
||||||
for(i = 0; i < 2 && message->FindPoint("view-point", i, &p) == B_OK; i++){
|
for(i = 0; i < 2 && message->FindPoint("view-point", i, &p) == B_OK; i++) {
|
||||||
points[i] = p;
|
points[i] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,7 +158,7 @@ void MwView::MessageReceived(BMessage* message) {
|
||||||
}
|
}
|
||||||
case BVIEW_MW_BITMAP:
|
case BVIEW_MW_BITMAP:
|
||||||
{
|
{
|
||||||
BRect rc;
|
BRect rc;
|
||||||
BBitmap* bitmap;
|
BBitmap* bitmap;
|
||||||
|
|
||||||
if(message->FindRect("view-rect", &rc) != B_OK) break;
|
if(message->FindRect("view-rect", &rc) != B_OK) break;
|
||||||
|
|
@ -168,14 +172,15 @@ void MwView::MessageReceived(BMessage* message) {
|
||||||
this->Invalidate();
|
this->Invalidate();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default:
|
||||||
|
{
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::PostMessage(BMessage* message){
|
void MwView::PostMessage(BMessage* message) {
|
||||||
BMessage copy = *message;
|
BMessage copy = *message;
|
||||||
|
|
||||||
copy.AddPointer("window-view", this);
|
copy.AddPointer("window-view", this);
|
||||||
|
|
@ -183,21 +188,21 @@ void MwView::PostMessage(BMessage* message){
|
||||||
this->Window()->PostMessage(©);
|
this->Window()->PostMessage(©);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::PostMessage(uint32 command){
|
void MwView::PostMessage(uint32 command) {
|
||||||
BMessage msg(command);
|
BMessage msg(command);
|
||||||
|
|
||||||
this->PostMessage(&msg);
|
this->PostMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::Invalidate(){
|
void MwView::Invalidate() {
|
||||||
this->Draw(BRect(0, 0, 0, 0));
|
this->Draw(BRect(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::AttachedToWindow(){
|
void MwView::AttachedToWindow() {
|
||||||
this->SetOrigin(0, 0);
|
this->SetOrigin(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::Draw(BRect updateRect){
|
void MwView::Draw(BRect updateRect) {
|
||||||
MwLLHaikuEvent ev;
|
MwLLHaikuEvent ev;
|
||||||
|
|
||||||
(void)updateRect;
|
(void)updateRect;
|
||||||
|
|
@ -209,24 +214,24 @@ void MwView::Draw(BRect updateRect){
|
||||||
this->locker->Unlock();
|
this->locker->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::MouseDown(BPoint point){
|
void MwView::MouseDown(BPoint point) {
|
||||||
MwLLHaikuEvent ev;
|
MwLLHaikuEvent ev;
|
||||||
uint32 btn;
|
uint32 btn;
|
||||||
BPoint p;
|
BPoint p;
|
||||||
|
|
||||||
this->GetMouse(&p, &btn, false);
|
this->GetMouse(&p, &btn, false);
|
||||||
|
|
||||||
this->SetMouseEventMask(B_LOCK_WINDOW_FOCUS);
|
this->SetMouseEventMask(B_LOCK_WINDOW_FOCUS);
|
||||||
|
|
||||||
ev.type = MwLLHAIKU_EVENT_MOUSEDOWN;
|
ev.type = MwLLHAIKU_EVENT_MOUSEDOWN;
|
||||||
ev.mouse.point.x = point.x;
|
ev.mouse.point.x = point.x;
|
||||||
ev.mouse.point.y = point.y;
|
ev.mouse.point.y = point.y;
|
||||||
|
|
||||||
if((btn & B_PRIMARY_MOUSE_BUTTON) && !(this->buttons & B_PRIMARY_MOUSE_BUTTON)){
|
if((btn & B_PRIMARY_MOUSE_BUTTON) && !(this->buttons & B_PRIMARY_MOUSE_BUTTON)) {
|
||||||
ev.mouse.button = MwMOUSE_LEFT;
|
ev.mouse.button = MwMOUSE_LEFT;
|
||||||
}else if((btn & B_SECONDARY_MOUSE_BUTTON) && !(this->buttons & B_SECONDARY_MOUSE_BUTTON)){
|
} else if((btn & B_SECONDARY_MOUSE_BUTTON) && !(this->buttons & B_SECONDARY_MOUSE_BUTTON)) {
|
||||||
ev.mouse.button = MwMOUSE_RIGHT;
|
ev.mouse.button = MwMOUSE_RIGHT;
|
||||||
}else if((btn & B_TERTIARY_MOUSE_BUTTON) && !(this->buttons & B_TERTIARY_MOUSE_BUTTON)){
|
} else if((btn & B_TERTIARY_MOUSE_BUTTON) && !(this->buttons & B_TERTIARY_MOUSE_BUTTON)) {
|
||||||
ev.mouse.button = MwMOUSE_MIDDLE;
|
ev.mouse.button = MwMOUSE_MIDDLE;
|
||||||
}
|
}
|
||||||
this->buttons = btn;
|
this->buttons = btn;
|
||||||
|
|
@ -236,22 +241,22 @@ void MwView::MouseDown(BPoint point){
|
||||||
this->locker->Unlock();
|
this->locker->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::MouseUp(BPoint point){
|
void MwView::MouseUp(BPoint point) {
|
||||||
MwLLHaikuEvent ev;
|
MwLLHaikuEvent ev;
|
||||||
uint32 btn;
|
uint32 btn;
|
||||||
BPoint p;
|
BPoint p;
|
||||||
|
|
||||||
this->GetMouse(&p, &btn, false);
|
this->GetMouse(&p, &btn, false);
|
||||||
|
|
||||||
ev.type = MwLLHAIKU_EVENT_MOUSEUP;
|
ev.type = MwLLHAIKU_EVENT_MOUSEUP;
|
||||||
ev.mouse.point.x = point.x;
|
ev.mouse.point.x = point.x;
|
||||||
ev.mouse.point.y = point.y;
|
ev.mouse.point.y = point.y;
|
||||||
|
|
||||||
if(!(btn & B_PRIMARY_MOUSE_BUTTON) && (this->buttons & B_PRIMARY_MOUSE_BUTTON)){
|
if(!(btn & B_PRIMARY_MOUSE_BUTTON) && (this->buttons & B_PRIMARY_MOUSE_BUTTON)) {
|
||||||
ev.mouse.button = MwMOUSE_LEFT;
|
ev.mouse.button = MwMOUSE_LEFT;
|
||||||
}else if(!(btn & B_SECONDARY_MOUSE_BUTTON) && (this->buttons & B_SECONDARY_MOUSE_BUTTON)){
|
} else if(!(btn & B_SECONDARY_MOUSE_BUTTON) && (this->buttons & B_SECONDARY_MOUSE_BUTTON)) {
|
||||||
ev.mouse.button = MwMOUSE_RIGHT;
|
ev.mouse.button = MwMOUSE_RIGHT;
|
||||||
}else if(!(btn & B_TERTIARY_MOUSE_BUTTON) && (this->buttons & B_TERTIARY_MOUSE_BUTTON)){
|
} else if(!(btn & B_TERTIARY_MOUSE_BUTTON) && (this->buttons & B_TERTIARY_MOUSE_BUTTON)) {
|
||||||
ev.mouse.button = MwMOUSE_MIDDLE;
|
ev.mouse.button = MwMOUSE_MIDDLE;
|
||||||
}
|
}
|
||||||
this->buttons = btn;
|
this->buttons = btn;
|
||||||
|
|
@ -261,20 +266,20 @@ void MwView::MouseUp(BPoint point){
|
||||||
this->locker->Unlock();
|
this->locker->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::MouseMoved(BPoint point, uint32 transit, const BMessage* message){
|
void MwView::MouseMoved(BPoint point, uint32 transit, const BMessage* message) {
|
||||||
MwLLHaikuEvent ev;
|
MwLLHaikuEvent ev;
|
||||||
|
|
||||||
ev.type = MwLLHAIKU_EVENT_MOUSEMOVED;
|
ev.type = MwLLHAIKU_EVENT_MOUSEMOVED;
|
||||||
ev.mouse.point.x = point.x;
|
ev.mouse.point.x = point.x;
|
||||||
ev.mouse.point.y = point.y;
|
ev.mouse.point.y = point.y;
|
||||||
ev.mouse.button = 0;
|
ev.mouse.button = 0;
|
||||||
|
|
||||||
this->locker->Lock();
|
this->locker->Lock();
|
||||||
arrput(this->handle->haiku.events, ev);
|
arrput(this->handle->haiku.events, ev);
|
||||||
this->locker->Unlock();
|
this->locker->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwView::SetColor(MwLLColor color){
|
void MwView::SetColor(MwLLColor color) {
|
||||||
BMessage msg(BVIEW_MW_SET_COLOR);
|
BMessage msg(BVIEW_MW_SET_COLOR);
|
||||||
|
|
||||||
msg.AddInt32("view-color", color->common.red);
|
msg.AddInt32("view-color", color->common.red);
|
||||||
|
|
@ -290,7 +295,7 @@ MwWindow::MwWindow(BRect frame, window_type type, uint32 flags) : BWindow(frame,
|
||||||
void MwWindow::MessageReceived(BMessage* message) {
|
void MwWindow::MessageReceived(BMessage* message) {
|
||||||
void* ptr;
|
void* ptr;
|
||||||
|
|
||||||
if(message->FindPointer("window-view", &ptr) == B_OK){
|
if(message->FindPointer("window-view", &ptr) == B_OK) {
|
||||||
MwView* v = (MwView*)ptr;
|
MwView* v = (MwView*)ptr;
|
||||||
|
|
||||||
v->MessageReceived(message);
|
v->MessageReceived(message);
|
||||||
|
|
@ -299,7 +304,8 @@ void MwWindow::MessageReceived(BMessage* message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case BWIN_MW_SET_TITLE: {
|
case BWIN_MW_SET_TITLE:
|
||||||
|
{
|
||||||
const char* title;
|
const char* title;
|
||||||
|
|
||||||
if(message->FindString("window-title", &title) != B_OK) break;
|
if(message->FindString("window-title", &title) != B_OK) break;
|
||||||
|
|
@ -307,7 +313,8 @@ void MwWindow::MessageReceived(BMessage* message) {
|
||||||
this->SetTitle(title);
|
this->SetTitle(title);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default:
|
||||||
|
{
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +338,7 @@ static int32 app_thread(void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
MwLL r = (MwLL)malloc(sizeof(*r));
|
MwLL r = (MwLL)malloc(sizeof(*r));
|
||||||
BRect rc = BRect(BPoint(x, y), BSize(width, height));
|
BRect rc = BRect(BPoint(x, y), BSize(width, height));
|
||||||
|
|
||||||
MwLLCreateCommon(r);
|
MwLLCreateCommon(r);
|
||||||
|
|
@ -351,7 +358,7 @@ MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
p->rc = rc;
|
p->rc = rc;
|
||||||
p->handle = r;
|
p->handle = r;
|
||||||
|
|
||||||
r->haiku.app = NULL;
|
r->haiku.app = NULL;
|
||||||
r->haiku.view = NULL;
|
r->haiku.view = NULL;
|
||||||
|
|
||||||
r->haiku.app_thread = spawn_thread(app_thread, NULL, B_NORMAL_PRIORITY, p);
|
r->haiku.app_thread = spawn_thread(app_thread, NULL, B_NORMAL_PRIORITY, p);
|
||||||
|
|
@ -370,9 +377,9 @@ MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
parent->haiku.view->AddChild(r->haiku.view);
|
parent->haiku.view->AddChild(r->haiku.view);
|
||||||
}
|
}
|
||||||
|
|
||||||
r->haiku.x = x;
|
r->haiku.x = x;
|
||||||
r->haiku.y = y;
|
r->haiku.y = y;
|
||||||
r->haiku.width = width;
|
r->haiku.width = width;
|
||||||
r->haiku.height = height;
|
r->haiku.height = height;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
|
@ -396,7 +403,7 @@ void MwLLDestroyImpl(MwLL handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
int i;
|
int i;
|
||||||
BMessage msg(BVIEW_MW_POLYGON);
|
BMessage msg(BVIEW_MW_POLYGON);
|
||||||
|
|
||||||
for(i = 0; i < points_count; i++) {
|
for(i = 0; i < points_count; i++) {
|
||||||
|
|
@ -412,10 +419,10 @@ void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor c
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||||
int i;
|
int i;
|
||||||
BMessage msg(BVIEW_MW_LINE);
|
BMessage msg(BVIEW_MW_LINE);
|
||||||
|
|
||||||
for(i = 0; i < 2; i++){
|
for(i = 0; i < 2; i++) {
|
||||||
BPoint p(points[i].x, points[i].y);
|
BPoint p(points[i].x, points[i].y);
|
||||||
|
|
||||||
fix_point(&p, handle->haiku.view);
|
fix_point(&p, handle->haiku.view);
|
||||||
|
|
@ -427,9 +434,11 @@ void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||||
handle->haiku.view->PostMessage(&msg);
|
handle->haiku.view->PostMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLBeginDrawImpl(MwLL handle) {}
|
void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
|
}
|
||||||
|
|
||||||
void MwLLEndDrawImpl(MwLL handle) {}
|
void MwLLEndDrawImpl(MwLL handle) {
|
||||||
|
}
|
||||||
|
|
||||||
MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||||
MwLLColor c = (MwLLColor)malloc(sizeof(*c));
|
MwLLColor c = (MwLLColor)malloc(sizeof(*c));
|
||||||
|
|
@ -451,11 +460,11 @@ void MwLLFreeColorImpl(MwLLColor color) {
|
||||||
|
|
||||||
void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
||||||
BRect rc;
|
BRect rc;
|
||||||
int m = 0;
|
int m = 0;
|
||||||
|
|
||||||
if(handle->haiku.app == NULL){
|
if(handle->haiku.app == NULL) {
|
||||||
rc = BRect(BPoint(handle->haiku.x, handle->haiku.y), BSize(handle->haiku.width, handle->haiku.height));
|
rc = BRect(BPoint(handle->haiku.x, handle->haiku.y), BSize(handle->haiku.width, handle->haiku.height));
|
||||||
}else{
|
} else {
|
||||||
rc = handle->haiku.app->window->Frame();
|
rc = handle->haiku.app->window->Frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -480,7 +489,7 @@ void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||||
void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
||||||
BMessage msg(BVIEW_MW_RESIZE);
|
BMessage msg(BVIEW_MW_RESIZE);
|
||||||
|
|
||||||
handle->haiku.width = w;
|
handle->haiku.width = w;
|
||||||
handle->haiku.height = h;
|
handle->haiku.height = h;
|
||||||
|
|
||||||
msg.AddInt32("view-width", w);
|
msg.AddInt32("view-width", w);
|
||||||
|
|
@ -503,7 +512,7 @@ void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||||
|
|
||||||
int MwLLPendingImpl(MwLL handle) {
|
int MwLLPendingImpl(MwLL handle) {
|
||||||
handle->haiku.view->locker->Lock();
|
handle->haiku.view->locker->Lock();
|
||||||
if(arrlen(handle->haiku.events) > 0){
|
if(arrlen(handle->haiku.events) > 0) {
|
||||||
handle->haiku.view->locker->Unlock();
|
handle->haiku.view->locker->Unlock();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -514,22 +523,22 @@ int MwLLPendingImpl(MwLL handle) {
|
||||||
|
|
||||||
void MwLLNextEventImpl(MwLL handle) {
|
void MwLLNextEventImpl(MwLL handle) {
|
||||||
handle->haiku.view->locker->Lock();
|
handle->haiku.view->locker->Lock();
|
||||||
while(arrlen(handle->haiku.events) > 0){
|
while(arrlen(handle->haiku.events) > 0) {
|
||||||
MwLLHaikuEvent* ev = &handle->haiku.events[0];
|
MwLLHaikuEvent* ev = &handle->haiku.events[0];
|
||||||
MwMouse m;
|
MwMouse m;
|
||||||
|
|
||||||
if(ev->type == MwLLHAIKU_EVENT_MOUSEDOWN || ev->type == MwLLHAIKU_EVENT_MOUSEUP){
|
if(ev->type == MwLLHAIKU_EVENT_MOUSEDOWN || ev->type == MwLLHAIKU_EVENT_MOUSEUP) {
|
||||||
m.point = ev->mouse.point;
|
m.point = ev->mouse.point;
|
||||||
m.button = ev->mouse.button;
|
m.button = ev->mouse.button;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ev->type == MwLLHAIKU_EVENT_DRAW){
|
if(ev->type == MwLLHAIKU_EVENT_DRAW) {
|
||||||
MwLLDispatch(handle, draw, NULL);
|
MwLLDispatch(handle, draw, NULL);
|
||||||
}else if(ev->type == MwLLHAIKU_EVENT_MOUSEDOWN){
|
} else if(ev->type == MwLLHAIKU_EVENT_MOUSEDOWN) {
|
||||||
MwLLDispatch(handle, down, &m);
|
MwLLDispatch(handle, down, &m);
|
||||||
}else if(ev->type == MwLLHAIKU_EVENT_MOUSEUP){
|
} else if(ev->type == MwLLHAIKU_EVENT_MOUSEUP) {
|
||||||
MwLLDispatch(handle, up, &m);
|
MwLLDispatch(handle, up, &m);
|
||||||
}else if(ev->type == MwLLHAIKU_EVENT_MOUSEMOVED){
|
} else if(ev->type == MwLLHAIKU_EVENT_MOUSEMOVED) {
|
||||||
MwLLDispatch(handle, move, &ev->mouse.point);
|
MwLLDispatch(handle, move, &ev->mouse.point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -556,9 +565,9 @@ MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int
|
||||||
|
|
||||||
void MwLLPixmapUpdateImpl(MwLLPixmap pixmap) {
|
void MwLLPixmapUpdateImpl(MwLLPixmap pixmap) {
|
||||||
uint32* px = (uint32*)malloc(4 * pixmap->common.width * pixmap->common.height);
|
uint32* px = (uint32*)malloc(4 * pixmap->common.width * pixmap->common.height);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < pixmap->common.width * pixmap->common.height; i++){
|
for(i = 0; i < pixmap->common.width * pixmap->common.height; i++) {
|
||||||
unsigned char* ipx = &pixmap->common.raw[4 * i];
|
unsigned char* ipx = &pixmap->common.raw[4 * i];
|
||||||
|
|
||||||
px[i] = (ipx[3] << 24) | (ipx[0] << 16) | (ipx[1] << 8) | (ipx[2] << 0);
|
px[i] = (ipx[3] << 24) | (ipx[0] << 16) | (ipx[1] << 8) | (ipx[2] << 0);
|
||||||
|
|
@ -580,8 +589,8 @@ void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
||||||
BPoint p;
|
BPoint p;
|
||||||
BRect rc;
|
BRect rc;
|
||||||
BMessage msg(BVIEW_MW_BITMAP);
|
BMessage msg(BVIEW_MW_BITMAP);
|
||||||
|
|
||||||
p = BPoint(rect->x, rect->y);
|
p = BPoint(rect->x, rect->y);
|
||||||
|
|
@ -605,9 +614,9 @@ void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {}
|
||||||
void MwLLDetachImpl(MwLL handle, MwPoint* point) {}
|
void MwLLDetachImpl(MwLL handle, MwPoint* point) {}
|
||||||
|
|
||||||
void MwLLShowImpl(MwLL handle, int show) {
|
void MwLLShowImpl(MwLL handle, int show) {
|
||||||
if(show){
|
if(show) {
|
||||||
handle->haiku.view->PostMessage(BVIEW_MW_SHOW);
|
handle->haiku.view->PostMessage(BVIEW_MW_SHOW);
|
||||||
}else{
|
} else {
|
||||||
handle->haiku.view->PostMessage(BVIEW_MW_HIDE);
|
handle->haiku.view->PostMessage(BVIEW_MW_HIDE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -637,8 +646,8 @@ void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {}
|
||||||
void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
||||||
BScreen* screen = new BScreen();
|
BScreen* screen = new BScreen();
|
||||||
|
|
||||||
if(screen->IsValid()){
|
if(screen->IsValid()) {
|
||||||
rect->width = screen->Frame().Width();
|
rect->width = screen->Frame().Width();
|
||||||
rect->height = screen->Frame().Height();
|
rect->height = screen->Frame().Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,27 +75,33 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
||||||
icon = MwCreateWidget(MwImageClass, "image", window, 8, (h - 48) / 2, 48, 48);
|
icon = MwCreateWidget(MwImageClass, "image", window, 8, (h - 48) / 2, 48, 48);
|
||||||
|
|
||||||
switch(flag & MwMB_ICONMASK) {
|
switch(flag & MwMB_ICONMASK) {
|
||||||
case MwMB_ICONWARNING: {
|
case MwMB_ICONWARNING:
|
||||||
|
{
|
||||||
data = MwIconWarning;
|
data = MwIconWarning;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MwMB_ICONINFO: {
|
case MwMB_ICONINFO:
|
||||||
|
{
|
||||||
data = MwIconInfo;
|
data = MwIconInfo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MwMB_ICONNOTE: {
|
case MwMB_ICONNOTE:
|
||||||
|
{
|
||||||
data = MwIconNote;
|
data = MwIconNote;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MwMB_ICONNEWS: {
|
case MwMB_ICONNEWS:
|
||||||
|
{
|
||||||
data = MwIconNews;
|
data = MwIconNews;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MwMB_ICONERROR: {
|
case MwMB_ICONERROR:
|
||||||
|
{
|
||||||
data = MwIconError;
|
data = MwIconError;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MwMB_ICONCLOCK: {
|
case MwMB_ICONCLOCK:
|
||||||
|
{
|
||||||
data = MwIconClock;
|
data = MwIconClock;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue