- Exits if a bitmap is not available

- Fixes the text placement of Mouse Type and FFM
- The drawing of the Mouse and bitmaps are done only if needed
	(depend on the updateRect)
- Call DrawBitmapAsync instead of DrawBitmap


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5928 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2004-01-06 09:05:50 +00:00
parent b3a4ae39dd
commit b855ae3d39
+42 -15
View File
@@ -90,8 +90,22 @@ MouseView::MouseView(BRect rect)
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fDoubleClickBitmap = BTranslationUtils::GetBitmap("double_click_bmap"); fDoubleClickBitmap = BTranslationUtils::GetBitmap("double_click_bmap");
if(!fDoubleClickBitmap) {
printf("can't load double_click_bmap with BTranslationUtils::GetBitmap\n");
exit(1);
}
fSpeedBitmap = BTranslationUtils::GetBitmap("speed_bmap"); fSpeedBitmap = BTranslationUtils::GetBitmap("speed_bmap");
if(!fSpeedBitmap) {
printf("can't load speed_bmap with BTranslationUtils::GetBitmap\n");
exit(1);
}
fAccelerationBitmap = BTranslationUtils::GetBitmap("acceleration_bmap"); fAccelerationBitmap = BTranslationUtils::GetBitmap("acceleration_bmap");
if(!fAccelerationBitmap) {
printf("can't load acceleration_bmap with BTranslationUtils::GetBitmap\n");
exit(1);
}
// i don't really understand this bitmap SetBits : i have to substract 4 lines and add 15 pixels // i don't really understand this bitmap SetBits : i have to substract 4 lines and add 15 pixels
BRect mouseRect(0,0,kMouseWidth-1,kMouseHeight-5); BRect mouseRect(0,0,kMouseWidth-1,kMouseHeight-5);
@@ -127,9 +141,10 @@ MouseView::MouseView(BRect rect)
mouseTypeMenu->AddItem(new BMenuItem("2-Button",new BMessage(POPUP_MOUSE_TYPE))); mouseTypeMenu->AddItem(new BMenuItem("2-Button",new BMessage(POPUP_MOUSE_TYPE)));
mouseTypeMenu->AddItem(new BMenuItem("3-Button",new BMessage(POPUP_MOUSE_TYPE))); mouseTypeMenu->AddItem(new BMenuItem("3-Button",new BMessage(POPUP_MOUSE_TYPE)));
frame.Set(17,8,208,20); frame.Set(7,8,208,20);
menufield = new BMenuField(frame, "mouse_type", "Mouse type", mouseTypeMenu); menufield = new BMenuField(frame, "mouse_type", "Mouse type", mouseTypeMenu);
menufield->SetDivider(menufield->Divider() - 34); menufield->SetDivider(menufield->Divider() - 29);
menufield->SetAlignment(B_ALIGN_RIGHT);
fBox->AddChild(menufield); fBox->AddChild(menufield);
// Add the "Focus follows mouse" pop up menu // Add the "Focus follows mouse" pop up menu
@@ -140,8 +155,9 @@ MouseView::MouseView(BRect rect)
focusMenu->AddItem(new BMenuItem("Instant-Warping",new BMessage(POPUP_MOUSE_FOCUS))); focusMenu->AddItem(new BMenuItem("Instant-Warping",new BMessage(POPUP_MOUSE_FOCUS)));
frame.Set(165,208,440,200); frame.Set(165,208,440,200);
menufield = new BMenuField(frame, "Focus follows mouse", "Focus follows mouse:", focusMenu); menufield = new BMenuField(frame, "Focus follows mouse", "Focus follows mouse", focusMenu);
menufield->SetDivider(menufield->Divider() - 32); menufield->SetDivider(menufield->Divider() - 18);
menufield->SetAlignment(B_ALIGN_RIGHT);
fBox->AddChild(menufield); fBox->AddChild(menufield);
// Create the "Double-click speed slider... // Create the "Double-click speed slider...
@@ -234,24 +250,32 @@ MouseView::Draw(BRect updateFrame)
// Line in the middle // Line in the middle
fBox->StrokeLine(BPoint(156,10),BPoint(156,230),B_SOLID_HIGH); fBox->StrokeLine(BPoint(156,10),BPoint(156,230),B_SOLID_HIGH);
fBox->StrokeLine(BPoint(157,11),BPoint(157,230),B_SOLID_LOW); fBox->StrokeLine(BPoint(157,11),BPoint(157,230),B_SOLID_LOW);
// Draw the icons
fBox->DrawBitmap(fDoubleClickBitmap,BPoint(344,16));
fBox->DrawBitmap(fSpeedBitmap,BPoint(333,90));
fBox->DrawBitmap(fAccelerationBitmap,BPoint(333,155));
// Draw the icons
if(updateFrame.Intersects( // i have to add 10 pixels width and height, so weird
BRect(333,16,354+fDoubleClickBitmap->Bounds().Width(),
165+fAccelerationBitmap->Bounds().Height()))) {
fBox->DrawBitmapAsync(fDoubleClickBitmap,BPoint(344,16));
fBox->DrawBitmapAsync(fSpeedBitmap,BPoint(333,90));
fBox->DrawBitmapAsync(fAccelerationBitmap,BPoint(333,155));
}
// Draw the mouse
// i have to add 10 pixels width and height, so weird
if(updateFrame.Intersects(BRect(50,41,60+kMouseWidth,51+kMouseHeight))) {
fBox->SetDrawingMode(B_OP_OVER); fBox->SetDrawingMode(B_OP_OVER);
// Draw the mouse top // Draw the mouse top
fBox->DrawBitmap(fMouseBitmap,BPoint(50, 41)); fBox->DrawBitmapAsync(fMouseBitmap,BPoint(50, 41));
int32 index = mouseTypeMenu->IndexOf(mouseTypeMenu->FindMarked()); int32 index = mouseTypeMenu->IndexOf(mouseTypeMenu->FindMarked());
if (index == 0) { // 1 button if (index == 0) { // 1 button
if (fButtons & fCurrentMouseMap.button[0]) { if (fButtons & fCurrentMouseMap.button[0]) {
fBox->DrawBitmap(fMouseDownBitmap,BPoint(50, 47)); fBox->DrawBitmapAsync(fMouseDownBitmap,BPoint(50, 47));
fBox->SetHighColor(64,64,64); fBox->SetHighColor(64,64,64);
} }
} else if (index == 1) { // 2 button } else if (index == 1) { // 2 button
if ( fButtons & fCurrentMouseMap.button[0]) { if ( fButtons & fCurrentMouseMap.button[0]) {
fBox->DrawBitmap(fMouseDownBitmap, BRect(0,0,27,28), BRect(50,47,77,75)); fBox->DrawBitmapAsync(fMouseDownBitmap, BRect(0,0,27,28), BRect(50,47,77,75));
fBox->SetHighColor(120,120,120); fBox->SetHighColor(120,120,120);
} else } else
fBox->SetHighColor(184,184,184); fBox->SetHighColor(184,184,184);
@@ -259,7 +283,7 @@ MouseView::Draw(BRect updateFrame)
if (fButtons & fCurrentMouseMap.button[1]) { if (fButtons & fCurrentMouseMap.button[1]) {
fBox->SetHighColor(120,120,120); fBox->SetHighColor(120,120,120);
fBox->DrawBitmap(fMouseDownBitmap, BRect(27,0,54,28), BRect(77,47,104,75)); fBox->DrawBitmapAsync(fMouseDownBitmap, BRect(27,0,54,28), BRect(77,47,104,75));
} else } else
fBox->SetHighColor(255,255,255); fBox->SetHighColor(255,255,255);
fBox->StrokeLine(BPoint(78,49),BPoint(78,71),B_SOLID_HIGH); fBox->StrokeLine(BPoint(78,49),BPoint(78,71),B_SOLID_HIGH);
@@ -272,14 +296,14 @@ MouseView::Draw(BRect updateFrame)
} else { // 3 button } else { // 3 button
if ( fButtons & fCurrentMouseMap.button[0]) { if ( fButtons & fCurrentMouseMap.button[0]) {
fBox->DrawBitmap(fMouseDownBitmap, BRect(0,0,18,28), BRect(50,47,68,75)); fBox->DrawBitmapAsync(fMouseDownBitmap, BRect(0,0,18,28), BRect(50,47,68,75));
fBox->SetHighColor(120,120,120); fBox->SetHighColor(120,120,120);
} else } else
fBox->SetHighColor(184,184,184); fBox->SetHighColor(184,184,184);
fBox->StrokeLine(BPoint(67,49),BPoint(67,71),B_SOLID_HIGH); fBox->StrokeLine(BPoint(67,49),BPoint(67,71),B_SOLID_HIGH);
if (fButtons & fCurrentMouseMap.button[2]) { if (fButtons & fCurrentMouseMap.button[2]) {
fBox->DrawBitmap(fMouseDownBitmap, BRect(18,0,36,28), BRect(68,47,86,75)); fBox->DrawBitmapAsync(fMouseDownBitmap, BRect(18,0,36,28), BRect(68,47,86,75));
fBox->SetHighColor(120,120,120); fBox->SetHighColor(120,120,120);
} else } else
fBox->SetHighColor(184,184,184); fBox->SetHighColor(184,184,184);
@@ -292,7 +316,7 @@ MouseView::Draw(BRect updateFrame)
fBox->StrokeLine(BPoint(69,49),BPoint(69,71),B_SOLID_HIGH); fBox->StrokeLine(BPoint(69,49),BPoint(69,71),B_SOLID_HIGH);
if (fButtons & fCurrentMouseMap.button[1]) { if (fButtons & fCurrentMouseMap.button[1]) {
fBox->DrawBitmap(fMouseDownBitmap, BRect(36,0,54,28), BRect(86,47,104,75)); fBox->DrawBitmapAsync(fMouseDownBitmap, BRect(36,0,54,28), BRect(86,47,104,75));
fBox->SetHighColor(120,120,120); fBox->SetHighColor(120,120,120);
} else } else
fBox->SetHighColor(255,255,255); fBox->SetHighColor(255,255,255);
@@ -327,6 +351,9 @@ MouseView::Draw(BRect updateFrame)
fBox->MovePenTo(offsets[index][i], 65); fBox->MovePenTo(offsets[index][i], 65);
fBox->DrawString(number); fBox->DrawString(number);
} }
}
fBox->Sync();
fBox->SetDrawingMode(B_OP_COPY); fBox->SetDrawingMode(B_OP_COPY);
} }