📄 buttons.c
字号:
#include <membox.h>
#include "GUI.h"
#include "Globalvars.h"
#include "pwin.h"
#include "guidebug.h"
#define BUTTON_DEFAULT_FONT F9x15_pwf
extern unsigned char xhuge _HeapGUI[GUI_HEAP_SIZE];
void cbPaintButton (Pw_GC * gc) {
Pw_Window* win;
Pw_Coord w, h, x, y, wt;
char *s;
win = Pw_GCGetWindow(gc);
Pw_WindowGetSize(win, &w, &h);
Pw_DrawFrameRect(gc, 0, 0, w, h, 2, NULL);
s = (char *) Pw_WindowGetClientData(win);
Pw_GCSetFont(gc, BUTTON_DEFAULT_FONT);
wt = Pw_FontGetStringWidth(gc->font, s);
x = (w - wt)/2;
y = Pw_GCGetFontHeight(gc)+(h - Pw_GCGetFontHeight(gc))/2 - Pw_FontGetDescent(gc->font)+1;
if (Pw_WindowIsInFocus(win)) {
Pw_GCSetColor(gc, pw_white_pixel);
Pw_FillRect(gc, 3, 3, w - 6, h - 6);
// Pw_DrawGrayTextBackgr(gc, 0, 0, w-1, h-1);
Pw_GCSetColor(gc, pw_black_pixel);
Pw_DrawString(gc, x, y, s);
}
else {
// Pw_DrawFrameRect(gc, 3, 3, w-6, h-6, 1, NULL);
Pw_GCSetColor(gc, pw_white_pixel);
Pw_DrawString(gc, x, y, s);
}
}
int cbButton (Pw_Event * ev) {
Pw_Window * win;
int CtrlType;
win = Pw_EventGetWindow(ev);
CtrlType = Pw_WindowGetClientDataId(win);
switch (Pw_EventGetType(ev)) {
case Pw_DestroyEventType :
// GUI_Log1("destroy BUTTON Button", (unsigned long)Pw_EventGetWindow(ev));
_free_boxh (_HeapGUI, Pw_EventGetWindow(ev));
return TRUE;
/* case Pw_KeyPressEventType:
key = ev->key.keycode;
switch (key) {
/* case ESC_KEY :
GUI_Log("BUTTON ESC");
BPA_GUI_SendMessage(win->parent, GUI_BUTTON_PRESSED, &CtrlType);//&MeasPoint);
return TRUE;
case ENTER_KEY :
GUI_Log("BUTTON ENTER");
BPA_GUI_SendMessage(win->parent, GUI_BUTTON_PRESSED, &CtrlType);//&MeasPoint);
return TRUE; */
}
return FALSE;
}
Pw_Window * CreateButton (const CONTROL_CREATE_INFO *info_struct ,
Pw_Window * Parent, Pw_EventCb cb) {
Pw_Window * butt;
butt = _calloc_boxh (_HeapGUI);
cb = cb;
Pw_WindowCreate(Parent, info_struct->x0, info_struct->y0,
info_struct->xSize, info_struct->ySize, butt);
//GUI_Log1("BUTTON ",(long) butt);
Pw_WindowSetClientDataId(butt, info_struct->ID);
Pw_WindowSetClientData(butt, info_struct->Data);
Pw_WindowSetRepaintCallback(butt, cbPaintButton);
Pw_WindowSetEventCallback(butt, cbButton);
Pw_WindowSetFocusAccept(butt, info_struct->FocusAccept);
Pw_WindowMap(butt);
return butt;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -