Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 54404 Details for
Bug 165640
[painting] GC.drawString draws 1 pixel too high compared to StyledText
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
SWT snippet showing the bug
Bug_165640.java (text/plain), 2.09 KB, created by
Dani Megert
on 2006-11-23 05:49:35 EST
(
hide
)
Description:
SWT snippet showing the bug
Filename:
MIME Type:
Creator:
Dani Megert
Created:
2006-11-23 05:49:35 EST
Size:
2.09 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2000, 2006 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * IBM Corporation - initial API and implementation > ******************************************************************************/ >package org.eclipse.swt.snippets; > >import org.eclipse.swt.SWT; >import org.eclipse.swt.custom.StyledText; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.graphics.Font; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Shell; > >public class Bug_165640 { > > private static String TEXT= "This demonstrates drawing a string which is too high: XXX .\n"; //$NON-NLS-1$ > > private static String SEARCH_STRING= "XXX"; //$NON-NLS-1$ > > public static void main(String[] args) { > final Display display= new Display(); > final Color RED= display.getSystemColor(SWT.COLOR_RED); > > Shell shell= new Shell(display); > shell.setLayout(new FillLayout()); > > final StyledText text= new StyledText(shell, SWT.NONE); > Font font= new Font(shell.getDisplay(), "Courier New", 10, SWT.NORMAL); //$NON-NLS-1$ > text.setFont(font); > text.setText(TEXT); > > // The painter > text.addListener(SWT.Paint, new Listener() { > > public void handleEvent(Event event) { > String contents= text.getText(); > event.gc.setForeground(RED); > int index= contents.indexOf(SEARCH_STRING) + 3; > Point topLeft= text.getLocationAtOffset(index); > event.gc.drawString(SEARCH_STRING, topLeft.x, topLeft.y, true); > } > }); > > shell.pack(); > shell.open(); > > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > > display.dispose(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 165640
: 54404