本文整理汇总了C++中ANPPaintInterfaceV0::setTextSize方法的典型用法代码示例。如果您正苦于以下问题:C++ ANPPaintInterfaceV0::setTextSize方法的具体用法?C++ ANPPaintInterfaceV0::setTextSize怎么用?C++ ANPPaintInterfaceV0::setTextSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ANPPaintInterfaceV0
的用法示例。
在下文中一共展示了ANPPaintInterfaceV0::setTextSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPlugin
void BackgroundPlugin::drawPlugin(int surfaceWidth, int surfaceHeight) {
// get the plugin's dimensions according to the DOM
PluginObject *obj = (PluginObject*) inst()->pdata;
const int W = obj->window->width;
const int H = obj->window->height;
// compute the current zoom level
const float zoomFactorW = static_cast<float>(surfaceWidth) / W;
const float zoomFactorH = static_cast<float>(surfaceHeight) / H;
// check to make sure the zoom level is uniform
if (zoomFactorW + .01 < zoomFactorH && zoomFactorW - .01 > zoomFactorH)
gLogI.log(kError_ANPLogType, " ------ %p zoom is out of sync (%f,%f)",
inst(), zoomFactorW, zoomFactorH);
// scale the variables based on the zoom level
const int fontSize = (int)(zoomFactorW * 16);
const int leftMargin = (int)(zoomFactorW * 10);
// lock the surface
ANPBitmap bitmap;
JNIEnv* env = NULL;
if (!m_surface || gVM->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK ||
!gSurfaceI.lock(env, m_surface, &bitmap, NULL)) {
gLogI.log(kError_ANPLogType, " ------ %p unable to lock the plugin", inst());
return;
}
// create a canvas
ANPCanvas* canvas = gCanvasI.newCanvas(&bitmap);
gCanvasI.drawColor(canvas, 0xFFFFFFFF);
ANPPaint* paint = gPaintI.newPaint();
gPaintI.setFlags(paint, gPaintI.getFlags(paint) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(paint, 0xFFFF0000);
gPaintI.setTextSize(paint, fontSize);
ANPTypeface* tf = gTypefaceI.createFromName("serif", kItalic_ANPTypefaceStyle);
gPaintI.setTypeface(paint, tf);
gTypefaceI.unref(tf);
ANPFontMetrics fm;
gPaintI.getFontMetrics(paint, &fm);
gPaintI.setColor(paint, 0xFF0000FF);
const char c[] = "This is a background plugin.";
gCanvasI.drawText(canvas, c, sizeof(c)-1, leftMargin, -fm.fTop, paint);
// clean up variables and unlock the surface
gPaintI.deletePaint(paint);
gCanvasI.deleteCanvas(canvas);
gSurfaceI.unlock(env, m_surface);
}
示例2: SurfaceSubPlugin
PaintPlugin::PaintPlugin(NPP inst) : SurfaceSubPlugin(inst) {
m_isTouchActive = false;
m_isTouchCurrentInput = true;
m_activePaintColor = s_redColor;
memset(&m_drawingSurface, 0, sizeof(m_drawingSurface));
memset(&m_inputToggle, 0, sizeof(m_inputToggle));
memset(&m_colorToggle, 0, sizeof(m_colorToggle));
memset(&m_fullScreenToggle, 0, sizeof(m_fullScreenToggle));
memset(&m_clearSurface, 0, sizeof(m_clearSurface));
// initialize the drawing surface
m_surface = NULL;
// initialize the path
m_touchPath = gPathI.newPath();
if(!m_touchPath)
gLogI.log(kError_ANPLogType, "----%p Unable to create the touch path", inst);
// initialize the paint colors
m_paintSurface = gPaintI.newPaint();
gPaintI.setFlags(m_paintSurface, gPaintI.getFlags(m_paintSurface) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintSurface, 0xFFC0C0C0);
gPaintI.setTextSize(m_paintSurface, 18);
m_paintButton = gPaintI.newPaint();
gPaintI.setFlags(m_paintButton, gPaintI.getFlags(m_paintButton) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintButton, 0xFFA8A8A8);
// initialize the typeface (set the colors)
ANPTypeface* tf = gTypefaceI.createFromName("serif", kItalic_ANPTypefaceStyle);
gPaintI.setTypeface(m_paintSurface, tf);
gTypefaceI.unref(tf);
//register for touch events
ANPEventFlags flags = kTouch_ANPEventFlag;
NPError err = browser->setvalue(inst, kAcceptEvents_ANPSetValue, &flags);
if (err != NPERR_NO_ERROR) {
gLogI.log(kError_ANPLogType, "Error selecting input events.");
}
}
示例3: SubPlugin
FormPlugin::FormPlugin(NPP inst) : SubPlugin(inst) {
m_hasFocus = false;
m_activeInput = NULL;
memset(&m_usernameInput, 0, sizeof(m_usernameInput));
memset(&m_passwordInput, 0, sizeof(m_passwordInput));
m_usernameInput.text[0] = '\0';
m_usernameInput.charPtr = 0;
m_passwordInput.text[0] = '\0';
m_passwordInput.charPtr = 0;
m_paintInput = gPaintI.newPaint();
gPaintI.setFlags(m_paintInput, gPaintI.getFlags(m_paintInput) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintInput, 0xFFFFFFFF);
m_paintActive = gPaintI.newPaint();
gPaintI.setFlags(m_paintActive, gPaintI.getFlags(m_paintActive) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintActive, 0xFFFFFF00);
m_paintText = gPaintI.newPaint();
gPaintI.setFlags(m_paintText, gPaintI.getFlags(m_paintText) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintText, 0xFF000000);
gPaintI.setTextSize(m_paintText, 18);
ANPTypeface* tf = gTypefaceI.createFromName("serif", kItalic_ANPTypefaceStyle);
gPaintI.setTypeface(m_paintText, tf);
gTypefaceI.unref(tf);
//register for key and visibleRect events
ANPEventFlags flags = kKey_ANPEventFlag;
NPError err = browser->setvalue(inst, kAcceptEvents_ANPSetValue, &flags);
if (err != NPERR_NO_ERROR) {
gLogI.log(kError_ANPLogType, "Error selecting input events.");
}
}
示例4: if
AudioPlugin::AudioPlugin(NPP inst) : SubPlugin(inst) {
const char path[] = "/sdcard/sample.raw";
// open a file stream
FILE* f = fopen(path, "r");
gLogI.log(inst, kDebug_ANPLogType, "--- path %s FILE %p", path, f);
// setup our private audio struct's default values
m_soundPlay = new SoundPlay;
m_soundPlay->instance = inst;
m_soundPlay->progress = 0;
m_soundPlay->fileSize = 0;
m_soundPlay->file = f;
m_soundPlay->track = NULL;
// create the audio track
if (f) {
m_soundPlay->track = gSoundI.newTrack(44100, kPCM16Bit_ANPSampleFormat, 2, audioCallback, m_soundPlay);
if (!m_soundPlay->track) {
fclose(f);
m_soundPlay->file = NULL;
}
}
// get the audio file's size
int fileDescriptor = open(path, O_RDONLY);
struct stat fileStatus;
if(fileDescriptor <= 0) {
gLogI.log(inst, kError_ANPLogType, "fopen error");
}
else if (fstat(fileDescriptor, &fileStatus) != 0) {
gLogI.log(inst, kDebug_ANPLogType, "File Size: %d", fileStatus.st_size);
m_soundPlay->fileSize = fileStatus.st_size;
} else {
gLogI.log(inst, kError_ANPLogType, "fstat error");
}
// configure the UI elements
m_activeTouch = false;
memset(&m_trackRect, 0, sizeof(m_trackRect));
memset(&m_playRect, 0, sizeof(m_playRect));
memset(&m_pauseRect, 0, sizeof(m_pauseRect));
memset(&m_stopRect, 0, sizeof(m_stopRect));
m_paintTrack = gPaintI.newPaint();
gPaintI.setFlags(m_paintTrack, gPaintI.getFlags(m_paintTrack) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintTrack, 0xFFC0C0C0);
m_paintRect = gPaintI.newPaint();
gPaintI.setFlags(m_paintRect, gPaintI.getFlags(m_paintRect) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintRect, 0xFFA8A8A8);
m_paintText = gPaintI.newPaint();
gPaintI.setFlags(m_paintText, gPaintI.getFlags(m_paintText) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintText, 0xFF2F4F4F);
gPaintI.setTextSize(m_paintText, 18);
m_paintTrackProgress = gPaintI.newPaint();
gPaintI.setFlags(m_paintTrackProgress, gPaintI.getFlags(m_paintTrackProgress) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintTrackProgress, 0xFF545454);
m_paintActiveRect = gPaintI.newPaint();
gPaintI.setFlags(m_paintActiveRect, gPaintI.getFlags(m_paintActiveRect) | kAntiAlias_ANPPaintFlag);
gPaintI.setColor(m_paintActiveRect, 0xFF545454);
ANPTypeface* tf = gTypefaceI.createFromName("serif", kItalic_ANPTypefaceStyle);
gPaintI.setTypeface(m_paintText, tf);
gTypefaceI.unref(tf);
//register for touch events
ANPEventFlags flags = kTouch_ANPEventFlag;
NPError err = browser->setvalue(inst, kAcceptEvents_ANPSetValue, &flags);
if (err != NPERR_NO_ERROR) {
gLogI.log(inst, kError_ANPLogType, "Error selecting input events.");
}
}