Thursday, November 23rd 2017, 12:08pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Geryhold

Beginner

Date of registration: Oct 16th 2017

Posts: 3

1

Monday, October 16th 2017, 10:39am

How to implement? - Lower underscore and blinking, as well as blinking character

Hi, Segger

How to implement? - Lower underscore and blinking, as well as blinking character in EDIT. And the movement of the symbol and the lower support is independent of each other.


Sorry my English is not very good, so I drew, what I need to get in the EDIT window.

How to implement it programmatically.

[img]https://scontent-frt3-1.xx.fbcdn.net/v/t1.0-9/22552535_1896558620356093_4505525865695238324_n.jpg?oh=f3635ca2c0454901d7b75a706f472a36&oe=5A701A24[/img]
Geryhold has attached the following image:
  • Безымянный.png

This post has been edited 1 times, last edit by "Geryhold" (Oct 16th 2017, 10:43am)


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 414

2

Wednesday, October 18th 2017, 4:01pm

Hi,

This is not that easy, because it is necessary to overwrite the callback function of the EDIT widget and take care about the whole drawing process.

Attached is an example on how you can overwrite the callback and achieve a blinking cursor. A blinking character independent of the cursor is even harder to achieve, but you might use the example as a starting point.

Regards
Sven
SEGGER - Schoenen has attached the following file:

Geryhold

Beginner

Date of registration: Oct 16th 2017

Posts: 3

3

Friday, October 27th 2017, 2:01am

Hi,

This is not that easy, because it is necessary to overwrite the callback function of the EDIT widget and take care about the whole drawing process.

Attached is an example on how you can overwrite the callback and achieve a blinking cursor. A blinking character independent of the cursor is even harder to achieve, but you might use the example as a starting point.

Regards
Sven

Thank you for your help. I managed to get the lower cursor flashing. I also entered a few additional variables (int16_t Cursor_Position to move the cursor, and then I will int16_t Char_Position to select the symbol and its flashing) with the type extern to transfer data from the main program.
Look at how I moved the bottom cursor, maybe I did not do it correctly or not optimally.
Also I can not make a choice of a symbol and its blinking. Help make the choice of the symbol and its blinking.

C/C++ Source code

