Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 37
Registered: ‎09-15-2009
My Device: Not Specified
Accepted Solution

Custom ObjectChoiseField

Hi everyone.

 

Well, I have a problem. I've to create screen with "unusual" design controls - buttons, text edits etc.

 

So, I've already create all controls except one. I could not create a custom drop-down list. I  don't know how could I draw a dropped list - this is a real problem for me. Do I have to draw some modal screen for this or something like this? How it could be drawn? Maybe it is possible to "redraw" the ObjectChoiceield design?

 

So, this is a problem. Could anyone help me?

 

Thanks. 

Developer
Posts: 43
Registered: ‎09-28-2009
My Device: Not Specified

Re: Custom ObjectChoiseField

Hi magfed,

 

I find the easiest way to accomplish this is to have the default RIM ObjectChoiceField do all the work for you, the secret is to call  super.pain() in the public void paint(Graphics g) method of your inherited field. This way, when you click on the CustomObjectChoiceField you will receive the popup display of the values.

 

So,

 

1. class CustomObjectChoiceField extends ObjectChoiceField

2. 

public void paint(Graphics g) { super.paint(g); g.clear(); //do custom code/drawing here }

 

This will give you a custom ObjectChoiceField while maintaining the functionality of the popup list.

 

Hope this is what you are looking for.

 

Regards

 

 

Developer
Posts: 37
Registered: ‎09-15-2009
My Device: Not Specified

Re: Custom ObjectChoiseField

Thank you, I've made my own ObjectChoiceField (the same as you describe above).

 

If anyone need I can upload the code. 

Developer
Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified

Re: Custom ObjectChoiseField

Hi..

 

plzz upload the code for it..it will be really helpful..

 

thanx in advance..

Developer
Posts: 37
Registered: ‎09-15-2009
My Device: Not Specified

Re: Custom ObjectChoiseField

Ok

 

 

import net.rim.device.api.ui.component.ObjectChoiceField;import net.rim.device.api.ui.Graphics;import java.lang.String;import net.rim.device.api.ui.XYRect;import net.rim.device.api.ui.Font;public class CMyChoiceField extends ObjectChoiceField { /** Constants for the horizontal text alignment */ public static final int TEXT_HALINGMENT_LEFT = 0; public static final int TEXT_HALINGMENT_CENTER = 1; /** Array of choices */ String[] m_Choices; /** Left margin of the field */ private int m_MarginLeft = 1; /** Right margin of the field */ private int m_MarginRight = 1; /** Top margin of the field */ private int m_MarginTop = 1; /** Top margin of the field */ private int m_MarginBottom = 1; /** Right margin of the text in the selectbox */ private int m_TextMarginRight = 5; /** Left margin of the text in the selectbox */ private int m_TextMarginLeft = 5; /** Horizonta text alingment */ private int m_HTextAlignment = TEXT_HALINGMENT_CENTER; /** Width of the chpice box */ private int m_ChoiceFieldWidth; /** Height of the field */ private int m_Height; /** Determones is field focused */ private boolean m_isFocused = false; /** Width of thr DropDown arrow */ private int m_DropDownArrowWidth; /** Field default color */ private int m_DefBgColor = 0xffffff; /** Field text default color */ private int m_DefTextColor = 0; /** Field color when it is focused */ private int m_FocusedBgColor = 0xf6921e; /** Field text color when it is focused */ private int m_FocusedTextColor = 0; /** * Constructor. The width of choice box became as big as * maximum length of choice strings + text marfins + derop-down arrow width. * * @param String - label of the field * @param String[] - field choices */ public CMyChoiceField(String label, String[] choices) { super(label, choices); m_Choices = choices; //dimensions of selectable field Font currFont = getFont(); m_DropDownArrowWidth = m_Height = currFont.getHeight(); m_ChoiceFieldWidth = currFont.getAdvance(choices[0]); for(int i = 1; i < choices.length; i++){ if(m_ChoiceFieldWidth < currFont.getAdvance(choices[i])) m_ChoiceFieldWidth = currFont.getAdvance(choices[i]); } m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight + m_DropDownArrowWidth; } /** * Constructor. The width of choice box became as big as * maximum length of choice strings + text marfins + derop-down arrow width. * * @param String - label of the field * @param String[] - field choices * @param int - initial choice index */ public CMyChoiceField(String label, String[] choices, int initialIndex) { super(label, choices, initialIndex); m_Choices = choices; //dimensions of selectable field Font currFont = getFont(); m_DropDownArrowWidth = m_Height = currFont.getHeight(); m_ChoiceFieldWidth = currFont.getAdvance(choices[0]); for(int i = 1; i < choices.length; i++){ if(m_ChoiceFieldWidth < currFont.getAdvance(choices[i])) m_ChoiceFieldWidth = currFont.getAdvance(choices[i]); } m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight + m_DropDownArrowWidth; } /** * Constructor. The width of choice box became as big as * maximum length of choice strings + text marfins + derop-down arrow width. * * @param String - label of the field * @param String[] - field choices * @param int - initial choice index * @param long - field style(see ObjectChoiceField styles) */ public CMyChoiceField(String label, String[] choices, int initialIndex, long style) { super(label, choices, initialIndex, style); m_Choices = choices; //dimensions of selectable field Font currFont = getFont(); m_DropDownArrowWidth = m_Height = currFont.getHeight(); m_ChoiceFieldWidth = currFont.getAdvance(choices[0]); for(int i = 1; i < choices.length; i++){ if(m_ChoiceFieldWidth < currFont.getAdvance(choices[i])) m_ChoiceFieldWidth = currFont.getAdvance(choices[i]); } m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight + m_DropDownArrowWidth; } /** * Set field choices * * @param String[] - array of field choices */ public void setChoices(Object[] choices){ super.setChoices(choices); m_Choices = (String[])choices; } /** * Set field margins. This method takes an effect for * parameter to be >= 0. * * @param int - left margin of the field * @param int - right margin of the field * @param int - top margin of the field * @param int - bottom margin of the field */ public void setMargins(int marginLeft, int marginRight, int marginTop, int marginBottom){ if(marginLeft >= 0) this.m_MarginLeft = marginLeft; if(marginRight >= 0) this.m_MarginRight = marginRight; if(marginTop >= 0) this.m_MarginTop = marginTop; if(marginBottom >= 0) this.m_MarginBottom = marginBottom; } /** * Set horizontal text alignment in the text box. * * @param int - alignment of the text */ public void setTextHAlignment(int alignment){ m_HTextAlignment = alignment; } /** * Set choice box width. * * @param int - choice box width. */ public void setChoiceWidth(int width){ m_ChoiceFieldWidth = width; } /** * Set text font. * * @param int - font style (see Font class) * @param int - font height * @param boolean - if true control height updates according to the new font height. */ public void setTextFont(int style, int height, boolean updateHeight){ this.setFont(getFont().derive(style, height)); if(updateHeight) m_DropDownArrowWidth = m_Height = getFont().getHeight(); } /** * Method retrieves this field's preferred width. * * @return int - field's preferred width */ public int getPreferredWidth(){ return m_MarginLeft + m_MarginRight + m_ChoiceFieldWidth + getFont().getAdvance(getLabel()); } /** * Method retrieves this field's preferred height. * * @return int - field's preferred height */ public int getPreferredHeight(){ return m_MarginTop + m_MarginBottom + m_Height; } /** * Determines if this field accepts the focus. * * @return boolean - always true. */ public boolean isFocusable(){ return true; } /** * Retrieves this field's current focus region. * * @param XYRect - object to contain the focus rect for this field in local coordinates */ public void getFocusRect(XYRect rect){ rect.set(m_MarginLeft + getFont().getAdvance(getLabel()), m_MarginTop, m_ChoiceFieldWidth, m_Height); } /** * Draws the focus indicator for this field * * @param Graphics - graphics context for drawing the focus * @param boolean - true if the focus should be set; otherwise, false. */ protected void drawFocus(Graphics graphics, boolean on){ invalidate(); } /** * Lays out field contents. * * @param int - amount of available horizontal space. * @param int - amount of available vertical space. */ protected void layout(int width, int height){ setExtent(Math.min(getPreferredWidth(), width), Math.min(getPreferredHeight(), height)); } /** * Invoked when a field receives the focus. * * @param int - Indicates from which direction the focus enters the field. */ public void onFocus(int direction){ m_isFocused = true; invalidate(); } /** * Invoked when a field loses the focus. */ public void onUnfocus(){ m_isFocused = false; invalidate(); } /** * Method draws a edit field. * * @param Graphics - graphic context. */ public void paint(Graphics g){ //needed variables String visibleText = (getSelectedIndex() == -1 || getSelectedIndex() >= m_Choices.length)?"":m_Choices[getSelectedIndex()]; int textLength = getFont().getAdvance(visibleText); int labelLength = getFont().getAdvance(getLabel()); int textY = m_MarginTop + (m_Height - getFont().getHeight())/2; if(textY < 0) textY = m_MarginTop; //Text can be as big as text box field while(textLength > m_ChoiceFieldWidth - m_TextMarginLeft - m_TextMarginRight - m_DropDownArrowWidth && visibleText.length() > 0){ visibleText = visibleText.substring(0, visibleText.length()-1); textLength = getFont().getAdvance(visibleText); } int textX = (m_HTextAlignment == TEXT_HALINGMENT_CENTER)? m_MarginLeft + labelLength + m_TextMarginLeft + (m_ChoiceFieldWidth - m_TextMarginLeft - m_TextMarginRight - m_DropDownArrowWidth - textLength)/2: m_MarginLeft + labelLength + m_TextMarginLeft; if(textX < 0) textX = m_MarginLeft + labelLength + m_TextMarginLeft; //draw a lable g.setColor(0); g.drawText(getLabel(), m_MarginLeft, textY); if(m_isFocused == false){ //Draw edit box bg g.setColor(m_DefBgColor); g.fillRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); //Draw edit box rect g.setColor(0); g.drawRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); //Draw edit box text g.setColor(m_DefTextColor); g.drawText(visibleText, textX, textY); //g.drawText(Integer.toString(cursorPosition), m_MarginLeft + labelLength + m_TextMarginLeft, textY); } else { //Draw edit box bg g.setColor(m_FocusedBgColor); g.fillRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); //Draw edit box rect g.setColor(0); g.drawRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); //Draw edit box text g.setColor(m_FocusedTextColor); g.drawText(visibleText, textX, textY); } //draw DropDown arrow int ddaLeft = m_MarginLeft + labelLength + m_ChoiceFieldWidth - m_DropDownArrowWidth; //fill arrow g.setColor(0xc6d4e9); g.fillRect(ddaLeft, m_MarginTop, m_DropDownArrowWidth, m_Height / 2); int leftPoint = ddaLeft, rightPoint = ddaLeft + m_DropDownArrowWidth - 1, height = m_MarginTop + m_Height / 2; int bottom = m_MarginTop + m_Height - 1; for(; height < bottom; height++, leftPoint++, rightPoint--) g.drawLine(leftPoint, height, rightPoint, height); //outer line g.setColor(0); g.drawLine(ddaLeft, m_MarginTop, ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop); g.drawLine(ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop, ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop + m_Height / 2); g.drawLine(ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop + m_Height / 2, ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 1); g.drawLine(ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 1, ddaLeft, m_MarginTop + m_Height / 2); g.drawLine(ddaLeft, m_MarginTop + m_Height / 2, ddaLeft, m_MarginTop); //inner line g.drawLine(ddaLeft + 1, m_MarginTop + 1, ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + 1); g.drawLine(ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + 1, ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + m_Height / 2); g.drawLine(ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + m_Height / 2, ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 2); g.drawLine(ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 2, ddaLeft + 1, m_MarginTop + m_Height / 2); g.drawLine(ddaLeft + 1, m_MarginTop + m_Height / 2, ddaLeft + 1, m_MarginTop + 1); }};

 

 than

 

 

String[] choices = {"New York", "Los Angeles", "My own city"};CMyChoiceField myField = new CMyChoiceField("Cities: ", choices);

 

 

 

 

Developer
Posts: 37
Registered: ‎09-15-2009
My Device: Not Specified

Re: Custom ObjectChoiseField

well, I don't know why this code is so unreadable. Sorry, it is not my fault - my newlines just disapear.
BlackBerry Development Advisor
Posts: 15,083
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Custom ObjectChoiseField

If you run the spell checker after adding your code it can do this.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 13
Registered: ‎08-27-2008
My Device: Not Specified

Re: Custom ObjectChoiseField

Hi ,

I have one issue regarding Blackberry storm.

I have one object choice field that contains lists of item.

.With the items in the drop down box so close together it is very difficult to select an item.

So how will i resolve this problem .Is it possible to reduce or increase the height of item or increase space

between the items but how it can be done so that the confusion avoids by the touch screen user.

 

I had customItem object choice field it will draw a dropdown box but who will handle event in dropdown box o get llist

so that i can increase or descrease hieght or space between items.

 

 

Thanks regards

Vilas Talewale

New Developer
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800
My Carrier: Vodafone

Re: Custom ObjectChoiseField

Nice Work :Balloon:

 

I have made the visibility of the code more clear please find it......But the credit goes to magfed....

package com.emx.forex.components;

import net.rim.device.api.ui.component.ObjectChoiceField;
import net.rim.device.api.ui.Graphics;
import java.lang.String;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.Font;

public class CMyChoiceField extends ObjectChoiceField
{
	/** Constants for the horizontal text alignment */
	public static final int TEXT_HALINGMENT_LEFT = 0;
	public static final int TEXT_HALINGMENT_CENTER = 1;
	/** Array of choices */
	String[] m_Choices;
	/** Left margin of the field */
	private int m_MarginLeft = 1;
	/** Right margin of the field */
	private int m_MarginRight = 1;
	/** Top margin of the field */
	private int m_MarginTop = 1;
	/** Top margin of the field */
	private int m_MarginBottom = 1;
	/** Right margin of the text in the selectbox */
	private int m_TextMarginRight = 5;
	/** Left margin of the text in the selectbox */
	private int m_TextMarginLeft = 5;
	/** Horizonta text alingment */
	private int m_HTextAlignment = TEXT_HALINGMENT_CENTER;
	/** Width of the chpice box */
	private int m_ChoiceFieldWidth;
	/** Height of the field */
	private int m_Height;
	/** Determones is field focused */
	private boolean m_isFocused = false;
	/** Width of thr DropDown arrow */
	private int m_DropDownArrowWidth;
	/** Field default color */
	private int m_DefBgColor = 0xffffff;
	/** Field text default color */
	private int m_DefTextColor = 0;
	/** Field color when it is focused */
	private int m_FocusedBgColor = 0xf6921e;
	/** Field text color when it is focused */
	private int m_FocusedTextColor = 0;

	/** * Constructor. The width of choice box became as big as * maximum length of choice strings + text marfins + derop-down arrow width. * * @param String - label of the field * @param String[] - field choices */
	public CMyChoiceField(String label, String[] choices)
	{
		super(label, choices);
		m_Choices = choices;
		// dimensions of selectable field
		Font currFont = getFont();
		m_DropDownArrowWidth = m_Height = currFont.getHeight();
		m_ChoiceFieldWidth = currFont.getAdvance(choices[0]);
		for (int i = 1; i < choices.length; i++)
		{
			if (m_ChoiceFieldWidth < currFont.getAdvance(choices[i]))
				m_ChoiceFieldWidth = currFont.getAdvance(choices[i]);
		}
		m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight + m_DropDownArrowWidth;
	}

	/** * Constructor. The width of choice box became as big as * maximum length of choice strings + text marfins + derop-down arrow width. * * @param String - label of the field * @param String[] - field choices * @param int - initial choice index */
	public CMyChoiceField(String label, String[] choices, int initialIndex)
	{
		super(label, choices, initialIndex);
		m_Choices = choices; // dimensions of selectable field
		Font currFont = getFont();
		m_DropDownArrowWidth = m_Height = currFont.getHeight();
		m_ChoiceFieldWidth = currFont.getAdvance(choices[0]);
		for (int i = 1; i < choices.length; i++)
		{
			if (m_ChoiceFieldWidth < currFont.getAdvance(choices[i]))
				m_ChoiceFieldWidth = currFont.getAdvance(choices[i]);
		}
		m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight + m_DropDownArrowWidth;
	}

	/**
	 * * Constructor. The width of choice box became as big as * maximum length of choice strings + text marfins + derop-down arrow width. * * @param String - label of the field * @param String[] - field choices * @param int - initial choice index * @param long - field style(see
	 * ObjectChoiceField styles)
	 */
	public CMyChoiceField(String label, String[] choices, int initialIndex, long style)
	{
		super(label, choices, initialIndex, style);
		m_Choices = choices; // dimensions of selectable field
		Font currFont = getFont();
		m_DropDownArrowWidth = m_Height = currFont.getHeight();
		m_ChoiceFieldWidth = currFont.getAdvance(choices[0]);
		for (int i = 1; i < choices.length; i++)
		{
			if (m_ChoiceFieldWidth < currFont.getAdvance(choices[i]))
				m_ChoiceFieldWidth = currFont.getAdvance(choices[i]);
		}
		m_ChoiceFieldWidth += m_TextMarginLeft + m_TextMarginRight + m_DropDownArrowWidth;
	}

	/** * Set field choices * * @param String[] - array of field choices */
	public void setChoices(Object[] choices)
	{
		super.setChoices(choices);
		m_Choices = (String[]) choices;
	}

	/** * Set field margins. This method takes an effect for * parameter to be >= 0. * * @param int - left margin of the field * @param int - right margin of the field * @param int - top margin of the field * @param int - bottom margin of the field */
	public void setMargins(int marginLeft, int marginRight, int marginTop, int marginBottom)
	{
		if (marginLeft >= 0)
			this.m_MarginLeft = marginLeft;
		if (marginRight >= 0)
			this.m_MarginRight = marginRight;
		if (marginTop >= 0)
			this.m_MarginTop = marginTop;
		if (marginBottom >= 0)
			this.m_MarginBottom = marginBottom;
	}

	/** * Set horizontal text alignment in the text box. * * @param int - alignment of the text */
	public void setTextHAlignment(int alignment)
	{
		m_HTextAlignment = alignment;
	}

	/** * Set choice box width. * * @param int - choice box width. */
	public void setChoiceWidth(int width)
	{
		m_ChoiceFieldWidth = width;
	}

	/** * Set text font. * * @param int - font style (see Font class) * @param int - font height * @param boolean - if true control height updates according to the new font height. */
	public void setTextFont(int style, int height, boolean updateHeight)
	{
		this.setFont(getFont().derive(style, height));
		if (updateHeight)
			m_DropDownArrowWidth = m_Height = getFont().getHeight();
	}

	/** * Method retrieves this field's preferred width. * * @return int - field's preferred width */
	public int getPreferredWidth()
	{
		return m_MarginLeft + m_MarginRight + m_ChoiceFieldWidth + getFont().getAdvance(getLabel());
	}

	/** * Method retrieves this field's preferred height. * * @return int - field's preferred height */
	public int getPreferredHeight()
	{
		return m_MarginTop + m_MarginBottom + m_Height;
	}

	/** * Determines if this field accepts the focus. * * @return boolean - always true. */
	public boolean isFocusable()
	{
		return true;
	}

	/** * Retrieves this field's current focus region. * * @param XYRect - object to contain the focus rect for this field in local coordinates */
	public void getFocusRect(XYRect rect)
	{
		rect.set(m_MarginLeft + getFont().getAdvance(getLabel()), m_MarginTop, m_ChoiceFieldWidth, m_Height);
	}

	/** * Draws the focus indicator for this field * * @param Graphics - graphics context for drawing the focus * @param boolean - true if the focus should be set; otherwise, false. */
	protected void drawFocus(Graphics graphics, boolean on)
	{
		invalidate();
	}

	/** * Lays out field contents. * * @param int - amount of available horizontal space. * @param int - amount of available vertical space. */
	protected void layout(int width, int height)
	{
		setExtent(Math.min(getPreferredWidth(), width), Math.min(getPreferredHeight(), height));
	}

	/** * Invoked when a field receives the focus. * * @param int - Indicates from which direction the focus enters the field. */
	public void onFocus(int direction)
	{
		m_isFocused = true;
		invalidate();
	}

	/** * Invoked when a field loses the focus. */
	public void onUnfocus()
	{
		m_isFocused = false;
		invalidate();
	}

	/** * Method draws a edit field. * * @param Graphics - graphic context. */
	public void paint(Graphics g)
	{ // needed variables
		String visibleText = (getSelectedIndex() == -1 || getSelectedIndex() >= m_Choices.length) ? "" : m_Choices[getSelectedIndex()];
		int textLength = getFont().getAdvance(visibleText);
		int labelLength = getFont().getAdvance(getLabel());
		int textY = m_MarginTop + (m_Height - getFont().getHeight()) / 2;
		if (textY < 0)
			textY = m_MarginTop; // Text can be as big as text box field
		while (textLength > m_ChoiceFieldWidth - m_TextMarginLeft - m_TextMarginRight - m_DropDownArrowWidth && visibleText.length() > 0)
		{
			visibleText = visibleText.substring(0, visibleText.length() - 1);
			textLength = getFont().getAdvance(visibleText);
		}
		int textX = (m_HTextAlignment == TEXT_HALINGMENT_CENTER) ? m_MarginLeft + labelLength + m_TextMarginLeft + (m_ChoiceFieldWidth - m_TextMarginLeft - m_TextMarginRight - m_DropDownArrowWidth - textLength) / 2 : m_MarginLeft + labelLength + m_TextMarginLeft;
		if (textX < 0)
			textX = m_MarginLeft + labelLength + m_TextMarginLeft; // draw a lable
		g.setColor(0);
		g.drawText(getLabel(), m_MarginLeft, textY);
		if (m_isFocused == false)
		{ // Draw edit box b
			g.setColor(m_DefBgColor);
			g.fillRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); // Draw edit box rect
			g.setColor(0);
			g.drawRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); // Draw edit box text
			g.setColor(m_DefTextColor);
			g.drawText(visibleText, textX, textY); // g.drawText(Integer.toString(cursorPosition), m_MarginLeft + labelLength + m_TextMarginLeft, textY);
		}
		else
		{ // Draw edit box bg
			g.setColor(m_FocusedBgColor);
			g.fillRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); // Draw edit box rect
			g.setColor(0);
			g.drawRect(m_MarginLeft + labelLength, m_MarginTop, m_ChoiceFieldWidth, m_Height); // Draw edit box text
			g.setColor(m_FocusedTextColor);
			g.drawText(visibleText, textX, textY);
		} // draw DropDown arrow
		int ddaLeft = m_MarginLeft + labelLength + m_ChoiceFieldWidth - m_DropDownArrowWidth; // fill arrow
		g.setColor(0xc6d4e9);
		g.fillRect(ddaLeft, m_MarginTop, m_DropDownArrowWidth, m_Height / 2);
		int leftPoint = ddaLeft, rightPoint = ddaLeft + m_DropDownArrowWidth - 1, height = m_MarginTop + m_Height / 2;
		int bottom = m_MarginTop + m_Height - 1;
		for (; height < bottom; height++, leftPoint++, rightPoint--)
			g.drawLine(leftPoint, height, rightPoint, height); // outer line
		g.setColor(0);
		g.drawLine(ddaLeft, m_MarginTop, ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop);
		g.drawLine(ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop, ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop + m_Height / 2);
		g.drawLine(ddaLeft + m_DropDownArrowWidth - 1, m_MarginTop + m_Height / 2, ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 1);
		g.drawLine(ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 1, ddaLeft, m_MarginTop + m_Height / 2);
		g.drawLine(ddaLeft, m_MarginTop + m_Height / 2, ddaLeft, m_MarginTop); // inner line
		g.drawLine(ddaLeft + 1, m_MarginTop + 1, ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + 1);
		g.drawLine(ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + 1, ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + m_Height / 2);
		g.drawLine(ddaLeft + m_DropDownArrowWidth - 2, m_MarginTop + m_Height / 2, ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 2);
		g.drawLine(ddaLeft + m_DropDownArrowWidth / 2, m_MarginTop + m_Height - 2, ddaLeft + 1, m_MarginTop + m_Height / 2);
		g.drawLine(ddaLeft + 1, m_MarginTop + m_Height / 2, ddaLeft + 1, m_MarginTop + 1);
	};
}

 

Amar
Developer
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Custom ObjectChoiseField

 

If any one want I can provide custom choice field.

 ===========================================================================

feel free to press the like button on the right side to thank the user that helped you.

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.