librdtk: stub NinePatch, TextField and Button
This commit is contained in:
parent
abd87ace55
commit
24b594d592
@ -24,25 +24,46 @@
|
|||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/windows.h>
|
#include <winpr/windows.h>
|
||||||
|
|
||||||
|
#include <freerdp/codec/color.h>
|
||||||
|
#include <freerdp/codec/region.h>
|
||||||
|
|
||||||
|
typedef struct rdtk_engine rdtkEngine;
|
||||||
typedef struct rdtk_font rdtkFont;
|
typedef struct rdtk_font rdtkFont;
|
||||||
typedef struct rdtk_glyph rdtkGlyph;
|
typedef struct rdtk_glyph rdtkGlyph;
|
||||||
typedef struct rdtk_surface rdtkSurface;
|
typedef struct rdtk_surface rdtkSurface;
|
||||||
|
typedef struct rdtk_button rdtkButton;
|
||||||
|
typedef struct rdtk_text_field rdtkTextField;
|
||||||
|
typedef struct rdtk_nine_patch rdtkNinePatch;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Engine */
|
||||||
|
|
||||||
|
rdtkEngine* rdtk_engine_new();
|
||||||
|
void rdtk_engine_free(rdtkEngine* engine);
|
||||||
|
|
||||||
/* Surface */
|
/* Surface */
|
||||||
|
|
||||||
RDTK_EXPORT rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline);
|
RDTK_EXPORT int rdtk_surface_fill(rdtkSurface* surface, int x, int y, int width, int height, UINT32 color);
|
||||||
|
|
||||||
|
RDTK_EXPORT rdtkSurface* rdtk_surface_new(rdtkEngine* engine, BYTE* data, int width, int height, int scanline);
|
||||||
RDTK_EXPORT void rdtk_surface_free(rdtkSurface* surface);
|
RDTK_EXPORT void rdtk_surface_free(rdtkSurface* surface);
|
||||||
|
|
||||||
/* Font */
|
/* Font */
|
||||||
|
|
||||||
RDTK_EXPORT int rdtk_font_draw_text(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, const char* text);
|
RDTK_EXPORT int rdtk_font_draw_text(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, const char* text);
|
||||||
|
|
||||||
RDTK_EXPORT rdtkFont* rdtk_font_new(const char* path, const char* file);
|
/* Button */
|
||||||
RDTK_EXPORT void rdtk_font_free(rdtkFont* font);
|
|
||||||
|
RDTK_EXPORT int rdtk_button_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, int nHeight,
|
||||||
|
rdtkButton* button, const char* text);
|
||||||
|
|
||||||
|
/* TextField */
|
||||||
|
|
||||||
|
RDTK_EXPORT int rdtk_text_field_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, int nHeight,
|
||||||
|
rdtkTextField* textField, const char* text);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,15 @@ set(${MODULE_PREFIX}_SRCS
|
|||||||
rdtk_surface.c
|
rdtk_surface.c
|
||||||
rdtk_surface.h
|
rdtk_surface.h
|
||||||
rdtk_font.c
|
rdtk_font.c
|
||||||
rdtk_font.h)
|
rdtk_font.h
|
||||||
|
rdtk_button.c
|
||||||
|
rdtk_button.h
|
||||||
|
rdtk_nine_patch.c
|
||||||
|
rdtk_nine_patch.h
|
||||||
|
rdtk_text_field.c
|
||||||
|
rdtk_text_field.h
|
||||||
|
rdtk_engine.c
|
||||||
|
rdtk_engine.h)
|
||||||
|
|
||||||
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||||
|
|
||||||
|
66
rdtk/librdtk/rdtk_button.c
Normal file
66
rdtk/librdtk/rdtk_button.c
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rdtk_button.h"
|
||||||
|
|
||||||
|
int rdtk_button_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, int nHeight,
|
||||||
|
rdtkButton* button, const char* text)
|
||||||
|
{
|
||||||
|
button = surface->engine->button;
|
||||||
|
|
||||||
|
rdtk_nine_patch_draw(surface, nXDst, nYDst, nWidth, nHeight, button->ninePatch);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rdtkButton* rdtk_button_new(rdtkEngine* engine, rdtkNinePatch* ninePatch)
|
||||||
|
{
|
||||||
|
rdtkButton* button;
|
||||||
|
|
||||||
|
button = (rdtkButton*) calloc(1, sizeof(rdtkButton));
|
||||||
|
|
||||||
|
if (!button)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
button->engine = engine;
|
||||||
|
button->ninePatch = ninePatch;
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdtk_button_free(rdtkButton* button)
|
||||||
|
{
|
||||||
|
if (!button)
|
||||||
|
return;
|
||||||
|
|
||||||
|
free(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rdtk_button_engine_init(rdtkEngine* engine)
|
||||||
|
{
|
||||||
|
if (!engine->button)
|
||||||
|
{
|
||||||
|
engine->button = rdtk_button_new(engine, engine->button9patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
49
rdtk/librdtk/rdtk_button.h
Normal file
49
rdtk/librdtk/rdtk_button.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RDTK_BUTTON_PRIVATE_H
|
||||||
|
#define RDTK_BUTTON_PRIVATE_H
|
||||||
|
|
||||||
|
#include <rdtk/rdtk.h>
|
||||||
|
|
||||||
|
#include "rdtk_surface.h"
|
||||||
|
#include "rdtk_nine_patch.h"
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
|
struct rdtk_button
|
||||||
|
{
|
||||||
|
rdtkEngine* engine;
|
||||||
|
rdtkNinePatch* ninePatch;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rdtk_button_engine_init(rdtkEngine* engine);
|
||||||
|
|
||||||
|
rdtkButton* rdtk_button_new(rdtkEngine* engine, rdtkNinePatch* ninePatch);
|
||||||
|
void rdtk_button_free(rdtkButton* button);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RDTK_BUTTON_PRIVATE_H */
|
||||||
|
|
53
rdtk/librdtk/rdtk_engine.c
Normal file
53
rdtk/librdtk/rdtk_engine.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rdtk_font.h"
|
||||||
|
#include "rdtk_nine_patch.h"
|
||||||
|
#include "rdtk_button.h"
|
||||||
|
#include "rdtk_text_field.h"
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
|
rdtkEngine* rdtk_engine_new()
|
||||||
|
{
|
||||||
|
rdtkEngine* engine;
|
||||||
|
|
||||||
|
engine = (rdtkEngine*) calloc(1, sizeof(rdtkEngine));
|
||||||
|
|
||||||
|
if (!engine)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
rdtk_font_engine_init(engine);
|
||||||
|
rdtk_nine_patch_engine_init(engine);
|
||||||
|
rdtk_button_engine_init(engine);
|
||||||
|
rdtk_text_field_engine_init(engine);
|
||||||
|
|
||||||
|
return engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdtk_engine_free(rdtkEngine* engine)
|
||||||
|
{
|
||||||
|
if (!engine)
|
||||||
|
return;
|
||||||
|
|
||||||
|
free(engine);
|
||||||
|
}
|
46
rdtk/librdtk/rdtk_engine.h
Normal file
46
rdtk/librdtk/rdtk_engine.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RDTK_ENGINE_PRIVATE_H
|
||||||
|
#define RDTK_ENGINE_PRIVATE_H
|
||||||
|
|
||||||
|
#include <rdtk/rdtk.h>
|
||||||
|
|
||||||
|
struct rdtk_engine
|
||||||
|
{
|
||||||
|
rdtkFont* font;
|
||||||
|
|
||||||
|
rdtkButton* button;
|
||||||
|
rdtkNinePatch* button9patch;
|
||||||
|
|
||||||
|
rdtkTextField* textField;
|
||||||
|
rdtkNinePatch* textField9patch;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RDTK_ENGINE_PRIVATE_H */
|
||||||
|
|
@ -24,13 +24,12 @@
|
|||||||
#include <winpr/path.h>
|
#include <winpr/path.h>
|
||||||
#include <winpr/print.h>
|
#include <winpr/print.h>
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
#include "rdtk_resources.h"
|
#include "rdtk_resources.h"
|
||||||
#include "rdtk_surface.h"
|
#include "rdtk_surface.h"
|
||||||
|
|
||||||
#include "rdtk_font.h"
|
#include "rdtk_font.h"
|
||||||
|
|
||||||
static rdtkFont* g_Font = NULL;
|
|
||||||
|
|
||||||
int rdtk_font_draw_glyph(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, rdtkGlyph* glyph)
|
int rdtk_font_draw_glyph(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* font, rdtkGlyph* glyph)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -124,11 +123,7 @@ int rdtk_font_draw_text(rdtkSurface* surface, int nXDst, int nYDst, rdtkFont* fo
|
|||||||
int length;
|
int length;
|
||||||
rdtkGlyph* glyph;
|
rdtkGlyph* glyph;
|
||||||
|
|
||||||
if (!font)
|
font = surface->engine->font;
|
||||||
{
|
|
||||||
rdtk_load_embedded_fonts();
|
|
||||||
font = g_Font;
|
|
||||||
}
|
|
||||||
|
|
||||||
length = strlen(text);
|
length = strlen(text);
|
||||||
|
|
||||||
@ -556,7 +551,7 @@ int rdtk_font_load_descriptor(rdtkFont* font, const char* filename)
|
|||||||
return rdtk_font_parse_descriptor_buffer(font, (BYTE*) buffer, size);
|
return rdtk_font_parse_descriptor_buffer(font, (BYTE*) buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
rdtkFont* rdtk_font_new(const char* path, const char* file)
|
rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int length;
|
int length;
|
||||||
@ -601,6 +596,8 @@ rdtkFont* rdtk_font_new(const char* path, const char* file)
|
|||||||
if (!font)
|
if (!font)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
font->engine = engine;
|
||||||
|
|
||||||
font->image = winpr_image_new();
|
font->image = winpr_image_new();
|
||||||
|
|
||||||
if (!font->image)
|
if (!font->image)
|
||||||
@ -619,7 +616,7 @@ rdtkFont* rdtk_font_new(const char* path, const char* file)
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdtkFont* rdtk_embedded_font_new(BYTE* imageData, int imageSize, BYTE* descriptorData, int descriptorSize)
|
rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, BYTE* imageData, int imageSize, BYTE* descriptorData, int descriptorSize)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
rdtkFont* font;
|
rdtkFont* font;
|
||||||
@ -629,6 +626,8 @@ rdtkFont* rdtk_embedded_font_new(BYTE* imageData, int imageSize, BYTE* descripto
|
|||||||
if (!font)
|
if (!font)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
font->engine = engine;
|
||||||
|
|
||||||
font->image = winpr_image_new();
|
font->image = winpr_image_new();
|
||||||
|
|
||||||
if (!font->image)
|
if (!font->image)
|
||||||
@ -652,9 +651,9 @@ void rdtk_font_free(rdtkFont* font)
|
|||||||
free(font);
|
free(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rdtk_load_embedded_fonts()
|
int rdtk_font_engine_init(rdtkEngine* engine)
|
||||||
{
|
{
|
||||||
if (!g_Font)
|
if (!engine->font)
|
||||||
{
|
{
|
||||||
int imageSize;
|
int imageSize;
|
||||||
int descriptorSize;
|
int descriptorSize;
|
||||||
@ -667,7 +666,7 @@ int rdtk_load_embedded_fonts()
|
|||||||
if ((imageSize < 0) || (descriptorSize < 0))
|
if ((imageSize < 0) || (descriptorSize < 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
g_Font = rdtk_embedded_font_new(imageData, imageSize, descriptorData, descriptorSize);
|
engine->font = rdtk_embedded_font_new(engine, imageData, imageSize, descriptorData, descriptorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <winpr/synch.h>
|
#include <winpr/synch.h>
|
||||||
#include <winpr/image.h>
|
#include <winpr/image.h>
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
struct rdtk_glyph
|
struct rdtk_glyph
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
@ -39,6 +41,8 @@ struct rdtk_glyph
|
|||||||
|
|
||||||
struct rdtk_font
|
struct rdtk_font
|
||||||
{
|
{
|
||||||
|
rdtkEngine* engine;
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
int height;
|
int height;
|
||||||
char* family;
|
char* family;
|
||||||
@ -52,7 +56,10 @@ struct rdtk_font
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int rdtk_load_embedded_fonts();
|
int rdtk_font_engine_init(rdtkEngine* engine);
|
||||||
|
|
||||||
|
rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file);
|
||||||
|
void rdtk_font_free(rdtkFont* font);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
187
rdtk/librdtk/rdtk_nine_patch.c
Normal file
187
rdtk/librdtk/rdtk_nine_patch.c
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <freerdp/codec/color.h>
|
||||||
|
|
||||||
|
#include "rdtk_resources.h"
|
||||||
|
|
||||||
|
#include "rdtk_nine_patch.h"
|
||||||
|
|
||||||
|
int rdtk_nine_patch_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, int nHeight, rdtkNinePatch* ninePatch)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
int nXSrc;
|
||||||
|
int nYSrc;
|
||||||
|
int nSrcStep;
|
||||||
|
int nDstStep;
|
||||||
|
int nSrcPad;
|
||||||
|
int nDstPad;
|
||||||
|
BYTE* pSrcData;
|
||||||
|
BYTE* pSrcPixel;
|
||||||
|
BYTE* pDstData;
|
||||||
|
BYTE* pDstPixel;
|
||||||
|
BYTE A, R, G, B;
|
||||||
|
wImage* image = ninePatch->image;
|
||||||
|
|
||||||
|
nXSrc = 0;
|
||||||
|
nYSrc = 0;
|
||||||
|
|
||||||
|
nWidth = image->width;
|
||||||
|
nHeight = image->height;
|
||||||
|
|
||||||
|
nSrcStep = image->scanline;
|
||||||
|
pSrcData = image->data;
|
||||||
|
|
||||||
|
pDstData = surface->data;
|
||||||
|
nDstStep = surface->scanline;
|
||||||
|
|
||||||
|
nSrcPad = (nSrcStep - (nWidth * 4));
|
||||||
|
nDstPad = (nDstStep - (nWidth * 4));
|
||||||
|
|
||||||
|
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
|
||||||
|
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
|
||||||
|
|
||||||
|
for (y = 0; y < nHeight; y++)
|
||||||
|
{
|
||||||
|
pSrcPixel = &pSrcData[((nYSrc + y) * nSrcStep) + (nXSrc * 4)];
|
||||||
|
pDstPixel = &pDstData[((nYDst + y) * nDstStep) + (nXDst * 4)];
|
||||||
|
|
||||||
|
for (x = 0; x < nWidth; x++)
|
||||||
|
{
|
||||||
|
B = pSrcPixel[0];
|
||||||
|
G = pSrcPixel[1];
|
||||||
|
R = pSrcPixel[2];
|
||||||
|
A = pSrcPixel[3];
|
||||||
|
pSrcPixel += 4;
|
||||||
|
|
||||||
|
if (A == 255)
|
||||||
|
{
|
||||||
|
pDstPixel[0] = B;
|
||||||
|
pDstPixel[1] = G;
|
||||||
|
pDstPixel[2] = R;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
R = (R * A) / 255;
|
||||||
|
G = (G * A) / 255;
|
||||||
|
B = (B * A) / 255;
|
||||||
|
|
||||||
|
pDstPixel[0] = B + (pDstPixel[0] * (255 - A) + (255 / 2)) / 255;
|
||||||
|
pDstPixel[1] = G + (pDstPixel[1] * (255 - A) + (255 / 2)) / 255;
|
||||||
|
pDstPixel[2] = R + (pDstPixel[2] * (255 - A) + (255 / 2)) / 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDstPixel[3] = 0xFF;
|
||||||
|
pDstPixel += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
pSrcPixel += nSrcPad;
|
||||||
|
pDstPixel += nDstPad;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rdtkNinePatch* rdtk_nine_patch_new(rdtkEngine* engine)
|
||||||
|
{
|
||||||
|
rdtkNinePatch* ninePatch;
|
||||||
|
|
||||||
|
ninePatch = (rdtkNinePatch*) calloc(1, sizeof(rdtkNinePatch));
|
||||||
|
|
||||||
|
if (!ninePatch)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ninePatch->engine = engine;
|
||||||
|
|
||||||
|
return ninePatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdtk_nine_patch_free(rdtkNinePatch* ninePatch)
|
||||||
|
{
|
||||||
|
if (!ninePatch)
|
||||||
|
return;
|
||||||
|
|
||||||
|
winpr_image_free(ninePatch->image, TRUE);
|
||||||
|
|
||||||
|
free(ninePatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rdtk_nine_patch_engine_init(rdtkEngine* engine)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
wImage* image;
|
||||||
|
rdtkNinePatch* ninePatch;
|
||||||
|
|
||||||
|
if (!engine->button9patch)
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
BYTE* data;
|
||||||
|
|
||||||
|
status = -1;
|
||||||
|
|
||||||
|
size = rdtk_get_embedded_resource_file("btn_default_normal.9.png", &data);
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
|
image = winpr_image_new();
|
||||||
|
|
||||||
|
if (image)
|
||||||
|
status = winpr_image_read_buffer(image, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status > 0)
|
||||||
|
{
|
||||||
|
ninePatch = engine->button9patch = rdtk_nine_patch_new(engine);
|
||||||
|
|
||||||
|
if (ninePatch)
|
||||||
|
ninePatch->image = image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!engine->textField9patch)
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
BYTE* data;
|
||||||
|
|
||||||
|
status = -1;
|
||||||
|
|
||||||
|
size = rdtk_get_embedded_resource_file("textfield_default.9.png", &data);
|
||||||
|
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
|
image = winpr_image_new();
|
||||||
|
|
||||||
|
if (image)
|
||||||
|
status = winpr_image_read_buffer(image, data, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status > 0)
|
||||||
|
{
|
||||||
|
ninePatch = engine->textField9patch = rdtk_nine_patch_new(engine);
|
||||||
|
|
||||||
|
if (ninePatch)
|
||||||
|
ninePatch->image = image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
53
rdtk/librdtk/rdtk_nine_patch.h
Normal file
53
rdtk/librdtk/rdtk_nine_patch.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RDTK_NINE_PATCH_PRIVATE_H
|
||||||
|
#define RDTK_NINE_PATCH_PRIVATE_H
|
||||||
|
|
||||||
|
#include <rdtk/rdtk.h>
|
||||||
|
|
||||||
|
#include <winpr/image.h>
|
||||||
|
|
||||||
|
#include "rdtk_surface.h"
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
|
struct rdtk_nine_patch
|
||||||
|
{
|
||||||
|
rdtkEngine* engine;
|
||||||
|
|
||||||
|
wImage* image;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rdtk_nine_patch_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, int nHeight, rdtkNinePatch* ninePatch);
|
||||||
|
|
||||||
|
int rdtk_nine_patch_engine_init(rdtkEngine* engine);
|
||||||
|
|
||||||
|
rdtkNinePatch* rdtk_nine_patch_new(rdtkEngine* engine);
|
||||||
|
void rdtk_nine_patch_free(rdtkNinePatch* ninePatch);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RDTK_NINE_PATCH_PRIVATE_H */
|
||||||
|
|
@ -22,6 +22,110 @@
|
|||||||
|
|
||||||
#include "rdtk_resources.h"
|
#include "rdtk_resources.h"
|
||||||
|
|
||||||
|
/* Nine Patches */
|
||||||
|
|
||||||
|
static BYTE btn_default_normal_9_png[] = {
|
||||||
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||||
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x32,
|
||||||
|
0x08, 0x06, 0x00, 0x00, 0x00, 0x42, 0xb5, 0xcb, 0x95, 0x00, 0x00, 0x00,
|
||||||
|
0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x89, 0x00, 0x00, 0x0b,
|
||||||
|
0x89, 0x01, 0x37, 0xc9, 0xcb, 0xad, 0x00, 0x00, 0x02, 0x5d, 0x49, 0x44,
|
||||||
|
0x41, 0x54, 0x58, 0x85, 0xed, 0x58, 0x41, 0xae, 0xd3, 0x40, 0x0c, 0x7d,
|
||||||
|
0x9e, 0x52, 0x84, 0x10, 0x69, 0xd5, 0x05, 0x57, 0xe8, 0x8e, 0x4d, 0x51,
|
||||||
|
0x57, 0xdc, 0x80, 0x43, 0xf4, 0x08, 0x1c, 0xaa, 0x87, 0xe0, 0x02, 0x88,
|
||||||
|
0x13, 0xb0, 0xeb, 0x0d, 0x10, 0x8b, 0x4a, 0x5f, 0x15, 0x42, 0xe4, 0x63,
|
||||||
|
0xb3, 0xa0, 0x53, 0x39, 0x8e, 0x3d, 0x33, 0x49, 0xbf, 0xf4, 0x37, 0x58,
|
||||||
|
0x8a, 0x32, 0x3f, 0x99, 0xf1, 0xf3, 0x1b, 0x3f, 0x7b, 0xd2, 0x4f, 0x22,
|
||||||
|
0x02, 0x22, 0x82, 0x63, 0xe2, 0x3d, 0x6c, 0xb0, 0x91, 0x33, 0x91, 0xb9,
|
||||||
|
0xae, 0x9e, 0x02, 0x1d, 0xc0, 0xeb, 0xe3, 0xf1, 0xf8, 0x71, 0xbb, 0xdd,
|
||||||
|
0x7e, 0x00, 0x40, 0x44, 0x74, 0x63, 0x6c, 0x99, 0xe7, 0x48, 0x45, 0x24,
|
||||||
|
0x8f, 0xe5, 0x74, 0x3a, 0x7d, 0x3d, 0x1c, 0x0e, 0x9f, 0x01, 0xfc, 0xd4,
|
||||||
|
0x73, 0x5f, 0x38, 0x40, 0xdd, 0x7e, 0xbf, 0xff, 0xb4, 0xd9, 0x6c, 0x76,
|
||||||
|
0x44, 0x84, 0x94, 0x52, 0x13, 0x10, 0x33, 0x43, 0x44, 0xb0, 0x5e, 0xaf,
|
||||||
|
0xdf, 0x03, 0xf8, 0xd2, 0x02, 0xb4, 0xea, 0xba, 0x6e, 0xd7, 0xf7, 0xbd,
|
||||||
|
0xa4, 0x94, 0x6e, 0x40, 0x16, 0xcc, 0xb2, 0x61, 0x66, 0x30, 0x33, 0xba,
|
||||||
|
0xae, 0xdb, 0x01, 0x58, 0x01, 0xf8, 0xae, 0x9d, 0x26, 0x8c, 0x93, 0xbe,
|
||||||
|
0x64, 0xe6, 0x41, 0xd4, 0x3a, 0x99, 0xb5, 0xbf, 0xaf, 0x6b, 0x97, 0x36,
|
||||||
|
0x7a, 0x8f, 0xd1, 0x20, 0xda, 0xcc, 0x42, 0x8f, 0xf5, 0x3b, 0x0d, 0x66,
|
||||||
|
0x41, 0x2d, 0x23, 0x6b, 0xe4, 0x2d, 0x72, 0x12, 0x1f, 0x82, 0xc1, 0x11,
|
||||||
|
0x99, 0x07, 0x14, 0x32, 0x9c, 0xfa, 0x4e, 0x4f, 0xf3, 0xb6, 0x6e, 0x10,
|
||||||
|
0x4d, 0x0d, 0x24, 0xd8, 0xae, 0x36, 0x46, 0x59, 0xaa, 0xf9, 0x1e, 0x6d,
|
||||||
|
0x65, 0x74, 0x79, 0xe6, 0x32, 0xca, 0x0b, 0xb4, 0x08, 0x22, 0x86, 0x01,
|
||||||
|
0xd0, 0x88, 0x91, 0xab, 0x3a, 0xed, 0x00, 0x88, 0x55, 0x67, 0x05, 0x32,
|
||||||
|
0x8b, 0x91, 0x8e, 0x9e, 0x99, 0x5d, 0x59, 0xe7, 0x77, 0x16, 0xcc, 0x63,
|
||||||
|
0x54, 0x55, 0x5d, 0x8b, 0xe2, 0x5a, 0x94, 0x57, 0xcc, 0x11, 0x00, 0xa4,
|
||||||
|
0x94, 0x06, 0x0e, 0x4b, 0x2d, 0x68, 0x32, 0xa3, 0x28, 0xe1, 0x76, 0x6c,
|
||||||
|
0xe7, 0x96, 0x98, 0x85, 0x75, 0xa4, 0x23, 0xd5, 0x2c, 0x22, 0x46, 0x26,
|
||||||
|
0x80, 0x76, 0xd5, 0x45, 0x36, 0xf7, 0xb4, 0x2c, 0x32, 0xca, 0x6c, 0xf4,
|
||||||
|
0x65, 0x41, 0xed, 0x75, 0x9d, 0xd3, 0x94, 0x23, 0x8a, 0xa2, 0x8e, 0x1a,
|
||||||
|
0x6a, 0x14, 0x6c, 0x8d, 0xd1, 0x28, 0xc1, 0x59, 0x79, 0x5e, 0x7e, 0x74,
|
||||||
|
0x00, 0x93, 0x0b, 0x36, 0x2f, 0xce, 0x8e, 0xb5, 0x20, 0xac, 0xd9, 0x43,
|
||||||
|
0x32, 0xda, 0xba, 0x62, 0x1d, 0x79, 0x2c, 0x22, 0x33, 0x2c, 0xa7, 0xd5,
|
||||||
|
0x51, 0xa9, 0xa1, 0x96, 0xba, 0xb9, 0x67, 0xc5, 0x5e, 0x07, 0x60, 0xa0,
|
||||||
|
0xbc, 0x08, 0xbc, 0xa5, 0x8e, 0x5c, 0xd5, 0xd5, 0xa2, 0xaf, 0x3d, 0xf7,
|
||||||
|
0x80, 0x8a, 0x05, 0x5b, 0xcb, 0x91, 0xc7, 0x2e, 0x12, 0x8d, 0xbb, 0x75,
|
||||||
|
0x5a, 0x49, 0x79, 0xec, 0x39, 0x28, 0xc8, 0xfb, 0xbe, 0x16, 0xd4, 0xc2,
|
||||||
|
0x2a, 0xb2, 0xb0, 0x8e, 0x98, 0x19, 0x29, 0xfd, 0x4b, 0xa1, 0x77, 0xa4,
|
||||||
|
0x5b, 0xb0, 0x5a, 0x0b, 0x6a, 0xfa, 0x80, 0xb4, 0x7b, 0xaf, 0x81, 0xa3,
|
||||||
|
0xe3, 0xc3, 0x5a, 0x73, 0xaf, 0x6b, 0x3d, 0x77, 0x9e, 0xe4, 0x28, 0x8f,
|
||||||
|
0x24, 0x7f, 0xf7, 0x51, 0x9e, 0x73, 0x64, 0xc7, 0x36, 0x10, 0xe7, 0x23,
|
||||||
|
0x66, 0x7e, 0x1d, 0x79, 0x8d, 0xb5, 0x75, 0x3b, 0x43, 0x46, 0x76, 0x71,
|
||||||
|
0xad, 0xb1, 0x3a, 0x42, 0x78, 0xb6, 0x8f, 0xfc, 0xb8, 0xd7, 0x59, 0x47,
|
||||||
|
0x25, 0x25, 0x3a, 0xef, 0x2c, 0x23, 0xba, 0xbb, 0x33, 0xb4, 0x5a, 0x53,
|
||||||
|
0x1d, 0xcd, 0xd8, 0x3a, 0x57, 0x75, 0xa3, 0x87, 0xcc, 0x8c, 0xbe, 0xef,
|
||||||
|
0x5d, 0x27, 0x25, 0x61, 0x10, 0x11, 0x96, 0xcb, 0xd1, 0xcf, 0xd7, 0x1b,
|
||||||
|
0x90, 0xb5, 0xc7, 0xf3, 0xf9, 0xfc, 0xb0, 0x58, 0x2c, 0x56, 0x53, 0xb7,
|
||||||
|
0x8a, 0x88, 0x70, 0xb9, 0x5c, 0x1e, 0x00, 0x3c, 0x8e, 0xde, 0x39, 0xf3,
|
||||||
|
0xdf, 0x02, 0x78, 0x77, 0xbd, 0x2f, 0x26, 0x21, 0x01, 0x7f, 0x00, 0xfc,
|
||||||
|
0x00, 0xf0, 0xed, 0x7a, 0x2f, 0x02, 0xbd, 0x04, 0xf0, 0x06, 0xc0, 0x2b,
|
||||||
|
0x34, 0xca, 0x5f, 0x19, 0x03, 0xf8, 0x05, 0xe0, 0x02, 0xe0, 0xf7, 0xc4,
|
||||||
|
0xb5, 0xff, 0xed, 0xb9, 0x6d, 0x46, 0xb5, 0x0b, 0x26, 0xfe, 0xd3, 0x50,
|
||||||
|
0x44, 0xf0, 0x17, 0xa0, 0xb1, 0xe0, 0x73, 0xc3, 0xe6, 0x24, 0xdb, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
|
||||||
|
};
|
||||||
|
static int btn_default_normal_9_png_len = 683;
|
||||||
|
|
||||||
|
static BYTE textfield_default_9_png[] = {
|
||||||
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||||
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x32,
|
||||||
|
0x08, 0x06, 0x00, 0x00, 0x00, 0x46, 0x40, 0x1b, 0xa8, 0x00, 0x00, 0x00,
|
||||||
|
0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x89, 0x00, 0x00, 0x0b,
|
||||||
|
0x89, 0x01, 0x37, 0xc9, 0xcb, 0xad, 0x00, 0x00, 0x01, 0x53, 0x49, 0x44,
|
||||||
|
0x41, 0x54, 0x58, 0x85, 0xed, 0x98, 0x4b, 0x6e, 0x83, 0x30, 0x10, 0x86,
|
||||||
|
0x67, 0xc6, 0xa8, 0x8a, 0x58, 0xb1, 0x45, 0xa2, 0x9b, 0x8a, 0x83, 0xf4,
|
||||||
|
0x28, 0xbd, 0x03, 0xea, 0x71, 0xb8, 0x0b, 0xf7, 0x60, 0x55, 0xa9, 0x97,
|
||||||
|
0x60, 0x51, 0x4f, 0x17, 0xcd, 0x44, 0x7e, 0x76, 0x30, 0x09, 0x52, 0xa9,
|
||||||
|
0xf8, 0x25, 0x0b, 0x3f, 0x26, 0xf3, 0xf9, 0xb7, 0xad, 0x10, 0x07, 0x98,
|
||||||
|
0x19, 0x0a, 0x54, 0x16, 0xcc, 0x0c, 0x18, 0xf4, 0x3d, 0x03, 0x44, 0x7d,
|
||||||
|
0xa5, 0xb2, 0x00, 0xf0, 0x29, 0x8d, 0xca, 0x1d, 0x99, 0xa6, 0xe9, 0xbd,
|
||||||
|
0xef, 0xfb, 0x37, 0x71, 0x85, 0xa8, 0xb3, 0xdc, 0x15, 0xa8, 0xaa, 0x0a,
|
||||||
|
0xda, 0xb6, 0x7d, 0xcd, 0x02, 0x2e, 0x97, 0x0b, 0xd7, 0x75, 0xfd, 0x63,
|
||||||
|
0xcd, 0x49, 0x9e, 0x02, 0xb9, 0x89, 0x83, 0x09, 0x7d, 0xb9, 0x71, 0x1e,
|
||||||
|
0xc0, 0x18, 0xc3, 0xc6, 0x18, 0x40, 0xc4, 0x5b, 0x59, 0xeb, 0x80, 0x99,
|
||||||
|
0xa5, 0x6e, 0xb3, 0x00, 0x22, 0x62, 0x22, 0x8a, 0x00, 0x39, 0x50, 0x98,
|
||||||
|
0xfc, 0xda, 0xf6, 0x0e, 0x82, 0x07, 0x90, 0xa4, 0x2e, 0x24, 0x07, 0x90,
|
||||||
|
0x65, 0x94, 0xa7, 0xb5, 0x16, 0x52, 0x27, 0x32, 0x02, 0x48, 0x72, 0x79,
|
||||||
|
0x6a, 0x0e, 0xa4, 0x10, 0x51, 0x32, 0x46, 0x75, 0xb0, 0x66, 0x1f, 0xc4,
|
||||||
|
0x41, 0x22, 0x96, 0x93, 0x00, 0xb7, 0x9e, 0x83, 0xb8, 0x27, 0x47, 0x92,
|
||||||
|
0xa7, 0xe2, 0x92, 0xbe, 0xb4, 0xe4, 0xa9, 0xc9, 0xe4, 0x54, 0x85, 0x1d,
|
||||||
|
0xa9, 0xe4, 0xbf, 0x6d, 0x72, 0x0a, 0xa8, 0x3a, 0x08, 0x81, 0x25, 0xfd,
|
||||||
|
0xc5, 0x80, 0x7b, 0x75, 0x38, 0x40, 0xb4, 0x6e, 0x87, 0x73, 0xa0, 0x02,
|
||||||
|
0xee, 0x7d, 0xd9, 0xa8, 0x80, 0x87, 0xeb, 0x7f, 0x00, 0x8a, 0x7e, 0x29,
|
||||||
|
0x6c, 0x01, 0x3c, 0x7c, 0x63, 0x43, 0xc0, 0xae, 0xf2, 0x00, 0x6b, 0xbf,
|
||||||
|
0xc0, 0x36, 0x03, 0xf6, 0xd0, 0x09, 0x38, 0x01, 0x27, 0xe0, 0x04, 0xfc,
|
||||||
|
0x01, 0x00, 0xaa, 0x80, 0xc2, 0x6b, 0x6e, 0xa4, 0xcd, 0x0e, 0xd6, 0x82,
|
||||||
|
0xa3, 0xfb, 0x41, 0x70, 0xdf, 0x52, 0x21, 0x5a, 0xac, 0xe7, 0x80, 0x88,
|
||||||
|
0x10, 0x11, 0x09, 0x11, 0xe9, 0x3a, 0xe6, 0xd5, 0x53, 0x45, 0xc6, 0xe5,
|
||||||
|
0x73, 0x4d, 0xd3, 0x78, 0x6f, 0x2d, 0xaf, 0x31, 0x0c, 0xc3, 0x4b, 0xd7,
|
||||||
|
0x75, 0x4f, 0xea, 0xd4, 0x33, 0x5a, 0x96, 0xc5, 0xce, 0xf3, 0xbc, 0x8c,
|
||||||
|
0xe3, 0xf8, 0xb1, 0x35, 0xc7, 0xa9, 0x23, 0x6a, 0xef, 0x3f, 0xa4, 0xbe,
|
||||||
|
0x01, 0x9f, 0x91, 0x87, 0x71, 0x3a, 0x69, 0xd1, 0x87, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
|
||||||
|
};
|
||||||
|
static int textfield_default_9_png_len = 417;
|
||||||
|
|
||||||
|
/* Fonts */
|
||||||
|
|
||||||
static BYTE source_serif_pro_regular_12_png[] = {
|
static BYTE source_serif_pro_regular_12_png[] = {
|
||||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||||
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x02, 0xe7, 0x00, 0x00, 0x00, 0x11,
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x02, 0xe7, 0x00, 0x00, 0x00, 0x11,
|
||||||
@ -1230,6 +1334,16 @@ int rdtk_get_embedded_resource_file(const char* filename, BYTE** pData)
|
|||||||
*pData = (BYTE*) source_serif_pro_regular_12_xml;
|
*pData = (BYTE*) source_serif_pro_regular_12_xml;
|
||||||
return source_serif_pro_regular_12_xml_len;
|
return source_serif_pro_regular_12_xml_len;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(filename, "btn_default_normal.9.png") == 0)
|
||||||
|
{
|
||||||
|
*pData = (BYTE*) btn_default_normal_9_png;
|
||||||
|
return btn_default_normal_9_png_len;
|
||||||
|
}
|
||||||
|
else if (strcmp(filename, "textfield_default.9.png") == 0)
|
||||||
|
{
|
||||||
|
*pData = (BYTE*) textfield_default_9_png;
|
||||||
|
return textfield_default_9_png_len;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include <rdtk/rdtk.h>
|
#include <rdtk/rdtk.h>
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,7 +22,15 @@
|
|||||||
|
|
||||||
#include "rdtk_surface.h"
|
#include "rdtk_surface.h"
|
||||||
|
|
||||||
rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline)
|
int rdtk_surface_fill(rdtkSurface* surface, int x, int y, int width, int height, UINT32 color)
|
||||||
|
{
|
||||||
|
freerdp_image_fill(surface->data, PIXEL_FORMAT_XRGB32,
|
||||||
|
surface->scanline, x, y, width, height, color);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rdtkSurface* rdtk_surface_new(rdtkEngine* engine, BYTE* data, int width, int height, int scanline)
|
||||||
{
|
{
|
||||||
rdtkSurface* surface;
|
rdtkSurface* surface;
|
||||||
|
|
||||||
@ -31,6 +39,8 @@ rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline)
|
|||||||
if (!surface)
|
if (!surface)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
surface->engine = engine;
|
||||||
|
|
||||||
surface->width = width;
|
surface->width = width;
|
||||||
surface->height = height;
|
surface->height = height;
|
||||||
|
|
||||||
|
@ -21,8 +21,12 @@
|
|||||||
|
|
||||||
#include <rdtk/rdtk.h>
|
#include <rdtk/rdtk.h>
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
struct rdtk_surface
|
struct rdtk_surface
|
||||||
{
|
{
|
||||||
|
rdtkEngine* engine;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int scanline;
|
int scanline;
|
||||||
@ -34,7 +38,7 @@ struct rdtk_surface
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rdtkSurface* rdtk_surface_new(BYTE* data, int width, int height, int scanline);
|
rdtkSurface* rdtk_surface_new(rdtkEngine* engine, BYTE* data, int width, int height, int scanline);
|
||||||
void rdtk_surface_free(rdtkSurface* surface);
|
void rdtk_surface_free(rdtkSurface* surface);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
66
rdtk/librdtk/rdtk_text_field.c
Normal file
66
rdtk/librdtk/rdtk_text_field.c
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rdtk_text_field.h"
|
||||||
|
|
||||||
|
int rdtk_text_field_draw(rdtkSurface* surface, int nXDst, int nYDst, int nWidth, int nHeight,
|
||||||
|
rdtkTextField* textField, const char* text)
|
||||||
|
{
|
||||||
|
textField = surface->engine->textField;
|
||||||
|
|
||||||
|
rdtk_nine_patch_draw(surface, nXDst, nYDst, nWidth, nHeight, textField->ninePatch);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rdtkTextField* rdtk_text_field_new(rdtkEngine* engine, rdtkNinePatch* ninePatch)
|
||||||
|
{
|
||||||
|
rdtkTextField* textField;
|
||||||
|
|
||||||
|
textField = (rdtkTextField*) calloc(1, sizeof(rdtkTextField));
|
||||||
|
|
||||||
|
if (!textField)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
textField->engine = engine;
|
||||||
|
textField->ninePatch = ninePatch;
|
||||||
|
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rdtk_text_field_free(rdtkTextField* textField)
|
||||||
|
{
|
||||||
|
if (!textField)
|
||||||
|
return;
|
||||||
|
|
||||||
|
free(textField);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rdtk_text_field_engine_init(rdtkEngine* engine)
|
||||||
|
{
|
||||||
|
if (!engine->textField)
|
||||||
|
{
|
||||||
|
engine->textField = rdtk_text_field_new(engine, engine->textField9patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
49
rdtk/librdtk/rdtk_text_field.h
Normal file
49
rdtk/librdtk/rdtk_text_field.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* RdTk: Remote Desktop Toolkit
|
||||||
|
*
|
||||||
|
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RDTK_TEXT_FIELD_PRIVATE_H
|
||||||
|
#define RDTK_TEXT_FIELD_PRIVATE_H
|
||||||
|
|
||||||
|
#include <rdtk/rdtk.h>
|
||||||
|
|
||||||
|
#include "rdtk_surface.h"
|
||||||
|
#include "rdtk_nine_patch.h"
|
||||||
|
|
||||||
|
#include "rdtk_engine.h"
|
||||||
|
|
||||||
|
struct rdtk_text_field
|
||||||
|
{
|
||||||
|
rdtkEngine* engine;
|
||||||
|
rdtkNinePatch* ninePatch;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rdtk_text_field_engine_init(rdtkEngine* engine);
|
||||||
|
|
||||||
|
rdtkTextField* rdtk_text_field_new(rdtkEngine* engine, rdtkNinePatch* ninePatch);
|
||||||
|
void rdtk_text_field_free(rdtkTextField* textField);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RDTK_TEXT_FIELD_PRIVATE_H */
|
||||||
|
|
@ -30,6 +30,7 @@ int shadow_client_init_lobby(rdpShadowClient* client)
|
|||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
rdtkEngine* engine;
|
||||||
rdtkSurface* surface;
|
rdtkSurface* surface;
|
||||||
RECTANGLE_16 invalidRect;
|
RECTANGLE_16 invalidRect;
|
||||||
rdpShadowSurface* lobby;
|
rdpShadowSurface* lobby;
|
||||||
@ -44,15 +45,20 @@ int shadow_client_init_lobby(rdpShadowClient* client)
|
|||||||
if (!client->lobby)
|
if (!client->lobby)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
freerdp_image_fill(lobby->data, PIXEL_FORMAT_XRGB32, lobby->scanline,
|
engine = rdtk_engine_new();
|
||||||
0, 0, lobby->width, lobby->height, 0x3BB9FF);
|
|
||||||
|
|
||||||
surface = rdtk_surface_new(lobby->data, lobby->width, lobby->height, lobby->scanline);
|
surface = rdtk_surface_new(engine, lobby->data, lobby->width, lobby->height, lobby->scanline);
|
||||||
|
|
||||||
rdtk_font_draw_text(surface, 16, 16, NULL, "Welcome to the shadow server!");
|
rdtk_surface_fill(surface, 0, 0, width, height, 0x3BB9FF);
|
||||||
|
|
||||||
|
//rdtk_font_draw_text(surface, 16, 16, NULL, "Welcome to the shadow server!");
|
||||||
|
//rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button");
|
||||||
|
//rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field");
|
||||||
|
|
||||||
rdtk_surface_free(surface);
|
rdtk_surface_free(surface);
|
||||||
|
|
||||||
|
rdtk_engine_free(engine);
|
||||||
|
|
||||||
invalidRect.left = 0;
|
invalidRect.left = 0;
|
||||||
invalidRect.top = 0;
|
invalidRect.top = 0;
|
||||||
invalidRect.right = width;
|
invalidRect.right = width;
|
||||||
|
Loading…
Reference in New Issue
Block a user