/**
 * Copyright (C) 2004-2011 Jive Software. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jivesoftware.spark.component.tabbedPane;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.Icon;
import javax.swing.JPanel;

public class SparkTab extends JPanel {
    private final SparkTabbedPane pane;
    private final Component component;

    public SparkTab(SparkTabbedPane pane, Component comp) {
        this.pane = pane;
        this.component = comp;
        this.setLayout(new BorderLayout());
        add(comp);
    }

    public void setTabTitle(String title) {
        pane.setTitleAt(pane.getTabPosition(this), title);
    }

    public void setIcon(Icon icon) {
        pane.setIconAt(pane.getTabPosition(this), icon);
    }

    public Component getComponent() {
        return component;
    }

    public String getTitleLabel() {
        return pane.getTitleAt(pane.getTabPosition(this));
    }

    public String getActualText() {
        return pane.getTitleAt(pane.getTabPosition(this));
    }

    public void setTitleColor(Color color) {
        pane.setTitleColorAt(pane.getTabPosition(this), color);
    }
    
    public Color getTitleColor() {
       return pane.getTitleColorAt(pane.getTabPosition(this));
    }

    public void setTabBold(boolean bold) {
        pane.setTitleBoldAt(pane.getTabPosition(this), bold);
    }

    public Font getDefaultFont() {
        return pane.getDefaultFontAt(pane.getTabPosition(this));
    }

    public void setTabFont(Font font) {
        pane.setTitleFontAt(pane.getTabPosition(this), font);
    }

    public void setShowUnreadMessageIcon(boolean show, int unreadCount) {
        pane.showUnreadMessageIndicator(pane.getTabbedPane(), show, unreadCount);
    }

    public void validateTab() {
        invalidate();
        validate();
        repaint();
    }
}
