machine.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* machine.cpp
  2. *
  3. * Copyright (C) 1992-2011,2012,2013,2016 Paul Boersma
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "machine.h"
  19. #include "melder.h"
  20. #define LookAndFeel_MOTIF 0
  21. #define LookAndFeel_SGI 1
  22. #define LookAndFeel_CDE 2
  23. #define LookAndFeel_SOLARIS 3
  24. #define LookAndFeel_HP 4
  25. #define LookAndFeel_SUN4 5
  26. #define LookAndFeel_MAC 6
  27. #define LookAndFeel_WIN32 7
  28. #define LookAndFeel_LINUX 8
  29. #define LookAndFeel_COCOA 9
  30. static int lookAndFeel;
  31. int Machine_getMenuBarHeight () {
  32. static int heights [] = {
  33. 26, /* Motif */
  34. 24, /* SGI */
  35. 28, /* CDE */
  36. 26, /* Solaris */
  37. 26, /* HP */
  38. 26, /* Sun4 */
  39. 36, /* Mac */
  40. 0, /* Win32 */
  41. 30, /* Linux */
  42. 36 /* Cocoa */
  43. };
  44. return heights [lookAndFeel];
  45. }
  46. int Machine_getMainWindowMenuBarHeight () {
  47. #ifdef macintoshXXX
  48. return 0;
  49. #else
  50. return Machine_getMenuBarHeight ();
  51. #endif
  52. }
  53. int Machine_getTitleBarHeight () {
  54. static int heights [] = { /* Mostly copied from menu-bar height. */
  55. 26, /* Motif */
  56. 24, /* SGI */
  57. 28, /* CDE */
  58. 26, /* Solaris */
  59. 26, /* HP */
  60. 26, /* Sun4 */
  61. 22, /* Mac */
  62. 20, /* Win32 */
  63. 30, /* Linux */
  64. 22 /* Cocoa */
  65. };
  66. return heights [lookAndFeel];
  67. }
  68. int Machine_getScrollBarWidth () {
  69. static int widths [] = {
  70. 22, /* Motif */
  71. 22, /* SGI */
  72. 22, /* CDE */
  73. 22, /* Solaris */
  74. 22, /* HP */
  75. 22, /* Sun4 */
  76. 16, /* Mac */
  77. 17, /* Win32 */
  78. 18, /* Linux */
  79. 16 /* Cocoa */
  80. };
  81. return widths [lookAndFeel];
  82. }
  83. int Machine_getTextHeight () {
  84. static int heights [] = {
  85. 29, /* Motif */
  86. 29, /* SGI */
  87. 25, /* CDE */
  88. 29, /* Solaris */
  89. 29, /* HP */
  90. 29, /* Sun4 */
  91. 22, /* Mac */
  92. 20, /* Win32 */
  93. 25, /* Linux */
  94. 23 /* Cocoa */
  95. };
  96. return heights [lookAndFeel];
  97. }
  98. void Machine_initLookAndFeel (int argc, char **argv) {
  99. /*
  100. * Determining the appropriate look-and-feel: the default depends on the client machine.
  101. */
  102. #if defined (macintosh)
  103. lookAndFeel = LookAndFeel_COCOA;
  104. return;
  105. #elif defined (_WIN32)
  106. lookAndFeel = LookAndFeel_WIN32;
  107. return;
  108. #elif defined (linux)
  109. lookAndFeel = LookAndFeel_LINUX;
  110. #endif
  111. /*
  112. * Command line may override the look-and-feel.
  113. */
  114. if (argc > 1) {
  115. if (strequ (argv [1], "-sgi")) lookAndFeel = LookAndFeel_SGI;
  116. else if (strequ (argv [1], "-motif")) lookAndFeel = LookAndFeel_MOTIF;
  117. else if (strequ (argv [1], "-cde")) lookAndFeel = LookAndFeel_CDE;
  118. else if (strequ (argv [1], "-solaris")) lookAndFeel = LookAndFeel_SOLARIS;
  119. else if (strequ (argv [1], "-hp")) lookAndFeel = LookAndFeel_HP;
  120. else if (strequ (argv [1], "-sun4")) lookAndFeel = LookAndFeel_SUN4;
  121. else if (strequ (argv [1], "-mac")) lookAndFeel = LookAndFeel_MAC;
  122. else if (strequ (argv [1], "-linux")) lookAndFeel = LookAndFeel_LINUX;
  123. else if (strequ (argv [1], "-cocoa")) lookAndFeel = LookAndFeel_COCOA;
  124. }
  125. }
  126. /* End of file machine.cpp */