;;; -*- package: ccl -*- ;********************************************************************* ;* * ;* PROGRAM H E L P B U T T O N D I A L O G I T E M * ;* * ;********************************************************************* ;* Author : Alexander Repenning (alexander@agentsheets.com) * ;* http://www.agentsheets.com * ;* Copyright : (c) 1996-2004, AgentSheets Inc. * ;* Filename : help-button-dialog-item.lisp * ;* Updated : 03/23/04 * ;* Version : * ;* 1.0 : 12/19/03 * ;* 2.0 : 02/23/04 subclass of bevel-button-dialog-item * ;* HW/SW : G4, MCL 5, OS X 10.3.2 * ;* Abstract : OS X Bevel buttons * ;****************************************************************** (in-package :ccl) (export '(help-button-dialog-item)) (defclass HELP-BUTTON-DIALOG-ITEM (bevel-button-dialog-item) () (:documentation "Round Help Button")) (defmethod INITIALIZE-INSTANCE ((Self help-button-dialog-item) &rest Args) (declare (ignore Args)) (call-next-method) (set-view-size Self #@(22 22))) (defmethod INSTALL-VIEW-IN-WINDOW :before ((dialog-item help-button-dialog-item) dialog) (when (dialog-item-handle dialog-item) (return-from install-view-in-window)) (set-default-size-and-position dialog-item (view-container dialog-item)) (with-item-rect (rect dialog-item) (rlet ((&control :pointer)) ;; do not use the more generic NewControl (#_CreateRoundButtonControl (wptr dialog) rect #$kControlRoundButtonNormalSize (make-record :ControlButtonContentInfo :contentType #$kControlContentIconRef :IconRef (help-icon-ref)) &control) (setf (dialog-item-handle dialog-item) (%get-ptr &control))) (unless (slot-value dialog-item 'dialog-item-enabled-p) ;sync up what we believe with what the mac believes. (#_HiliteControl (dialog-item-handle dialog-item) 255)))) (defmethod VIEW-ACTIVATE-EVENT-HANDLER :before ((item help-button-dialog-item)) (dialog-item-enable item)) (defmethod VIEW-DEACTIVATE-EVENT-HANDLER :before ((item help-button-dialog-item)) (dialog-item-disable item)) #| Examples: (defparameter *Window* (make-instance 'window)) (defparameter *Button* (make-dialog-item 'help-button-dialog-item #@(20 20) #@(30 30) "Help" #'(lambda (Item) (print "help me now!")))) (add-subviews *Window* *Button*) (set-view-position *Button* #@(100 50)) |#