📄 waypointdialog.cpp
字号:
/* GHelm - Nautical Navigation Software * Copyright (C) 2005 Jon Michaelchuck * * This application is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */#include "waypointdialog.h"#include "util.h"/** * Constructor */WaypointDialog::WaypointDialog(){ set_title("Edit Waypoint"); add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); Gtk::VBox *vbox = get_vbox(); Gtk::HBox *name_box = manage(new Gtk::HBox()); Gtk::HBox *lat_box = manage(new Gtk::HBox()); Gtk::HBox *long_box = manage(new Gtk::HBox()); Gtk::Label *name_label = manage(new Gtk::Label("Name: ")); Gtk::Label *lat_label = manage(new Gtk::Label("Latitude: ")); Gtk::Label *long_label = manage(new Gtk::Label("Longitude: ")); name_box->add(*name_label); name_box->add(name_entry); lat_box->add(*lat_label); lat_box->add(lat_deg_entry); lat_box->add(lat_min_entry); long_box->add(*long_label); long_box->add(long_deg_entry); long_box->add(long_min_entry); vbox->add(*name_box); vbox->add(*lat_box); vbox->add(*long_box);}/** * Destructor */WaypointDialog::~WaypointDialog(){}/** * Run the dialog * @param x x position to add point * @param y y position to add point * @return waypoint added */waypoint_t *WaypointDialog::Run(double x, double y){ std::pair<std::string, std::string> longitude = GetLongLatStringPair(x); std::pair<std::string, std::string> latitude = GetLongLatStringPair(y); long_deg_entry.set_text(longitude.first); long_min_entry.set_text(longitude.second); lat_deg_entry.set_text(latitude.first); lat_min_entry.set_text(latitude.second); show_all(); switch (Gtk::Dialog::run()) { case Gtk::RESPONSE_OK: waypoint.longlat[0] = (atof(long_deg_entry.get_text().c_str()) * 60) + (atof(long_min_entry.get_text().c_str())); waypoint.longlat[1] = (atof(lat_deg_entry.get_text().c_str()) * 60) + (atof(lat_min_entry.get_text().c_str())); waypoint.name = name_entry.get_text(); break; default: return NULL; } return &waypoint;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -