I want a Text label that reads degreesC - symbol, not the word degree. The only way I've found to do it is to copy a degree symbol from Character Map and then size the Text widget accordingly, then overwrite the degree symbol with \260, leaving me with a Text label reading "\260C" (can't do this with hex, only octal) so of course it looks rubbish in GUI Builder (but ok at run time.) Is there a better way to do this?
Degree symbol in GUI Builder
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
Hello,
there is only support of the base ASCII set in text editable parameters of the widgets in GUIBuilder.
The only thing you can do is generate the degree symbol as '°' in a text editor with extended symbols support (for example, in Word) and then paste it to the field "Content" of the text widget in GUIBuilder.
Alex. -
Hi,
the proper way is to use UTF8 encoding.
As LexaGB already said the GUIBuilder supports only the ASCII range.
You have to set other strings manually. After GUI_Init() call GUI_SetEncodeUTF8() to enable UTF8 encoding.
When setting a string to the TEXT widget you have to pass an UTF8 encoded string.
You can use the tool U2C.exe to convert a txt file (it has to be saved with UTF8 encoding without BOM) into a c-file with the UTF8 string.
More information can be found in the emWin user manual chapter 32.1.1 UTF-8 encoding.
Here is an example:
C Source Code
- #include "DIALOG.h"
- /*********************************************************************
- *
- * Externals
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * Types
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
- #define ID_TEXT_0 (GUI_ID_USER + 0x01)
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
- { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
- { TEXT_CreateIndirect, "Text", ID_TEXT_0, 20, 20, 80, 20, 0, 0x64, 0 },
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg) {
- WM_HWIN hItem;
- switch (pMsg->MsgId) {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Text'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
- TEXT_SetText(hItem, "\xc2\xb0""C");
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * _cbBk
- */
- static void _cbBk(WM_MESSAGE * pMsg) {
- switch (pMsg->MsgId) {
- case WM_PAINT:
- GUI_SetBkColor(GUI_BLACK);
- GUI_Clear();
- break;
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * MainTask
- */
- void MainTask(void) {
- GUI_Init();
- GUI_UC_SetEncodeUTF8();
- WM_MULTIBUF_Enable(1);
- WM_SetCallback(WM_HBKWIN, _cbBk);
- GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- while (1) {
- GUI_Delay(100);
- }
- }
- /*************************** End of file ****************************/
SvenPlease read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail. -
Thanks both.
Sven: I more-or-less tried this approach with the generated C file to set the Text widget, although I used octal rather than hex - I learnt something today from the use of hex in your code above! I did know how to do it in code - and when I tried, I didn't need to set anything to UTF-8 as the font used supported the character.
I rather suspected that I would need to do it manually if necessary, I just thought I'd check as I'm new to emWin. The approach I tried, by setting the text to "\260C" in GUI Builder works at run-time and if it only supports ASCII fonts then that's not surprising.
Thanks
Andrew
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0