()
| 414 | } |
| 415 | |
| 416 | func (tv *TableView) ApplySysColors() { |
| 417 | tv.WidgetBase.ApplySysColors() |
| 418 | |
| 419 | // As some combinations of property and state may be invalid for any theme, |
| 420 | // we set some defaults here. |
| 421 | tv.themeNormalBGColor = Color(win.GetSysColor(win.COLOR_WINDOW)) |
| 422 | tv.themeNormalTextColor = Color(win.GetSysColor(win.COLOR_WINDOWTEXT)) |
| 423 | tv.themeSelectedBGColor = tv.themeNormalBGColor |
| 424 | tv.themeSelectedTextColor = tv.themeNormalTextColor |
| 425 | tv.themeSelectedNotFocusedBGColor = tv.themeNormalBGColor |
| 426 | tv.alternatingRowBGColor = Color(win.GetSysColor(win.COLOR_BTNFACE)) |
| 427 | tv.alternatingRowTextColor = Color(win.GetSysColor(win.COLOR_BTNTEXT)) |
| 428 | |
| 429 | type item struct { |
| 430 | stateID int32 |
| 431 | propertyID int32 |
| 432 | color *Color |
| 433 | } |
| 434 | |
| 435 | getThemeColor := func(theme win.HTHEME, partId int32, items []item) { |
| 436 | for _, item := range items { |
| 437 | var c win.COLORREF |
| 438 | if result := win.GetThemeColor(theme, partId, item.stateID, item.propertyID, &c); !win.FAILED(result) { |
| 439 | (*item.color) = Color(c) |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | if hThemeListView := win.OpenThemeData(tv.hwndNormalLV, syscall.StringToUTF16Ptr("Listview")); hThemeListView != 0 { |
| 445 | defer win.CloseThemeData(hThemeListView) |
| 446 | |
| 447 | getThemeColor(hThemeListView, win.LVP_LISTITEM, []item{ |
| 448 | {win.LISS_NORMAL, win.TMT_FILLCOLOR, &tv.themeNormalBGColor}, |
| 449 | {win.LISS_NORMAL, win.TMT_TEXTCOLOR, &tv.themeNormalTextColor}, |
| 450 | {win.LISS_SELECTED, win.TMT_FILLCOLOR, &tv.themeSelectedBGColor}, |
| 451 | {win.LISS_SELECTED, win.TMT_TEXTCOLOR, &tv.themeSelectedTextColor}, |
| 452 | {win.LISS_SELECTEDNOTFOCUS, win.TMT_FILLCOLOR, &tv.themeSelectedNotFocusedBGColor}, |
| 453 | }) |
| 454 | } else { |
| 455 | // The others already have been retrieved above. |
| 456 | tv.themeSelectedBGColor = Color(win.GetSysColor(win.COLOR_HIGHLIGHT)) |
| 457 | tv.themeSelectedTextColor = Color(win.GetSysColor(win.COLOR_HIGHLIGHTTEXT)) |
| 458 | tv.themeSelectedNotFocusedBGColor = Color(win.GetSysColor(win.COLOR_BTNFACE)) |
| 459 | } |
| 460 | |
| 461 | if hThemeButton := win.OpenThemeData(tv.hwndNormalLV, syscall.StringToUTF16Ptr("BUTTON")); hThemeButton != 0 { |
| 462 | defer win.CloseThemeData(hThemeButton) |
| 463 | |
| 464 | getThemeColor(hThemeButton, win.BP_PUSHBUTTON, []item{ |
| 465 | {win.PBS_NORMAL, win.TMT_FILLCOLOR, &tv.alternatingRowBGColor}, |
| 466 | {win.PBS_NORMAL, win.TMT_TEXTCOLOR, &tv.alternatingRowTextColor}, |
| 467 | }) |
| 468 | } |
| 469 | |
| 470 | win.SendMessage(tv.hwndNormalLV, win.LVM_SETBKCOLOR, 0, uintptr(tv.themeNormalBGColor)) |
| 471 | win.SendMessage(tv.hwndFrozenLV, win.LVM_SETBKCOLOR, 0, uintptr(tv.themeNormalBGColor)) |
| 472 | } |
| 473 |
no test coverage detected