Next: Boolean, Previous: X11FreeTypeFont, Up: Classes [Index]
X11Bitmap
ClassA X11Bitmap
object is similar to a Bitmap object - it
contains the address of a bitmap in memory. In addition, a
X11Bitmap
object has its own X11 graphics context for
graphics operations.
backgroundColor
A String
that contains the name of a X color. Setting
this variable does not affect the color of a displayed bitmap -
programs should call the X11Bitmap : background
method,
which also sets this variable.
depth
An Integer
that contains the depth of the bitmap.
displayPtr
A Symbol
that contains the address of the connection
to the X server that was returned by a call to XOpenDisplay.
This is generally the address of the main window pane’s displayPtr
instance variable, and in this class, it is expressly set in
the create
method.
height
An Integer
that contains the height of the bitmap.
modal
A Boolean
that helps determine how Ctalk draws graphics on the
X11Bitmap. True for X11Bitmap objects that are displayed in popup
windows, false otherwise.
parentDrawable
An Integer
that contains the window ID of the
bitmap’s parent drawable. Normally this is set by
the create
method, below.
width
An Integer
that contains the width of the bitmap.
xGC
A Symbol
object that contains the address of the X11
graphics context.
xID
The X resource ID of the Pixmap associated with this object.
background
(String
color)
Set the background color of the receiver to color.
Note: When changing foreground and background color,
make sure that an application has is receiving and
processing events, using the openEventStream
method in
class X11Pane
.
Clear the receiver to the background color.
clearRectangle
(Integer
x, Integer
y, Integer
width, Integer
height)
Clear the specified area to the background color.
Copies the contents of srcBitmap to the receiver’s drawing surface. The source dimensions are determined by srcX, srcY, srcWidth, and srcHeight. The method draws the source bitmap’s contents with the source’s upper left-hand corner at destX, destY.
initialize
(void *
displayPtr
, int
parentWindow, int
width, int
height, int
depth)
Create a X11Bitmap object and its graphics data.
delete
(void
)
Delete a pixmap and its graphics data.
drawCircle
(Circle
aCircle, Integer
filled, String
bgColor)
drawCircle
(Circle
aCircle, Pen
aPen, Integer
filled, String
bgColor)
Draw the circle defined by aCircle in the receiver’s paneBuffer.
If filled is true, draws a filled circle. If the aPen
argument is given, draws the circle with the color and the line width
defined by the aPen
, and fills the interior of the circle with
bgColor.
drawFilledRectangle (Rectangle
aRect, Pen
aPen)
Draw a filled rectangle with the dimensions given in aRect, using
the color given by aPen. For other variations on this method
refer to drawRectangle
.
drawLine
(Integer
xStart, Integer
yStart, Integer
xEnd, Integer
yEnd, Pen
aPen)
drawLine
(Line
aLine, Pen
aPen)
Draw a point on the receiver’s drawing surface between the points xStart,yStart and xEnd,yEnd using the color, width, and transparency defined by the argument aPen. See Pen.
If a program uses the two-argument form of the method, aLine is a member of class Line. See Line.
drawPoint
(Integer
x, Integer
y, Pen
aPen)
Draw a point on the receiver’s drawing surface at x,y using the color, width, and transparency defined by the argument aPen. See Pen.
drawFilledRectangle (Rectangle
aRect, Pen
aPen)
drawFilledRectangle (Rectangle
aRect, Pen
aPen,
Integer
fill, Integer
corner_radius)
drawFilledRectangle (Integer
xOrg, Integer
yOrg, Integer
xSize, Integer
ySize, Ineter
fill,
Integer
line_width, String
color,
Integer
corner_radius) Draw a rectangle on the receiver
bitmap. The fill argument, if given, draws a filled rectangle
if the argument is true. If fill is false, use the
pen_width argument to determine the line width. If radius
is non-zero, draw the rectangle with rounded corners with the radius
in pixels given by the argument.
entryIcon (int
iconID)
entryIconEye (void
)
entryIconEyeSlashed (void
)
Draws an eye or slashed eye icon on the receiver bitmap. The bitmap
should already be created with a call to the X11Bitmap : create
method, and should have the dimensions ‘ENTRY_ICON_WIDTH_PX’ by
‘ENTRY_ICON_HEIGHT_PX’. These values are defined in ctalkdefs.h
,
which can be included in programs and classes with the line:
#include <ctalk/ctalkdefs.h>
In the case of the entryIcon
method, the iconID argument
should have one of the following values.
ENTRY_ICON_EYE_NONE ENTRY_ICON_EYE_OK ENTRY_ICON_EYE_SLASHED
These constants are also defined in ctalkdefs.h
.
faceRegular (void
)
faceBold (void
)
faceItalic (void
)
faceBoldItalic (void
)
Selects the typeface of the currently selected font. The font should
have been selected by a previous call to font
, below, which
loads the regular, bold, italic (or oblique), and bold italic flavors
of the selected font if they are available.
font
(String
font_desc)
Set the font of the receiver.
foreground
(String
color)
Set the foreground color of the receiver.
Note: When changing foreground and background color,
make sure that an application has is receiving and
processing events, using the openEventStream
method in
class X11Pane
.
icon
(int
iconID)
iconStop
(void
)
iconCaution
(void
)
iconInfo
(void
)
These methods draw a 64x64 dialog icon on the receiver’s drawing
surface. In the case of the icon
method, the iconID
argument can be one of the following.
ICON_NONE ICON_STOP ICON_CAUTION ICON_INFO
Before calling any of these methods, a program must have created
the pane’s drawing surface with the create
method. It is
also generally necessary to set the pane’s background color to
that of the surrounding window. Here is an example.
myIcon create aPane displayPtr, aPane paneBuffer xID, ICON_WIDTH_PX, ICON_HEIGHT_PX, pPane paneBuffer depth; myIcon background "blue";
Because icons are generally rendered off-screen, the program should
use the parent pane’s display connection, paneBuffer xID,
and
depth. Then the program can use the X11Bitmap : copy
method
to draw the bitmap on the surround pane’s buffer. Here’s another example.
aPane paneBuffer copy myIcon, 0, 0, ICON_WIDTH_PX, ICON_HEIGHT_PX, iconLeftOrigin, iconTopOrigin;
The constants ICON_WIDTH_PX
and ICON_HEIGHT_PX
are defined
in ctalkdefs.h
, so programs and classes that use icons should
add this line near the top of the source module.
#include <ctalk/ctalkdefs.h>
putStr
(Integer
x, Integer
y, String
text)
putStr
(Integer
x, Integer
y, String
text, String
font_desc)
putStr
(Integer
x, Integer
y, String
text, String
font_desc, String
colorName)
Print text on the receiver’s drawable X resource, at x,y.
If font_desc, (which is either a X Logical Font Descriptor if using X bitmap fonts or a Fontconfig descriptor if using Freetype fonts), is given, use that font to display the text.
For information about Fontconfig descriptors, refer to the
X11FreeTypeFont
section See X11FreeTypeFont. For
information about X Logical Font Descriptors, refer to the
X11Font
section See X11Font.
If colorName is also given, render the text using that color.
pixmapFromData
(int
x_org, int
y_org, char *
xpm_data[])
Draw the X pixmap defined by xpm_data with the upper left corner at x_org,y_org on the receiver’s pane buffer.
The xpm_data argument is the name of the array declared at the
start of a xpm
file’s data array.
In Ctalk’s standard libraries, the image will appear on a
X11CanvasPane
object, and programs can use the
pixmapFromData
method in X11CanvasPane
instead of calling
this method directly. See X11CanvasPane_pixmapFromData.
resize
(Integer
parentVisual, Integer
new_width, Integer
new_height)
Resize the receiver Pixmap. This method is normally called by an
event handler in a parent class (typically, that’s a
X11CanvasPane
). If you need to resize a graphics pane’s buffers,
then the program should also call subPaneNotify
(class X11Pane
),
which invokes the handler for a RESIZENOTIFY
event.
Here is the X11CanvasPane
classes’ RESIZENOTIFY
event handler.
X11CanvasPane instanceMethod subPaneResize (Object __subPane, InputEvent __event) { "Resize the receiver pane. This is the resize event handler called by the parent window's pane dispatcher." if (__ctalkX11ResizeWindow (__subPane, __event xEventData3, __event xEventData4, __subPane depth) > 0) { /* refreshReframe uses viewWidth and viewHeight, refresh uses size x and size y */ __subPane viewWidth = __event xEventData3; __subPane viewHeight = __event xEventData4; __subPane size x = __event xEventData3; __subPane size y = __event xEventData4; (X11Bitmap *)self paneBuffer resize self xWindowID, __event xEventData3, __event xEventData4; (X11Bitmap *)self paneBackingStore resize self xWindowID, __event xEventData3, __event xEventData4; } return NULL; }
For an example of how a program can handle RESIZENOTIFY
events,
refer to the examples in the X11CanvasPane
section.
See X11CanvasPane.
xpmInfoFromData
(char **
xpm_data, Array
dataReturn)
Fills in the Array
dataReturn with the information from the
X pixmap data referred to by xpm_data: [width, height, colors, characters_per_color];
xpmCharsPerColorFromData
(char **
xpm_data)
Returns an Integer
with the number characters per color in the
X pixmap referred to by xpm_data.
xpmColorsFromData
(char **
xpm_data)
Returns an Integer
with the number of colors in the X pixmap referred to
by xpm_data.
xpmHeightFromData
(char **
xpm_data)
Returns an Integer
with the height of the X pixmap referred to
by xpm_data.
xpmWidthFromData
(char **
xpm_data)
Returns an Integer
with the width of the X pixmap referred to
by xpm_data.
Next: Boolean, Previous: X11FreeTypeFont, Up: Classes [Index]