DirectGuiGlobals.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. """
  2. Global definitions used by Direct Gui Classes and handy constants
  3. that can be used during widget construction
  4. """
  5. __all__ = []
  6. from panda3d.core import *
  7. defaultFont = None
  8. defaultFontFunc = TextNode.getDefaultFont
  9. defaultClickSound = None
  10. defaultRolloverSound = None
  11. defaultDialogGeom = None
  12. defaultDialogRelief = PGFrameStyle.TBevelOut
  13. drawOrder = 100
  14. panel = None
  15. # USEFUL GUI CONSTANTS
  16. #: Constant used to indicate that an option can only be set by a call
  17. #: to the constructor.
  18. INITOPT = ['initopt']
  19. # Mouse buttons
  20. LMB = 0
  21. MMB = 1
  22. RMB = 2
  23. # Widget state
  24. NORMAL = 'normal'
  25. DISABLED = 'disabled'
  26. # Frame style
  27. FLAT = PGFrameStyle.TFlat
  28. RAISED = PGFrameStyle.TBevelOut
  29. SUNKEN = PGFrameStyle.TBevelIn
  30. GROOVE = PGFrameStyle.TGroove
  31. RIDGE = PGFrameStyle.TRidge
  32. TEXTUREBORDER = PGFrameStyle.TTextureBorder
  33. FrameStyleDict = {'flat': FLAT, 'raised': RAISED, 'sunken': SUNKEN,
  34. 'groove': GROOVE, 'ridge': RIDGE,
  35. 'texture_border': TEXTUREBORDER,
  36. }
  37. # Orientation of DirectSlider and DirectScrollBar
  38. HORIZONTAL = 'horizontal'
  39. VERTICAL = 'vertical'
  40. VERTICAL_INVERTED = 'vertical_inverted'
  41. # Dialog button values
  42. DIALOG_NO = 0
  43. DIALOG_OK = DIALOG_YES = DIALOG_RETRY = 1
  44. DIALOG_CANCEL = -1
  45. # User can bind commands to these gui events
  46. DESTROY = 'destroy-'
  47. PRINT = 'print-'
  48. ENTER = PGButton.getEnterPrefix()
  49. EXIT = PGButton.getExitPrefix()
  50. WITHIN = PGButton.getWithinPrefix()
  51. WITHOUT = PGButton.getWithoutPrefix()
  52. B1CLICK = PGButton.getClickPrefix() + MouseButton.one().getName() + '-'
  53. B2CLICK = PGButton.getClickPrefix() + MouseButton.two().getName() + '-'
  54. B3CLICK = PGButton.getClickPrefix() + MouseButton.three().getName() + '-'
  55. B1PRESS = PGButton.getPressPrefix() + MouseButton.one().getName() + '-'
  56. B2PRESS = PGButton.getPressPrefix() + MouseButton.two().getName() + '-'
  57. B3PRESS = PGButton.getPressPrefix() + MouseButton.three().getName() + '-'
  58. B1RELEASE = PGButton.getReleasePrefix() + MouseButton.one().getName() + '-'
  59. B2RELEASE = PGButton.getReleasePrefix() + MouseButton.two().getName() + '-'
  60. B3RELEASE = PGButton.getReleasePrefix() + MouseButton.three().getName() + '-'
  61. # For DirectEntry widgets
  62. OVERFLOW = PGEntry.getOverflowPrefix()
  63. ACCEPT = PGEntry.getAcceptPrefix() + KeyboardButton.enter().getName() + '-'
  64. ACCEPTFAILED = PGEntry.getAcceptFailedPrefix() + KeyboardButton.enter().getName() + '-'
  65. TYPE = PGEntry.getTypePrefix()
  66. ERASE = PGEntry.getErasePrefix()
  67. CURSORMOVE = PGEntry.getCursormovePrefix()
  68. # For DirectSlider and DirectScrollBar widgets
  69. ADJUST = PGSliderBar.getAdjustPrefix()
  70. # For setting the sorting order of a widget's visible components
  71. IMAGE_SORT_INDEX = 10
  72. GEOM_SORT_INDEX = 20
  73. TEXT_SORT_INDEX = 30
  74. FADE_SORT_INDEX = 1000
  75. NO_FADE_SORT_INDEX = 2000
  76. # Handy conventions for organizing top-level gui objects in loose buckets.
  77. BACKGROUND_SORT_INDEX = -100
  78. MIDGROUND_SORT_INDEX = 0
  79. FOREGROUND_SORT_INDEX = 100
  80. # Symbolic constants for the indexes into an optionInfo list.
  81. _OPT_DEFAULT = 0
  82. _OPT_VALUE = 1
  83. _OPT_FUNCTION = 2
  84. # DirectButton States:
  85. BUTTON_READY_STATE = PGButton.SReady # 0
  86. BUTTON_DEPRESSED_STATE = PGButton.SDepressed # 1
  87. BUTTON_ROLLOVER_STATE = PGButton.SRollover # 2
  88. BUTTON_INACTIVE_STATE = PGButton.SInactive # 3
  89. def getDefaultRolloverSound():
  90. return defaultRolloverSound
  91. def setDefaultRolloverSound(newSound):
  92. global defaultRolloverSound
  93. defaultRolloverSound = newSound
  94. def getDefaultClickSound():
  95. return defaultClickSound
  96. def setDefaultClickSound(newSound):
  97. global defaultClickSound
  98. defaultClickSound = newSound
  99. def getDefaultFont():
  100. global defaultFont
  101. if defaultFont == None:
  102. defaultFont = defaultFontFunc()
  103. return defaultFont
  104. def setDefaultFont(newFont):
  105. global defaultFont
  106. defaultFont = newFont
  107. def setDefaultFontFunc(newFontFunc):
  108. global defaultFontFunc
  109. defaultFontFunc = newFontFunc
  110. def getDefaultDialogGeom():
  111. global defaultDialogGeom
  112. return defaultDialogGeom
  113. def getDefaultDialogRelief():
  114. global defaultDialogRelief
  115. return defaultDialogRelief
  116. def setDefaultDialogGeom(newDialogGeom, relief=None):
  117. global defaultDialogGeom, defaultDialogRelief
  118. defaultDialogGeom = newDialogGeom
  119. defaultDialogRelief = relief
  120. def getDefaultDrawOrder():
  121. return drawOrder
  122. def setDefaultDrawOrder(newDrawOrder):
  123. global drawOrder
  124. drawOrder = newDrawOrder
  125. def getDefaultPanel():
  126. return panel
  127. def setDefaultPanel(newPanel):
  128. global panel
  129. panel = newPanel