Changeset fb5887c in git


Ignore:
Timestamp:
26/07/10 04:28:16 (9 years ago)
Author:
Olly Betts <olly@…>
Branches:
add-show-splays, line_contents, master, stereo, svn/github/master, svn/origin/master, svn/tags/1.1.14, svn/tags/1.1.15, svn/tags/1.1.16, svn/tags/1.2.0, svn/tags/1.2.1, svn/tags/1.2.2, svn/tags/1.2.3, svn/tags/1.2.4, svn/tags/1.2.5, svn/trunk, travis-osx
Children:
652b73b
Parents:
bc73093
Message:

src/: Add "Rerun" and "OK" buttons to the CavernLog? window (as
appropriate). (Addition of "OK" button fixes ticket#13). Fix up
handling of splitter window to fix poor handling of various cases.

git-svn-id: file:///home/survex-svn/survex/trunk@3489 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rbc73093 rfb5887c  
     1Mon Jul 26 03:24:38 GMT 2010  Olly Betts <olly@survex.com>
     2
     3        * src/: Add "Rerun" and "OK" buttons to the CavernLog window (as
     4          appropriate).  (Addition of "OK" button fixes ticket#13).  Fix up
     5          handling of splitter window to fix poor handling of various cases.
     6
    17Sun Jul 25 15:32:42 GMT 2010  Olly Betts <olly@survex.com>
    28
  • src/Makefile.am

    rbc73093 rfb5887c  
    5151 rotatemask.xbm rotate.xbm vrotatemask.xbm vrotate.xbm \
    5252 rotatezoom.xbm rotatezoommask.xbm \
    53  avenprcore.cc printwx.cc ini.c hash.c
     53 avenprcore.cc printwx.cc ini.c hash.c \
     54 buttontaghandler.cc
    5455
    5556dump3d_SOURCES = dump3d.c img.c useful.c $(COMMONSRC)
  • src/cavernlog.cc

    rbc73093 rfb5887c  
    2626#include "cavernlog.h"
    2727#include "filename.h"
     28#include "mainfrm.h"
    2829#include "message.h"
    2930
     
    3839#include <sys/types.h>
    3940#include <unistd.h>
     41
     42enum { LOG_RERUN = 1234 };
     43
     44BEGIN_EVENT_TABLE(CavernLogWindow, wxHtmlWindow)
     45    EVT_BUTTON(LOG_RERUN, CavernLogWindow::OnRerun)
     46    EVT_BUTTON(wxID_OK, CavernLogWindow::OnOK)
     47END_EVENT_TABLE()
    4048
    4149static wxString escape_for_shell(wxString s, bool protect_dash = false)
     
    7583}
    7684
    77 CavernLogWindow::CavernLogWindow(wxWindow * parent) : wxHtmlWindow(parent) {
     85CavernLogWindow::CavernLogWindow(MainFrm * mainfrm_, wxWindow * parent)
     86    : wxHtmlWindow(parent), mainfrm(mainfrm_)
     87{
    7888    int fsize = parent->GetFont().GetPointSize();
    7989    int sizes[7] = { fsize, fsize, fsize, fsize, fsize, fsize, fsize };
     
    141151CavernLogWindow::process(const wxString &file)
    142152{
     153    SetFocus();
     154    filename = file;
     155
    143156    char *cavern = use_path(msg_exepth(), "cavern");
    144157#ifdef __WXMSW__
     
    306319        }
    307320    }
     321
    308322    int retval = pclose(cavern_out);
    309323    if (retval) {
     324        AppendToPage(wxT("<avenbutton default id=1234 name=\"Rerun\">"));
    310325        if (retval == -1) {
    311326            wxString m = wxT("Problem running cavern: ");
     
    314329            return -2;
    315330        }
    316         wxGetApp().ReportError(wxT("Failed to process survey data - see log window for details"));
    317331        return -1;
    318332    }
     333    if (link_count) {
     334        AppendToPage(wxT("<avenbutton id=1234 name=\"Rerun\">"));
     335        AppendToPage(wxString::Format(wxT("<avenbutton default id=%d>"), (int)wxID_OK));
     336        Update();
     337    }
    319338    return link_count;
    320339}
     340
     341void
     342CavernLogWindow::OnRerun(wxCommandEvent & e)
     343{
     344    SetPage(wxString());
     345    if (process(filename) == 0) {
     346        OnOK(e);
     347    }
     348}
     349
     350void
     351CavernLogWindow::OnOK(wxCommandEvent &)
     352{
     353    mainfrm->InitialiseAfterLoad(filename);
     354}
  • src/cavernlog.h

    rbc73093 rfb5887c  
    22 * Run cavern inside an Aven window
    33 *
    4  * Copyright (C) 2005,2006 Olly Betts
     4 * Copyright (C) 2005,2006,2010 Olly Betts
    55 *
    66 * This program is free software; you can redistribute it and/or modify
     
    2525#include <wx/html/htmlwin.h>
    2626
     27class MainFrm;
     28
    2729class CavernLogWindow : public wxHtmlWindow {
     30    wxString filename;
     31
     32    MainFrm * mainfrm;
     33
    2834  public:
    29     CavernLogWindow(wxWindow * parent);
     35    CavernLogWindow(MainFrm * mainfrm_, wxWindow * parent);
    3036
    3137    /** Process survey data in file.
     
    3743
    3844    virtual void OnLinkClicked(const wxHtmlLinkInfo &link);
     45
     46    void OnRerun(wxCommandEvent &);
     47
     48    void OnOK(wxCommandEvent &);
     49
     50    DECLARE_EVENT_TABLE()
    3951};
    4052
  • src/mainfrm.cc

    rbc73093 rfb5887c  
    950950}
    951951
    952 bool
    953 MainFrm::ProcessSVXFile(const wxString & file)
    954 {
    955     Show(true);
    956     m_Splitter->Show(false);
    957     CavernLogWindow * log = new CavernLogWindow(this);
    958     m_Splitter->ReplaceWindow(m_Gfx, log);
    959 
    960     int result = log->process(file);
    961     if (result == 0) {
    962         m_Splitter->ReplaceWindow(log, m_Gfx);
    963         m_Splitter->Show();
    964         log->Destroy();
    965     }
    966     return result >= 0;
    967 }
    968 
    969952bool MainFrm::LoadData(const wxString& file, wxString prefix)
    970953{
     
    16171600        ext.MakeLower();
    16181601        if (ext == wxT("svx") || ext == wxT("dat") || ext == wxT("mak")) {
    1619             if (!ProcessSVXFile(file)) {
    1620                 // ProcessSVXFile() reports the error to the user.
     1602            CavernLogWindow * log = new CavernLogWindow(this, m_Splitter);
     1603            wxWindow * win = m_Splitter->GetWindow1();
     1604            m_Splitter->ReplaceWindow(win, log);
     1605            if (m_Splitter->GetWindow2() == NULL) {
     1606                if (win != m_Gfx) win->Destroy();
     1607            } else {
     1608                if (m_Splitter->IsSplit()) m_Splitter->Unsplit();
     1609            }
     1610
     1611            int result = log->process(file);
     1612            if (result < 0) {
     1613                // Error running cavern or processing data.
    16211614                return;
    16221615            }
     1616
    16231617            AddToFileHistory(file);
    16241618            wxString file3d(file, 0, file.length() - 3);
     
    16261620            if (!LoadData(file3d, survey))
    16271621                return;
    1628             InitialiseAfterLoad(file);
     1622            if (result == 0) {
     1623                InitialiseAfterLoad(file);
     1624            }
    16291625            return;
    16301626        }
     
    16491645        x /= 5;
    16501646
    1651     m_Splitter->SplitVertically(m_Notebook, m_Gfx, x);
    1652     m_SashPosition = x; // Save width of panel.
    1653 
     1647    // Do this before we potentially delete the log window which may own the
     1648    // wxString which parameter file refers to!
    16541649    bool same_file = (file == m_File);
    16551650    if (!same_file)
    16561651        m_File = file;
    16571652
     1653    wxWindow * win = NULL;
     1654    if (m_Splitter->GetWindow2() == NULL) {
     1655        win = m_Splitter->GetWindow1();
     1656        if (win == m_Gfx) win = NULL;
     1657    }
     1658
     1659    m_Splitter->SplitVertically(m_Notebook, m_Gfx, x);
     1660    m_SashPosition = x; // Save width of panel.
     1661
    16581662    m_Gfx->Initialise(same_file);
    16591663    m_Notebook->Show(true);
     
    16611665    m_Gfx->Show(true);
    16621666    m_Gfx->SetFocus();
     1667
     1668    if (win) win->Destroy();
    16631669}
    16641670
  • src/mainfrm.h

    rbc73093 rfb5887c  
    265265
    266266    void AddToFileHistory(const wxString & file);
    267     void InitialiseAfterLoad(const wxString & file);
    268267
    269268public:
    270269    MainFrm(const wxString& title, const wxPoint& pos, const wxSize& size);
    271270    ~MainFrm();
     271
     272    void InitialiseAfterLoad(const wxString & file);
    272273
    273274    void OnMRUFile(wxCommandEvent& event);
Note: See TracChangeset for help on using the changeset viewer.