Skip to content
Snippets Groups Projects
FXApp.rb 16.3 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
module Fox
  # FOX Event 
  class FXEvent
  
    # Event type [Integer]
    attr_reader :type
    
    # Time of last event [Integer]
    attr_reader :time
    
    # Window-relative x-coordinate [Integer]
    attr_reader :win_x
    
    # Window-relative y-coordinate [Integer]
    attr_reader :win_y
    
    # Root window x-coordinate [Integer]
    attr_reader :root_x
    
    # Root window y-coordinate [Integer]
    attr_reader :root_y
    
    # Keyboard/modifier state [Integer]
    attr_reader :state
    
    # Button, keysym or mode; DDE source [Integer]
    attr_reader :code
    
    # Text of keyboard event [String]
    attr_reader :text
    
    # Window-relative x-coordinate of previous mouse location [Integer]
    attr_reader :last_x
    
    # Window-relative y-coordinate of previous mouse location [Integer]
    attr_reader :last_y
    
    # Window-relative x-coordinate of mouse press [Integer]
    attr_reader :click_x
    
    # Window-relative y-coordinate of mouse press [Integer]
    attr_reader :click_y
    
    # Root window x-coordinate of mouse press [Integer]
    attr_reader :rootclick_x
    
    # Root window y-coordinate of mouse press [Integer]
    attr_reader :rootclick_y
    
    # Time of mouse button press [Integer]
    attr_reader :click_time
    
    # Mouse button pressed [Integer]
    attr_reader :click_button
    
    # Click count [Integer]
    attr_reader :click_count
    
    # Target drag type being requested [Integer]
    attr_reader :target

    # Return true if cursor moved since last press
    def moved? ; end

    # Exposed rectangle for paint events
    def rect ; end

    # Return true if this is a synthetic expose event
    def synthetic? ; end
  end

  #
  # Application Object
  #
  # === Events
  #
  # The FXApp object itself doesn't have a designated message target like
  # other FOX objects, but it can send messages to objects for a few
  # special events.
  #
  # [*Timers*]
  #   When a timeout event is registered with the application using the
  #   addTimeout method, a +SEL_TIMEOUT+ message is sent to the message
  #   target.
  # [*Chores*]
  #   When a chore event is registered with the application using the
  #   addChore method, a +SEL_CHORE+ message is sent to the message target.
  # [*Inputs*]
  #   When an input event is registered with the application using the
  #   addInput method, a +SEL_IO_READ+, +SEL_IO_WRITE+ or +SEL_IO_EXCEPT+
  #   message may be sent to the message target.
  # [*Signals*]
  #   When a signal handler object is registered with the application using
  #   the addSignal method, a +SEL_SIGNAL+ message may be sent to the message
  #   target.
  # 
  # === File input modes for #addInput
  #
  # +INPUT_NONE+::		inactive
  # +INPUT_READ+::		read input fd
  # +INPUT_WRITE+::		write input fd
  # +INPUT_EXCEPT+::		except input fd
  #
  # === All ways of being modal
  #
  # +MODAL_FOR_NONE+::		Non modal event loop (dispatch normally)
  # +MODAL_FOR_WINDOW+::	Modal dialog (beep if outside of modal dialog)
  # +MODAL_FOR_POPUP+::		Modal for popup (always dispatch to popup)
  #
  # === Default cursors provided by the application
  #
  # These constants symbolically represent the different cursor shapes used
  # in FOX applications, and can be used as the _which_ arguments for
  # #getDefaultCursor and #setDefaultCursor.
  #
  # +DEF_ARROW_CURSOR+::      Arrow cursor
  # +DEF_RARROW_CURSOR+::     Reverse arrow cursor
  # +DEF_TEXT_CURSOR+::       Text cursor
  # +DEF_HSPLIT_CURSOR+::     Horizontal split cursor
  # +DEF_VSPLIT_CURSOR+::     Vertical split cursor
  # +DEF_XSPLIT_CURSOR+::     Cross split cursor
  # +DEF_SWATCH_CURSOR+::     Color swatch drag cursor
  # +DEF_MOVE_CURSOR+::       Move cursor
  # +DEF_DRAGH_CURSOR+::      Resize horizontal edge
  # +DEF_DRAGV_CURSOR+::      Resize vertical edge
  # +DEF_DRAGTL_CURSOR+::     Resize upper-leftcorner
  # +DEF_DRAGBR_CURSOR+::     Resize bottom-right corner
  # +DEF_DRAGTR_CURSOR+::     Resize upper-right corner
  # +DEF_DRAGBL_CURSOR+::     Resize bottom-left corner
  # +DEF_DNDSTOP_CURSOR+::    Drag and drop stop
  # +DEF_DNDCOPY_CURSOR+::    Drag and drop copy
  # +DEF_DNDMOVE_CURSOR+::    Drag and drop move
  # +DEF_DNDLINK_CURSOR+::    Drag and drop link
  # +DEF_CROSSHAIR_CURSOR+::  Cross hair cursor
  # +DEF_CORNERNE_CURSOR+::   North-east cursor
  # +DEF_CORNERNW_CURSOR+::   North-west cursor
  # +DEF_CORNERSE_CURSOR+::   South-east cursor
  # +DEF_CORNERSW_CURSOR+::   South-west cursor
  # +DEF_HELP_CURSOR+::	      Help arrow cursor
  # +DEF_HAND_CURSOR+::	      Hand cursor
  # +DEF_ROTATE_CURSOR+::     Rotate cursor
  # +DEF_WAIT_CURSOR+::       Wait cursor
  #
  # === Messages identifiers
  #
  # +ID_QUIT+::               Terminate the application normally
  # +ID_DUMP+::               Dump the current widget tree

  class FXApp < FXObject

    # Application name [String]
    attr_reader :appName

    # Vendor name [String]
    attr_reader :vendorName
    
    # Argument count [Integer]
    attr_reader :argc
    
    # Argument vector [Array]
    attr_reader :argv

    # Display [Integer]
    attr_reader :display

    # Border color [FXColor]
    attr_accessor :borderColor

    # Background color of GUI controls [FXColor]
    attr_accessor :baseColor

    # Hilite color of GUI controls [FXColor]
    attr_accessor :hiliteColor

    # Shadow color of GUI controls [FXColor]
    attr_accessor :shadowColor

    # Default background color [FXColor]
    attr_accessor :backColor

    # Default foreground color [FXColor]
    attr_accessor :foreColor

    # Default foreground color for selected objects [FXColor]
    attr_accessor :selforeColor

    # Default background color for selected objects [FXColor]
    attr_accessor :selbackColor

    # Default foreground color for tooltips [FXColor]
    attr_accessor :tipforeColor

    # Default background color for tooltips [FXColor]
    attr_accessor :tipbackColor
    
    # Default text color for selected menu items [FXColor]
    attr_accessor :selMenuTextColor
    
    # Default background color for selected menu items [FXColor]
    attr_accessor :selMenuBackColor

    # Default visual [FXVisual]
    attr_accessor :defaultVisual

    # Default font [FXFont]
    attr_accessor :normalFont

    # Wait cursor [FXCursor]
    attr_accessor :waitCursor

    # Monochrome visual [FXVisual]
    attr_reader :monoVisual

    # Root window [FXRootWindow]
    attr_reader :rootWindow

    # The window under the cursor, if any [FXWindow]
    attr_reader :cursorWindow

    # The window at the end of the focus chain, if any [FXWindow]
    attr_reader :focusWindow
    
    # The active top-level window, if any [FXWindow]
    attr_reader :activeWindow

    # The main window, if any [FXWindow]
    attr_reader :mainWindow

    # The window of the current modal loop [FXWindow]
    attr_reader :modalWindow

    # Mode of current modal loop [Integer]
    attr_reader :modalModality

    # Typing speed used for the FXIconList, FXList and FXTreeList widgets' lookup features,
    # in milliseconds. Default value is 1000 milliseconds.
    attr_accessor :typingSpeed

    # Click speed, in milliseconds [Integer]
    attr_accessor :clickSpeed

    # Scroll speed, in milliseconds [Integer]
    attr_accessor :scrollSpeed

    # Scroll delay time, in milliseconds [Integer]
    attr_accessor :scrollDelay

    # Blink speed, in milliseconds [Integer]
    attr_accessor :blinkSpeed

    # Animation speed, in milliseconds [Integer]
    attr_accessor :animSpeed

    # Menu pause, in milliseconds [Integer]
    attr_accessor :menuPause

    # Tooltip pause, in milliseconds [Integer]
    attr_accessor :tooltipPause

    # Tooltip time, in milliseconds [Integer]
    attr_accessor :tooltipTime

    # Drag delta, in pixels [Integer]
    attr_accessor :dragDelta

    # Number of wheel lines [Integer]
    attr_accessor :wheelLines
    
    # Scroll bar size [Integer]
    attr_accessor :scrollBarSize

    # Amount of time (in milliseconds) to yield to Ruby's thread scheduler [Integer]
    attr_accessor :sleepTime
    
    # Message translator [FXTranslator]
    attr_accessor :translator

    # Copyright notice for library
    def FXApp.copyright() ; end

    #
    # Construct application object; the _appName_ and _vendorName_ strings are used
    # as keys into the registry database for this application's settings.
    # Only one single application object can be constructed.
    #
    def initialize(appName="Application", vendorName="FoxDefault") # :yields: theApp
    end

    #
    # Open connection to display; this is called by #init.
    #
    def openDisplay(dpyname=nil) ; end
  
    # Close connection to the display
    def closeDisplay() ; end

    # Return true if the application has been initialized.
    def initialized?; end

    # Return +true+ if input methods are supported.
    def hasInputMethod?; end

    #
    # Process any timeouts due at this time.
    #
    def handleTimeouts(); end
    
    #
    # Add signal processing message to be sent to target object when 
    # the signal _sig_ is raised; flags are to be set as per POSIX definitions.
    # When _immediate_ is +true+, the message will be sent to the target right away;
    # this should be used with extreme care as the application is interrupted
    # at an unknown point in its execution.
    #
    def addSignal(sig, tgt, sel, immediate=false, flags=0) ; end

    #
    # Remove signal message for signal _sig_.
    #
    def removeSignal(sig) ; end

    #
    # Remove input message and target object for the specified file descriptor
    # and mode, which is a bitwise OR of (+INPUT_READ+, +INPUT_WRITE+, +INPUT_EXCEPT+).
    #
    def removeInput(fd, mode) ; end

    # Create application's windows
    def create() ; end

    # Destroy application's windows
    def destroy() ; end

    # Detach application's windows
    def detach() ; end

    #
    # Return key state (either +true+ or +false+) for _keysym_.
    #
    def getKeyState(keysym); end

    #
    # Peek to determine if there's an event.
    #
    def peekEvent(); end

    # Perform one event dispatch; return +true+ if event was dispatched.
    def runOneEvent(blocking=true); end

    # Run the main application event loop until #stop is called,
    # and return the exit code passed as argument to #stop.
    def run(); end

    #
    # Run an event loop till some flag becomes non-zero, and
    # then return.
    #
    def runUntil(condition); end

    #
    # Run event loop while events are available, non-modally.
    # Return when no more events, timers, or chores are outstanding.
    #
    def runWhileEvents(); end

    #
    # Run event loop while there are events are available in the queue.
    # Returns 1 when all events in the queue have been handled, and 0 when
    # the event loop was terminated due to #stop or #stopModal.
    # Except for the modal window and its children, user input to all windows 
    # is blocked; if the modal window is +nil+, all user input is blocked.
    #
    def runModalWhileEvents(window=nil); end

    # Run modal event loop, blocking keyboard and mouse events to all windows
    # until #stopModal is called.
    def runModal(); end

    # Run a modal event loop for the given window, until #stop or #stopModal is 
    # called. Except for the modal window and its children, user input to all
    # windows is blocked; if the modal window is +nil+ all user input is blocked.
    def runModalFor(window); end
  
    # Run modal while window is shown, or until #stop or #stopModal is called. 
    # Except for the modal window and its children, user input to all windows
    # is blocked; if the modal window is +nil+ all user input is blocked.
    def runModalWhileShown(window); end
  
    # Run popup menu while shown, until #stop or #stopModal is called.
    # Also returns when entering previous cascading popup menu.
    def runPopup(window); end
  
    # Returns +true+ if the window is modal
    def modal?(window) ; end

    # Terminate the outermost event loop, and all inner modal loops;
    # All more deeper nested event loops will be terminated with code equal
    # to 0, while the outermost event loop will return code equal to _value_.
    def stop(value=0); end
  
    #
    # Break out of the matching modal loop, returning code equal to _value_.
    # All deeper nested event loops are terminated with code equal to 0.
    #
    def stopModal(window, value=0); end
  
    #
    # Break out of the innermost modal loop, returning code equal to _value_.
    #
    def stopModal(value=0); end

    # Force GUI refresh
    def forceRefresh(); end

    # Schedule a refresh
    def refresh(); end

    # Flush pending repaints
    def flush(sync=false); end

    # Paint all windows marked for repainting.
    # On return all the applications windows have been painted.
    def repaint(); end
  
    #
    # Return a reference to the registry (an FXRegistry instance).
    # The registry keeps settings and configuration information for an application,
    # which are automatically loaded when the application starts
    # up, and saved when the application terminates.
    #
    def reg; end

    # Initialize application.
    # Parses and removes common command line arguments, reads the registry.
    # Finally, if _connect_ is +true+, it opens the display.
    def init(argv, connect=true) ; end

    # Exit application.
    # Closes the display and writes the registry.
    def exit(code=0); end
  
    #
    # Register a drag type with the given name and return the drag
    # drag type. If this drag type has already been registered, this
    # method will return the previously returned drag type. For example,
    #
    #   yamlDragType = app.registerDragType("application/x-yaml")
    #
    # See also #getDragTypeName.
    #
    def registerDragType(name) ; end

    #
    # Return the name of a previously registered drag type, e.g.
    #
    #   dragTypeName = app.getDragTypeName(yamlDragType)
    #
    # See also #registerDragType.
    #
    def getDragTypeName(dragType) ; end

    # Beep
    def beep(); end
  
    # Return application instance
    def FXApp.instance(); end
  
    # End the most deeply nested wait-cursor block.
    # See also #beginWaitCursor.
    def endWaitCursor(); end
  
    #
    # Return a reference to one of the default application cursors (an
    # FXCursor instance), where _which_ is one of the default cursor
    # identifiers listed above, e.g.
    #
    #   rotateCursor = app.getDefaultCursor(DEF_ROTATE_CURSOR)
    # 
    # See also #setDefaultCursor.
    #
    def getDefaultCursor(which) ; end
  
    #
    # Replace one of the default application cursors with _cursor_; e.g
    #
    #   app.setDefaultCursor(DEF_ROTATE_CURSOR, myRotateCursor)
    #
    # See also #getDefaultCursor.
    #
    def setDefaultCursor(which, cursor); end
  
    #
    # Write a window and its children, and all resources reachable from this
    # window, into the stream _store_ (an FXStream instance).
    #
    # ==== Parameters:
    #
    # +store+::		[FXStream]
    # +window+::	[FXWindow]
    #
    def writeWindow(store, window); end

    #
    # Read a window and its children from the stream store, and append
    # it under father; note it is initially not created yet.
    # Return a reference to the new window.
    #
    # ==== Parameters:
    #
    # +store+::		[FXStream]
    # +father+::	[FXWindow]
    # +owner+::		[FXWindow]
    #
    def readWindow(store, father, owner); end

    #
    # Return a reference to the application-wide mutex (an FXMutex instance).
    # Normally, the main user interface thread holds this mutex,
    # insuring that no other threads are modifying data during the
    # processing of user interface messages. However, whenever the
    # main user interface thread blocks for messages, it releases
    # this mutex, to allow other threads to modify the same data.
    # When a new message becomes available, the main user interface
    # thread regains the mutex prior to dispatching the message.
    # Other threads should hold this mutex only for short durations,
    # so as to not starve the main user interface thread.
    #
    def mutex(); end

    # Dump widget information
    def dumpWidgets() ; end
    
    # Return the number of existing windows.
    def windowCount; end
    
    # Enable support for multithreaded applications
    def enableThreads(); end
  
    # Disable support for multithreaded applications
    def disableThreads(); end

    # Check to see if multithreaded applications are supported
    def threadsEnabled?(); end
  end
end