Sunday, October 22nd 2017, 1:10am UTC+2

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.

Damaso

Beginner

Date of registration: Nov 20th 2014

Posts: 4

1

Tuesday, December 2nd 2014, 3:59pm

Drawing over widgets

I'm using a Windows Manager to create a window with some widgets in it: logo image, buttons and an iconview. I want to be able to use 2D draw functions to paint lines and such in that window.
At the moment, I'm using the WM_PAINT event to draw lines, but they are drawn "behind" the widgets. Even with WM_SetHasTrans(), I'm not abe to draw "above" them.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*********************************************************************
*
*   	_aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { WINDOW_CreateIndirect, "MenuPrincipal", ID_W1_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "B_MainMenu", ID_W1_BUTTON_0, 2, 0, 116, 32, 0, 0x0, 0 },
  { PROGBAR_CreateIndirect, "PB_Battery", ID_W1_PROGBAR_0, 412, 249, 64, 20, 0, 0x0, 0 },
  { ICONVIEW_CreateIndirect, "IV_Icons", ID_W1_ICONVIEW_0, 0, 70, 480, 110, 0, 0x00640064, 0 },
  { IMAGE_CreateIndirect, "I_Logo", ID_W1_IMAGE_0, 310, 16, 120, 30, 0, 0, 0 },
  { BUTTON_CreateIndirect, "B_Off", ID_W1_BUTTON_1, 446, 0, 32, 32, 0, 0x0, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*   	Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*   	_cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN  	hItem;
  int      	NCode;
  int      	Id;
  unsigned char iNumIcon = 0;
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
	case WM_PAINT:
    	WM_DefaultProc(pMsg);
    	GUI_SetPenSize(4);
    	GUI_SetColor(GUI_BLACK);
    	GUI_DrawLine(x0, y0, x1, y1);
    	GUI_DrawPoint(ts.x, ts.y);
  	break;
	case WM_INIT_DIALOG:
	//
	// Initialization of 'MenuPrincipal'
	//
	hItem = pMsg->hWin;
	WINDOW_SetBkColor(hItem, 0x00886040);
	//
	// Initialization of 'B_MainMenu'
	//
	hItem = WM_GetDialogItem(pMsg->hWin, ID_W1_BUTTON_0);
	BUTTON_SetFont(hItem, GUI_FONT_16_1);
	LangDataArray_GetLabel(W01L01, WindowsLabelText);
	BUTTON_SetText(hItem, WindowsLabelText);
	WM_SetHasTrans(hItem);
//
	// Initialization of 'IV_Icons'
	//
	hItem = WM_GetDialogItem(pMsg->hWin, ID_W1_ICONVIEW_0);
	LangDataArray_GetLabel(W01L02, WindowsLabelText);
	ICONVIEW_AddBitmapItem(hItem,&bmLOOP,WindowsLabelText);
	LangDataArray_GetLabel(W01L03, WindowsLabelText);
	ICONVIEW_AddBitmapItem(hItem,&bmTESTER,WindowsLabelText);
	LangDataArray_GetLabel(W01L04, WindowsLabelText);
	ICONVIEW_AddBitmapItem(hItem,&bmREGIST,WindowsLabelText);
	LangDataArray_GetLabel(W01L05, WindowsLabelText);
	ICONVIEW_AddBitmapItem(hItem,&bmCONFIG,WindowsLabelText);
	ICONVIEW_SetBkColor(hItem, ICONVIEW_CI_BK, 0x00886040);  //Color del background normalmente
	ICONVIEW_SetBkColor(hItem, ICONVIEW_CI_SEL, GUI_BLUE | 0xC0000000);  //Color del BK cuando seleccionas
	ICONVIEW_SetFont(hItem, GUI_FONT_13B_1);
	ICONVIEW_SetFrame(hItem,GUI_COORD_X,22);
	ICONVIEW_SetSpace(hItem,GUI_COORD_X,12);
WM_SetHasTrans(hItem);
	//
	// Initialization of 'I_Logo'
	//
	hItem = WM_GetDialogItem(pMsg->hWin, ID_W1_IMAGE_0);
	IMAGE_SetBitmap(hItem,&bmLOGO_ESSER);
	WM_SetHasTrans(hItem);
//
	// Initialization of 'B_Off'
	//
	hItem = WM_GetDialogItem(pMsg->hWin, ID_W1_BUTTON_1);
	BUTTON_SetText(hItem, "");
	BUTTON_SetBitmap(hItem,BUTTON_BI_UNPRESSED,&bmB_OFF);
	WM_SetHasTrans(hItem);
//
	// Initialization of 'PB_Battery'
	//
	hItem = WM_GetDialogItem(pMsg->hWin, ID_W1_PROGBAR_0);
	PROGBAR_SetBarColor(hItem, 0, GUI_GREEN);   //Color de barra de la parte izquierda
	PROGBAR_SetBarColor(hItem, 1, 0x00AFAFAF);   //Color de barra de la parte derecha
	PROGBAR_SetMinMax(hItem, 0, 100);
	PROGBAR_SetFont(hItem, GUI_FONT_16_1);
	PROGBAR_SetTextColor(hItem, 0, GUI_BLACK);  //Color de texto de la parte izquierda
	PROGBAR_SetTextColor(hItem, 1, GUI_BLACK);  //Color de texto de la parte derecha
	BatLevel(&hItem);
WM_SetHasTrans(hItem);
	//
	// Initialization of "Plug Icon"
	//
	PlugDetection();
	// USER START (Optionally insert additional code for further widget initialization)
	// USER END
	break;
  case WM_NOTIFY_PARENT:
	Id	= WM_GetId(pMsg->hWinSrc);
	NCode = pMsg->Data.v;
	if (NCode == WM_NOTIFICATION_RELEASED)
    	PWM_BUZ_Tick();
	switch(Id) {
	case ID_W1_BUTTON_0: // Notifications sent by 'B_MainMenu'
  	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_W1_ICONVIEW_0: // Notifications sent by 'IV_Icons'
  	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)

    	iNumIcon = ICONVIEW_GetSel(pMsg->hWinSrc);
    	switch(iNumIcon){
        	case 0: //Icono Lazo
            	Trans_MPtoMP_L();
            	break;
        	case 1: //Icono Multimetro
            	Trans_MPtoMP_M();
            	break;
        	case 2: //Icono Registro
            	Trans_MPtoMP_R();
            	break;
        	case 3: //Icono Configurar
            	Trans_MPtoMP_C();
            	break;
    	}
    	// USER END
    	break;
  	case WM_NOTIFICATION_MOVED_OUT:
    	// USER START (Optionally insert code for reacting on notification message)
    	// USER END
    	break;
  	case WM_NOTIFICATION_SCROLL_CHANGED:
    	// USER START (Optionally insert code for reacting on notification message)
    	// USER END
    	break;
  	case WM_NOTIFICATION_SEL_CHANGED:
    	// 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_W1_BUTTON_1: // Notifications sent by 'B_Off'
  	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)

//    	SystemState++;
    	// 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;
  }
}

/*********************************************************************
*
*   	Public code
*
**********************************************************************
*/
/*********************************************************************
*
*   	CreateMenuPrincipal
*/

WM_HWIN CreateMenuPrincipal(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  return hWin;
}


Is there a way to acheive this behaviour?

SEGGER - Adrian

Super Moderator

Date of registration: May 26th 2009

Posts: 994

2

Friday, December 5th 2014, 9:26am

Hello,

Yes, of course. You are currently drawing within the paint event of the dialog. The child windows are drawn on top of the dialog. If you want to draw something which should be part of a certain window, you will have to create a custom callback function of the according window.

Best regards,
Adrian