You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

theme.cxx 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Copyright 2011-2022 Pierre Ossman for Cendio AB
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining
  4. * a copy of this software and associated documentation files (the
  5. * "Software"), to deal in the Software without restriction, including
  6. * without limitation the rights to use, copy, modify, merge, publish,
  7. * distribute, sublicense, and/or sell copies of the Software, and to
  8. * permit persons to whom the Software is furnished to do so, subject to
  9. * the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be
  12. * included in all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  18. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  19. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. #ifdef HAVE_CONFIG_H
  24. #include <config.h>
  25. #endif
  26. #ifdef WIN32
  27. #include <windows.h>
  28. #endif
  29. #ifdef __APPLE__
  30. #include <ApplicationServices/ApplicationServices.h>
  31. #endif
  32. #include <FL/Fl.H>
  33. #include <FL/Fl_Widget.H>
  34. #include <FL/fl_ask.H>
  35. #include "theme.h"
  36. void init_theme()
  37. {
  38. #if defined(WIN32) || defined(__APPLE__)
  39. static char font_name[256];
  40. #endif
  41. // Basic text size (10pt @ 96 dpi => 13px)
  42. FL_NORMAL_SIZE = 13;
  43. // Select a FLTK scheme and background color that looks somewhat
  44. // close to modern systems
  45. Fl::scheme("gtk+");
  46. Fl::background(220, 220, 220);
  47. // macOS has a slightly brighter default background though
  48. #ifdef __APPLE__
  49. Fl::background(240, 240, 240);
  50. #endif
  51. // This makes the "icon" in dialogs rounded, which fits better
  52. // with the above schemes.
  53. fl_message_icon()->box(FL_UP_BOX);
  54. #if defined(WIN32)
  55. NONCLIENTMETRICS metrics;
  56. metrics.cbSize = sizeof(metrics);
  57. if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
  58. sizeof(metrics), &metrics, 0)) {
  59. strcpy(font_name, metrics.lfMessageFont.lfFaceName);
  60. Fl::set_font(FL_HELVETICA, font_name);
  61. }
  62. #elif defined(__APPLE__)
  63. CTFontRef font;
  64. CFStringRef name;
  65. font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, NULL);
  66. if (font != NULL) {
  67. name = CTFontCopyFullName(font);
  68. if (name != NULL) {
  69. CFStringGetCString(name, font_name, sizeof(font_name),
  70. kCFStringEncodingUTF8);
  71. Fl::set_font(FL_HELVETICA, font_name);
  72. CFRelease(name);
  73. }
  74. CFRelease(font);
  75. }
  76. #else
  77. // FIXME: Get font from GTK or QT
  78. #endif
  79. }