Changeset 11841 for release/1.3


Ignore:
Timestamp:
Mar 26, 2009, 11:57:47 AM (10 years ago)
Author:
cater
Message:

Canned EASYGUI dialogs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/1.3/source/examples/cocoa/easygui/dialogs.lisp

    r11814 r11841  
    1313(defun y-or-n-dialog (message)
    1414  (let ((alert (make-instance 'ns:ns-alert)))
    15     (#/setMessageText: alert message)
    16     (#/addButtonWithTitle: alert "Yes")
    17     (#/addButtonWithTitle: alert "No")
     15    (#/setMessageText: alert (ccl::%make-nsstring message))
     16    (#/addButtonWithTitle: alert (ccl::%make-nsstring "Yes"))
     17    (#/addButtonWithTitle: alert (ccl::%make-nsstring "No"))
    1818    (eql (#/runModal alert) #$NSAlertFirstButtonReturn)))
    1919
     20(defvar *beepnsleep* t)
     21
    2022(defun choose-file-dialog (&key button-string)
    21   (declare (ignorable button-string))
    2223  (gui::with-autorelease-pool
    2324      (let* ((panel (dcc (#/autorelease (dcc (#/openPanel ns:ns-open-panel)))))) ; allocate an NSOpenPanel
    2425        (dcc (#/setAllowsMultipleSelection: panel nil)) ; return at most one filename
    25         (when button-string (dcc (#/setPrompt: panel button-string)))
     26        (when button-string
     27          (setf button-string (ccl::%make-nsstring button-string))
     28          (dcc (#/setPrompt: panel button-string)))
    2629        (when (eql #$NSOKButton
    2730                   (dcc (#/runModalForDirectory:file:types: panel
    28                       +null-ptr+ ; default to last dir used
    29                       +null-ptr+ ; no preselected file
    30                       ;; If not NIL below then an ObjC array containing NSStrings could be used
    31                       ;; to restrict the file types we're interested in
    32                       #$NIL)))
     31                           +null-ptr+ ; default to last dir used
     32                           +null-ptr+ ; no preselected file
     33                           ;; If not NIL below then an ObjC array containing NSStrings could be used
     34                           ;; to restrict the file types we're interested in
     35                           #$NIL)))
    3336          ;; Because we told the panel to disallow multiple selection,
    3437          ;; there should be exactly one object in this array, an
    3538          ;; NSString describing the selected file.
    36           (let* ((files (dcc (#/filenames panel))))
     39          (let* ((files (dcc (#/filenames panel))) thing)
    3740            (if (eql 1 (dcc (#/count files)))
    38               (gui::lisp-string-from-nsstring (dcc (#/objectAtIndex: files 0)))
    39               (error "Don't know why we didn't get an NSArray containing exactly 1 file here.")))))))
     41              (progn
     42                (setf thing (dcc (#/objectAtIndex: files 0)))
     43                (gui::lisp-string-from-nsstring thing))
     44              "Don't know why we didn't get an NSArray containing exactly 1 file here."))))))
    4045
    4146(defun choose-new-file-dialog (&key button-string)
     
    4348  (gui::with-autorelease-pool
    4449      (let* ((panel (dcc (#/autorelease (dcc (#/savePanel ns:ns-save-panel)))))) ; allocate an NSSavePanel
    45         (when button-string (dcc (#/setPrompt: panel button-string)))
     50        (when button-string (dcc (#/setPrompt: panel (ccl::%make-nsstring button-string))))
    4651        (when (eql #$NSOKButton
    4752                   (dcc (#/runModalForDirectory:file: panel
     
    6570    (let* ((panel (dcc (#/sharedColorPanel ns:ns-color-panel)))) ; find or create the NSColorPanel
    6671      (dcc (#/setPickerMode: ns:ns-color-panel #$NSWheelModeColorPanel))
    67       (dcc (#/setTitle: panel prompt))
     72      (dcc (#/setTitle: panel (ccl::%make-nsstring prompt)))
    6873      (dcc (#/addObserver:selector:name:object:                 ; observe yourself close but
    6974       (dcc (#/defaultCenter ns:ns-notification-center))        ; sadly confound OK & CANCEL
    7075       panel
    7176       (objc:\@selector #/NSWindowWillCloseNotification)
    72        "NSWindowWillCloseNotification"
     77       (ccl::%make-nsstring "NSWindowWillCloseNotification")
    7378       panel))
    7479      (when color (dcc (#/setColor: panel color)))
     
    7782       (dcc (#/defaultCenter ns:ns-notification-center))
    7883       panel
    79        "NSWindowWillCloseNotification"
     84       (ccl::%make-nsstring "NSWindowWillCloseNotification")
    8085       panel))
    8186      (dcc (#/retain (dcc (#/color panel)))))))
Note: See TracChangeset for help on using the changeset viewer.