static int slider_msg_proc (skin_item_t* item, int message, WPARAM wparam, LPARAM lparam) { int pos = 0; if ( item->style & SI_NRMSLIDER_STATIC ) return 0; /* assert (item != NULL) */ switch (message) { // case SKIN_MSG_CLICK: /* SLIDER_CHANGED event */ case SKIN_MSG_LBUTTONDOWN: case SKIN_MSG_MOUSEDRAG: /* SLIDER_CHANGED event */ pos = get_changed_pos (item, (int)wparam, (int)lparam); /* default operation */ if (skin_get_thumb_pos (item->hostskin, item->id) != pos) { skin_set_thumb_pos ( item->hostskin, item->id, pos); RAISE_EVENT ( SIE_SLIDER_CHANGED, (void *)pos ); } break; case SKIN_MSG_SETFOCUS: RAISE_EVENT ( SIE_GAIN_FOCUS, NULL ); break; case SKIN_MSG_KILLFOCUS: RAISE_EVENT ( SIE_LOST_FOCUS, NULL ); break; } return 1; }
void register_changed_pos (struct pos *p) { struct pos np; npos (p, &np); if (get_changed_pos (&np)) return; changed_pos = add_to_array (&np, 1, changed_pos, &changed_pos_nmemb, changed_pos_nmemb, sizeof (np)); qsort (changed_pos, changed_pos_nmemb, sizeof (np), (m_comparison_fn_t) cpos); }
void register_changed_pos (struct pos *p, enum changed_pos_reason reason) { struct pos np; npos (p, &np); struct changed_pos cp; cp.p = np; cp.reason = reason; if (get_changed_pos (&cp)) return; changed_pos = add_to_array (&cp, 1, changed_pos, &changed_pos_nmemb, changed_pos_nmemb, sizeof (*changed_pos)); qsort (changed_pos, changed_pos_nmemb, sizeof (*changed_pos), (m_comparison_fn_t) c_changed_pos); }
void optimize_changed_pos (void) { if (changed_pos_nmemb < FLOORS * PLACES) return; size_t total = 0; struct pos p; new_pos (&p, &global_level, -1, -1, -1); for (p.room = 1; p.room < ROOMS; p.room++) { int per_room = 0; if (has_room_changed (p.room)) continue; for (p.floor = 0; p.floor < FLOORS; p.floor++) for (p.place = 0; p.place < PLACES; p.place++) { if (get_changed_pos (&p) && ++per_room > OPTIMIZE_CHANGED_POS_THRESHOLD) { register_changed_room (p.room); goto next_room; } if (++total > changed_pos_nmemb) return; } next_room:; } }