Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4068 in orxonox.OLD


Ignore:
Timestamp:
May 5, 2005, 9:34:08 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: new Widget for FileSelector

Location:
orxonox/trunk/src/lib/gui/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/gui/gui/gui_exec.cc

    r4062 r4068  
    6969      this->saveSettings->saveability();
    7070      execBox->fill(this->saveSettings);
     71
    7172      verboseMode = new Menu("verbose mode", "nothing", "error", "warning", "info", "lastItem");
    7273      verboseMode->setFlagName("verbose", "v", 2);
    7374      verboseMode->saveability();
    7475      execBox->fill(verboseMode);
     76
    7577      alwaysShow = new CheckButton("Always Show this Menu");
    7678      alwaysShow->setFlagName("gui", "g", 0);
    7779      alwaysShow->saveability();
    7880      execBox->fill(alwaysShow);
     81
    7982      quit = new Button("Quit");
    8083#ifdef HAVE_GTK2
  • orxonox/trunk/src/lib/gui/gui/gui_gtk.cc

    r4062 r4068  
    772772   \brief Creates a new Frame with name title
    773773*/
    774 Frame::Frame(char* frameName)
     774Frame::Frame(const char* frameName)
    775775{
    776776#ifdef HAVE_GTK2
     
    14751475  strcpy(this->cValue, newValue);
    14761476#ifdef HAVE_GTK2
    1477   gtk_label_set_text(GTK_LABEL(this->widget), this->cValue);
     1477  gtk_label_set_text(GTK_LABEL(this->widget), newValue);
    14781478#endif /* HAVE_GTK2 */
    14791479}
     
    14951495{
    14961496#ifdef HAVE_GTK2
    1497   this->cValue =(char*)gtk_label_get_text(GTK_LABEL(this->widget));
     1497  this->cValue = (char*)gtk_label_get_text(GTK_LABEL(this->widget));
    14981498#else /* HAVE_GTK2 */
    14991499  PRINT(0)("\nPlease give me a new input for %s: ", this->title);
     
    17361736  strcpy(this->title, name);
    17371737}
     1738
     1739
     1740/////////////////
     1741/* FILE DIALOG */
     1742/////////////////
     1743/**
     1744   \brief Creates a new FileDialog
     1745   \param fileDialogName a Name for the Dialog
     1746*/
     1747FileDialog::FileDialog(const char* fileDialogName)
     1748{
     1749  this->isOption = 0;
     1750  this->isOpen = false;
     1751  this->changeOption = NULL;
     1752  this->openUpButton = NULL;
     1753
     1754#ifdef HAVE_GTK2
     1755  this->widget = gtk_file_selection_new(fileDialogName);
     1756  g_signal_connect(GTK_FILE_SELECTION (this->widget)->cancel_button,
     1757                     "button_release_event",
     1758                     G_CALLBACK (FileDialog::dialogClose),
     1759                     this);
     1760  g_signal_connect(GTK_FILE_SELECTION (this->widget),
     1761                     "delete_event",
     1762                     G_CALLBACK (FileDialog::dialogClose),
     1763                     this);
     1764  g_signal_connect(GTK_FILE_SELECTION (this->widget)->ok_button,
     1765                     "button_release_event",
     1766                     G_CALLBACK (FileDialog::dialogOK),
     1767                     this);
     1768#endif /* HAVE_GTK2 */
     1769  if (fileDialogName)
     1770    this->setTitle(fileDialogName);
     1771}
     1772
     1773/**
     1774   \brief destructs a FileDialog
     1775*/
     1776FileDialog::~FileDialog(void)
     1777{
     1778  PRINTF(5)("deleting FileDialog %s\n", this->title);
     1779}
     1780
     1781void FileDialog::setChangeOption(OptionLabel* changeOption)
     1782{
     1783  this->changeOption = changeOption;
     1784}
     1785
     1786void FileDialog::setOpenUpButton(Button* openUpButton)
     1787{
     1788  this->openUpButton = openUpButton;
     1789
     1790  openUpButton->connectSignal("button_release_event", this, FileDialog::dialogOpen);
     1791}
     1792
     1793
     1794void FileDialog::setDefaultFileName(const char* defaultFileName)
     1795{
     1796#ifdef HAVE_GTK2
     1797  gtk_file_selection_set_filename (GTK_FILE_SELECTION(this->widget), defaultFileName);
     1798#endif /* HAVE_GTK2 */
     1799}
     1800
     1801void FileDialog::setMask(const char* mask)
     1802{
     1803#ifdef HAVE_GTK2
     1804  gtk_file_selection_complete(GTK_FILE_SELECTION(this->widget), mask);
     1805#endif /* HAVE_GTK2 */
     1806}
     1807
     1808void FileDialog::okEvent(void)
     1809{
     1810  if (this->changeOption)
     1811#ifdef HAVE_GTK2
     1812    changeOption->setValue(gtk_file_selection_get_filename(GTK_FILE_SELECTION(this->widget)));
     1813#endif /* HAVE_GTK2 */
     1814  this->close();
     1815}
     1816
     1817void FileDialog::open(void)
     1818{
     1819  isOpen = true;
     1820#ifdef HAVE_GTK2
     1821  gtk_widget_show_all(this->widget);
     1822  gtk_grab_add(this->widget);
     1823#endif /* HAVE_GTK2 */
     1824}
     1825
     1826void FileDialog::close(void)
     1827{
     1828  this->isOpen = false;
     1829#ifdef HAVE_GTK2
     1830  gtk_grab_remove(this->widget);
     1831  gtk_widget_hide(this->widget);
     1832#endif /* HAVE_GTK2 */
     1833}
     1834
     1835#ifdef HAVE_GTK2
     1836gint FileDialog::dialogOK(GtkWidget* widget, GdkEvent* event, void* dialog)
     1837{
     1838  static_cast<FileDialog*>(dialog)->okEvent();
     1839}
     1840#else /* HAVE_GTK2 */
     1841int FileDialog::dialogOK(void* widget, void* event, void* dialog){}
     1842#endif /* HAVE_GTK2 */
     1843
     1844#ifdef HAVE_GTK2
     1845gint FileDialog::dialogOpen(GtkWidget* widget, GdkEvent* event, void* dialog)
     1846{
     1847  static_cast<FileDialog*>(dialog)->open();
     1848}
     1849#else /* HAVE_GTK2 */
     1850int FileDialog::dialogOpen(void* widget, void* event, void* dialog){}
     1851#endif /* HAVE_GTK2 */
     1852
     1853#ifdef HAVE_GTK2
     1854gint FileDialog::dialogClose(GtkWidget* widget, GdkEvent* event, void* dialog)
     1855{
     1856  static_cast<FileDialog*>(dialog)->close();
     1857}
     1858#else /* HAVE_GTK2 */
     1859int FileDialog::dialogClose(void* widget, void* event, void* dialog){}
     1860#endif /* HAVE_GTK2 */
  • orxonox/trunk/src/lib/gui/gui/gui_gtk.h

    r4064 r4068  
    2828#include <gtk/gtkeventbox.h>
    2929#include <gtk/gtkprogressbar.h>
     30#include <gtk/gtkfilesel.h>
    3031#endif /* HAVE_GTK2 */
    3132
     
    184185{
    185186 public:
    186   Frame(char* frameName = NULL);
     187  Frame(const char* frameName = NULL);
    187188  virtual ~Frame(void);
    188189
     
    420421};
    421422
    422 //gint orxonox_gui_quit(GtkWidget* widget, GdkEvent* event, gpointer data);
     423//! A FileDialog is a window with wich one can select a File
     424class FileDialog : public Widget
     425{
     426 private:
     427  OptionLabel* changeOption;
     428  Button* openUpButton;
     429  bool isOpen;
     430 public:
     431  FileDialog(const char* fileDialogName);
     432  virtual ~FileDialog(void);
     433
     434  void setChangeOption(OptionLabel* changeOption);
     435  void setOpenUpButton(Button* openUpButton);
     436  void setDefaultFileName(const char* defaultFileName);
     437  void setMask(const char* mask);
     438
     439  void okEvent();
     440  void open();
     441  void close();
     442
     443#ifdef HAVE_GTK2
     444  static gint dialogOK(GtkWidget* widget, GdkEvent* event, void* dialog);
     445  static gint dialogOpen(GtkWidget* widget, GdkEvent* event, void* dialog);
     446  static gint dialogClose(GtkWidget* widget, GdkEvent* event, void* dialog);
     447#else /* HAVE_GTK2 */
     448  static int dialogOK(void* widget, void* event, void* dialog);
     449  static int dialogOpen(void* widget, void* event, void* dialog);
     450  static int dialogClose(void* widget, void* event, void* dialog);
     451#endif /* HAVE_GTK2 */
     452};
    423453
    424454#endif /* _GUI_GTK_H */
  • orxonox/trunk/src/lib/gui/gui/gui_update.cc

    r4064 r4068  
    3737GuiUpdate::GuiUpdate(void)
    3838{
     39  FileDialog* dataDirDialog;   //!< A FileDialog for the selection of the DataRepos
     40  Button* dataDirButton;       //!< A Button for the selection of the DataRepos
     41  OptionLabel* dataDirLabel;   //!< A Label fot the selection of the DataRepos
     42
    3943  this->tmpDir = NULL;
    4044  this->homeDir = NULL;
     
    5458  this->autoUpdate->setFlagName("update", "u", 0);
    5559  this->autoUpdate->saveability();
     60
     61 
     62  dataDirButton = new Button("browse");
     63  dataDirLabel = new OptionLabel("DataDir", "test");
     64  dataDirLabel->saveability();
     65  dataDirDialog = new FileDialog("data-Repos-location");
     66  dataDirDialog->setDefaultFileName("../data");
     67  dataDirDialog->setOpenUpButton(dataDirButton);
     68  dataDirDialog->setChangeOption(dataDirLabel);
     69  updateBox->fill(dataDirLabel);
     70  updateBox->fill(dataDirButton);
     71
    5672
    5773  this->updateSourceWindowCreate();
     
    6783  this->updateFrame->fill(this->updateBox);
    6884  this->setMainWidget(this->updateFrame);
     85
     86
    6987}
    7088
  • orxonox/trunk/src/lib/gui/gui/gui_video.cc

    r4064 r4068  
    154154 
    155155      closeButton = new Button("close");
     156#ifdef HAVE_GTK2
    156157      closeButton->connectSignal("button_press_event", advancedWindow, Window::windowClose);
     158#endif /* HAVE_GTK2 */
    157159
    158160      advancedBox->fill(closeButton);
Note: See TracChangeset for help on using the changeset viewer.