Home » Eclipse Projects » Remote Application Platform (RAP) » rap calendar(problem in creating calender in rap application)
rap calendar [message #657824] |
Fri, 04 March 2011 09:01 |
marie Missing name Messages: 63 Registered: March 2011 |
Member |
|
|
hi all,
I am facing a problem in creating calender dialog in rap application.
i have wriiten the code n getting compliation error
private void onPaint(PaintEvent event) {
Rectangle rect = getClientArea();
GC gc0 = event.gc;
Image image = new Image(m_Display, rect.width, rect.height); GC gc = new GC(image);
gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
gc.fillRectangle(rect);
int x = 0;
int y = 0;
for (int i = 0; i < 7; i++) {
if (i == 0)
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
else
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
String text = getDayName(i);
Point size = gc.stringExtent(text);
gc.drawText(text, x + (m_ColSize-size.x)/2, (m_RowSize-size.y)/2, true);
x += m_ColSize;
}
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
y += m_RowSize;
gc.drawLine(0, 0, rect.width, 0);
gc.drawLine(0, y - 1, rect.width, y - 1);
//
m_Calendar.set(Calendar.YEAR, m_Year);
m_Calendar.set(Calendar.MONTH, m_Month);
int day = 1;
while (true) {
m_Calendar.set(Calendar.DAY_OF_MONTH, day);
if (m_Calendar.get(Calendar.MONTH) != m_Month)
break;
int day_of_week = calendarDayToNormal(m_Calendar.get(Calendar.DAY_OF_WEEK));
Point p = getDayPoint(day);
if (day == m_Day) {
//gc.setForeground(m_Display.getSystemColor(SWT.COLOR_LIST_S ELECTION_TEXT));
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLUE));
gc.setBackground(m_Display.getSystemColor(SWT.COLOR_LIST_SEL ECTION));
}
else {
gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
if (day_of_week == 0)
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
else
gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
}
String text = ""+day;
Point size = gc.stringExtent(text);
gc.drawText(text, p.x + ((m_ColSize-size.x)/2), p.y + ((m_RowSize-size.y)/2), true);
day++;
}
gc0.drawImage(image, 0, 0);
gc.dispose();
image.dispose();
please help me to sovle this problem.
thanks in advance
|
|
|
Re: rap calendar [message #657840 is a reply to message #657824] |
Fri, 04 March 2011 09:44 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
currently, GC drawing is only supported on Canvas, but not on image -
see bug:
318900: Image class doesn't implement Drawable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=318900
If you want to create a Calandar, you can use DateTime widget with
SWT.CALENDAR style flag or SWT.DATE | SWT.DROP_DOWN.
HTH,
Ivan
On 3/4/2011 11:01 AM, mamta wrote:
> hi all,
> I am facing a problem in creating calender dialog in rap application.
> i have wriiten the code n getting compliation error
> private void onPaint(PaintEvent event) {
> Rectangle rect = getClientArea();
> GC gc0 = event.gc;
> Image image = new Image(m_Display, rect.width,
> rect.height); GC gc = new GC(image);
>
>
>
> gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
> gc.fillRectangle(rect);
> int x = 0;
> int y = 0;
> for (int i = 0; i < 7; i++) {
> if (i == 0)
>
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
> else
>
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
>
>
> String text = getDayName(i);
> Point size = gc.stringExtent(text);
> gc.drawText(text, x + (m_ColSize-size.x)/2,
> (m_RowSize-size.y)/2, true);
> x += m_ColSize;
>
>
> }
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
> y += m_RowSize;
> gc.drawLine(0, 0, rect.width, 0);
> gc.drawLine(0, y - 1, rect.width, y - 1);
> //
>
>
> m_Calendar.set(Calendar.YEAR, m_Year);
> m_Calendar.set(Calendar.MONTH, m_Month);
> int day = 1;
> while (true) {
> m_Calendar.set(Calendar.DAY_OF_MONTH, day);
> if (m_Calendar.get(Calendar.MONTH) != m_Month)
>
> break;
> int day_of_week =
> calendarDayToNormal(m_Calendar.get(Calendar.DAY_OF_WEEK));
> Point p = getDayPoint(day);
> if (day == m_Day) {
>
> //gc.setForeground(m_Display.getSystemColor(SWT.COLOR_LIST_S
> ELECTION_TEXT));
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLUE));
>
>
> gc.setBackground(m_Display.getSystemColor(SWT.COLOR_LIST_SEL ECTION));
> }
> else {
> gc.setBackground(m_Display.getSystemColor(SWT.COLOR_WIDGET_B ACKGROUND));
> if (day_of_week == 0)
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_RED));
>
> else
> gc.setForeground(m_Display.getSystemColor(SWT.COLOR_BLACK));
> }
> String text = ""+day;
> Point size = gc.stringExtent(text);
> gc.drawText(text, p.x + ((m_ColSize-size.x)/2), p.y +
> ((m_RowSize-size.y)/2), true);
>
>
> day++;
> }
> gc0.drawImage(image, 0, 0);
> gc.dispose();
> image.dispose();
>
> please help me to sovle this problem.
> thanks in advance
|
|
| | |
Goto Forum:
Current Time: Fri Apr 19 23:18:09 GMT 2024
Powered by FUDForum. Page generated in 0.03288 seconds
|