info_edit.cpp

Go to the documentation of this file.
00001 #ifndef INFO_EDIT_IMPLEMENTATION_FILE
00002 #define INFO_EDIT_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : info_edit                                                         *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2006-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "info_edit.h"
00019 
00020 #include <textual/string_convert.h>
00021 
00022 BEGIN_MESSAGE_MAP(info_edit, CNSFlexDialog)
00023 END_MESSAGE_MAP()
00024 
00025 info_edit::info_edit(CWnd *parent, const char *initial_edit, int max_length,
00026     const char *description, const char *title, bool onnatop)
00027 : CNSFlexDialog(info_edit::IDD, parent),
00028   _title(new istring(title)),
00029   _max_length(max_length),
00030   _on_top(onnatop)
00031 {
00032   // text box treatment.
00033   AddFlexConstraint(IDC_INFO_EDIT_DESC, NSFlexExpandRight, NSFlexExpandDown);
00034   AddFlexConstraint(IDC_INFO_EDITBOX, NSFlexExpandRight, NSFlexShiftDown);
00035   // button treatment.
00036   AddFlexConstraint(IDOK, NSFlexShiftRight, NSFlexShiftDown);
00037   AddFlexConstraint(IDCANCEL, NSFlexShiftRight, NSFlexShiftDown);
00038 
00039   istring temp_edit = initial_edit;
00040   if (temp_edit.length() > max_length)
00041     temp_edit.zap(max_length - 1, temp_edit.end());
00042   _text_field = string_convert::to_CString(temp_edit);
00043   _description_field = description;
00044 }
00045 
00046 istring info_edit::text() const
00047 { return string_convert::to_istring(_text_field); }
00048 
00049 void info_edit::DoDataExchange(CDataExchange* pDX)
00050 {
00051   CNSFlexDialog::DoDataExchange(pDX);
00052   DDX_Text(pDX, IDC_INFO_EDITBOX, _text_field);
00053   DDV_MaxChars(pDX, _text_field, _max_length);
00054   DDX_Text(pDX, IDC_INFO_EDIT_DESC, _description_field);
00055 }
00056 
00057 BOOL info_edit::OnInitDialog() 
00058 {
00059   CNSFlexDialog::OnInitDialog();  // base class initialization.
00060   SetWindowText(string_convert::to_CString(*_title));
00061     // set the window's title to our text.
00062   if (_on_top) {
00063     // make the window run as the top most due to constructor choice.
00064     SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
00065   }
00066   return TRUE;
00067 }
00068 
00069 void info_edit::OnOK() 
00070 {
00071   UpdateData(TRUE); 
00072   CNSFlexDialog::OnOK();
00073 }
00074 
00075 
00076 #endif //INFO_EDIT_IMPLEMENTATION_FILE
00077 

Generated on Thu Nov 20 04:28:49 2008 for HOOPLE Libraries by  doxygen 1.5.1