void MapCanvas::mousePressEvent( QMouseEvent *e ) { LocationDialog *ld = (LocationDialog *)topLevelWidget(); //Determine Lat/Long corresponding to event press int lng = ( e->x() - origin.x() ); int lat = ( origin.y() - e->y() ); ld->findCitiesNear( lng, lat ); }
MapCanvas::MapCanvas(QWidget *parent, const char *name ) : QWidget(parent,name) { BGColor = "#33A"; setBackgroundColor( QColor( BGColor ) ); setBackgroundMode( QWidget::NoBackground ); Canvas = new QPixmap(); bgImage = new QPixmap(); LocationDialog *ld = (LocationDialog *)topLevelWidget(); KStars *ks = (KStars *)ld->parent(); QString bgFile = ks->data()->stdDirs->findResource( "data", "kstars/geomap.png" ); bgImage->load( bgFile, "PNG" ); }
void ScreenSetup::doLocationDialog(ScreenListInfo *si) { MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); LocationDialog *locdialog = new LocationDialog(mainStack, "locationdialog", this, si, m_sourceManager); if (locdialog->Create()) mainStack->AddScreen(locdialog); else delete locdialog; }
LRESULT CALLBACK MapProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) // Handle a message for map window. { LocationDialog *theDlg = (LocationDialog *)GetWindowLongPtr( hwnd, GWLP_USERDATA ); // These are the messages we handle specially. switch (msg) { case WM_LBUTTONDOWN: case WM_MOUSEMOVE: // Eat these messages. return TRUE; case WM_LBUTTONUP: theDlg->mapClick(GetParent(hwnd), hwnd); return TRUE; } // Pass it on. return (CallWindowProc(theDlg->oldMapProc, hwnd, msg, wparam, lparam)); }
void AccountActionsManager::handleAccountSetLocation () { IAccount *account = GetAccountFromSender (sender (), Q_FUNC_INFO); if (!account) return; QObject *obj = account->GetQObject (); ISupportGeolocation *loc = qobject_cast<ISupportGeolocation*> (obj); if (!loc) { qWarning () << Q_FUNC_INFO << obj << "doesn't support geolocation"; return; } LocationDialog dia (MW_); if (dia.exec () != QDialog::Accepted) return; loc->SetGeolocationInfo (dia.GetInfo ()); }
void LocationEditor::setGeography(qint32 lid, double longitude, double latitude, double altitude, QString placeName) { this->startLongitude = longitude; this->startLatitude = latitude; this->startAltitude = altitude; currentLid = lid; Note n; NoteTable ntable(global.db); ntable.get(n, lid, false, false); NoteAttributes attributes; if (n.attributes.isSet()) attributes = n.attributes; if (!attributes.latitude.isSet() || !attributes.longitude.isSet()) return; if (placeName == "") { LocationDialog dialog; dialog.setLongitude(this->startLongitude); dialog.setLatitude(this->startLatitude); dialog.setAltitude(this->startAltitude); this->setText(dialog.locationText()); } else this->setText(placeName); }
void LocationEditor::buttonClicked() { LocationDialog dialog; dialog.setLongitude(this->startLongitude); dialog.setLatitude(this->startLatitude); dialog.setAltitude(this->startAltitude); dialog.exec(); double lon = dialog.getLongitude(); double lat = dialog.getLatitude(); double alt = dialog.getAltitude(); startAltitude = alt; startLongitude = lon; startLatitude = lat; if (dialog.okPressed()) { NoteTable ntable(global.db); if (lon == 0.0 && lat == 0.0) { setText(defaultText); ntable.resetGeography(currentLid, true); return; } this->setText(dialog.locationText()); ntable.setGeography(currentLid, lon,lat,alt, true); } }
void MapCanvas::paintEvent( QPaintEvent * ) { QPainter pcanvas; LocationDialog *ld = (LocationDialog *)topLevelWidget(); KStars *ks = (KStars *)ld->parent(); //prepare the canvas pcanvas.begin( Canvas ); // pcanvas.fillRect( 0, 0, width(), height(), QBrush( QColor( BGColor ) ) ); pcanvas.drawPixmap( 0, 0, *bgImage ); // pcanvas.setBrush( white ); pcanvas.setPen( QPen( QColor( "SlateGrey" ) ) ); //Draw cities QPoint o; for ( GeoLocation *g=ks->data()->geoList.first(); g; g = ks->data()->geoList.next() ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) { pcanvas.drawPoint( o.x(), o.y() ); } } //redraw the cities that appear in the filtered list, with a white pen //If the list has not been filtered, skip the redraw. if ( ld->filteredList()->count() ) { pcanvas.setPen( white ); for ( GeoLocation *g=ld->filteredList()->first(); g; g = ld->filteredList()->next() ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) { pcanvas.drawPoint( o.x(), o.y() ); } } } GeoLocation *g = ld->selectedCity(); if ( g ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); pcanvas.setPen( red ); pcanvas.setBrush( red ); pcanvas.drawEllipse( o.x()-3, o.y()-3, 6, 6 ); pcanvas.moveTo( o.x()-16, o.y() ); pcanvas.lineTo( o.x()-8, o.y() ); pcanvas.moveTo( o.x()+8, o.y() ); pcanvas.lineTo( o.x()+16, o.y() ); pcanvas.moveTo( o.x(), o.y()-16 ); pcanvas.lineTo( o.x(), o.y()-8 ); pcanvas.moveTo( o.x(), o.y()+8 ); pcanvas.lineTo( o.x(), o.y()+16 ); pcanvas.setPen( white ); pcanvas.setBrush( white ); } pcanvas.end(); bitBlt( this, 0, 0, Canvas ); }
static INT_PTR CALLBACK GetLocationDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { LocationDialog *theDlg = (LocationDialog *)GetWindowLongPtr( hWnd, GWLP_USERDATA ); Interval valid = FOREVER; HWND hMap = GetDlgItem(hWnd, IDC_MAP_PICTURE); switch (msg) { case WM_INITDIALOG: theDlg = (LocationDialog *)lParam; SetWindowLongPtr( hWnd, GWLP_USERDATA, (LONG_PTR)theDlg ); // Set the initial lat and long. theDlg->updatedLatitude = (double)theDlg->theLatitude; theDlg->updatedLongitude = (double)theDlg->theLongitude; // Subclass the map owner draw button. theDlg->oldMapProc = (WNDPROC)GetWindowLongPtr(hMap, GWLP_WNDPROC); SetWindowLongPtr(hMap, GWLP_WNDPROC, (LONG_PTR)MapProc); SetWindowLongPtr(hMap, GWLP_USERDATA, (LONG_PTR)theDlg ); // Initialize items. theDlg->initCityList(); theDlg->initMapList(GetDlgItem(hWnd, IDC_MAP_NAME)); theDlg->changeMap(hWnd, hMap); CenterWindow(hWnd,GetParent(hWnd)); #ifdef DAYLIGHT_CITY_PICKER_BIG_CITY_DEFAULT SetCheckBox(hWnd, IDC_NEAREST, true); #endif // DAYLIGHT_CITY_PICKER_BIG_CITY_DEFAULT break; case WM_DRAWITEM: theDlg->displayMap(hWnd, ((LPDRAWITEMSTRUCT)lParam)->hwndItem); theDlg->displayCross(hWnd, theDlg->theLatitude, theDlg->theLongitude); break; case WM_COMMAND: // First check for ok or cancel. switch (LOWORD(wParam)) { case IDOK: EndDialog(hWnd,1); break; case IDCANCEL: EndDialog(hWnd,0); break; } // Then check for notifications. switch(HIWORD(wParam)) { case LBN_SELCHANGE: // User chose a city from the list box or map from combo box. if (GetDlgItem(hWnd, IDC_CITYLIST) == (HWND)lParam) theDlg->chooseCity(hWnd, SendMessage((HWND)lParam, LB_GETCURSEL,0,0)); else { int sel = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0); if (theDlg->mapIndex != sel) { lastMap = theDlg->mapIndex = sel; lastCity = 0; theDlg->changeMap(hWnd, GetDlgItem(hWnd, IDC_MAP_PICTURE)); } } break; case LBN_DBLCLK: // User may have double-clicked a city; if so, accept it and end dialog. if (GetDlgItem(hWnd, IDC_CITYLIST) == (HWND)lParam) { theDlg->chooseCity(hWnd, SendMessage((HWND)lParam, LB_GETCURSEL,0,0)); EndDialog(hWnd,1); } break; default: break; } break; default: return 0; } return 1; }