<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tonegod.gui.controls.buttons;

/**
 *
 * @author t0neg0d
 */
public class CheckBox {
	
}<commit_msg>Update consisting of the addition of a default label associated with the CheckBox.  It is added to the scene only if setCheckboxText(String text) is called, and removed with the text is set to null.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tonegod.gui.controls.buttons;

import com.jme3.font.BitmapText;
import com.jme3.font.LineWrapMode;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector4f;
import tonegod.gui.controls.text.Label;
import tonegod.gui.core.Screen;
import tonegod.gui.effects.Effect;

/**
 *
 * @author t0neg0d
 */
public class CheckBox extends Button {
	
	Label label;
	
	public CheckBox(Screen screen, String UID, Vector2f position) {
		this(screen, UID, position,
			screen.getStyle("CheckBox").getVector2f("defaultSize"),
			screen.getStyle("CheckBox").getVector4f("resizeBorders"),
			screen.getStyle("CheckBox").getString("defaultImg")
		);
	}
	
	public CheckBox(Screen screen, String UID, Vector2f position, Vector2f dimensions) {
		this(screen, UID, position, dimensions,
			screen.getStyle("CheckBox").getVector4f("resizeBorders"),
			screen.getStyle("CheckBox").getString("defaultImg")
		);
	}
	
	public CheckBox(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
		super(screen, UID, position, dimensions, resizeBorders, defaultImg);
		
		this.clearAltImages();
		this.removeEffect(Effect.EffectEvent.Hover);
		this.removeEffect(Effect.EffectEvent.Press);
		this.removeEffect(Effect.EffectEvent.LoseFocus);
		
		label = new Label(
			screen,
			UID + ":Label",
			new Vector2f(getWidth(), 0),
			new Vector2f(100,getHeight())
		);
		label.setIgnoreMouse(true);
		label.setTextWrap(LineWrapMode.NoWrap);
		
		this.setIsToggleButton(true);
		
		if (screen.getStyle("CheckBox").getString("hoverImg") != null) {
			setButtonHoverInfo(
				screen.getStyle("CheckBox").getString("hoverImg"),
				screen.getStyle("CheckBox").getColorRGBA("hoverColor")
			);
		}
		if (screen.getStyle("CheckBox").getString("pressedImg") != null) {
			setButtonPressedInfo(
				screen.getStyle("CheckBox").getString("pressedImg"),
				screen.getStyle("CheckBox").getColorRGBA("pressedColor")
			);
		}
		
		populateEffects("CheckBox");
	}
	
	public void setCheckboxText(String text) {
		if (label.getParent() != null) {
			elementChildren.remove(label.getUID());
			label.removeFromParent();
		}
		
		BitmapText temp = new BitmapText(font);
		temp.setSize(fontSize);
		temp.setLineWrapMode(LineWrapMode.NoWrap);
		
		temp.setBox(null);
		temp.setText(text);
		float width = temp.getLineWidth();
		
		label.setWidth(width+getWidth());
		label.setFontSize(fontSize);
		label.setText(text);
		
		addChild(label);
	}
	
	public boolean getIsChecked() {
		return this.getIsToggled();
	}
	
	@Override
	public void onMouseLeftDown(MouseButtonEvent evt, boolean toggled) {  }

	@Override
	public void onMouseRightDown(MouseButtonEvent evt, boolean toggled) {  }

	@Override
	public void onMouseLeftUp(MouseButtonEvent evt, boolean toggled) {  }

	@Override
	public void onMouseRightUp(MouseButtonEvent evt, boolean toggled) {  }

	@Override
	public void onButtonFocus(MouseMotionEvent evt) {  }

	@Override
	public void onButtonLostFocus(MouseMotionEvent evt) {  }

	@Override
	public void onStillPressedInterval() {  }
	
}
{'fraction_non_alphanumeric': 0.1220108695652174, 'fraction_numerical': 0.007336956521739131, 'mean_word_length': 4.833597464342314, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, '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': '4731650', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1158, 'n_words': 248}