bool PG_ScrollBar::ScrollButton::eventMouseMotion(const SDL_MouseMotionEvent* motion) { PG_Point p; if(GetPressed()) { //SDL_GetMouseState(&x, &y); p = GetParent()->ScreenToClient(motion->x, motion->y); if(GetParent()->sb_direction == VERTICAL) { p.y -= offset.y; if(p.y < GetParent()->position[2].y) { p.y = GetParent()->position[2].y; } int maxy; if(!my_tickMode) { maxy = GetParent()->position[2].y + (GetParent()->position[2].h) - my_height; } else { maxy = GetParent()->my_height - my_height; } if(p.y > maxy) { p.y = maxy; } MoveWidget(GetParent()->position[2].x, p.y); } else { p.x -= offset.x; if(p.x < GetParent()->position[2].x) { p.x = GetParent()->position[2].x; } int maxx; if(!my_tickMode) { maxx = GetParent()->position[2].x + (GetParent()->position[2].w) - (my_width); } else { maxx = GetParent()->my_width - my_width; } if(p.x > maxx) { p.x = maxx; } MoveWidget(p.x, GetParent()->position[2].y); } int pos = GetPosFromPoint(p); if(GetParent()->scroll_current != pos || my_tickMode) { GetParent()->scroll_current = pos; GetParent()->sigScrollTrack(GetParent(), pos); } } return true; }
BOOL OpPersonalbar::ChangeItem(OpTreeModel* model, INT32 model_pos) { if( !model ) { return FALSE; } OpTreeModelItem* model_item = model->GetItemByPosition(model_pos); if( !model_item ) { return FALSE; } INT32 pos = FindItem(model_item->GetID(), model); if (pos == -1) return AddItem(model, model_pos); if (model_item->GetType() == SEARCHTEMPLATE_TYPE) { #ifdef DESKTOP_UTIL_SEARCH_ENGINES SearchTemplate* search = (SearchTemplate*) model_item; INT32 personalbar_pos = search->GetPersonalbarPos(); if (personalbar_pos != -1) { MoveWidget(pos, personalbar_pos); return TRUE; } #endif // DESKTOP_UTIL_SEARCH_ENGINES return RemoveItem(model, model_pos); } HotlistManager::ItemData item_data; if( !g_hotlist_manager->IsOnPersonalBar(model_item) ) { return RemoveItem(model, model_pos); } if( !g_hotlist_manager->GetItemValue(model_item, item_data ) ) { return FALSE; } OpWidget* widget = GetWidget(pos); widget->GetForegroundSkin()->SetImage(item_data.direct_image_pointer); if( ((HotlistModelItem*)model_item)->IsBookmark()) { Image icon = ((Bookmark*)model_item)->GetIcon(); widget->GetForegroundSkin()->SetBitmapImage( icon ); widget->GetForegroundSkin()->SetRestrictImageSize(TRUE); } widget->SetText(item_data.name.CStr()); if( item_data.personalbar_position != -1 ) { MoveWidget(pos,item_data.personalbar_position); } return TRUE; }