<commit_before>/*
 * CPColorPanel.j
 * AppKit
 *
 * Created by <NAME>.
 * Copyright 2008, 280 North, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

import "CPButton.j"
import "CPColorPicker.j"
import "CPCookie.j"
import "CPKulerColorPicker.j"
import "CPPanel.j"
import "CPSliderColorPicker.j"
import "CPView.j"


CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification";

var PREVIEW_HEIGHT = 20.0,
    TOOLBAR_HEIGHT = 32.0,
    SWATCH_HEIGHT  = 14.0;

var SharedColorPanel = nil;

/*
    A color wheel
    @global
    @group CPColorPanelMode
*/
CPWheelColorPickerMode = 1;
/*
    Kuler color picker
    @global
    @group CPColorPanelMode
*/
CPKulerColorPickerMode = 2;
/*
    Slider based picker
    @global
    @group CPColorPanelMode
*/
CPSliderColorPickerMode = 3;

CPColorPickerViewWidth  = 265,
CPColorPickerViewHeight = 370;

/*
    <objj>CPColorPanel</objj> provides a reusable panel that can be used
    displayed on screen to prompt the user for a color selection. To
    obtain the panel, call the <code>sharedColorPanel</code> method.
*/
@implementation CPColorPanel : CPPanel
{    
    _CPColorPanelToolbar    _toolbar;
    _CPColorPanelSwatches   _swatchView;
    _CPColorPanelPreview    _previewView;
    
    CPTextField     _previewLabel;
    CPTextField     _swatchLabel;
        
    CPView          _activeView;
    
    CPColorPicker   _activePicker;
    CPColorPicker   _wheelPicker;
    CPColorPicker   _kulerPicker;
    CPColorPicker   _sliderPicker;
    
    CPColor         _color;
    
    id              _target;
    SEL             _action;       
    
    int             _mode;             
}

/*
    Returns (and if necessary, creates) the shared color panel.
*/
+ (CPColorPanel)sharedColorPanel
{
    if (!SharedColorPanel)
        SharedColorPanel = [[CPColorPanel alloc] init];
    
    return SharedColorPanel;
}

/*
    Returns the shared color panel set to display in <code>mode</code>.
    @param mode the mode to which the color panel will be set before returning
*/
+ (void)setPickerMode:(CPColorPanelMode)mode
{
    var panel = [CPColorPanel sharedColorPanel];
    [panel setMode: mode];
}

/*
    To obtain the color panel, use <code>sharedColorPanel</code>.
    @ignore
*/
- (id)init
{
    self = [super initWithContentRect:CGRectMake(500.0, 50.0, 218.0, 360.0) 
                            styleMask:(CPHUDBackgroundWindowMask | CPTitledWindowMask | CPClosableWindowMask | CPResizableWindowMask)];
    
    if (self)
    {
        [self setTitle:@"Color Panel"];
        [self setLevel:CPFloatingWindowLevel];
        
        [self setBecomesKeyOnlyIfNeeded:YES];
        
        [self setMinSize:CGSizeMake(218.0, 360.0)];
        [self setMaxSize:CGSizeMake(327.0, 540.0)];
    }
    
    return self;
}

/*
    Sets the color of the panel, and updates the picker. Also posts a <code>CPColorPanelDidChangeNotification</code>.
*/
- (void)setColor:(CPColor)aColor
{
    _color = aColor;
    [_previewView setBackgroundColor: _color];
    <commit_msg>Set the color panel to have floating panel status.<commit_after>/*
 * CPColorPanel.j
 * AppKit
 *
 * Created by <NAME>.
 * Copyright 2008, 280 North, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

import "CPButton.j"
import "CPColorPicker.j"
import "CPCookie.j"
import "CPKulerColorPicker.j"
import "CPPanel.j"
import "CPSliderColorPicker.j"
import "CPView.j"


CPColorPanelColorDidChangeNotification = @"CPColorPanelColorDidChangeNotification";

var PREVIEW_HEIGHT = 20.0,
    TOOLBAR_HEIGHT = 32.0,
    SWATCH_HEIGHT  = 14.0;

var SharedColorPanel = nil;

/*
    A color wheel
    @global
    @group CPColorPanelMode
*/
CPWheelColorPickerMode = 1;
/*
    Kuler color picker
    @global
    @group CPColorPanelMode
*/
CPKulerColorPickerMode = 2;
/*
    Slider based picker
    @global
    @group CPColorPanelMode
*/
CPSliderColorPickerMode = 3;

CPColorPickerViewWidth  = 265,
CPColorPickerViewHeight = 370;

/*
    <objj>CPColorPanel</objj> provides a reusable panel that can be used
    displayed on screen to prompt the user for a color selection. To
    obtain the panel, call the <code>sharedColorPanel</code> method.
*/
@implementation CPColorPanel : CPPanel
{    
    _CPColorPanelToolbar    _toolbar;
    _CPColorPanelSwatches   _swatchView;
    _CPColorPanelPreview    _previewView;
    
    CPTextField     _previewLabel;
    CPTextField     _swatchLabel;
        
    CPView          _activeView;
    
    CPColorPicker   _activePicker;
    CPColorPicker   _wheelPicker;
    CPColorPicker   _kulerPicker;
    CPColorPicker   _sliderPicker;
    
    CPColor         _color;
    
    id              _target;
    SEL             _action;       
    
    int             _mode;             
}

/*
    Returns (and if necessary, creates) the shared color panel.
*/
+ (CPColorPanel)sharedColorPanel
{
    if (!SharedColorPanel)
        SharedColorPanel = [[CPColorPanel alloc] init];
    
    return SharedColorPanel;
}

/*
    Sets the mode for the shared color panel.
    @param mode the mode to which the color panel will be set
*/
+ (void)setPickerMode:(CPColorPanelMode)mode
{
    var panel = [CPColorPanel sharedColorPanel];
    [panel setMode: mode];
}

/*
    To obtain the color panel, use <code>sharedColorPanel</code>.
    @ignore
*/
- (id)init
{
    self = [super initWithContentRect:CGRectMake(500.0, 50.0, 218.0, 360.0) 
                            styleMask:(CPHUDBackgroundWindowMask | CPTitledWindowMask | CPClosableWindowMask | CPResizableWindowMask)];
    
    if (self)
    {
        [self setTitle:@"Color Panel"];
        [self setLevel:CPFloatingWindowLevel];
        
        [self setFloatingPanel:YES];
        [self setBecomesKeyOnlyIfNeeded:YES];
        
        [self setMinSize:CGSizeMake(218.0, 360.0)];
        [self setMaxSize:CGSizeMake(327.0, 540.0)];
    }
    
    return self;
}

/*
    Sets the color of the panel, and updates the picker. Also posts a <code>CPColorPanelDidChangeNotification</code>.
*/
- (void)setColor:(CPColor)aColor
{
    _color = aColor;
    [_previewView setBackgroundColor: _color];
    
{'fraction_non_alphanumeric': 0.08116406354291816, 'fraction_numerical': 0.0184221065278334, 'mean_word_length': 2.9577390385631275, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1317271', 'n_tokens_mistral': 2369, 'n_tokens_neox': 2233, 'n_words': 698}