auth_form.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:4k
- /*
- * ===========================================================================
- * PRODUCTION $Log: auth_form.cpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 21:02:09 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3
- * PRODUCTION
- * ===========================================================================
- */
- /*
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Lou Friedman
- *
- * File Description:
- * Implementation of a author name entry form table (CAuthEntryFormTable).
- *
- */
- #include <ncbi_pch.hpp>
- #include <gui/types.hpp>
- #include <FL/Fl_Window.H>
- #include <FL/Fl_Group.H>
- #include <FL/Fl_Input.H>
- #include <FL/Fl_Button.H>
- #include <FL/Fl_Pack.H>
- #include "auth_form.hpp"
- #define LABEL_WIDTH 75
- #define MIDDLE_WIDTH 25
- #define GAP 5
- #define COL_NUM 5
- #define TOTAL_GAP (COL_NUM - 1) * GAP
- #define BUTTON_WIDTH 15
- BEGIN_NCBI_SCOPE
- Fl_Group* CAuthEntryFormTable::AddAuthRow()
- {
- int row_ht = 25;
- int x_place = 0;
- int name_width = (m_Pack->w() - TOTAL_GAP - LABEL_WIDTH -
- MIDDLE_WIDTH - BUTTON_WIDTH)/2;
- // stringstream label;
- Fl_Group* row = new Fl_Group(0, 0, m_Pack->w(), row_ht);
- // Author label
- Fl_Box* label = new Fl_Box(0, 0, LABEL_WIDTH, row_ht);
- label->label("Author:");
- label->labeltype(FL_NORMAL_LABEL);
- label->align(FL_ALIGN_INSIDE | FL_ALIGN_RIGHT);
- label->box(FL_BORDER_FRAME);
- x_place = LABEL_WIDTH + GAP;
- // Add Name Cols
- // First
- new Fl_Input(x_place, 0, name_width, row_ht);
- x_place += name_width + GAP;
- // Middle
- new Fl_Input(x_place, 0, MIDDLE_WIDTH, row_ht);
- x_place += MIDDLE_WIDTH + GAP;
-
- // Last
- new Fl_Input(x_place, 0, name_width, row_ht);
- x_place += name_width + GAP;
-
- // Delete Button
- Fl_Button* button = new Fl_Button(x_place, 5, 15, 15);
- button->label("X");
- button->callback(&cb_DeleteRow, (void*) this);
- button->tooltip("Delete Author");
- row->end();
-
- // add to table pack
- int h = m_Pack->h() + row_ht;
- m_Pack->size(m_Pack->w(), h);
- m_Pack->insert(*row, m_AddButton);
- return row;
- }
- void CAuthEntryFormTable::cb_DeleteRow (Fl_Widget* w, void* u)
- {
- // Get the delete buttons parent.
- // This is the row to be deleted.
- Fl_Group* row = w->parent();
- ((CAuthEntryFormTable*) u)->x_DeleteRow(row);
- }
- void CAuthEntryFormTable::x_DeleteRow(Fl_Group *row)
- {
- int row_ht = 25;
- m_Pack->remove(row);
- delete row;
- int h = m_Pack->h() - row_ht - m_Pack->spacing();
- resize(0, 0, w(), h);
- window()->redraw();
- }
- void CAuthEntryFormTable::AddButtonRow()
- {
- int button_w = 100;
- int x_pos = (m_Pack->w() - button_w)/2;
- int row_ht = 25;
- Fl_Group* row = new Fl_Group(0, 0, m_Pack->w(), row_ht);
- Fl_Button* button = new Fl_Button(x_pos, 0, button_w, row_ht);
- button->label("Add Author");
- button->callback(&cb_AddNewRow, (void*) this);
-
- row->end();
- m_AddButton = row;
- // add to table pack
- int h = m_Pack->h() + row_ht;
- m_Pack->size(m_Pack->w(), h);
- m_Pack->add(row);
- }
- void CAuthEntryFormTable::x_AddNewAuthRow() {
- AddAuthRow();
- int ht = m_Pack->h() + m_Pack->spacing();
- resize(0, 0, w(), ht);
- window()->redraw();
- }
- END_NCBI_SCOPE