void rclick_root(void) { XEvent ev; if (!grab(root, MouseMask, None)) { return; } draw_menubar(); do { XMaskEvent(dsply, MouseMask|KeyMask, &ev); switch (ev.type) { case MotionNotify: if (ev.xmotion.y < BARHEIGHT()) { ungrab(); rclick_taskbar(ev.xmotion.x); return; } break; case KeyPress: XPutBackEvent(dsply, &ev); break; } } while (ev.type != ButtonRelease && ev.type != KeyPress); redraw_taskbar(); ungrab(); }
static void render_screen(int page, int *maxindex) { DIR dir; FILINFO file; __Clear_Screen(0); draw_menubar("Run", "Refresh", "", "About"); f_opendir(&dir, "/"); if (!seek_dir(page, &dir, &file)) { debugf("Directory seek failed"); return; } int i; for (i = 0; i < ICONS_ON_SCREEN; ) { if (f_readdir(&dir, &file) != 0 || file.fname[0] == 0) break; if (is_a_script(file.fname)) { uint32_t icon_buf[32]; const uint32_t *icon = default_icon; int icon_size = 0; char name[20] = {0}; if (get_program_metadata(file.fname, icon_buf, &icon_size, name, sizeof(name))) { if (icon_size != 0) { icon = icon_buf; } } if (icon == default_icon) icon_size = DEFAULT_ICON_HEIGHT; if (name[0] == 0) memcpy(name, file.fname, 13); draw_item(i, icon, icon_size, name, ""); i++; } } if (f_readdir(&dir, &file) == 0 && file.fname[0] != 0) i++; *maxindex = i; if (*maxindex == 0) { draw_text("Please copy some .AMX files to the USB drive :)", 200, 100, 0xFFFF, 0, true); } }
static cell AMX_NATIVE_CALL amx_draw_menubar(AMX *amx, const cell *params) { char *b1, *b2, *b3, *b4; amx_StrParam(amx, params[1], b1); amx_StrParam(amx, params[2], b2); amx_StrParam(amx, params[3], b3); amx_StrParam(amx, params[4], b4); draw_menubar(b1, b2, b3, b4); return 0; }
void rclick_taskbar(int x) { XEvent ev; int mousex, mousey; Rect bounddims; unsigned int current_item = UINT_MAX; Window constraint_win; XSetWindowAttributes pattr; get_mouse_position(&mousex, &mousey); bounddims.x = 0; bounddims.y = 0; bounddims.width = DisplayWidth(dsply, screen); bounddims.height = BARHEIGHT(); constraint_win = XCreateWindow(dsply, root, bounddims.x, bounddims.y, bounddims.width, bounddims.height, 0, CopyFromParent, InputOnly, CopyFromParent, 0, &pattr); XMapWindow(dsply, constraint_win); if (!(XGrabPointer(dsply, root, False, MouseMask, GrabModeAsync, GrabModeAsync, constraint_win, None, CurrentTime) == GrabSuccess)) { XDestroyWindow(dsply, constraint_win); return; } draw_menubar(); update_menuitem(INT_MAX); // force initial highlight current_item = update_menuitem(x); do { XMaskEvent(dsply, MouseMask|KeyMask, &ev); switch (ev.type) { case MotionNotify: current_item = update_menuitem(ev.xmotion.x); break; case ButtonRelease: if (current_item != UINT_MAX) { fork_exec(menuitems[current_item].command); } break; case KeyPress: XPutBackEvent(dsply, &ev); break; } } while (ev.type != ButtonPress && ev.type != ButtonRelease && ev.type != KeyPress); redraw_taskbar(); XUnmapWindow(dsply, constraint_win); XDestroyWindow(dsply, constraint_win); ungrab(); }
static void draw_func (GtkDrawingArea *da, cairo_t *cr, int width, int height, gpointer data) { GtkWidget *widget = GTK_WIDGET (da); gint panewidth; gint x, y; panewidth = width / 2; cairo_rectangle (cr, 0, 0, width, height); cairo_set_source_rgb (cr, 0.9, 0.9, 0.9); cairo_fill (cr); x = y = 10; draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 30, GTK_STATE_FLAG_NORMAL, &height); y += height + 8; draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 40, GTK_STATE_FLAG_PRELIGHT, &height); y += height + 8; draw_horizontal_scrollbar (widget, cr, x, y, panewidth - 20, 50, GTK_STATE_FLAG_ACTIVE|GTK_STATE_FLAG_PRELIGHT, &height); y += height + 8; draw_text (widget, cr, x, y, panewidth - 20, 20, "Not selected", GTK_STATE_FLAG_NORMAL); y += 20 + 10; draw_text (widget, cr, x, y, panewidth - 20, 20, "Selected", GTK_STATE_FLAG_SELECTED); x = 10; y += 20 + 10; draw_check (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height); x += width + 10; draw_check (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height); x += width + 10; draw_radio (widget, cr, x, y, GTK_STATE_FLAG_NORMAL, &width, &height); x += width + 10; draw_radio (widget, cr, x, y, GTK_STATE_FLAG_CHECKED, &width, &height); x = 10; y += height + 10; draw_progress (widget, cr, x, y, panewidth - 20, 50, &height); y += height + 10; draw_scale (widget, cr, x, y, panewidth - 20, 75, &height); y += height + 20; draw_notebook (widget, cr, x, y, panewidth - 20, 160); /* Second column */ x += panewidth; y = 10; draw_menu (widget, cr, x, y, panewidth - 20, &height); y += height + 10; draw_menubar (widget, cr, x, y, panewidth - 20, &height); y += height + 20; draw_spinbutton (widget, cr, x, y, panewidth - 20, &height); y += height + 30; draw_combobox (widget, cr, x, y, panewidth - 20, FALSE, &height); y += height + 10; draw_combobox (widget, cr, 10 + panewidth, y, panewidth - 20, TRUE, &height); }
int main(void) { __Set(BEEP_VOLUME, 0); // USART1 8N1 115200bps debug port RCC->APB2ENR |= RCC_APB2ENR_USART1EN; USART1->BRR = 72000000 / 115200; USART1->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE; gpio_usart1_tx_mode(GPIO_AFOUT_10); gpio_usart1_rx_mode(GPIO_HIGHZ_INPUT); printf("\nBoot!\n"); // Reduce the wait states of the FPGA & LCD interface // It works for me, hopefully it works for you too :) FSMC_BTR1 = 0x10100110; FSMC_BTR2 = 0x10100110; __Set(ADC_CTRL, EN); __Set(ADC_MODE, SEPARATE); alterbios_init(); int status = alterbios_check(); if (status < 0) { char buf[100]; snprintf(buf, sizeof(buf), "AlterBIOS not found or too old: %d\n" "Please install it from https://github.com/PetteriAimonen/AlterBIOS", status); while (1) show_msgbox("AlterBIOS is required", buf); } get_keys(ALL_KEYS); // Clear key buffer while (true) { select_file(amx_filename); get_keys(ANY_KEY); __Clear_Screen(0); char error[50] = {0}; int status = loadprogram(amx_filename, error, sizeof(error)); if (status != 0) { char buffer[200]; snprintf(buffer, sizeof(buffer), "Loading of program %s failed:\n\n" "Error %d: %s\n\n" "%s\n", amx_filename, status, my_aux_StrError(status), error); printf(buffer); printf(amx_filename); show_msgbox("Program load failed", buffer); } else { int idle_func = -1; if (amx_FindPublic(&amx, "@idle", &idle_func) != 0) idle_func = -1; cell ret; status = amx_Exec(&amx, &ret, AMX_EXEC_MAIN); while (status == AMX_ERR_SLEEP) { AMX nested_amx = amx; uint32_t end = get_time() + amx.pri; do { status = doevents(&nested_amx); } while (get_time() < end && status == 0); if (status == 0) status = amx_Exec(&amx, &ret, AMX_EXEC_CONT); else amx = nested_amx; // Report errors properly } if (status == 0 && idle_func != -1) { // Main() exited, keep running idle function. do { status = doevents(&amx); if (status == 0) status = amx_Exec(&amx, &ret, idle_func); } while (status == 0 && ret != 0); } amxcleanup_wavein(&amx); amxcleanup_file(&amx); if (status == AMX_ERR_EXIT && ret == 0) status = 0; // Ignore exit(0), but inform about e.g. exit(1) if (status != 0) { show_pawn_traceback(amx_filename, &amx, status); } else { draw_menubar("Close", "", "", ""); while (!get_keys(BUTTON1)); } } } return 0; }