On Wed, Jul 02, 2003 at 06:54:30PM +0100, John Levon spake thusly:
> 
> On Wed, Jul 02, 2003 at 04:33:07PM +0200, Juergen Spitzmueller wrote:
> 
> > From a first glance (without looking at the source):
> > 
> > - What's the "Note" state for which is used by default and does not do 
> > anything obviously?
> 
> Sorry to be a pain Martin, but can I get up to  date  screenshots (for
> Qt ?) and a patch ?
> 
> thanks
> john

A patch yes, attached (plus the new files). I don't have Qt to 
produce a screenshot, unfortunately. A new xforms shot is at

        www.hut.fi/~mvermeer/branch7.jpeg

This patch is unfinished: I began implementing a "list of all
branches" in the document, which is stored in the doc header;
unfortunately I don't yet manage to get it from bufferparams to the
Note dialog, to be put in a choice box. 

I am trying to make the Note inset send this data (from the buffer it
belongs to) to the dialog through the controller... but I'm stuck with
that. Have a look if you will.

I'll be outside the reach of the Internet until next week, so if you
want something to happen inbetween, bring it about :-)

Martin

Attachment: branch7.diff.gz
Description: application/gunzip

/**
 * \file FormNote.C
 * This file is part of LyX, the document processor.
 * Licence details can be found in the file COPYING.
 *
 * \author Angus Leeming
 *
 * Full author contact details are available in file CREDITS
 */


#include <config.h>

#include "xformsBC.h"
#include "ControlNote.h"
#include "FormNote.h"
#include "forms/form_note.h"
#include "xforms_helpers.h" // formatted
#include "lyx_forms.h"
#include "insets/insetnote.h"
#include "debug.h"

typedef FormController<ControlNote, FormView<FD_note> > base_class;

FormNote::FormNote(Dialog & parent)
        : base_class(parent, _("Note"))
{}


void FormNote::build()
{
        string all_branches(controller().params().all_branches);
        string all;
lyxerr << "FormNote::Build: all_branches" << all_branches << endl;
        all = all_branches 
                +  _("blind|comment|foot|margin|petite|greyedout|branch");

        dialog_.reset(build_note(this));

        fl_addto_choice(dialog_->choice_type, all.c_str());
        
    bcview().setOK(dialog_->button_ok);
    bcview().setApply(dialog_->button_apply);
        bcview().setCancel(dialog_->button_cancel);
}


void FormNote::update()
{
        string type(controller().params().type);
        string branch(controller().params().branch);
        
/*
        if (type == "branch") {
                setEnabled(dialog_->string_branch, true);
        } else {
                setEnabled(dialog_->string_branch, false);
        }
*/
        fl_set_choice_text(dialog_->choice_type, type.c_str());
        fl_set_input(dialog_->string_branch, branch.c_str());
}


void FormNote::apply()
{
        string const type = fl_get_choice_text(dialog_->choice_type);
        string const branch = fl_get_input(dialog_->string_branch);

    controller().params().type = type;
        controller().params().branch = branch;
}


// -*- C++ -*-
/**
 * \file FormNote.h
 * This file is part of LyX, the document processor.
 * Licence details can be found in the file COPYING.
 *
 * \author Angus Leeming
 *
 * Full author contact details are available in file CREDITS
 */

#ifndef FORMNOTE_H
#define FORMNOTE_H


#include "FormDialogView.h"


class ControlNote;
struct FD_note;

/** This class provides an XForms implementation of the Note Dialog.
 */
class FormNote : public FormController<ControlNote, FormView<FD_note> > {
public:
        /// Constructor
        FormNote(Dialog &);
private:
        /// 
        virtual void apply();
        /// Build the dialog
        virtual void build();
        /// Update dialog before showing it
        virtual void update();
};

#endif // FORMNOTE_H
Magic: 13000

Internal Form Definition File
    (do not change)

Number of forms: 1
Unit of measure: FL_COORD_PIXEL
SnapGrid: 7

=============== FORM ===============
Name: form_note
Width: 451
Height: 162
Number of Objects: 6

--------------------
class: FL_BOX
type: UP_BOX
box: 0 0 451 162
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: 
shortcut: 
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: 
callback: 
argument: 

--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 110 60 210 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Branch|#B
shortcut: 
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: string_branch
callback: C_FormDialogView_InputCB
argument: 0

--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 110 20 110 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Type|#T
shortcut: 
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_type
callback: C_FormDialogView_InputCB
argument: 0

--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 49 112 84 28
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: OK
shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
callback: C_FormDialogView_OKCB
argument: 0

--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 154 112 119 28
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Apply|#A
shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_apply
callback: C_FormDialogView_ApplyCB
argument: 0

--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 287 112 126 28
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Cancel|^[
shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_cancel
callback: C_FormDialogView_CancelCB
argument: 0

==============================
create_the_forms
/**
 * \file ControlNote.C
 * This file is part of LyX, the document processor.
 * Licence details can be found in the file COPYING.
 *
 * \author Angus Leeming
 *
 * Full author contact details are available in file CREDITS
 */

#include <config.h>

#include "ControlNote.h"
#include "funcrequest.h"
#include "insets/insetnote.h"
#include "debug.h"

ControlNote::ControlNote(Dialog & parent)
        : Dialog::Controller(parent)
{}


bool ControlNote::initialiseParams(string const & data)
{
    InsetNoteParams params;
        InsetNoteMailer::string2params(data, params);
        params_.reset(new InsetNoteParams(params));
        // Hack:
        params_->all_branches = params.all_branches; // <- This doesn't work!
lyxerr << "ControlNote: all_branches" << params_->all_branches << endl;
        
        return true;

}


void ControlNote::clearParams()
{
        params_.reset();
}

void ControlNote::dispatchParams()
{
        string const lfun = InsetNoteMailer::params2string(string("note"), params());
        kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

// -*- C++ -*-
/**
 * \file ControlNote.h
 * This file is part of LyX, the document processor.
 * Licence details can be found in the file COPYING.
 *
 * \author Angus Leeming
 *
 * Full author contact details are available in file CREDITS
 */

#ifndef CONTROLNOTE_H
#define CONTROLNOTE_H


#include "Dialog.h"
#include "debug.h"

class InsetNoteParams;

class ControlNote : public Dialog::Controller {
public:
        ///
        ControlNote(Dialog &);
        ///
        virtual bool initialiseParams(string const & data);
        ///
        virtual void clearParams();
        ///
        virtual void dispatchParams();
        ///
        virtual bool isBufferDependent() const { return true; }
        ///
        InsetNoteParams & params() { return *params_.get(); }
        ///
        InsetNoteParams const & params() const { return *params_.get(); }
        ///
private:
        ///
        boost::scoped_ptr<InsetNoteParams> params_;
};

#endif // CONTROLNOTE_H

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to