| 102 | static property_info sProperties[] = { |
| 103 | { "ShowInfo", { B_EXECUTE_PROPERTY, 0 }, |
| 104 | { B_DIRECT_SPECIFIER, 0 }, |
| 105 | "Show info.", 0, |
| 106 | }, |
| 107 | { "HideInfo", { B_EXECUTE_PROPERTY, 0 }, |
| 108 | { B_DIRECT_SPECIFIER, 0 }, |
| 109 | "Hide info.", 0, |
| 110 | }, |
| 111 | { "ShowGrid", { B_EXECUTE_PROPERTY, 0 }, |
| 112 | { B_DIRECT_SPECIFIER, 0 }, |
| 113 | "Show grid.", 0, |
| 114 | }, |
| 115 | { "HideGrid", { B_EXECUTE_PROPERTY, 0 }, |
| 116 | { B_DIRECT_SPECIFIER, 0 }, |
| 117 | "Hide grid.", 0, |
| 118 | }, |
| 119 | { "MakeSquare", { B_EXECUTE_PROPERTY, 0 }, |
| 120 | { B_DIRECT_SPECIFIER, 0 }, |
| 121 | "Make the view square.", 0, |
| 122 | }, |
| 123 | { "Zoom", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, |
| 124 | { B_DIRECT_SPECIFIER, 0 }, |
| 125 | "Gets/sets the zoom factor (1-16).", 0, |
| 126 | { B_INT32_TYPE } |
| 127 | }, |
| 128 | { "Stick", { B_EXECUTE_PROPERTY, 0 }, |
| 129 | { B_DIRECT_SPECIFIER, 0 }, |
| 130 | "Stick coordinates.", 0, |
| 131 | }, |
| 132 | { "Unstick", { B_EXECUTE_PROPERTY, 0 }, |
| 133 | { B_DIRECT_SPECIFIER, 0 }, |
| 134 | "Unstick coordinates.", 0, |
| 135 | }, |
| 136 | { "CopyImage", { B_EXECUTE_PROPERTY, 0 }, |
| 137 | { B_DIRECT_SPECIFIER, 0 }, |
| 138 | "Copy image.", 0, |
| 139 | }, |
| 140 | |
| 141 | { 0 } |
| 142 | }; |
| 143 | |
| 144 | |
| 351 | status_t |
| 352 | TWindow::GetSupportedSuites(BMessage* msg) |
| 353 | { |
| 354 | msg->AddString("suites", "suite/x-vnd.Haiku-Magnify"); |
| 355 | |
| 356 | BPropertyInfo propertyInfo(sProperties); |
| 357 | msg->AddFlat("messages", &propertyInfo); |
| 358 | |
| 359 | return BHandler::GetSupportedSuites(msg); |
| 360 | } |
| 361 | |
| 362 | |
| 363 | BHandler* |
| 364 | TWindow::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, |
| 365 | int32 what, const char* property) |
| 366 | { |
| 367 | BPropertyInfo propertyInfo(sProperties); |
| 368 | if (propertyInfo.FindMatch(msg, index, specifier, what, property) >= 0) |
| 369 | return this; |
| 370 | |
| 371 | return BHandler::ResolveSpecifier(msg, index, specifier, what, property); |
| 372 | } |
| 373 | |
| 374 | |
| 381 | case B_EXECUTE_PROPERTY: |
| 382 | case B_GET_PROPERTY: |
| 383 | case B_SET_PROPERTY: |
| 384 | { |
| 385 | int32 index; |
| 386 | BMessage specifier; |
| 387 | int32 what; |
| 388 | const char* property; |
| 389 | if (m->GetCurrentSpecifier(&index, &specifier, &what, &property) |
| 390 | != B_OK) |
| 391 | return BWindow::MessageReceived(m); |
| 392 | |
| 393 | status_t result = B_OK; |
| 394 | BMessage reply(B_REPLY); |
| 395 | |
| 396 | BPropertyInfo propertyInfo(sProperties); |
| 397 | switch (propertyInfo.FindMatch(m, index, &specifier, what, |
| 398 | property)) { |
| 399 | case 0: |
| 400 | fInfoBarState = true; |
| 401 | ShowInfo(true); |
| 402 | break; |
| 403 | |
| 404 | case 1: |
| 405 | fInfoBarState = false; |
| 406 | ShowInfo(false); |
| 407 | break; |
| 408 | |
| 409 | case 2: |
| 410 | SetGrid(true); |
| 411 | break; |
| 412 | |
| 413 | case 3: |
| 414 | SetGrid(false); |
| 415 | break; |
| 416 | |
| 417 | case 4: |
| 418 | if (fHPixelCount != fVPixelCount) { |
| 419 | int32 big = fHPixelCount > fVPixelCount ? fHPixelCount |
| 420 | : fVPixelCount; |
| 421 | ResizeWindow(big, big); |
| 422 | } |
| 423 | break; |
| 424 | |
| 425 | case 5: |
| 426 | if (m->what == B_GET_PROPERTY) |
| 427 | result = reply.AddInt32("result", fPixelSize); |
| 428 | else if (m->what == B_SET_PROPERTY) { |
| 429 | int32 zoom; |
| 430 | result = m->FindInt32("data", &zoom); |
| 431 | if (result == B_OK) |
| 432 | SetPixelSize(zoom); |
| 433 | } |
| 434 | break; |
| 435 | |
| 436 | case 6: |
| 437 | fFatBits->MakeSticked(true); |
| 438 | break; |
| 439 | |
| 440 | case 7: |
| 441 | fFatBits->MakeSticked(false); |
| 442 | break; |
| 443 | |
| 444 | case 8: |
| 445 | fFatBits->CopyImage(); |
| 446 | break; |
| 447 | |
| 448 | default: |
| 449 | return BWindow::MessageReceived(m); |
| 450 | } |
| 451 | |
| 452 | if (result != B_OK) { |
| 453 | reply.what = B_MESSAGE_NOT_UNDERSTOOD; |
| 454 | reply.AddString("message", strerror(result)); |
| 455 | reply.AddInt32("error", result); |
| 456 | } |
| 457 | |
| 458 | m->SendReply(&reply); |
| 459 | break; |
| 460 | } |
| 461 | |