1
2
3
4
5
6
7
8
9
/***********************************************************************       _cbEdit*/static void _cbEdit(WM_MESSAGE * pMsg) {  char      acBuffer[128];  GUI_COLOR BkColor;  GUI_COLOR FgColor;  GUI_RECT  Rect;  const GUI_FONT  * pFont;  int       Align;  int       xPos;  int       yPos;  int       Length;  int       CharIndex;  WM_HTIMER hTimer;	WM_HWIN hEdit;	WM_HWIN hItem;  int       Id;  static int OnOff, OnOffChar;
  switch (pMsg->MsgId) {  case WM_TIMER:    hTimer = (WM_HTIMER)pMsg->Data.v;    Id     = WM_GetTimerId(hTimer);    switch (Id) {    case ID_TIMER_CURSOR:      OnOff ^= 1;      WM_Invalidate(pMsg->hWin);      WM_RestartTimer(hTimer, 0);      break;    case ID_TIMER_CHAR:	    OnOffChar ^= 1;      WM_Invalidate(pMsg->hWin);      WM_RestartTimer(hTimer, 0);      break;    }    break;  case WM_PAINT:    BkColor = EDIT_GetBkColor(pMsg->hWin, EDIT_CI_ENABLED);    FgColor = EDIT_GetTextColor(pMsg->hWin, EDIT_CI_ENABLED);    Align   = GUI_TA_HCENTER | GUI_TA_VCENTER;    pFont   = EDIT_GetFont(pMsg->hWin);    EDIT_GetText(pMsg->hWin, acBuffer, sizeof(acBuffer));
    GUI_SetBkColor(BkColor);    GUI_SetColor(FgColor);    GUI_SetFont(pFont);    GUI_Clear();    WM_GetClientRect(&Rect);    GUI_DispStringInRect(acBuffer, &Rect, Align);    GUI_DrawRectEx(&Rect);    EDIT_GetCursorPixelPos(pMsg->hWin, &xPos, &yPos);    yPos += GUI_GetFontDistY();    xPos -= 1;    CharIndex = EDIT_GetCursorCharPos(pMsg->hWin);    Length = GUI_GetCharDistX(acBuffer[CharIndex]);	  /**** Drawing Cursor and blink *******/    if (Length) {      if (OnOff) {          GUI_DrawHLine(yPos +5, xPos + Cursor_Position * Length, xPos + (Cursor_Position + 1) * Length - 1);        GUI_DrawHLine(yPos +4, xPos + Cursor_Position * Length, xPos + (Cursor_Position + 1) * Length - 1);				GUI_DrawHLine(yPos +3, xPos + Cursor_Position * Length, xPos + (Cursor_Position + 1) * Length - 1);				GUI_DrawHLine(yPos +2, xPos + Cursor_Position * Length, xPos + (Cursor_Position + 1) * Length - 1);      }    }		/**** Drawing Char and blink *******/						hEdit = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);		//  EDIT_SetInsertMode(hEdit, 1);    //EDIT_SetBkColor (hEdit, EDIT_CI_DISABLED , GUI_GRAY);     //EDIT_SetBkColor (hEdit, EDIT_CI_ENABLED , GUI_WHITE); 	  //EDIT_SetDecMode(hItem, 1234567, 0, 9999999, 0, GUI_EDIT_NORMAL);	  //EDIT_SetTextColor(hEdit,EDIT_CI_ENABLED ,GUI_BLACK); 	  //EDIT_EnableBlink(hEdit, 500, 1);	  //EDIT_SetCursorAtChar(hEdit, 2);    sprintf(str01,"%05d", kolobok);		//acBuffer[2] = 0;    EDIT_SetText(hEdit, str01);	  //EDIT_SetTextAlign(hEdit, GUI_TA_HCENTER| GUI_TA_VCENTER);	//EDIT_SetFloatMode(hEdit, 555, 0.001, 999, 2, GUI_EDIT_NORMAL | GUI_EDIT_SUPPRESS_LEADING_ZEROES);   // WM_SetFocus(hEdit);				if (OnOffChar) 			{			        							}		    break;  default:    EDIT_Callback(pMsg);    break;  }}


// USER END
/***********************************************************************       _cbDialog*/static void _cbDialog(WM_MESSAGE * pMsg) {  WM_HWIN hItem;	WM_HWIN hEdit;  int     NCode;  int     Id;  // USER START (Optionally insert additional variables)  // USER END
  switch (pMsg->MsgId) {  case WM_INIT_DIALOG:    //    // Initialization of 'Window'    //    hItem = pMsg->hWin;    WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00FF8000));    //    // Initialization of 'Edit'    //    hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);	  //EDIT_SetText(hItem, "0");    EDIT_SetFont(hItem, GUI_FONT_D36X48);		  //EDIT_SetTextAlign(hItem, GUI_TA_RIGHT | GUI_TA_VCENTER);	  EDIT_SetDecMode(hItem, 1234567, 0, 9999999, 0, GUI_EDIT_NORMAL);    EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);    //EDIT_SetFont(hItem, &GUI_Font24B_1);    WM_SetCallback(hItem, _cbEdit);    WM_CreateTimer(hItem, ID_TIMER_CURSOR, 600, 0);		  WM_CreateTimer(hItem, ID_TIMER_CHAR, 600, 0); // Timer for char		// Initialization of 'KLEYMAN'    //    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);    BUTTON_SetText(hItem, "KLEYMAN");    BUTTON_SetFont(hItem, GUI_FONT_8X18);	        // USER START (Optionally insert additional code for further widget initialization)	  //hTimer1 = WM_CreateTimer(pMsg->hWin, 0, 100, 0); // 100mS INIT Timer    // USER END    break;			/*** IT IS MY CASE***************************************///	case WM_TIMER://  hEdit = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);//	//	//WM_SetTransState(hEdit,WM_CF_HASTRANS);//  EDIT_SetInsertMode(hEdit, 1);//  EDIT_SetBkColor (hEdit, EDIT_CI_DISABLED , GUI_GRAY); //  EDIT_SetBkColor (hEdit, EDIT_CI_ENABLED , GUI_WHITE); //	//	EDIT_SetTextColor(hEdit,EDIT_CI_ENABLED ,GUI_BLACK); //	EDIT_EnableBlink(hEdit, 500, 1);//	EDIT_SetCursorAtChar(hEdit, 2);//  sprintf(str01,"%05d", kolobok);	//  EDIT_SetText(hEdit, str01);//	EDIT_SetTextAlign(hEdit, GUI_TA_HCENTER| GUI_TA_VCENTER);//	//EDIT_SetFloatMode(hEdit, 555, 0.001, 999, 2, GUI_EDIT_NORMAL | GUI_EDIT_SUPPRESS_LEADING_ZEROES);//  WM_SetFocus(hEdit);//	//	//	//	//EDIT_SetSel(hEdit, 5, 5);//	//sprintf(str01,"Z: %05d", kolobok);	//  //EDIT_SetText(hEdit, str01);//	//	GUI_Exec();//	data_v = pMsg->Data.v;//	WM_RestartTimer(data_v, 10);//  break;	/*** IT IS MY CASE***************************************/	  case WM_NOTIFY_PARENT:    Id    = WM_GetId(pMsg->hWinSrc);    NCode = pMsg->Data.v;    switch(Id) {    case ID_EDIT_0: // Notifications sent by 'Edit'      switch(NCode) {      case WM_NOTIFICATION_CLICKED:        // USER START (Optionally insert code for reacting on notification message)        // USER END        break;      case WM_NOTIFICATION_RELEASED:        // USER START (Optionally insert code for reacting on notification message)        // USER END        break;      case WM_NOTIFICATION_VALUE_CHANGED:        // USER START (Optionally insert code for reacting on notification message)			//hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);    //EDIT_SetText(hItem, "5");        // USER END        break;      // USER START (Optionally insert additional code for further notification handling)      // USER END      }      break;    case ID_BUTTON_0: // Notifications sent by 'KLEYMAN'      switch(NCode) {      case WM_NOTIFICATION_CLICKED:        // USER START (Optionally insert code for reacting on notification message)        // USER END        break;      case WM_NOTIFICATION_RELEASED:        // USER START (Optionally insert code for reacting on notification message)        // USER END        break;      // USER START (Optionally insert additional code for further notification handling)      // USER END      }      break;    case ID_BUTTON_1: // Notifications sent by 'BREZMAN'      switch(NCode) {      case WM_NOTIFICATION_CLICKED:        // USER START (Optionally insert code for reacting on notification message)        // USER END        break;      case WM_NOTIFICATION_RELEASED:        // USER START (Optionally insert code for reacting on notification message)        // USER END        break;      // USER START (Optionally insert additional code for further notification handling)      // USER END      }      break;    // USER START (Optionally insert additional code for further Ids)			    // USER END    }    break;  // USER START (Optionally insert additional message handling)				  // USER END  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;  }}


..............................................................MAIN CODE
.........................
while (1) { GUI_Delay(100); Cursor_Position=3; }
Geryhold has attached the following files:
  • WindowDLG.zip (2.75 kB - 8 times downloaded - Last download: Nov 20th 2017, 8:53am)
  • WindowDLG.zip (301 Byte - 12 times downloaded - Last download: Nov 21st 2017, 5:48pm)

Geryhold

Beginner

Date of registration: Oct 16th 2017

Posts: 3

4

Sunday, November 5th 2017, 11:04pm

SEGGER - Schoenen very strongly you I ask to help or assist me, to choose a symbol and its or his blinking/ not blinking