Implemented a method for the update process. Rearanged some code.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8321 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adi Oanca
2004-07-05 20:39:03 +00:00
parent 16039b760a
commit 7c680a3569
+92 -92
View File
@@ -686,8 +686,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
switch ( msg->what ) { switch ( msg->what ) {
case B_ZOOM:{ case B_ZOOM:{
Zoom(); Zoom();
break;} break;
}
case B_MINIMIZE:{ case B_MINIMIZE:{
bool minimize; bool minimize;
@@ -695,8 +695,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fMinimized = minimize; fMinimized = minimize;
Minimize( minimize ); Minimize( minimize );
break;} break;
}
case B_WINDOW_RESIZED:{ case B_WINDOW_RESIZED:{
BPoint offset; BPoint offset;
int32 width, height; int32 width, height;
@@ -708,8 +708,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fFrame.SetRightBottom( fFrame.LeftTop() + offset ); fFrame.SetRightBottom( fFrame.LeftTop() + offset );
FrameResized( offset.x, offset.y ); FrameResized( offset.x, offset.y );
break;} break;
}
case B_WINDOW_MOVED:{ case B_WINDOW_MOVED:{
BPoint origin; BPoint origin;
@@ -717,8 +717,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fFrame.OffsetTo( origin ); fFrame.OffsetTo( origin );
FrameMoved( origin ); FrameMoved( origin );
break;} break;
}
// this is NOT an app_server message and we have to be cautious // this is NOT an app_server message and we have to be cautious
case B_WINDOW_MOVE_BY:{ case B_WINDOW_MOVE_BY:{
BPoint offset; BPoint offset;
@@ -727,8 +727,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
MoveBy( offset.x, offset.y ); MoveBy( offset.x, offset.y );
else else
msg->SendReply( B_MESSAGE_NOT_UNDERSTOOD ); msg->SendReply( B_MESSAGE_NOT_UNDERSTOOD );
break;} break;
}
// this is NOT an app_server message and we have to be cautious // this is NOT an app_server message and we have to be cautious
case B_WINDOW_MOVE_TO:{ case B_WINDOW_MOVE_TO:{
BPoint origin; BPoint origin;
@@ -737,8 +737,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
MoveTo( origin ); MoveTo( origin );
else else
msg->SendReply( B_MESSAGE_NOT_UNDERSTOOD ); msg->SendReply( B_MESSAGE_NOT_UNDERSTOOD );
break;} break;
}
case B_WINDOW_ACTIVATED:{ case B_WINDOW_ACTIVATED:{
bool active; bool active;
@@ -746,8 +746,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
fActive = active; fActive = active;
handleActivation( active ); handleActivation( active );
break;} break;
}
case B_SCREEN_CHANGED:{ case B_SCREEN_CHANGED:{
BRect frame; BRect frame;
uint32 mode; uint32 mode;
@@ -755,8 +755,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindRect("frame", &frame); msg->FindRect("frame", &frame);
msg->FindInt32("mode", (int32*)&mode); msg->FindInt32("mode", (int32*)&mode);
ScreenChanged( frame, (color_space)mode ); ScreenChanged( frame, (color_space)mode );
break;} break;
}
case B_WORKSPACE_ACTIVATED:{ case B_WORKSPACE_ACTIVATED:{
uint32 workspace; uint32 workspace;
bool active; bool active;
@@ -764,8 +764,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindInt32( "workspace", (int32*)&workspace ); msg->FindInt32( "workspace", (int32*)&workspace );
msg->FindBool( "active", &active ); msg->FindBool( "active", &active );
WorkspaceActivated( workspace, active ); WorkspaceActivated( workspace, active );
break;} break;
}
case B_WORKSPACES_CHANGED:{ case B_WORKSPACES_CHANGED:{
uint32 oldWorkspace; uint32 oldWorkspace;
uint32 newWorkspace; uint32 newWorkspace;
@@ -773,8 +773,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindInt32( "old", (int32*)&oldWorkspace ); msg->FindInt32( "old", (int32*)&oldWorkspace );
msg->FindInt32( "new", (int32*)&newWorkspace ); msg->FindInt32( "new", (int32*)&newWorkspace );
WorkspacesChanged( oldWorkspace, newWorkspace ); WorkspacesChanged( oldWorkspace, newWorkspace );
break;} break;
}
case B_KEY_DOWN:{ case B_KEY_DOWN:{
uint32 modifiers; uint32 modifiers;
int32 raw_char; int32 raw_char;
@@ -786,35 +786,35 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
// TODO: it is NOT "bytes" field you should pass to KeyDown(), it is "byte" field. // TODO: it is NOT "bytes" field you should pass to KeyDown(), it is "byte" field.
if ( !handleKeyDown( raw_char, (uint32)modifiers) ) if ( !handleKeyDown( raw_char, (uint32)modifiers) )
fFocus->KeyDown( string, strlen(string)-1 ); fFocus->KeyDown( string, strlen(string)-1 );
break;} break;
}
case B_KEY_UP:{ case B_KEY_UP:{
const char *string; const char *string;
msg->FindString( "bytes", &string ); msg->FindString( "bytes", &string );
fFocus->KeyUp( string, strlen(string)-1 ); fFocus->KeyUp( string, strlen(string)-1 );
break;} break;
}
case B_UNMAPPED_KEY_DOWN:{ case B_UNMAPPED_KEY_DOWN:{
if (fFocus) if (fFocus)
fFocus->MessageReceived( msg ); fFocus->MessageReceived( msg );
break;} break;
}
case B_UNMAPPED_KEY_UP:{ case B_UNMAPPED_KEY_UP:{
if (fFocus) if (fFocus)
fFocus->MessageReceived( msg ); fFocus->MessageReceived( msg );
break;} break;
}
case B_MODIFIERS_CHANGED:{ case B_MODIFIERS_CHANGED:{
if (fFocus) if (fFocus)
fFocus->MessageReceived( msg ); fFocus->MessageReceived( msg );
break;} break;
}
case B_MOUSE_WHEEL_CHANGED:{ case B_MOUSE_WHEEL_CHANGED:{
if (fFocus) if (fFocus)
fFocus->MessageReceived( msg ); fFocus->MessageReceived( msg );
break;} break;
}
case B_MOUSE_DOWN:{ case B_MOUSE_DOWN:{
BPoint where; BPoint where;
uint32 modifiers; uint32 modifiers;
@@ -827,8 +827,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindInt32( "clicks", &clicks ); msg->FindInt32( "clicks", &clicks );
sendMessageUsingEventMask( B_MOUSE_DOWN, where ); sendMessageUsingEventMask( B_MOUSE_DOWN, where );
break;} break;
}
case B_MOUSE_UP:{ case B_MOUSE_UP:{
BPoint where; BPoint where;
uint32 modifiers; uint32 modifiers;
@@ -837,8 +837,8 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindInt32( "modifiers", (int32*)&modifiers ); msg->FindInt32( "modifiers", (int32*)&modifiers );
sendMessageUsingEventMask( B_MOUSE_UP, where ); sendMessageUsingEventMask( B_MOUSE_UP, where );
break;} break;
}
case B_MOUSE_MOVED:{ case B_MOUSE_MOVED:{
BPoint where; BPoint where;
uint32 buttons; uint32 buttons;
@@ -847,72 +847,72 @@ void BWindow::DispatchMessage(BMessage *msg, BHandler *target)
msg->FindInt32( "buttons", (int32*)&buttons ); msg->FindInt32( "buttons", (int32*)&buttons );
sendMessageUsingEventMask( B_MOUSE_MOVED, where ); sendMessageUsingEventMask( B_MOUSE_MOVED, where );
break;} break;
}
case B_PULSE:{ case B_PULSE:{
if (fPulseEnabled) if (fPulseEnabled)
sendPulse( top_view ); sendPulse( top_view );
break;} break;
}
case B_QUIT_REQUESTED:{ case B_QUIT_REQUESTED:{
if (QuitRequested()) if (QuitRequested())
Quit(); Quit();
break;} break;
}
case _UPDATE_:{ case _UPDATE_:{
BRect updateRect; BRect updateRect;
msg->FindRect("_rect", &updateRect); msg->FindRect("_rect", &updateRect);
// TODO: ADD this method: DoUpdate(top_view, updateRect);
//DrawViews( updateRect ); break;
break;} }
case B_VIEW_MOVED:{ case B_VIEW_MOVED:{
BPoint where; BPoint where;
int32 token = B_NULL_TOKEN; int32 token = B_NULL_TOKEN;
BView *view; BView *view;
msg->FindPoint("where", &where); msg->FindPoint("where", &where);
msg->FindInt32("_token", &token); msg->FindInt32("_token", &token);
msg->RemoveName("_token"); msg->RemoveName("_token");
view = findView(top_view, token); view = findView(top_view, token);
if (view){ if (view){
STRACE(("Calling BView(%s)::FrameMoved( %f, %f )\n", view->Name(), where.x, where.y)); STRACE(("Calling BView(%s)::FrameMoved( %f, %f )\n", view->Name(), where.x, where.y));
view->FrameMoved( where ); view->FrameMoved( where );
} }
else else
printf("***PANIC: BW: Can't find view with ID: %ld !***\n", token); printf("***PANIC: BW: Can't find view with ID: %ld !***\n", token);
break;} break;
}
case B_VIEW_RESIZED:{ case B_VIEW_RESIZED:{
float newWidth, float newWidth,
newHeight; newHeight;
BPoint where; BPoint where;
int32 token = B_NULL_TOKEN; int32 token = B_NULL_TOKEN;
BView *view; BView *view;
msg->FindFloat("width", &newWidth); msg->FindFloat("width", &newWidth);
msg->FindFloat("height", &newHeight); msg->FindFloat("height", &newHeight);
msg->FindPoint("where", &where); msg->FindPoint("where", &where);
msg->FindInt32("_token", &token); msg->FindInt32("_token", &token);
msg->RemoveName("_token"); msg->RemoveName("_token");
view = findView(top_view, token); view = findView(top_view, token);
if (view){ if (view){
STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), newWidth, newHeight)); STRACE(("Calling BView(%s)::FrameResized( %f, %f )\n", view->Name(), newWidth, newHeight));
view->FrameResized( newWidth, newHeight ); view->FrameResized( newWidth, newHeight );
} }
else else
printf("***PANIC: BW: Can't find view with ID: %ld !***\n", token); printf("***PANIC: BW: Can't find view with ID: %ld !***\n", token);
break;} break;
}
default:{ default:{
BLooper::DispatchMessage(msg, target); BLooper::DispatchMessage(msg, target);
break;} break;
} }
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -2823,23 +2823,23 @@ void BWindow::drawAllViews(BView* aView){
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BWindow::drawView(BView* aView, BRect area){ void BWindow::DoUpdate(BView* aView, BRect& area){
aView->do_owner_check();
/* TODO: Drawing during an Update printf("------------\n");
These settings are temporary. When the update is over, all graphics area.PrintToStream();
parameters are reset to their initial values printf("------------\n");
*/ session->WriteInt32( AS_BEGIN_UPDATE );
aView->Draw( area ); aView->Draw( area );
session->WriteInt32( AS_END_UPDATE );
BView *child; BView *child;
if ( (child = aView->first_child) ){ if ( (child = aView->first_child) ){
while ( child ) { while ( child ) {
if ( area.Intersects( child->Frame() ) ){ if ( area.Intersects( child->Frame() ) ){
BRect newArea; BRect newArea;
newArea = area & child->Frame();
newArea = area & child->Frame();
child->ConvertFromParent( &newArea ); child->ConvertFromParent( &newArea );
child->Invalidate( newArea ); DoUpdate( child, newArea );
} }
child = child->next_sibling; child = child->next_sibling;
} }