KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > helloworld > renderer > HwListRenderer


1 /*******************************************************************************
2  * Copyright (c) 2004, Dirk von der Weiden.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * Dirk von der Weiden - initial API and implementation
10  *
11  * Created on 21.02.2005
12  *
13  * date: 21.02.2005
14  * project: WiSer-HelloWorld
15  *
16  * *******************************************************************************/

17
18 package helloworld.renderer;
19
20 import java.awt.*;
21
22 import Jmc.commonGui.*;
23 import Jmc.commonGui.loader.*;
24 import Jmc.baseGui.gui_fixedSize;
25 import Jmc.baseTools.*;
26
27 /**
28  * @author Dirk
29  *
30  * date: 21.02.2005
31  *
32  * <p>
33  * Purpose: This example shows how the render mechanism of the WidgetServer framework
34  * works.
35  * </p>
36  */

37 public class HwListRenderer implements base_listItemRenderer_if
38 {
39
40     /**
41          * <p>
42          * Renderes a list item
43          * </p><p>
44          *
45          * @return rendered widget
46          * </p><p>
47      * @param xToRender object wich has to be rendered
48      * @param xIdx index within the list-model
49      * @param xSelect selection state within the view
50          * </p>
51          */

52     public base_guiWidget_if pcmf_getRenderWidget(Object JavaDoc xToRender, int xIdx, boolean xSelected, base_listWidget_if xList)
53     {
54     // get all widgets from the registry
55
base_appl_if l_appl = (base_appl_if)base_registredObject.pcmf_getObjByName(base_appl_if.MY_APPL);
56     base_image_if l_img2 = (base_image_if)base_registredObject.pcmf_getObjByName("entry_icon");
57
58     // Create a text widget
59
base_text_if l_text = l_appl.pcmf_getGuiObjFactory().pcmf_createText(l_appl.pcmf_getApplType(), xToRender.toString(), Integer.toString(xIdx) + ". " + xToRender.toString(), l_appl);
60     
61     // Set some properties
62
l_text.pcmf_setFont(new base_fontDesc("ARIAL", 15, Font.BOLD));
63     l_text.pcmf_setFixedSize(150, 20, gui_fixedSize.FIX_SIZE);
64     l_text.pcmf_setIcon(l_img2);
65     if (xIdx % 2 == 0)
66       l_text.pcmf_setBgColor("#FFA000");
67     else
68       l_text.pcmf_setBgColor("#A0A000");
69     
70     // Render always
71
l_text.pcmf_setRenderIfHidden(true);
72     
73     return (l_text);
74     }
75 }
76
Popular Tags