| 2472 | |
| 2473 | |
| 2474 | void GuiType::ApplyEventStyles(GuiControlType *aControl, UINT aEvent, bool aAdded) |
| 2475 | { |
| 2476 | int style_type; |
| 2477 | DWORD style_bit; |
| 2478 | HWND hwnd; |
| 2479 | if (aControl) |
| 2480 | { |
| 2481 | // These styles are only added automatically, not removed, for a few reasons: |
| 2482 | // 1) Reduces code size (by 224 bytes on x86 vs. just 64 bytes for this section). |
| 2483 | // Note that it's necessary to check for handlers for every event in the group |
| 2484 | // before removing the style. |
| 2485 | // 2) The script may have applied the style manually, in which case it should not |
| 2486 | // be removed automatically (but we have no way to know). |
| 2487 | // 3) It's probably rare to remove a handler for one of these events. |
| 2488 | if (!aAdded) |
| 2489 | return; |
| 2490 | GuiControlType &control = *aControl; |
| 2491 | // This approach appears to produce the same code size as just checking for the |
| 2492 | // events which don't need the style; i.e. GUI_EVENT_CONTEXTMENU and (for Buttons) |
| 2493 | // GUI_EVENT_CLICK: |
| 2494 | static char sStaticNotify[] = {GUI_EVENT_CLICK, GUI_EVENT_DBLCLK, NULL}; |
| 2495 | static char sButtonNotify[] = {GUI_EVENT_DBLCLK, GUI_EVENT_FOCUS, GUI_EVENT_LOSEFOCUS, NULL}; |
| 2496 | char *event_group; |
| 2497 | switch (control.type) |
| 2498 | { |
| 2499 | case GUI_CONTROL_TEXT: |
| 2500 | case GUI_CONTROL_PIC: |
| 2501 | // Apply the SS_NOTIFY style *only* if the control actually has an associated action. |
| 2502 | // This is because otherwise the control would steal all clicks for any other controls |
| 2503 | // drawn on top of it (e.g. a picture control with some edit fields drawn on top of it). |
| 2504 | // See comments in the creation of GUI_CONTROL_PIC for more info: |
| 2505 | style_bit = SS_NOTIFY; |
| 2506 | event_group = sStaticNotify; |
| 2507 | break; |
| 2508 | |
| 2509 | case GUI_CONTROL_BUTTON: |
| 2510 | case GUI_CONTROL_CHECKBOX: |
| 2511 | case GUI_CONTROL_RADIO: |
| 2512 | style_bit = BS_NOTIFY; |
| 2513 | event_group = sButtonNotify; |
| 2514 | break; |
| 2515 | |
| 2516 | default: |
| 2517 | return; |
| 2518 | } |
| 2519 | if (!strchr(event_group, aEvent)) |
| 2520 | return; |
| 2521 | style_type = GWL_STYLE; |
| 2522 | hwnd = control.hwnd; |
| 2523 | } |
| 2524 | else // aControl == NULL |
| 2525 | { |
| 2526 | if (aEvent == GUI_EVENT_DROPFILES) |
| 2527 | { |
| 2528 | // Apply the WS_EX_ACCEPTFILES style to ensure the window can accept dropped files. |
| 2529 | // Remove the style to ensure the mouse cursor correctly changes to show that the |
| 2530 | // window no longer accepts dropped files. |
| 2531 | style_type = GWL_EXSTYLE; |
nothing calls this directly
no outgoing calls
no test coverage detected