-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.c
More file actions
69 lines (65 loc) · 1.99 KB
/
Copy pathwidget.c
File metadata and controls
69 lines (65 loc) · 1.99 KB
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
#include "widget.h"
extern FILE *fp;
void wwWidget_Create(wwWidget *widget, wchar_t *text, int x, int y, int width, int height)
{
size_t size;
if(text != NULL){
size = wcslen(text) + 1;
widget->text = malloc(size * sizeof(wchar_t));
memcpy(widget->text, text, size * sizeof(wchar_t));
}
else
widget->text = NULL;
widget->x = x;
widget->y = y;
widget->width = width;
widget->height = height;
widget->callback = NULL;
widget->userData = NULL;
}
void wwWidget_SetCallback(wwWidget *widget, wwWidgetCallback callback, void *userData)
{
if(widget == NULL)
return;
widget->callback = callback;
widget->userData = userData;
}
void wwWidget_SetText(wwWidget *widget, wchar_t *text)
{
if(text == NULL)
return;
widget->text = text;
SetWindowTextW(widget->window, text);
}
void wwWidget_SetX(wwWidget *widget, int x)
{
widget->x = x;
SetWindowPos(widget->window, 0, widget->x, widget->y, widget->width, widget->height, SWP_NOZORDER | SWP_SHOWWINDOW);
}
void wwWidget_SetY(wwWidget *widget, int y)
{
widget->y = y;
SetWindowPos(widget->window, 0, widget->x, widget->y, widget->width, widget->height, SWP_NOZORDER | SWP_SHOWWINDOW);
}
void wwWidget_SetWidth(wwWidget *widget, int width)
{
widget->width = width;
SetWindowPos(widget->window, 0, widget->x, widget->y, widget->width, widget->height, SWP_NOZORDER | SWP_SHOWWINDOW);
}
void wwWidget_SetHeight(wwWidget *widget, int height)
{
widget->height = height;
SetWindowPos(widget->window, 0, widget->x, widget->y, widget->width, widget->height, SWP_NOZORDER | SWP_SHOWWINDOW);
}
wchar_t* wwWidget_GetText(wwWidget *widget)
{
int length = GetWindowTextLengthW(widget->window);
wchar_t *text = (wchar_t*) malloc((length + 1) * sizeof(wchar_t));
GetWindowTextW(widget->window, text, length);
return text;
}
void wwWidget_FreeFunc(void *data)
{
wwWidget *widget = (wwWidget*) data;
free(widget->text);
}