⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personalpage.java

📁 lumaQQ的源文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.ui.config.user;

import static edu.tsinghua.lumaqq.resource.Messages.*;

import edu.tsinghua.lumaqq.events.IFaceSelectionListener;
import edu.tsinghua.lumaqq.models.User;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.qq.beans.ContactInfo;
import edu.tsinghua.lumaqq.qq.packets.BasicOutPacket;
import edu.tsinghua.lumaqq.qq.packets.out.ModifyInfoPacket;
import edu.tsinghua.lumaqq.resource.Colors;
import edu.tsinghua.lumaqq.resource.Resources;
import edu.tsinghua.lumaqq.ui.config.AbstractPage;
import edu.tsinghua.lumaqq.ui.config.IPacketFiller;
import edu.tsinghua.lumaqq.ui.helper.BeanHelper;
import edu.tsinghua.lumaqq.ui.helper.FaceRegistry;
import edu.tsinghua.lumaqq.ui.helper.HeadFactory;
import edu.tsinghua.lumaqq.ui.helper.UITool;
import edu.tsinghua.lumaqq.ui.listener.AroundBorderPaintListener;
import edu.tsinghua.lumaqq.ui.listener.CenterBorderPaintListener;
import edu.tsinghua.lumaqq.widgets.HeadImageAdvisor;
import edu.tsinghua.lumaqq.widgets.IImageSelectorAdvisor;
import edu.tsinghua.lumaqq.widgets.ImageSelector;
import edu.tsinghua.lumaqq.widgets.qstyle.LevelBar;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;

/**
 * 个人资料配置页
 * 
 * @author luma
 */
public class PersonalPage extends AbstractPage implements IPacketFiller, IFaceSelectionListener {	
    private User model;
    private PaintListener centerBorderPaintListener, aroundBorderPaintListener;
	private int headId;
    
    private Text textQQ, textNick, textRealName, textCollege, textHomePage, textAge, textIntro;
    private CCombo comboGender, comboOccupation, comboZodiac, comboHoroscope, comboBlood;
    private CLabel btnFace;
    private Cursor handCursor;
	private Text textSignature;
	private LevelBar levelBar;
    
    /**
     * @param parent
     */
    public PersonalPage(Composite parent, User model, int style) {
        super(parent, style);
        this.model = model;
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.shells.AbstractPage#setModel(java.lang.Object)
     */
	@Override
    public void setModel(Object model) {
        if(model instanceof User)
            this.model = (User)model;
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.shells.AbstractPage#initialVariable()
     */
	@Override
    protected void initialVariable() {
        centerBorderPaintListener = new CenterBorderPaintListener(new Class[] { Text.class, CCombo.class }, 20, Colors.PAGE_CONTROL_BORDER);
        aroundBorderPaintListener = new AroundBorderPaintListener(new Class[] { CLabel.class }, Colors.PAGE_CONTROL_BORDER);
        handCursor = Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND);
        headId = 0;
    }

	private boolean isEditable() {
		return (style & UserInfoWindow.EDITABLE) != 0;
	}
	
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.ui.config.AbstractPage#createContent(org.eclipse.swt.widgets.Composite)
     */
	@Override
    protected Control createContent(Composite parent) {
        Composite content = new Composite(parent, SWT.NONE);
        content.setBackground(Colors.PAGE_BACKGROUND);
        content.setLayout(new FormLayout());
        
        Composite container = new Composite(content, SWT.NONE);
        FormData fd = new FormData();
        fd.top = fd.left = new FormAttachment(0, 0);
        fd.bottom = new FormAttachment(100, -20);
        fd.right = new FormAttachment(100, -50);
        container.setLayoutData(fd);
        GridLayout layout = new GridLayout(4, false);
        layout.marginHeight = layout.horizontalSpacing = 8;
        layout.verticalSpacing = 14;
        layout.marginWidth = 15;
        container.setLayout(layout);
        container.setBackground(Colors.PAGE_BACKGROUND);
        container.addPaintListener(centerBorderPaintListener);
        container.addPaintListener(aroundBorderPaintListener);
        
        // 设置使用缺省背景色
        UITool.setDefaultBackground(null);
        
        // 用户号码
        UITool.createLabel(container, user_info_basic_qq);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
        gd.widthHint = 155;
        textQQ = UITool.createSingleText(container, gd, SWT.SINGLE | SWT.READ_ONLY);
        textQQ.setBackground(Colors.PAGE_READONLY_CONTROL_BACKGROUND);
        // 头像按钮
        btnFace = new CLabel(container, SWT.CENTER);
        gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING);
        gd.heightHint = gd.widthHint = 48;
        gd.horizontalSpan = 2;
        gd.verticalSpan = 3;
        gd.horizontalIndent = 30;
        btnFace.setLayoutData(gd);
        btnFace.setCursor(handCursor);
        btnFace.addMouseListener(new MouseAdapter() {
			public void mouseUp(MouseEvent e) {
				if(isEditable()) {
					Rectangle bound = btnFace.getBounds();
					bound.height++;					
					openImageSelectionShell(btnFace.getParent().toDisplay(bound.x, bound.y + bound.height));
				}
			}
        });
        // 用户昵称
        UITool.createLabel(container, user_info_basic_nick);
        gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
        gd.widthHint = 155;
        textNick = UITool.createSingleText(container, gd);
        // 性别
        UITool.createLabel(container, user_info_basic_gender);
        gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
        gd.widthHint = 155;
        comboGender = UITool.createCCombo(container, gd, SWT.FLAT);
        comboGender.setTextLimit(6);
		comboGender.add(user_info_basic_gender_male);
		comboGender.add(user_info_basic_gender_female);
		comboGender.add(user_info_basic_gender_ladyman);
		comboGender.add(user_info_basic_gender_both);
		comboGender.add(user_info_basic_gender_null);
		comboGender.setVisibleItemCount(5);
		// 个性签名
		gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
		UITool.createLabel(container, user_info_basic_signature, gd);
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 3;
		gd.heightHint = 40;
		textSignature = UITool.createMultiText(container, gd, SWT.MULTI | SWT.WRAP);
		textSignature.setTextLimit(100);
		// 等级
		UITool.createLabel(container, user_info_basic_level);
		levelBar = new LevelBar(container);
		levelBar.setBackground(container.getBackground());
		gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);
		gd.horizontalSpan = 3;
		gd.heightHint = 16;
		levelBar.setLayoutData(gd);
		levelBar.setGlyphDeepth(3);
		levelBar.setGlyphWeights(new int[] { 16, 4, 1});
		levelBar.setGlyphs(new Image[] { 
				Resources.getInstance().getImage(Resources.icoSun),
				Resources.getInstance().getImage(Resources.icoMoon),
				Resources.getInstance().getImage(Resources.icoStar)
		});
        // 真实姓名
        UITool.createLabel(container, user_info_basic_name);
        gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -