{"size": 2932, "ext": "scrbl", "max_stars_repo_path": "gui-doc/mrlib/scribblings/switchable-button.scrbl", "max_stars_repo_name": "jjsimpso/gui", "max_stars_repo_stars_event_min_datetime": "2015-03-17T22:11:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-12T15:09:34.000Z", "max_issues_repo_path": "gui-doc/mrlib/scribblings/switchable-button.scrbl", "max_issues_repo_name": "jjsimpso/gui", "max_issues_repo_issues_event_min_datetime": "2015-01-09T15:53:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T16:21:29.000Z", "max_forks_repo_path": "gui-doc/mrlib/scribblings/switchable-button.scrbl", "max_forks_repo_name": "jjsimpso/gui", "max_forks_repo_forks_event_min_datetime": "2015-01-08T13:03:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-26T21:49:09.000Z"}
{"max_stars_count": 65, "max_issues_count": 231, "max_forks_count": 89, "avg_line_length": 37.5897435897, "max_line_length": 96, "alphanum_fraction": 0.6603001364}
#lang scribble/doc
@(require "common.rkt" (for-label mrlib/switchable-button framework))

@title{Switchable Button}

@defmodule[mrlib/switchable-button]

@defclass[switchable-button% canvas% ()]{
  
  A @racket[switchable-button%] control displays
  an icon and a string label. It toggles between
  display of just the icon and a display with the 
  label and the icon side-by-side. 
  
  The @racket[panel:discrete-sizes-mixin] explicitly
  uses @racket[switchable-button%]s via their
  @method[switchable-button% get-small-width],
  @method[switchable-button% get-large-width], and
  @method[switchable-button% get-without-label-small-width] methods.
  See @racket[panel:discrete-sizes-mixin] for more details.
  
  @defconstructor/auto-super[([label (or/c string? (is-a?/c bitmap%) #f)]
                              [bitmap (is-a?/c bitmap%)]
                              [callback (-> (is-a?/c switchable-button%) any/c)]
                              [alternate-bitmap (is-a?/c bitmap%) bitmap]
                              [vertical-tight? boolean? #f]
                              [min-width-includes-label? boolean? #f])]{
    The @racket[callback] is called when the button
    is pressed. The @racket[label] and @racket[bitmap] are
    used as discussed above.
    
    If @racket[alternate-bitmap] is supplied, then it is used
    when the label is not visible (via a call to @method[switchable-button% set-label-visible]).
    If it is not supplied, both modes show @racket[bitmap].
    
    If the @racket[vertical-tight?] argument is @racket[#t], then the button takes up
    as little as possible vertical space.
    
    If the @racket[min-width-includes-label?] is @racket[#t], then the minimum
    width includes both the bitmap and the label. Otherwise, it includes
    only the bitmap.
  }
  
  @defmethod[(set-label-visible [visible? boolean?]) void?]{
    Sets the visibility of the string part of the label.
  }
  
  @defmethod[(command) void?]{
    Calls the button's callback function.
  }
  
  @defmethod[(get-button-label) string?]{
    Returns the label of this button.
  }
  
  @defmethod[(get-large-width) exact-nonnegative-integer?]{
     Returns the width of the button when it would show both
     the label and the bitmap and when it is in label-visible
     mode (i.e., when @racket[set-label-visible] has been called
     with @racket[#t]).
  }

  @defmethod[(get-small-width) exact-nonnegative-integer?]{
     Returns the width of the button when it would show both
     just the bitmap (not the alternate bitmap),
     and when it is in label-visible
     mode (i.e., when @racket[set-label-visible] has been called
     with @racket[#t]).
  }
  
  @defmethod[(get-without-label-small-width) exact-nonnegative-integer?]{
     Returns the width of the button when
     it is not in label-visible
     mode (i.e., when @racket[set-label-visible] has been called
     with @racket[#f]).
  }
}
