| 102 | static property_info sProperties[] = { |
| 103 | { "Info", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, |
| 104 | { B_DIRECT_SPECIFIER, 0 }, |
| 105 | "Gets/sets the state of 'Show info' (true/false).", 0, |
| 106 | { B_BOOL_TYPE } |
| 107 | }, |
| 108 | { "Grid", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, |
| 109 | { B_DIRECT_SPECIFIER, 0 }, |
| 110 | "Gets/sets the state of 'Show grid' (true/false).", 0, |
| 111 | { B_BOOL_TYPE } |
| 112 | }, |
| 113 | { "MakeSquare", { B_EXECUTE_PROPERTY, 0 }, |
| 114 | { B_DIRECT_SPECIFIER, 0 }, |
| 115 | "Make the view square.", 0, |
| 116 | }, |
| 117 | { "Zoom", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, |
| 118 | { B_DIRECT_SPECIFIER, 0 }, |
| 119 | "Gets/sets the zoom factor (1-16).", 0, |
| 120 | { B_INT32_TYPE } |
| 121 | }, |
| 122 | { "Stick", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, |
| 123 | { B_DIRECT_SPECIFIER, 0 }, |
| 124 | "Gets/sets the state of 'Stick coordinates' (true/false).", 0, |
| 125 | { B_BOOL_TYPE } |
| 126 | }, |
| 127 | { "CopyImage", { B_EXECUTE_PROPERTY, 0 }, |
| 128 | { B_DIRECT_SPECIFIER, 0 }, |
| 129 | "Copy image.", 0, |
| 130 | }, |
| 131 | |
| 132 | { 0 } |
| 133 | }; |
| 134 | |
| 135 | |
| 342 | status_t |
| 343 | TWindow::GetSupportedSuites(BMessage* msg) |
| 344 | { |
| 345 | msg->AddString("suites", "suite/x-vnd.Haiku-Magnify"); |
| 346 | |
| 347 | BPropertyInfo propertyInfo(sProperties); |
| 348 | msg->AddFlat("messages", &propertyInfo); |
| 349 | |
| 350 | return BHandler::GetSupportedSuites(msg); |
| 351 | } |
| 352 | |
| 353 | |
| 354 | BHandler* |
| 355 | TWindow::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, |
| 356 | int32 what, const char* property) |
| 357 | { |
| 358 | BPropertyInfo propertyInfo(sProperties); |
| 359 | if (propertyInfo.FindMatch(msg, index, specifier, what, property) >= 0) |
| 360 | return this; |
| 361 | |
| 362 | return BHandler::ResolveSpecifier(msg, index, specifier, what, property); |
| 363 | } |
| 364 | |
| 365 | |
| 372 | case B_EXECUTE_PROPERTY: |
| 373 | case B_GET_PROPERTY: |
| 374 | case B_SET_PROPERTY: |
| 375 | { |
| 376 | int32 index; |
| 377 | BMessage specifier; |
| 378 | int32 what; |
| 379 | const char* property; |
| 380 | if (m->GetCurrentSpecifier(&index, &specifier, &what, &property) |
| 381 | != B_OK) |
| 382 | return BWindow::MessageReceived(m); |
| 383 | |
| 384 | status_t result = B_OK; |
| 385 | BMessage reply(B_REPLY); |
| 386 | |
| 387 | BPropertyInfo propertyInfo(sProperties); |
| 388 | switch (propertyInfo.FindMatch(m, index, &specifier, what, |
| 389 | property)) { |
| 390 | case 0: |
| 391 | if (m->what == B_GET_PROPERTY) |
| 392 | result = reply.AddBool("result", fInfoBarState); |
| 393 | else if (m->what == B_SET_PROPERTY) { |
| 394 | bool showInfo; |
| 395 | result = m->FindBool("data", &showInfo); |
| 396 | if (result == B_OK) { |
| 397 | fInfoBarState = showInfo; |
| 398 | ShowInfo(fInfoBarState); |
| 399 | } |
| 400 | } |
| 401 | break; |
| 402 | |
| 403 | case 1: |
| 404 | if (m->what == B_GET_PROPERTY) |
| 405 | result = reply.AddBool("result", fShowGrid); |
| 406 | else if (m->what == B_SET_PROPERTY) { |
| 407 | bool showGrid; |
| 408 | result = m->FindBool("data", &showGrid); |
| 409 | if (result == B_OK) |
| 410 | SetGrid(showGrid); |
| 411 | } |
| 412 | break; |
| 413 | |
| 414 | case 2: |
| 415 | if (fHPixelCount != fVPixelCount) { |
| 416 | int32 big = fHPixelCount > fVPixelCount ? fHPixelCount |
| 417 | : fVPixelCount; |
| 418 | ResizeWindow(big, big); |
| 419 | } |
| 420 | break; |
| 421 | |
| 422 | case 3: |
| 423 | if (m->what == B_GET_PROPERTY) |
| 424 | result = reply.AddInt32("result", fPixelSize); |
| 425 | else if (m->what == B_SET_PROPERTY) { |
| 426 | int32 zoom; |
| 427 | result = m->FindInt32("data", &zoom); |
| 428 | if (result == B_OK) |
| 429 | SetPixelSize(zoom); |
| 430 | } |
| 431 | break; |
| 432 | |
| 433 | case 4: |
| 434 | if (m->what == B_GET_PROPERTY) |
| 435 | result = reply.AddBool("result", fFatBits->Sticked()); |
| 436 | else if (m->what == B_SET_PROPERTY) { |
| 437 | bool stick; |
| 438 | result = m->FindBool("data", &stick); |
| 439 | if (result == B_OK) |
| 440 | fFatBits->MakeSticked(stick); |
| 441 | } |
| 442 | break; |
| 443 | |
| 444 | case 5: |
| 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 | |