void DraggableListCtrl::OnMouseEvent(wxMouseEvent& event) { // Only care when in drag-mode if (! HasCapture()) { event.Skip(); return; } if (event.LeftUp()) { // Finished dragging; stop responding to mouse motion OnEndDrag(); ReleaseMouse(); } else if (event.Dragging()) { // Find which item the mouse is now over int flags; long dragTarget = HitTest(event.GetPosition(), flags); if (dragTarget == wxNOT_FOUND) { // Not over an item. Scroll the view up/down if the mouse is // outside the listctrl. if (flags & wxLIST_HITTEST_ABOVE) ScrollList(0, -ScrollSpeed); else if (flags & wxLIST_HITTEST_BELOW) ScrollList(0, ScrollSpeed); } else if (flags & wxLIST_HITTEST_ONITEM && dragTarget != m_DragSource) { // Move the source item to the location under the mouse AtlasWindowCommandProc* commandProc = AtlasWindowCommandProc::GetFromParentFrame(this); commandProc->Submit(new DragCommand(this, m_DragSource, dragTarget)); // and remember that the source item is now in a different place m_DragSource = dragTarget; } } else // Some other kind of event which we're not interested in - ignore it event.Skip(); }
void CShop::HandleCommands( const char *menuCommand, idUserInterface *gui ) { if( idStr::Icmp( menuCommand, "shopLoad" ) == 0 ) { // Clear out the shop Init(); // get list of all items that can be sold LoadShopItemDefinitions(); // init and update the shop GUI DisplayShop( gui ); // refresh the display so items are greyed out gui->HandleNamedEvent( "UpdateItemColours" ); } else if( idStr::Icmp( menuCommand, "shopBuy" ) == 0 ) { // Buy an item int boughtItem = gui->GetStateInt( "boughtItem", "0" ); BuyItem( boughtItem ); UpdateGUI( gui ); } else if( idStr::Icmp( menuCommand, "shopSold" ) == 0 ) { // Return an item to the shelf int soldItem = gui->GetStateInt( "soldItem", "0" ); SellItem( soldItem ); UpdateGUI( gui ); } else if( idStr::Icmp( menuCommand, "shopDropUndrop" ) == 0 ) { // Drop one of the starting items int dropItem = gui->GetStateInt( "dropItem", "0" ); // Decide depending on the item if we should drop or undrop DropUndropItem( dropItem ); UpdateGUI( gui ); } else if( idStr::Icmp( menuCommand, "shopMore" ) == 0 ) { const char *listName = gui->GetStateString( "moreList", "" ); if( idStr::Icmp( listName, "forSale" ) == 0 ) { _forSaleTop = ScrollList( _forSaleTop, LIST_SIZE_FOR_SALE, _itemsForSale ); } else if( idStr::Icmp( listName, "starting" ) == 0 ) { _startingTop = ScrollList( _startingTop, LIST_SIZE_STARTING, _startingItems ); } else if( idStr::Icmp( listName, "purchased" ) == 0 ) { _purchasedTop = ScrollList( _purchasedTop, LIST_SIZE_PURCHASED, _itemsPurchased ); } UpdateGUI( gui ); } else if( idStr::Icmp( menuCommand, "shopDone" ) == 0 ) { // The player is done shopping, now set up the starting equipment CopyPurchasedIntoStartingEquipment(); } }
void wxListCtrlEx::ScrollTopItem(int item) { const int current = GetTopItem(); int delta = item - current; if (!delta) return; wxRect rect; GetItemRect(current, rect, wxLIST_RECT_BOUNDS); delta *= rect.GetHeight(); ScrollList(0, delta); }
void wxListCtrlEx::ScrollTopItem(int item) { #ifdef __WXMSW__ const int current = GetTopItem(); int delta = item - current; if (!delta) return; wxRect rect; GetItemRect(current, rect, wxLIST_RECT_BOUNDS); delta *= rect.GetHeight(); ScrollList(0, delta); #else GetMainWindow()->Scroll(0, item); EnsureVisible(item); #endif }
void RtListBox::AutoScroll() { if ( m_iLastScroll != 0 ) { if ( m_iLastScroll > 0) { m_iLastScroll -= __AutoScroll_INTERVAL__; } else { m_iLastScroll += __AutoScroll_INTERVAL__; } ScrollList(m_iLastScroll); m_iLastScroll -= m_iLastScroll%__AutoScroll_INTERVAL__; } else { m_pQTimerScroll->stop(); } }
bool SelectLanguage() { if (InstallInfo.languages.size() == 1) { InstallInfo.cur_lang = InstallInfo.languages.front(); if (!ReadLang()) throwerror(true, "Could not load language file for %s", InstallInfo.cur_lang.c_str()); return true; } char title[] = "<C></B/29>Please select a language<!29!B>"; std::vector<char *> LangItems; ButtonBar.Clear(); ButtonBar.AddButton("Arrows", "Navigate menu"); ButtonBar.AddButton("A", "About"); ButtonBar.AddButton("ESC", "Exit program"); ButtonBar.Draw(); for (std::list<std::string>::iterator p=InstallInfo.languages.begin();p!=InstallInfo.languages.end();p++) LangItems.push_back(MakeCString(*p)); CCDKScroll ScrollList(CDKScreen, CENTER, CENTER, GetMaxHeight(20), GetMaxWidth(45), RIGHT, title, &LangItems[0], LangItems.size()); ScrollList.SetBgColor(5); ScrollList.Bind('a', ShowAboutK); int selection = ScrollList.Activate(); if (ScrollList.ExitType() == vNORMAL) { InstallInfo.cur_lang = LangItems[selection]; ReadLang(); } else return false; return true; }
bool ConfParams() { param_entry_s *pFirstParam = NULL; std::vector<char *> ParamItems; for (std::list<command_entry_s *>::iterator p=InstallInfo.command_entries.begin();p!=InstallInfo.command_entries.end(); p++) { for (std::map<std::string, param_entry_s *>::iterator p2=(*p)->parameter_entries.begin(); p2!=(*p)->parameter_entries.end();p2++) { if (!pFirstParam) pFirstParam = p2->second; ParamItems.push_back(MakeCString(p2->first)); } } if (!pFirstParam) return true; // No command entries...no need for this screen char *title = CreateText("<C></B/29>%s<!29!B>", GetTranslation("Configure parameters")); char *buttons[3] = { GetTranslation("Edit parameter"), GetTranslation("Continue"), GetTranslation("Cancel") }; ButtonBar.Clear(); ButtonBar.AddButton("TAB", "Next button"); ButtonBar.AddButton("ENTER", "Activate button"); ButtonBar.AddButton("Arrows", "Navigate menu"); ButtonBar.AddButton("A", "About"); ButtonBar.AddButton("ESC", "Exit program"); ButtonBar.Draw(); CCDKButtonBox ButtonBox(CDKScreen, CENTER, GetDefaultHeight()-1, 1, GetDefaultWidth(), 0, 1, 3, buttons, 3); ButtonBox.SetBgColor(5); CCDKScroll ScrollList(CDKScreen, getbegx(ButtonBox.GetBBox()->win), 2, getbegy(ButtonBox.GetBBox()->win)-1, GetDefaultWidth()/2, RIGHT, title, &ParamItems[0], ParamItems.size()); ScrollList.SetBgColor(5); ScrollList.Bind('a', ShowAboutK); const int defh = 3; CCDKSWindow DescWindow(CDKScreen, (getbegx(ScrollList.GetScroll()->win) + getmaxx(ScrollList.GetScroll()->win))-1, 2, getmaxy(ScrollList.GetScroll()->win)-defh-1, (GetDefaultWidth()/2)+1, CreateText("<C></B/29>%s<!29!B>", GetTranslation("Description")), 30); DescWindow.SetBgColor(5); DescWindow.AddText(GetTranslation(pFirstParam->description)); CCDKSWindow DefWindow(CDKScreen, (getbegx(ScrollList.GetScroll()->win) + getmaxx(ScrollList.GetScroll()->win))-1, getmaxy(DescWindow.GetSWin()->win), defh, (GetDefaultWidth()/2)+1, NULL, 4); DefWindow.SetBgColor(5); const char *str = pFirstParam->defaultval.c_str(); if (pFirstParam->param_type == PTYPE_BOOL) { if (!strcmp(str, "true")) str = GetTranslation("Enabled"); else str = GetTranslation("Disabled"); } DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Default"), str), false); DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Current"), str), false); setCDKScrollLLChar(ScrollList.GetScroll(), ACS_LTEE); setCDKScrollLRChar(ScrollList.GetScroll(), ACS_BTEE); setCDKScrollURChar(ScrollList.GetScroll(), ACS_TTEE); setCDKSwindowULChar(DescWindow.GetSWin(), ACS_TTEE); setCDKSwindowLLChar(DescWindow.GetSWin(), ACS_LTEE); setCDKSwindowLRChar(DescWindow.GetSWin(), ACS_RTEE); setCDKSwindowURChar(DefWindow.GetSWin(), ACS_RTEE); setCDKSwindowLRChar(DefWindow.GetSWin(), ACS_RTEE); setCDKButtonboxULChar(ButtonBox.GetBBox(), ACS_LTEE); setCDKButtonboxURChar(ButtonBox.GetBBox(), ACS_RTEE); ButtonBox.Draw(); DescWindow.Draw(); DefWindow.Draw(); void *Data[4] = { &DescWindow, &DefWindow, &ScrollList, &ParamItems }; setCDKScrollPreProcess(ScrollList.GetScroll(), ScrollParamMenuK, &Data); ScrollList.Bind(KEY_TAB, SwitchButtonK, ButtonBox.GetBBox()); bool success = false; while(1) { int selection = ScrollList.Activate(); if (ScrollList.ExitType() == vNORMAL) { if (ButtonBox.GetCurrent() == 1) { success = true; break; } else if (ButtonBox.GetCurrent() == 2) { success = false; break; } param_entry_s *pParam = GetParamByName(ParamItems[selection]); if (pParam->param_type == PTYPE_DIR) { CFileDialog filedialog(GetFirstValidDir(pParam->value), CreateText("<C>%s", GetTranslation("Select a directory")), true, false); if (filedialog.Activate()) pParam->value = filedialog.Result(); filedialog.Destroy(); refreshCDKScreen(CDKScreen); } else if (pParam->param_type == PTYPE_STRING) { CCDKEntry entry(CDKScreen, CENTER, CENTER, GetTranslation("Please enter new value"), "", 40, 0, 256); entry.SetBgColor(26); entry.SetValue(pParam->value); const char *newval = entry.Activate(); if ((entry.ExitType() == vNORMAL) && newval) pParam->value = newval; // Restore screen entry.Destroy(); refreshCDKScreen(CDKScreen); } else { std::vector<char *> chitems; int cur = 0; if (pParam->param_type == PTYPE_BOOL) { chitems.push_back(GetTranslation("Disable")); chitems.push_back(GetTranslation("Enable")); cur = (pParam->value == "true") ? 1 : 0; } else { int i = 0; for (std::list<std::string>::iterator it=pParam->options.begin(); it!=pParam->options.end();it++, i++) { chitems.push_back(GetTranslation(MakeCString(*it))); if (*it == pParam->value) cur = i; } } CCDKScroll chScrollList(CDKScreen, CENTER, CENTER, 6, 30, RIGHT, GetTranslation("Please choose new value"), &chitems[0], chitems.size()); chScrollList.SetBgColor(26); chScrollList.SetCurrent(cur); int chsel = chScrollList.Activate(); if (chScrollList.ExitType() == vNORMAL) { if (pParam->param_type == PTYPE_BOOL) { if (!strcmp(chitems[chsel], GetTranslation("Enable"))) pParam->value = "true"; else pParam->value = "false"; } else pParam->value = chitems[chsel]; } chScrollList.Destroy(); refreshCDKScreen(CDKScreen); } DefWindow.Clear(); DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Default"), GetParamDefault(pParam)), false); DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Current"), GetParamValue(pParam)), false); } else { success = false; break; } } return success; }