Main Page

Wino Documentation

Generated on Thu May 2 15:13:51 2002 for Wino by doxygen 1.2.13.1 written by Dimitri van Heesch, © 1997-2001


File Index

Wino File List

Here is a list of all documented files with brief descriptions:
AddressGridTable.cpp [code]
AddressGridTable.h [code]
AddressManager.cpp [code]
AddressManager.h [code]
AddressManagerFrame.cpp [code]
AddressManagerFrame.h [code]
ColumnField.h [code]
dialogs.cpp [code]
dialogs.h [code]


Annotated Index

Wino Compound List

Here are the classes, structs, unions and interfaces with brief descriptions:
AddressGridTable | Serializable wxGridTable
AddressManagerAboutDialog | Dialog for showing the about box
AddressManagerApp | The AddressManager application class
AddressManagerFrame | The frame with the wxGrid
ColumnDialog | Dialog for adding, renaming, moving and removing columns
ColumnField | Helper class for table sort and column change functionality
NullColumnField | Helper class for the column sort functionality
SortDialog | Dialog for choosing the columns for sorting the table
wxGridTableBaseWithNotifyMethods | Base class with some helper methods for AddressGridTable


AddressGridTable Class Reference

Serializable wxGridTable. More...

#include <AddressGridTable.h>

Inheritance diagram for AddressGridTable::

wxGridTableBaseWithNotifyMethods List of all members.

Public Methods

void | Initialize ()
Deletes and initializes the table with default values. More...

void | Initialize (wxDataInputStream &in)
Initializes the table from a stream. More...

void | serialize (wxDataOutputStream &out)
Saves the table to a stream. More...

void | Sort (int col1, int col2, int col3)
Sort the table. More...

void | ChangeColumns (ColumnFieldArray &column)
Rename, move, add and delete columns. More...

Detailed Description

Serializable wxGridTable.

Definition at line 88 of file AddressGridTable.h.

Member Function Documentation

void AddressGridTable::ChangeColumns ( ColumnFieldArray & columns )

Rename, move, add and delete columns.

Parameters:
column The new columns, referencing old columns, if moved or renamed.

Definition at line 538 of file AddressGridTable.cpp.

References wxGridTableBaseWithNotifyMethods::NotifyColsAppended(), and wxGridTableBaseWithNotifyMethods::NotifyRowsAppended().

Referenced by AddressManagerFrame::OnMenuTableConfig().

void AddressGridTable::Initialize ( wxDataInputStream & in )

Initializes the table from a stream.

Parameters:
in The stream from which the table data will be loaded.

Definition at line 422 of file AddressGridTable.cpp.

References wxGridTableBaseWithNotifyMethods::NotifyColsAppended(), and wxGridTableBaseWithNotifyMethods::NotifyRowsAppended().

void AddressGridTable::Initialize ( )

Deletes and initializes the table with default values.

Definition at line 404 of file AddressGridTable.cpp.

References wxGridTableBaseWithNotifyMethods::NotifyColsAppended(), and wxGridTableBaseWithNotifyMethods::NotifyRowsAppended().

Referenced by AddressManagerFrame::OnMenuFileNew(), and AddressManagerFrame::OnMenuFileOpen().

void AddressGridTable::serialize ( wxDataOutputStream & out )

Saves the table to a stream.

Parameters:
in The stream to which the table data will be saved.

Definition at line 101 of file AddressGridTable.cpp.

Referenced by AddressManagerFrame::FileSaveImpl().

void AddressGridTable::Sort | ( | int | col1,
 |  | int | col2,
 |  | int | col3
 | ) |

Sort the table.

Parameters:
col1 | Index of the first column, which will be used for sorting.
col2 | Index of the second column, which will be used for sorting or -1, if only sorting with one column.
col3 | Index of the third column, which will be used for sorting or -1, if only sorting with two columns.

Definition at line 494 of file AddressGridTable.cpp.

References wxGridTableBaseWithNotifyMethods::NotifyRowsAppended(), and wxGridTableBaseWithNotifyMethods::NotifyRowsDeleted().

Referenced by AddressManagerFrame::OnMenuTableSort().


AddressManagerAboutDialog Class Reference

Dialog for showing the about box. More...

#include <dialogs.h>

List of all members.

Detailed Description

Dialog for showing the about box.

Definition at line 109 of file dialogs.h.


AddressManagerApp Class Reference

The AddressManager application class. More...

#include <AddressManager.h>

List of all members.

Public Methods

virtual bool | OnInit (void)
Creates the menu and shows the frame. More...

virtual int | OnExit ()
Returns 0, because dirty tag handling is handled in the frame and there are only one frame. More...

Detailed Description

The AddressManager application class.

Definition at line 51 of file AddressManager.h.

Member Function Documentation

int AddressManagerApp::OnExit ( ) [virtual]

Returns 0, because dirty tag handling is handled in the frame and there are only one frame.

Returns:
0.

Definition at line 81 of file AddressManager.cpp.

bool AddressManagerApp::OnInit ( void ) [virtual]

Creates the menu and shows the frame.

Returns:
TRUE.

Definition at line 19 of file AddressManager.cpp.


AddressManagerFrame Class Reference

The frame with the wxGrid. More...

#include <AddressManagerFrame.h>

List of all members.

Public Methods

AddressManagerFrame (wxFrame *frame, const wxString &title, const wxPoint &pos, const wxSize &size)
Creates a frame, sets the accelerators and shows a default table. More...

~AddressManagerFrame ()
Deletes the table. More...

void | OnAbout (wxCommandEvent &event)
Callback for the about menu command. More...

void | OnMenuFileNew (wxCommandEvent &event)
Callback for the file new menu command. More...

void | OnMenuFileOpen (wxCommandEvent &event)
Callback for the file open menu command. More...

void | OnMenuFileClose (wxCommandEvent &event)
Callback for the file close menu command (currently deactivated). More...

bool | FileSaveImpl ()
Saves the table, if the current filename is set. More...

void | OnMenuFileSave (wxCommandEvent &event)
Callback for the file save menu command. More...

bool | FileSaveAsImpl ()
Shows the save dialog and saves the table, if the dialog was commited. More...

void | OnMenuFileSaveAs (wxCommandEvent &event)
Callback for the file save as menu command. More...

void | OnMenuFileExit (wxCommandEvent &event)
Callback for the file exit menu command. More...

void | OnMenuEditCut (wxCommandEvent &event)
Callback for the edit cut menu command. More...

void | OnMenuEditCopy (wxCommandEvent &event)
Callback for the edit copy menu command. More...

void | OnMenuEditPaste (wxCommandEvent &event)
Callback for the edit paste menu command. More...

void | OnMenuEditFind (wxCommandEvent &event)
Callback for the edit find menu command. More...

void | OnMenuTableDoublet (wxCommandEvent &event)
Callback for the table doublet menu command. More...

void | OnMenuTableSort (wxCommandEvent &event)
Callback for the table sort menu command. More...

void | OnMenuTableConfig (wxCommandEvent &event)
Callback for the table config menu command. More...

void | OnMenuExportEmail (wxCommandEvent &event)
Callback for the export email menu command (currently deactivated). More...

void | OnMenuExportSMS (wxCommandEvent &event)
Callback for the export SMS menu command (currently deactivated). More...

void | OnMenuExportFax (wxCommandEvent &event)
Callback for the export fax menu command (currently deactivated). More...

void | OnActivate (wxActivateEvent &event)
Callback for the activate event. More...

void | OnSize (wxSizeEvent &event)
Callback for the size event. More...

bool | onExit ()
Is called from every method which wants to close the frame and exit the application. More...

void | OnClose (wxCloseEvent &event)
Callback for the close event. More...

void | setDirty ()
Sets the dirty flag to true. More...

Detailed Description

The frame with the wxGrid.

Definition at line 16 of file AddressManagerFrame.h.

Constructor & Destructor Documentation

AddressManagerFrame::AddressManagerFrame | ( | wxFrame * | frame,
 |  | const wxString & | title,
 |  | const wxPoint & | pos,
 |  | const wxSize & | size
 | ) |

Creates a frame, sets the accelerators and shows a default table.

Definition at line 35 of file AddressManagerFrame.cpp.

References OnMenuFileNew().

AddressManagerFrame::~AddressManagerFrame ( )

Deletes the table.

Definition at line 67 of file AddressManagerFrame.cpp.

References OnAbout(), OnClose(), OnMenuEditCopy(), OnMenuEditCut(), OnMenuEditFind(), OnMenuEditPaste(), OnMenuExportEmail(), OnMenuExportFax(), OnMenuExportSMS(), OnMenuFileExit(), OnMenuFileNew(), OnMenuFileOpen(), OnMenuFileSave(), OnMenuFileSaveAs(), OnMenuTableConfig(), OnMenuTableDoublet(), OnMenuTableSort(), and OnSize().

Member Function Documentation

bool AddressManagerFrame::FileSaveAsImpl ( )

Shows the save dialog and saves the table, if the dialog was commited.

Returns:
true, if the user has not canceled the dialog.

Definition at line 235 of file AddressManagerFrame.cpp.

References FileSaveImpl().

Referenced by FileSaveImpl(), and OnMenuFileSaveAs().

bool AddressManagerFrame::FileSaveImpl ( )

Saves the table, if the current filename is set.

If the filename is not set, FileSaveAsImpl will be called.

Returns:
false, if the user has canceled the dialog, if FileSaveAsImpl was called, otherwise true, if no error occured.

Definition at line 198 of file AddressManagerFrame.cpp.

References FileSaveAsImpl(), and AddressGridTable::serialize().

Referenced by FileSaveAsImpl(), onExit(), OnMenuFileNew(), OnMenuFileOpen(), and OnMenuFileSave().

void AddressManagerFrame::OnAbout ( wxCommandEvent & event )

Callback for the about menu command.

Definition at line 96 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnActivate ( wxActivateEvent & event )

Callback for the activate event.

Definition at line 764 of file AddressManagerFrame.cpp.

void AddressManagerFrame::OnClose ( wxCloseEvent & event )

Callback for the close event.

Definition at line 780 of file AddressManagerFrame.cpp.

References onExit().

Referenced by ~AddressManagerFrame().

bool AddressManagerFrame::onExit ( )

Is called from every method which wants to close the frame and exit the application.

Checks the dirty flag and calls the FileSaveImpl, if something is to save and returns the result.

Parameters:
true, if the application can be exited, false, if the user vetoed it.

Definition at line 266 of file AddressManagerFrame.cpp.

References FileSaveImpl().

Referenced by OnClose(), and OnMenuFileExit().

void AddressManagerFrame::OnMenuEditCopy ( wxCommandEvent & event )

Callback for the edit copy menu command.

Definition at line 364 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuEditCut ( wxCommandEvent & event )

Callback for the edit cut menu command.

Definition at line 289 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuEditFind ( wxCommandEvent & event )

Callback for the edit find menu command.

Definition at line 503 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuEditPaste ( wxCommandEvent & event )

Callback for the edit paste menu command.

Definition at line 423 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuExportEmail ( wxCommandEvent & event )

Callback for the export email menu command (currently deactivated).

Definition at line 667 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuExportFax ( wxCommandEvent & event )

Callback for the export fax menu command (currently deactivated).

Definition at line 755 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuExportSMS ( wxCommandEvent & event )

Callback for the export SMS menu command (currently deactivated).

Definition at line 747 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuFileClose ( wxCommandEvent & event )

Callback for the file close menu command (currently deactivated).

Definition at line 187 of file AddressManagerFrame.cpp.

void AddressManagerFrame::OnMenuFileExit ( wxCommandEvent & event )

Callback for the file exit menu command.

Definition at line 281 of file AddressManagerFrame.cpp.

References onExit().

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuFileNew ( wxCommandEvent & event )

Callback for the file new menu command.

Definition at line 105 of file AddressManagerFrame.cpp.

References FileSaveImpl(), and AddressGridTable::Initialize().

Referenced by AddressManagerFrame(), and ~AddressManagerFrame().

void AddressManagerFrame::OnMenuFileOpen ( wxCommandEvent & event )

Callback for the file open menu command.

Definition at line 127 of file AddressManagerFrame.cpp.

References FileSaveImpl(), and AddressGridTable::Initialize().

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuFileSave ( wxCommandEvent & event )

Callback for the file save menu command.

Definition at line 227 of file AddressManagerFrame.cpp.

References FileSaveImpl().

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuFileSaveAs ( wxCommandEvent & event )

Callback for the file save as menu command.

Definition at line 258 of file AddressManagerFrame.cpp.

References FileSaveAsImpl().

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuTableConfig ( wxCommandEvent & event )

Callback for the table config menu command.

Definition at line 636 of file AddressManagerFrame.cpp.

References AddressGridTable::ChangeColumns(), and ColumnDialog::getNewColumns().

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuTableDoublet ( wxCommandEvent & event )

Callback for the table doublet menu command.

Definition at line 548 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnMenuTableSort ( wxCommandEvent & event )

Callback for the table sort menu command.

Definition at line 599 of file AddressManagerFrame.cpp.

References SortDialog::getSortOrder(), and AddressGridTable::Sort().

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::OnSize ( wxSizeEvent & event )

Callback for the size event.

Definition at line 770 of file AddressManagerFrame.cpp.

Referenced by ~AddressManagerFrame().

void AddressManagerFrame::setDirty ( )

Sets the dirty flag to true.

Definition at line 797 of file AddressManagerFrame.cpp.


ColumnDialog Class Reference

Dialog for adding, renaming, moving and removing columns. More...

#include <dialogs.h>

List of all members.

Public Methods

ColumnDialog (wxWindow *parent, ColumnFieldArray &columns)
Creates a new column config dialog with the current columns. More...

~ColumnDialog ()
Deletes all new created columns. More...

ColumnFieldArray getNewColumns ()
Gets an array with the configured columns. More...

Detailed Description

Dialog for adding, renaming, moving and removing columns.

Definition at line 18 of file dialogs.h.

Constructor & Destructor Documentation

ColumnDialog::ColumnDialog | ( | wxWindow * | parent,
 |  | ColumnFieldArray & | columns
 | ) |

Creates a new column config dialog with the current columns.

Parameters:
parent | The frame.
columns | The columns of the current table.

Definition at line 94 of file dialogs.cpp.

ColumnDialog::~ColumnDialog ( )

Deletes all new created columns.

Definition at line 172 of file dialogs.cpp.

References ColumnField::isNew().

Member Function Documentation

ColumnFieldArray ColumnDialog::getNewColumns ( )

Gets an array with the configured columns.

The columns are perhaps sorted in a way the user wants, perhaps labels are changed and if columns added, the isNew method of this columns returns true.

Definition at line 291 of file dialogs.cpp.

References SortDialog::OnOK().

Referenced by AddressManagerFrame::OnMenuTableConfig().


ColumnField Class Reference

Helper class for table sort and column change functionality. More...

#include <ColumnField.h>

Inheritance diagram for ColumnField::

NullColumnField List of all members.

Public Methods

ColumnField (wxString name, int oldIndex=-1, int oldWidth=0)
Creates a new column. More...

bool | isNew ()
Tests if the columns is new for the column change functionality. More...

int | getOldIndex ()
Gets the index of the current table column, for column change functionality. More...

int | getOldWidth ()
Gets the with of the current table column, for column change functionality. More...

wxString | getName ()
Gets the column label, perhaps changed by the column change dialog. More...

void | setName (wxString name)
Sets a new column label. More...

Detailed Description

Helper class for table sort and column change functionality.

Definition at line 13 of file ColumnField.h.

Constructor & Destructor Documentation

ColumnField::ColumnField | ( | wxString | name,
 |  | int | oldIndex = -1,
 |  | int | oldWidth = 0
 | ) |

Creates a new column.

Parameters:
name | Column label.
oldIndex | Reference to the current table column. -1 for new columns.
oldWidth | Reference to the current tabel column width, specified by oldIndex.

Definition at line 61 of file dialogs.cpp.

Member Function Documentation

wxString ColumnField::getName ( )

Gets the column label, perhaps changed by the column change dialog.

Definition at line 83 of file dialogs.cpp.

int ColumnField::getOldIndex ( )

Gets the index of the current table column, for column change functionality.

Definition at line 73 of file dialogs.cpp.

int ColumnField::getOldWidth ( )

Gets the with of the current table column, for column change functionality.

Definition at line 78 of file dialogs.cpp.

bool ColumnField::isNew ( )

Tests if the columns is new for the column change functionality.

Returns:
true, if the column is new.

Definition at line 68 of file dialogs.cpp.

Referenced by ColumnDialog::~ColumnDialog().

void ColumnField::setName ( wxString name )

Sets a new column label.

Definition at line 88 of file dialogs.cpp.


NullColumnField Class Reference

Helper class for the column sort functionality. More...

#include <ColumnField.h>

Inheritance diagram for NullColumnField::

ColumnField List of all members.

Detailed Description

Helper class for the column sort functionality.

An object of this class is the first entry in the column wxChoice control of the SortDialog for choosing nothing.

Definition at line 61 of file ColumnField.h.


SortDialog Class Reference

Dialog for choosing the columns for sorting the table. More...

#include <dialogs.h>

List of all members.

Public Methods

SortDialog (wxWindow *parent, ColumnFieldArray &columns)
Creates a new sort dialog with the current columns. More...

ColumnFieldArray | getSortOrder ()
Gets the columns in the order the user has choosen for sorting the table. More...

void | OnOK (wxCommandEvent &event)
Closes the dialog and retrieves the sort order. More...

Detailed Description

Dialog for choosing the columns for sorting the table.

Definition at line 65 of file dialogs.h.

Constructor & Destructor Documentation

SortDialog::SortDialog | ( | wxWindow * | parent,
 |  | ColumnFieldArray & | columns
 | ) |

Creates a new sort dialog with the current columns.

Parameters:
parent | The frame.
columns | The columns of the current table.

Definition at line 310 of file dialogs.cpp.

Member Function Documentation

ColumnFieldArray SortDialog::getSortOrder ( )

Gets the columns in the order the user has choosen for sorting the table.

Returns:
ColumnFieldArray, use getOldIndex for retrieving the column index (-1 if disabled).

Definition at line 394 of file dialogs.cpp.

Referenced by AddressManagerFrame::OnMenuTableSort().

void SortDialog::OnOK ( wxCommandEvent & event )

Closes the dialog and retrieves the sort order.

Definition at line 406 of file dialogs.cpp.

Referenced by ColumnDialog::getNewColumns().


wxGridTableBaseWithNotifyMethods Class Reference

Base class with some helper methods for AddressGridTable. More...

#include <AddressGridTable.h>

Inheritance diagram for wxGridTableBaseWithNotifyMethods::

AddressGridTable List of all members.

Public Methods

void | RequestViewGetValues ()
Sends a wxGRIDTABLE_REQUEST_VIEW_GET_VALUES wxGridTableMessage to the view, if not NULL. More...

void | RequestViewSendValues ()
Sends a wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES wxGridTableMessage to the view, if not NULL. More...

void | NotifyRowsInserted (int pos, int numRows)
Sends a wxGRIDTABLE_NOTIFY_ROWS_INSERTED wxGridTableMessage to the view, if not NULL. More...

void | NotifyRowsAppended (int numRows)
Sends a wxGRIDTABLE_NOTIFY_ROWS_APPENDED wxGridTableMessage to the view, if not NULL. More...

void | NotifyRowsDeleted (int pos, int numRows)
Sends a wxGRIDTABLE_NOTIFY_ROWS_DELETED wxGridTableMessage to the view, if not NULL. More...

void | NotifyColsInserted (int pos, int numCols)
Sends a wxGRIDTABLE_NOTIFY_COLS_INSERTED wxGridTableMessage to the view, if not NULL. More...

void | NotifyColsAppended (int numCols)
Sends a wxGRIDTABLE_NOTIFY_COLS_APPENDED wxGridTableMessage to the view, if not NULL. More...

void | NotifyColsDeleted (int pos, int numCols)
Sends a wxGRIDTABLE_NOTIFY_COLS_DELETED wxGridTableMessage to the view, if not NULL. More...

Detailed Description

Base class with some helper methods for AddressGridTable.

Definition at line 23 of file AddressGridTable.h.

Member Function Documentation

void wxGridTableBaseWithNotifyMethods::NotifyColsAppended ( int numCols )

Sends a wxGRIDTABLE_NOTIFY_COLS_APPENDED wxGridTableMessage to the view, if not NULL.

Parameters:
numCols Number of columns, which were appended to the end.

Definition at line 68 of file AddressGridTable.cpp.

Referenced by AddressGridTable::ChangeColumns(), and AddressGridTable::Initialize().

void wxGridTableBaseWithNotifyMethods::NotifyColsDeleted | ( | int | pos,
 |  | int | numCols
 | ) |

Sends a wxGRIDTABLE_NOTIFY_COLS_DELETED wxGridTableMessage to the view, if not NULL.

Parameters:
pos | Start position, from which the columns were deleted.
numCols | Number of columns, which were deleted.

Definition at line 77 of file AddressGridTable.cpp.

void wxGridTableBaseWithNotifyMethods::NotifyColsInserted | ( | int | pos,
 |  | int | numCols
 | ) |

Sends a wxGRIDTABLE_NOTIFY_COLS_INSERTED wxGridTableMessage to the view, if not NULL.

Parameters:
pos | Start position, from which the columns were inserted.
numCols | Number of columns, which were inserted.

Definition at line 59 of file AddressGridTable.cpp.

void wxGridTableBaseWithNotifyMethods::NotifyRowsAppended ( int numRows )

Sends a wxGRIDTABLE_NOTIFY_ROWS_APPENDED wxGridTableMessage to the view, if not NULL.

Parameters:
numRows Number of rows, which were appended to the end.

Definition at line 41 of file AddressGridTable.cpp.

Referenced by AddressGridTable::ChangeColumns(), AddressGridTable::Initialize(), and AddressGridTable::Sort().

void wxGridTableBaseWithNotifyMethods::NotifyRowsDeleted | ( | int | pos,
 |  | int | numRows
 | ) |

Sends a wxGRIDTABLE_NOTIFY_ROWS_DELETED wxGridTableMessage to the view, if not NULL.

Parameters:
pos | Start position, from which the rows were deleted.
numRows | Number of rows, which were deleted.

Definition at line 50 of file AddressGridTable.cpp.

Referenced by AddressGridTable::Sort().

void wxGridTableBaseWithNotifyMethods::NotifyRowsInserted | ( | int | pos,
 |  | int | numRows
 | ) |

Sends a wxGRIDTABLE_NOTIFY_ROWS_INSERTED wxGridTableMessage to the view, if not NULL.

Parameters:
pos | Start position, from which the rows were inserted.
numRows | Number of rows, which were inserted.

Definition at line 32 of file AddressGridTable.cpp.

void wxGridTableBaseWithNotifyMethods::RequestViewGetValues ( )

Sends a wxGRIDTABLE_REQUEST_VIEW_GET_VALUES wxGridTableMessage to the view, if not NULL.

Definition at line 14 of file AddressGridTable.cpp.

void wxGridTableBaseWithNotifyMethods::RequestViewSendValues ( )

Sends a wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES wxGridTableMessage to the view, if not NULL.

Definition at line 23 of file AddressGridTable.cpp.


Hierarchical Index

Wino Class Hierarchy

This inheritance list is sorted roughly, but not completely, alphabetically:
  • AddressManagerAboutDialog
  • AddressManagerApp
  • AddressManagerFrame
  • ColumnDialog
  • ColumnField
    • NullColumnField
  • SortDialog
  • wxGridTableBaseWithNotifyMethods
    • AddressGridTable


Compound Member Index

Wino Compound Members

a | c | f | g | i | n | o | r | s | ~

Here is a list of all documented class members with links to the classes they belong to:

- a -

  • AddressManagerFrame() : AddressManagerFrame

- c -
  • ChangeColumns() : AddressGridTable
  • ColumnDialog() : ColumnDialog
  • ColumnField() : ColumnField

- f -
  • FileSaveAsImpl() : AddressManagerFrame
  • FileSaveImpl() : AddressManagerFrame

- g -
  • getName() : ColumnField
  • getNewColumns() : ColumnDialog
  • getOldIndex() : ColumnField
  • getOldWidth() : ColumnField
  • getSortOrder() : SortDialog

- i -
  • Initialize() : AddressGridTable
  • isNew() : ColumnField

- n -
  • NotifyColsAppended() : wxGridTableBaseWithNotifyMethods
  • NotifyColsDeleted() : wxGridTableBaseWithNotifyMethods
  • NotifyColsInserted() : wxGridTableBaseWithNotifyMethods
  • NotifyRowsAppended() : wxGridTableBaseWithNotifyMethods
  • NotifyRowsDeleted() : wxGridTableBaseWithNotifyMethods
  • NotifyRowsInserted() : wxGridTableBaseWithNotifyMethods

- o -
  • OnAbout() : AddressManagerFrame
  • OnActivate() : AddressManagerFrame
  • OnClose() : AddressManagerFrame
  • onExit() : AddressManagerFrame
  • OnExit() : AddressManagerApp
  • OnInit() : AddressManagerApp
  • OnMenuEditCopy() : AddressManagerFrame
  • OnMenuEditCut() : AddressManagerFrame
  • OnMenuEditFind() : AddressManagerFrame
  • OnMenuEditPaste() : AddressManagerFrame
  • OnMenuExportEmail() : AddressManagerFrame
  • OnMenuExportFax() : AddressManagerFrame
  • OnMenuExportSMS() : AddressManagerFrame
  • OnMenuFileClose() : AddressManagerFrame
  • OnMenuFileExit() : AddressManagerFrame
  • OnMenuFileNew() : AddressManagerFrame
  • OnMenuFileOpen() : AddressManagerFrame
  • OnMenuFileSave() : AddressManagerFrame
  • OnMenuFileSaveAs() : AddressManagerFrame
  • OnMenuTableConfig() : AddressManagerFrame
  • OnMenuTableDoublet() : AddressManagerFrame
  • OnMenuTableSort() : AddressManagerFrame
  • OnOK() : SortDialog
  • OnSize() : AddressManagerFrame

- r -
  • RequestViewGetValues() : wxGridTableBaseWithNotifyMethods
  • RequestViewSendValues() : wxGridTableBaseWithNotifyMethods

- s -
  • serialize() : AddressGridTable
  • setDirty() : AddressManagerFrame
  • setName() : ColumnField
  • Sort() : AddressGridTable
  • SortDialog() : SortDialog

- ~ -
  • ~AddressManagerFrame() : AddressManagerFrame
  • ~ColumnDialog() : ColumnDialog


AddressGridTable.cpp Source File

AddressGridTable.cpp

00001 /*
00002  * Purpose: Serializable wxGridTable
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #include "AddressGridTable.h"
00008
00009 #include "wx/arrimpl.cpp"
00010 WX_DEFINE_OBJARRAY(StringArray);
00011 WX_DEFINE_OBJARRAY(StringGrid);
00012
00013
00014 void wxGridTableBaseWithNotifyMethods::RequestViewGetValues()
00015 {
00016     wxGrid* pView = GetView();
00017     if (pView) {
00018         wxGridTableMessage msg(this, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES);
00019         pView->ProcessTableMessage(msg);
00020     }
00021 }
00022
00023 void wxGridTableBaseWithNotifyMethods::RequestViewSendValues()
00024 {
00025     wxGrid* pView = GetView();
00026     if (pView) {
00027         wxGridTableMessage msg(this, wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES);
00028         pView->ProcessTableMessage(msg);
00029     }
00030 }
00031
00032 void wxGridTableBaseWithNotifyMethods::NotifyRowsInserted(int pos, int numRows)
00033 {
00034     wxGrid* pView = GetView();
00035     if (pView) {
00036         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, pos, numRows);
00037         pView->ProcessTableMessage(msg);
00038     }
00039 }
00040
00041 void wxGridTableBaseWithNotifyMethods::NotifyRowsAppended(int numRows)
00042 {
00043     wxGrid* pView = GetView();
00044     if (pView) {
00045         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, numRows);
00046         pView->ProcessTableMessage(msg);
00047     }
00048 }
00049
00050 void wxGridTableBaseWithNotifyMethods::NotifyRowsDeleted(int pos, int numRows)
00051 {
00052     wxGrid* pView = GetView();
00053     if (pView) {
00054         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_ROWS_DELETED, pos, numRows);
00055         pView->ProcessTableMessage(msg);
00056     }
00057 }
00058
00059 void wxGridTableBaseWithNotifyMethods::NotifyColsInserted(int pos, int numCols)
00060 {
00061     wxGrid* pView = GetView();
00062     if (pView) {
00063         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_COLS_INSERTED, pos, numCols);
00064         pView->ProcessTableMessage(msg);
00065     }
00066 }
00067
00068 void wxGridTableBaseWithNotifyMethods::NotifyColsAppended(int numCols)
00069 {
00070     wxGrid* pView = GetView();
00071     if (pView) {
00072         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_COLS_APPENDED, numCols);
00073         pView->ProcessTableMessage(msg);
00074     }
00075 }
00076
00077 void wxGridTableBaseWithNotifyMethods::NotifyColsDeleted(int pos, int numCols)
00078 {
00079     wxGrid* pView = GetView();
00080     if (pView) {
00081         wxGridTableMessage msg(this, wxGRIDTABLE_NOTIFY_COLS_DELETED, pos, numCols);
00082         pView->ProcessTableMessage(msg);
00083     }
00084 }
00085
00086
00088 //
00089 // A basic grid table for string data. An object of this class will
00090 // created by wxGrid if you don't specify an alternative table class.
00091 //
00092
00093 //WX_DEFINE_OBJARRAY(StringGrid)
00094
00095 bool isEmpty(StringArray& row, size_t cols)
00096 {
00097     for (size_t j = 0; j < cols; j++) if (row[j].Length()) return false;
00098     return true;
00099 }
00100
00101 void AddressGridTable::serialize(wxDataOutputStream& out)
00102 {
00103     // get number of cols and rows
00104     size_t cols = GetNumberCols();
00105     size_t rows = GetNumberRows();
00106
00107     // count number of rows, where at least one cell has text
00108     size_t textRows = 0;
00109     size_t i;
00110     for (i = 0; i < rows; i++) {
00111         if (!isEmpty(m_data[i], cols)) textRows++;
00112     }
00113
00114     // write number of cols and rows
00115     out.Write32(cols);
00116     out.Write32(textRows);
00117
00118     // write column info
00119     wxGrid* pView = GetView();
00120     for (i = 0; i < cols; i++) {
00121         out.WriteString(GetColLabelValue(i));
00122         out.Write32(pView->GetColumnWidth(i));
00123     }
00124
00125     // write all columns, where at least one cell has text
00126     for (i = 0; i < rows; i++) {
00127         if (!isEmpty(m_data[i], cols)) {
00128             for (size_t j = 0; j < cols; j++) out.WriteString(m_data[i][j]);
00129         }
00130     }
00131 }
00132
00133 int AddressGridTable::GetNumberRows()
00134 {
00135     return m_data.GetCount();
00136 }
00137
00138 int AddressGridTable::GetNumberCols()
00139 {
00140     return m_colLabels.GetCount();
00141 }
00142
00143 wxString AddressGridTable::GetValue( int row, int col )
00144 {
00145     wxASSERT_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
00146                   _T("invalid row or column index in AddressGridTable") );
00147
00148     return m_data[row][col];
00149 }
00150
00151 void AddressGridTable::SetValue( int row, int col, const wxString& value )
00152 {
00153     wxASSERT_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
00154                   _T("invalid row or column index in AddressGridTable") );
00155
00156     m_data[row][col] = value;
00157 }
00158
00159 bool AddressGridTable::IsEmptyCell( int row, int col )
00160 {
00161     wxASSERT_MSG( (row < GetNumberRows()) && (col < GetNumberCols()),
00162                   _T("invalid row or column index in AddressGridTable") );
00163
00164     return (m_data[row][col] == wxEmptyString);
00165 }
00166
00167 void AddressGridTable::Clear()
00168 {
00169     int row, col;
00170     int numRows, numCols;
00171
00172     numRows = m_data.GetCount();
00173     if ( numRows > 0 )
00174     {
00175         numCols = m_data[0].GetCount();
00176
00177         for ( row = 0;  row < numRows;  row++ )
00178         {
00179             for ( col = 0;  col < numCols;  col++ )
00180             {
00181                 m_data[row][col] = wxEmptyString;
00182             }
00183         }
00184     }
00185 }
00186
00187
00188 bool AddressGridTable::InsertRows( size_t pos, size_t numRows )
00189 {
00190     size_t row, col;
00191
00192     size_t curNumRows = m_data.GetCount();
00193     size_t curNumCols = ( curNumRows > 0 ? m_data[0].GetCount() :
00194                           ( GetView() ? GetView()->GetNumberCols() : 0 ) );
00195
00196     if ( pos >= curNumRows )
00197     {
00198         return AppendRows( numRows );
00199     }
00200
00201     StringArray sa;
00202     sa.Alloc( curNumCols );
00203     for ( col = 0;  col < curNumCols;  col++ )
00204     {
00205         sa.Add( wxEmptyString );
00206     }
00207
00208     for ( row = pos;  row < pos + numRows;  row++ )
00209     {
00210         m_data.Insert( sa, row );
00211     }
00212     NotifyRowsInserted(pos, numRows);
00213
00214     return TRUE;
00215 }
00216
00217 bool AddressGridTable::AppendRows( size_t numRows )
00218 {
00219     size_t row, col;
00220
00221     size_t curNumRows = m_data.GetCount();
00222     size_t curNumCols = ( curNumRows > 0 ? m_data[0].GetCount() :
00223                           ( GetView() ? GetView()->GetNumberCols() : 0 ) );
00224
00225     StringArray sa;
00226     if ( curNumCols > 0 )
00227     {
00228         sa.Alloc( curNumCols );
00229         for ( col = 0;  col < curNumCols;  col++ )
00230         {
00231             sa.Add( wxEmptyString );
00232         }
00233     }
00234
00235     for ( row = 0;  row < numRows;  row++ )
00236     {
00237         m_data.Add( sa );
00238     }
00239     NotifyRowsAppended(numRows);
00240
00241     return TRUE;
00242 }
00243
00244 bool AddressGridTable::DeleteRows( size_t pos, size_t numRows )
00245 {
00246     size_t n;
00247
00248     size_t curNumRows = m_data.GetCount();
00249
00250     if ( pos >= curNumRows )
00251     {
00252         wxString errmsg;
00253         errmsg.Printf(wxT("Called AddressGridTable::DeleteRows(pos=%d, N=%d)\nPos value is invalid for present table with %d rows"),
00254                       pos, numRows, curNumRows );
00255         wxFAIL_MSG( errmsg );
00256         return FALSE;
00257     }
00258
00259     if ( numRows > curNumRows - pos )
00260     {
00261         numRows = curNumRows - pos;
00262     }
00263
00264     if ( numRows >= curNumRows )
00265     {
00266         m_data.Empty();  // don't release memory just yet
00267     }
00268     else
00269     {
00270         for ( n = 0;  n < numRows;  n++ )
00271         {
00272             m_data.RemoveAt( pos );
00273         }
00274     }
00275     NotifyRowsDeleted(pos, numRows);
00276
00277     return TRUE;
00278 }
00279
00280 bool AddressGridTable::InsertCols( size_t pos, size_t numCols )
00281 {
00282     size_t row, col;
00283
00284     size_t curNumRows = m_data.GetCount();
00285     size_t curNumCols = ( curNumRows > 0 ? m_data[0].GetCount() :
00286                           ( GetView() ? GetView()->GetNumberCols() : 0 ) );
00287
00288     if ( pos >= curNumCols )
00289     {
00290         return AppendCols( numCols );
00291     }
00292
00293     for ( row = 0;  row < curNumRows;  row++ )
00294     {
00295         for ( col = pos;  col < pos + numCols;  col++ )
00296         {
00297             m_data[row].Insert( wxEmptyString, col );
00298         }
00299     }
00300     NotifyColsInserted(pos, numCols);
00301
00302     return TRUE;
00303 }
00304
00305 bool AddressGridTable::AppendCols( size_t numCols )
00306 {
00307     size_t row, n;
00308
00309     size_t curNumRows = m_data.GetCount();
00310
00311     for ( row = 0;  row < curNumRows;  row++ )
00312     {
00313         for ( n = 0;  n < numCols;  n++ )
00314         {
00315             m_data[row].Add( wxEmptyString );
00316         }
00317     }
00318     NotifyColsAppended(numCols);
00319
00320     return TRUE;
00321 }
00322
00323 bool AddressGridTable::DeleteCols( size_t pos, size_t numCols )
00324 {
00325     size_t row, n;
00326
00327     size_t curNumRows = m_data.GetCount();
00328     size_t curNumCols = ( curNumRows > 0 ? m_data[0].GetCount() :
00329                           ( GetView() ? GetView()->GetNumberCols() : 0 ) );
00330
00331     if ( pos >= curNumCols )
00332     {
00333         wxString errmsg;
00334         errmsg.Printf( wxT("Called AddressGridTable::DeleteCols(pos=%d, N=%d)...\nPos value is invalid for present table with %d cols"),
00335                         pos, numCols, curNumCols );
00336         wxFAIL_MSG( errmsg );
00337         return FALSE;
00338     }
00339
00340     if ( numCols > curNumCols - pos )
00341     {
00342         numCols = curNumCols - pos;
00343     }
00344
00345     for ( row = 0;  row < curNumRows;  row++ )
00346     {
00347         if ( numCols >= curNumCols )
00348         {
00349             m_data[row].Clear();
00350         }
00351         else
00352         {
00353             for ( n = 0;  n < numCols;  n++ )
00354             {
00355                 m_data[row].RemoveAt( pos );
00356             }
00357         }
00358     }
00359     NotifyColsDeleted(pos, numCols);
00360
00361     return TRUE;
00362 }
00363
00364 wxString AddressGridTable::GetColLabelValue( int col )
00365 {
00366     if ( col > (int)(m_colLabels.GetCount()) - 1 )
00367     {
00368         // using default label
00369         //
00370         return wxGridTableBase::GetColLabelValue( col );
00371     }
00372     else
00373     {
00374         return m_colLabels[ col ];
00375     }
00376 }
00377
00378 void AddressGridTable::SetColLabelValue( int col, const wxString& value )
00379 {
00380     if ( col > (int)(m_colLabels.GetCount()) - 1 )
00381     {
00382         int n = m_colLabels.GetCount();
00383         int i;
00384         for ( i = n;  i <= col;  i++ )
00385         {
00386             m_colLabels.Add( wxGridTableBase::GetColLabelValue(i) );
00387         }
00388     }
00389
00390     m_colLabels[col] = value;
00391 }
00392
00393 void AddressGridTable::ClearAll()
00394 {
00395     int rows = m_data.GetCount();
00396     m_data = StringGrid();
00397     NotifyRowsDeleted(0, rows);
00398
00399     int cols = m_colLabels.GetCount();
00400     m_colLabels = StringArray();
00401     NotifyColsDeleted(0, cols);
00402 }
00403
00404 void AddressGridTable::Initialize()
00405 {
00406     ClearAll();
00407     m_colLabels.Add("eMail");
00408     m_colLabels.Add("Handy");
00409     m_colLabels.Add("SMS-Export");
00410     m_colLabels.Add("Fax");
00411     StringArray empty;
00412     empty.Add(wxEmptyString);
00413     empty.Add(wxEmptyString);
00414     empty.Add(wxEmptyString);
00415     empty.Add(wxEmptyString);
00416     m_data.Add(empty);
00417     NotifyColsAppended(4);
00418     NotifyRowsAppended(1);
00419 }
00420
00421
00422 void AddressGridTable::Initialize(wxDataInputStream& in)
00423 {
00424     ClearAll();
00425
00426     // read number of cols and rows
00427     size_t cols = in.Read32();
00428     size_t rows = in.Read32();
00429
00430     // add columns for setting the column labels
00431     NotifyColsAppended(cols);
00432
00433     // read column labels and widths
00434     size_t i;
00435     wxGrid* pView = GetView();
00436     for (i = 0; i < cols; i++) {
00437         m_colLabels.Add(in.ReadString());
00438         pView->SetColumnWidth(i, in.Read32());
00439     }
00440
00441     // read rows
00442     m_data.Alloc(rows + 1);
00443     for (i = 0; i < rows; i++) {
00444         StringArray row;
00445         row.Alloc(cols);
00446         for (size_t j = 0; j < cols; j++) {
00447             row.Add(in.ReadString());
00448         }
00449         m_data.Add(row);
00450     }
00451
00452     // add empty row
00453     StringArray empty;
00454     empty.Alloc(cols);
00455     for (i = 0; i < cols; i++) empty.Add(wxEmptyString);
00456     m_data.Add(empty);
00457
00458     // tell the view how many rows were added
00459     NotifyRowsAppended(rows + 1);
00460 }
00461
00462
00463 int gSortCol1;
00464 int gSortCol2;
00465 int gSortCol3;
00466 StringGrid* gSortGrid;
00467 wxUint32* gSortArray;
00468
00469 int compare(const void *arg1, const void *arg2)
00470 {
00471     wxUint32 index1 = *((wxUint32*)arg1);
00472     wxUint32 index2 = *((wxUint32*)arg2);
00473     wxString& value1 = (*gSortGrid)[index1][gSortCol1];
00474     wxString& value2 = (*gSortGrid)[index2][gSortCol1];
00475     if (value1.Length() == 0) return 1;
00476     if (value2.Length() == 0) return -1;
00477     int cmp = value1.CmpNoCase(value2);
00478     if (cmp != 0) return cmp;
00479     if (gSortCol2 < 0) return cmp;
00480     wxString& value3 = (*gSortGrid)[index1][gSortCol2];
00481     wxString& value4 = (*gSortGrid)[index2][gSortCol2];
00482     if (value3.Length() == 0) return 1;
00483     if (value4.Length() == 0) return -1;
00484     cmp = value3.CmpNoCase(value4);
00485     if (cmp != 0) return cmp;
00486     if (gSortCol3 < 0) return cmp;
00487     wxString& value5 = (*gSortGrid)[index1][gSortCol3];
00488     wxString& value6 = (*gSortGrid)[index2][gSortCol3];
00489     if (value5.Length() == 0) return 1;
00490     if (value6.Length() == 0) return -1;
00491     return value5.CmpNoCase(value6);
00492 }
00493
00494 void AddressGridTable::Sort(int col1, int col2, int col3)
00495 {
00496     gSortCol1 = col1;
00497     gSortCol2 = col2;
00498     gSortCol3 = col3;
00499
00500     // create index array for sorting
00501     unsigned rowCount = GetNumberRows();
00502     gSortArray = new wxUint32[rowCount];
00503     size_t i;
00504     for (i = 0; i < rowCount; i++) gSortArray[i] = i;
00505
00506     // sort array
00507     gSortGrid = &m_data;
00508     qsort((void *)gSortArray, rowCount, sizeof(wxUint32), compare);
00509
00510     // copy in new grid
00511     unsigned colCount = GetNumberCols();
00512     unsigned newCount = 0;
00513     StringGrid newGrid = StringGrid();
00514     newGrid.Alloc(rowCount);
00515     for (i = 0; i < rowCount; i++)
00516     {
00517         unsigned len = 0;
00518         for (unsigned j = 0; j < colCount; j++) {
00519             wxString& value = m_data[gSortArray[i]][j];
00520             len += value.Length();
00521         }
00522         if (len > 0) {
00523             newGrid.Add(m_data[gSortArray[i]]);
00524             newCount++;
00525         }
00526     }
00527     delete [] gSortArray;
00528
00529     // set new grid
00530     m_data = newGrid;
00531
00532     // update view
00533     NotifyRowsDeleted(0, rowCount);
00534     NotifyRowsAppended(newCount);
00535 }
00536
00537
00538 void AddressGridTable::ChangeColumns(ColumnFieldArray& columns)
00539 {
00540     // get number of cols and rows
00541     size_t cols = columns.GetCount();
00542     size_t rows = GetNumberRows();
00543
00544     // create new empty data grid
00545     StringGrid newGrid = StringGrid();
00546     StringArray newColLabels;
00547     newGrid.Alloc(rows);
00548     StringArray empty;
00549     empty.Alloc(cols);
00550     size_t i;
00551     for (i = 0; i < cols; i++) empty.Add(wxEmptyString);
00552     for (i = 0; i < rows; i++) newGrid.Add(empty);
00553
00554     // fill with old values
00555     for (i = 0; i < cols; i++)
00556     {
00557         // create new column
00558         int oldIndex = columns[i].getOldIndex();
00559         newColLabels.Add(columns[i].getName());
00560
00561         // copy old values, if it is not a new column
00562         if (!columns[i].isNew()) {
00563             for (size_t j = 0; j < rows; j++) {
00564                 newGrid[j][i] = m_data[j][oldIndex];
00565             }
00566         }
00567     }
00568
00569     // set new grid
00570     ClearAll();
00571     m_data = newGrid;
00572     m_colLabels = newColLabels;
00573
00574     // update view
00575     NotifyColsAppended(cols);
00576     NotifyRowsAppended(rows);
00577
00578     // restore old column widths
00579     wxGrid* pView = GetView();
00580     for (i = 0; i < cols; i++)
00581     {
00582         if (!columns[i].isNew()) {
00583             pView->SetColumnWidth(i, columns[i].getOldWidth());
00584         }
00585     }
00586 }
00587


AddressGridTable.h Source File

AddressGridTable.h

00001 /*
00002  * Purpose: Serializable wxGridTable, based on wxStringGridTable
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #ifndef ADDRESS_GRID_TABLE_H
00008 #define ADDRESS_GRID_TABLE_H
00009
00010 #include <wx/wx.h>
00011 #include <wx/grid.h>
00012 #include <wx/datstrm.h>
00013
00014 #include "AddressManager.h"
00015 #include "ColumnField.h"
00016
00017 WX_DECLARE_OBJARRAY(wxString, StringArray);
00018 WX_DECLARE_OBJARRAY(StringArray, StringGrid);
00019
00023 class wxGridTableBaseWithNotifyMethods : public wxGridTableBase
00024 {
00025 public:
00030     void RequestViewGetValues();
00031
00036     void RequestViewSendValues();
00037
00044     void NotifyRowsInserted(int pos, int numRows);
00045
00051     void NotifyRowsAppended(int numRows);
00052
00059     void NotifyRowsDeleted(int pos, int numRows);
00060
00067     void NotifyColsInserted(int pos, int numCols);
00068
00074     void NotifyColsAppended(int numCols);
00075
00082     void NotifyColsDeleted(int pos, int numCols);
00083 };
00084
00088 class AddressGridTable : public wxGridTableBaseWithNotifyMethods
00089 {
00090 public:
00091     // these are pure virtual in wxGridTableBase
00092     //
00093     int GetNumberRows();
00094     int GetNumberCols();
00095     wxString GetValue( int row, int col );
00096     void SetValue( int row, int col, const wxString& s );
00097     bool IsEmptyCell( int row, int col );
00098
00099     // overridden functions from wxGridTableBase
00100     //
00101     void Clear();
00102     bool InsertRows( size_t pos = 0, size_t numRows = 1 );
00103     bool AppendRows( size_t numRows = 1 );
00104     bool DeleteRows( size_t pos = 0, size_t numRows = 1 );
00105     bool InsertCols( size_t pos = 0, size_t numCols = 1 );
00106     bool AppendCols( size_t numCols = 1 );
00107     bool DeleteCols( size_t pos = 0, size_t numCols = 1 );
00108
00109     void SetColLabelValue( int col, const wxString& );
00110     wxString GetColLabelValue( int col );
00111
00115     void Initialize();
00116
00121     void Initialize(wxDataInputStream& in);
00122
00127     void serialize(wxDataOutputStream& out);
00128
00135     void Sort(int col1, int col2, int col3);
00136
00141     void ChangeColumns(ColumnFieldArray& column);
00142
00143 private:
00144
00148     void ClearAll();
00149
00153     StringGrid m_data;
00154
00158     StringArray m_colLabels;
00159 };
00160
00161 #endif


AddressManager.cpp Source File

AddressManager.cpp

00001 /*
00002  * Purpose: AddressManager application
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #include "AddressManager.h"
00008 #include "AddressManagerFrame.h"
00009
00010 static const char sccsid[] = "%W% %G%";
00011
00012 #include "addresses.xpm"
00013
00014 // Main proc
00015
00016 IMPLEMENT_APP(AddressManagerApp)
00017
00018 // `Main program' equivalent, creating windows and returning main app frame
00019 bool AddressManagerApp::OnInit(void)
00020 {
00021     SetExitOnFrameDelete(TRUE);
00022
00023     // Create the main frame window
00024     AddressManagerFrame *frame = new AddressManagerFrame((wxFrame *) NULL, (char *) "Address Manager", wxPoint(50, 50), wxSize(450, 300));
00025
00026     // Give it an icon
00027     frame->SetIcon(wxIcon(addresses_xpm));
00028
00029     // Make a menubar
00030     wxMenu *file_menu = new wxMenu;
00031     file_menu->Append(wxID_NEW, "&Neu");
00032     file_menu->Append(wxID_OPEN, "&Öffnen...");
00033     file_menu->AppendSeparator();
00034 //    file_menu->Append(wxID_CLOSE, "Schließen");
00035     file_menu->Append(wxID_SAVE, "&Sichern\tCtrl+S");
00036     file_menu->Append(wxID_SAVEAS, "Sichern unter...");
00037     file_menu->AppendSeparator();
00038     file_menu->Append(MENU_FILE_EXIT, "Beenden\tCtrl+Q");
00039
00040     wxMenu *edit_menu = new wxMenu;
00041     edit_menu->Append(MENU_EDIT_CUT, "Ausschneiden\tCtrl+X");
00042     edit_menu->Append(MENU_EDIT_COPY, "Kopieren\tCtrl+C");
00043     edit_menu->Append(MENU_EDIT_PASTE, "Einfügen\tCtrl+V");
00044
00045     edit_menu->AppendSeparator();
00046     edit_menu->Append(wxID_FIND, "Suchen...\tCtrl+F");
00047
00048     wxMenu *table_menu = new wxMenu;
00049     table_menu->Append(MENU_TABLE_DOUBLET, "&Dublette Finden");
00050     table_menu->Append(MENU_TABLE_SORT, "So&rtieren...");
00051     table_menu->Append(MENU_TABLE_CONFIG, "Tabellenkonfiguration...");
00052 /*
00053     wxMenu *export_menu = new wxMenu;
00054     export_menu->Append(MENU_EXPORT_EMAIL, "eMail...");
00055     export_menu->Append(MENU_EXPORT_SMS, "SMS...");
00056     export_menu->Append(MENU_EXPORT_FAX, "Fax...");
00057 */
00058     wxMenuBar *menu_bar = new wxMenuBar;
00059     menu_bar->Append(file_menu, "&Datei");
00060     menu_bar->Append(edit_menu, "&Bearbeiten");
00061     menu_bar->Append(table_menu, "&Tabelle");
00062 //    menu_bar->Append(export_menu, "&Export");
00063
00064 #ifdef __WXMAC__
00065     s_macHelpMenuTitleName = "Hilfe";
00066     s_macAboutMenuItemId = wxID_ABOUT;
00067 #endif
00068     wxMenu *help_menu = new wxMenu;
00069     help_menu->Append(wxID_ABOUT, "Über Address Manager...");
00070     menu_bar->Append(help_menu, "Hilfe");
00071
00072     frame->SetMenuBar(menu_bar);
00073
00074     // Show the frame
00075     frame->Show(TRUE);
00076
00077     SetTopWindow(frame);
00078     return TRUE;
00079 }
00080
00081 int AddressManagerApp::OnExit()
00082 {
00083     // exit code is 0, everything is ok
00084     return 0;
00085 }
00086


AddressManager.h Source File

AddressManager.h

00001 /*
00002  * Purpose: AddressManager application
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #ifndef ADDRESS_MANAGER_H
00008 #define ADDRESS_MANAGER_H
00009
00010 #include <wx/wx.h>
00011 #include <wx/txtstrm.h>
00012 #include <wx/wfstream.h>
00013 #include <wx/zstream.h>
00014 #include <wx/grid.h>
00015 #include <wx/colordlg.h>
00016 #include "ColumnField.h"
00017
00018 #if !defined(__WXMSW__)
00019 extern char * addresses_xpm[];
00020 #endif
00021
00022 enum {
00023     MENU_EDIT_CUT = 1,
00024     MENU_EDIT_COPY,
00025     MENU_EDIT_PASTE,
00026     MENU_TABLE_DOUBLET,
00027     MENU_TABLE_SORT,
00028     MENU_TABLE_CONFIG,
00029     MENU_EXPORT_EMAIL,
00030     MENU_EXPORT_SMS,
00031     MENU_EXPORT_FAX,
00032     MENU_FILE_EXIT
00033 };
00034
00043 enum {
00044     admTagEnd = 0,
00045     admTagGrid = 2
00046 };
00047
00051 class AddressManagerApp: public wxApp
00052 {
00053 public:
00058     virtual bool OnInit(void);
00059
00065     virtual int OnExit();
00066 };
00067
00068 WX_DECLARE_OBJARRAY(ColumnField, ColumnFieldArray);
00069
00070 #endif


AddressManagerFrame.cpp Source File

AddressManagerFrame.cpp

00001 /*
00002  * Purpose: AddressManager frame
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #include <wx/clipbrd.h>
00008 #include <stdlib.h>
00009
00010 #include "AddressManager.h"
00011 #include "AddressManagerFrame.h"
00012 #include "dialogs.h"
00013
00014
00015 static const wxUint32 g_admFileId = ('a' | ('d' << 8) | ('m' << 16));
00016 static const wxUint32 g_admFileVersion = 1;
00017
00018
00019 class AddEmptyRowGridCellTextEditor : public wxGridCellTextEditor
00020 {
00021 public:
00022     AddEmptyRowGridCellTextEditor(AddressManagerFrame& frame) : m_frame(frame) {}
00023     void BeginEdit(int row, int col, wxGrid* grid)
00024     {
00025         // add an empty row, if editing the a cell in the last line
00026         if (grid->GetRows() - 1 == row) grid->AppendRows(1, false);
00027         wxGridCellTextEditor::BeginEdit(row, col, grid);
00028         m_frame.setDirty();
00029     }
00030 private:
00031     AddressManagerFrame& m_frame;
00032 };
00033
00034 // AddressManagerFrame constructor
00035 AddressManagerFrame::AddressManagerFrame(wxFrame *frame, const wxString& title,
00036                  const wxPoint& pos, const wxSize& size):
00037     wxFrame(frame, -1, title, pos, size)
00038 {
00039     m_dirty = false;
00040     m_pGrid = new wxGrid(this, -1, wxPoint(0,0), wxSize(600, 400));
00041     m_pTable = new AddressGridTable();
00042     m_pGrid->SetTable(m_pTable);
00043     m_pGrid->RegisterDataType(wxGRID_VALUE_STRING,
00044         new wxGridCellStringRenderer,
00045         new AddEmptyRowGridCellTextEditor(*this));
00046     m_pGrid->DisableDragRowSize();
00047     m_pGrid->SetColLabelSize(m_pGrid->GetDefaultRowSize());
00048     m_pGrid->SetDefaultRowSize(20);
00049
00050     wxAcceleratorEntry entries[6];
00051     entries[0].Set(wxACCEL_CTRL,  (int) 'S', wxID_SAVE);
00052     entries[1].Set(wxACCEL_CTRL,  (int) 'X', MENU_EDIT_CUT);
00053     entries[2].Set(wxACCEL_CTRL,  (int) 'C', MENU_EDIT_COPY);
00054     entries[3].Set(wxACCEL_CTRL,  (int) 'V', MENU_EDIT_PASTE);
00055     entries[4].Set(wxACCEL_CTRL,  (int) 'F', wxID_FIND);
00056     entries[5].Set(wxACCEL_CTRL,  (int) 'Q', MENU_FILE_EXIT);
00057     wxAcceleratorTable accel(6, entries);
00058     SetAcceleratorTable(accel);
00059
00060     m_pGrid->UpdateDimensions();
00061     Refresh();
00062
00063     wxCommandEvent dummy;
00064     OnMenuFileNew(dummy);
00065 }
00066
00067 AddressManagerFrame::~AddressManagerFrame()
00068 {
00069     delete m_pGrid;
00070     delete m_pTable;
00071 }
00072
00073 BEGIN_EVENT_TABLE(AddressManagerFrame, wxFrame)
00074     EVT_MENU(wxID_ABOUT, AddressManagerFrame::OnAbout)
00075     EVT_MENU(wxID_NEW, AddressManagerFrame::OnMenuFileNew)
00076     EVT_MENU(wxID_OPEN, AddressManagerFrame::OnMenuFileOpen)
00077 //    EVT_MENU(wxID_EXIT, AddressManagerFrame::OnMenuFileClose)
00078     EVT_MENU(wxID_SAVE, AddressManagerFrame::OnMenuFileSave)
00079     EVT_MENU(wxID_SAVEAS, AddressManagerFrame::OnMenuFileSaveAs)
00080     EVT_MENU(MENU_FILE_EXIT, AddressManagerFrame::OnMenuFileExit)
00081     EVT_MENU(MENU_EDIT_CUT, AddressManagerFrame::OnMenuEditCut)
00082     EVT_MENU(MENU_EDIT_COPY, AddressManagerFrame::OnMenuEditCopy)
00083     EVT_MENU(MENU_EDIT_PASTE, AddressManagerFrame::OnMenuEditPaste)
00084     EVT_MENU(wxID_FIND, AddressManagerFrame::OnMenuEditFind)
00085     EVT_MENU(MENU_TABLE_DOUBLET, AddressManagerFrame::OnMenuTableDoublet)
00086     EVT_MENU(MENU_TABLE_SORT, AddressManagerFrame::OnMenuTableSort)
00087     EVT_MENU(MENU_TABLE_CONFIG, AddressManagerFrame::OnMenuTableConfig)
00088     EVT_MENU(MENU_EXPORT_EMAIL, AddressManagerFrame::OnMenuExportEmail)
00089     EVT_MENU(MENU_EXPORT_SMS, AddressManagerFrame::OnMenuExportSMS)
00090     EVT_MENU(MENU_EXPORT_FAX, AddressManagerFrame::OnMenuExportFax)
00091     EVT_CLOSE(AddressManagerFrame::OnClose)
00092
00093     EVT_SIZE(AddressManagerFrame::OnSize)
00094 END_EVENT_TABLE()
00095
00096 void AddressManagerFrame::OnAbout(wxCommandEvent& event)
00097 {
00098     // save current edit cell, if neccessary
00099     m_pGrid->DisableCellEditControl();
00100
00101     AddressManagerAboutDialog dialog(this);
00102     dialog.ShowModal();
00103 }
00104
00105 void AddressManagerFrame::OnMenuFileNew(wxCommandEvent& event)
00106 {
00107     // save current edit cell, if neccessary
00108     m_pGrid->DisableCellEditControl();
00109
00110     if (m_dirty) {
00111         int result = wxMessageBox("Änderungen speichern?", "Address Manager", wxICON_QUESTION | wxYES_NO | wxCANCEL, this);
00112         if (result == wxCANCEL) return;
00113         if (result == wxYES) {
00114             if (!FileSaveImpl()) return;
00115         }
00116     }
00117     wxBusyCursor wait;
00118     m_pTable->Initialize();
00119
00120     int width, height;
00121     GetSize(&width, &height);
00122     SetSize(width - 1, height - 1);
00123     SetSize(width, height);
00124     m_dirty = false;
00125 }
00126
00127 void AddressManagerFrame::OnMenuFileOpen(wxCommandEvent& event)
00128 {
00129     // save current edit cell, if neccessary
00130     m_pGrid->DisableCellEditControl();
00131
00132     if (m_dirty) {
00133         int result = wxMessageBox("Änderungen speichern?", "Address Manager", wxICON_QUESTION | wxYES_NO | wxCANCEL, this);
00134         if (result == wxCANCEL) return;
00135         if (result == wxYES) {
00136             if (!FileSaveImpl()) return;
00137         }
00138     }
00139     wxFileDialog dialog(this, "Datei Öffnen", "", "", "Address Manager Dateien (*.adm)|*.adm", wxOPEN);
00140     if (dialog.ShowModal() == wxID_OK) {
00141         wxBusyCursor wait;
00142         m_currentFilename = dialog.GetPath();
00143
00144         // open file; TODO: file locking
00145         wxFileInputStream fileInStream(m_currentFilename);
00146         wxDataInputStream in(fileInStream);
00147
00148         // check if right file format and file is readable
00149         wxUint32 id = in.Read32();
00150         wxUint32 version = in.Read32();
00151         if (!in.IsOk() || id != g_admFileId || version > g_admFileVersion) {
00152             wxMessageDialog errorDialog(this, "Fehler beim Öffnen der Datei", "Address Manager", wxOK | wxICON_ERROR);
00153             errorDialog.ShowModal();
00154             return;
00155         }
00156
00157         // read file
00158         bool end = false;
00159         while (!end) {
00160             wxUint32 tag = in.Read32();
00161             wxUint32 size = in.Read32();
00162             switch (tag) {
00163                 case admTagGrid:
00164                     m_pTable->Initialize(in);
00165                     break;
00166                 case admTagEnd:
00167                     end = true;
00168                     break;
00169                 default:
00170                     fileInStream.SeekI(size, wxFromCurrent);
00171             }
00172         }
00173
00174         // update view
00175         int width, height;
00176         m_dirty = false;
00177         GetSize(&width, &height);
00178         SetSize(width - 1, height - 1);
00179         SetSize(width, height);
00180         m_pGrid->SetFocus();
00181
00182         // not modified
00183         m_dirty = false;
00184     }
00185 }
00186
00187 void AddressManagerFrame::OnMenuFileClose(wxCommandEvent& event)
00188 {
00189     // save current edit cell, if neccessary
00190     m_pGrid->DisableCellEditControl();
00191     // TODO
00192 /*  if (m_grid) {
00193         delete m_grid;
00194         m_grid = NULL;
00195     }*/
00196 }
00197
00198 bool AddressManagerFrame::FileSaveImpl()
00199 {
00200     if (m_currentFilename.Length() == 0) {
00201         if (!FileSaveAsImpl()) return false;
00202     }
00203     wxBusyCursor wait;
00204     wxFileOutputStream fileOutStream(m_currentFilename);
00205     wxDataOutputStream out(fileOutStream);
00206     out.Write32(g_admFileId);
00207     out.Write32(g_admFileVersion);
00208     out.Write32(admTagGrid);
00209     out.Write32(0);
00210     off_t cur = fileOutStream.TellO();
00211     m_pTable->serialize(out);
00212     off_t end = fileOutStream.TellO();
00213     fileOutStream.SeekO(cur - 4);
00214     out.Write32(end - cur);
00215     fileOutStream.SeekO(end);
00216     out.Write32(admTagEnd);
00217     out.Write32(0);
00218     if (!fileOutStream.IsOk()) {
00219         wxMessageDialog errorDialog(this, "Fehler beim Speichern der Datei", "Address Manager", wxOK | wxICON_ERROR);
00220         errorDialog.ShowModal();
00221         return false;
00222     }
00223     m_dirty = false;
00224     return true;
00225 }
00226
00227 void AddressManagerFrame::OnMenuFileSave(wxCommandEvent& event)
00228 {
00229     // save current edit cell, if neccessary
00230     m_pGrid->DisableCellEditControl();
00231
00232     FileSaveImpl();
00233 }
00234
00235 bool AddressManagerFrame::FileSaveAsImpl()
00236 {
00237     wxFileDialog dialog(this, "Datei Speichern unter", "", m_currentFilename, "Address Manager Dateien (*.adm)|*.adm", wxSAVE|wxOVERWRITE_PROMPT);
00238     if (dialog.ShowModal() == wxID_OK) {
00239         m_currentFilename = dialog.GetPath();
00240
00241         // add extension, if missing (on Mac)
00242         size_t pos = m_currentFilename.Length() - 4;
00243         if (pos < 0) pos = 0;
00244         wxString ext = m_currentFilename.Mid(pos);
00245         if (ext.CmpNoCase(".adm") != 0) m_currentFilename += ".adm";
00246
00247         // save file
00248         if (!FileSaveImpl()) return false;
00249
00250         // notify that the file was saved
00251         return true;
00252     }
00253
00254     // notify that the dialog was canceled
00255     return false;
00256 }
00257
00258 void AddressManagerFrame::OnMenuFileSaveAs(wxCommandEvent& event)
00259 {
00260     // save current edit cell, if neccessary
00261     m_pGrid->DisableCellEditControl();
00262
00263     FileSaveAsImpl();
00264 }
00265
00266 bool AddressManagerFrame::onExit()
00267 {
00268     // save current edit cell, if neccessary
00269     m_pGrid->DisableCellEditControl();
00270
00271     if (m_dirty) {
00272         int result = wxMessageBox("Änderungen speichern?", "Address Manager", wxICON_QUESTION | wxYES_NO | wxCANCEL, this);
00273         if (result == wxCANCEL) return false;
00274         if (result == wxYES) {
00275             if (!FileSaveImpl()) return false;
00276         }
00277     }
00278     return true;
00279 }
00280
00281 void AddressManagerFrame::OnMenuFileExit(wxCommandEvent& event)
00282 {
00283     // save current edit cell, if neccessary
00284     m_pGrid->DisableCellEditControl();
00285
00286     if (onExit()) Close(true);
00287 }
00288
00289 void AddressManagerFrame::OnMenuEditCut(wxCommandEvent& event)
00290 {
00291     // save current edit cell, if neccessary
00292     m_pGrid->DisableCellEditControl();
00293
00294     m_dirty = true;
00295     copy(true);
00296 }
00297
00298 void AddressManagerFrame::copy(bool erase)
00299 {
00300     // search first start
00301     int rowCount = m_pGrid->GetRows();
00302     int colCount = m_pGrid->GetCols();
00303     int startRow = -1;
00304     int startCol = -1;
00305     int row, col;
00306     for (row = 0; row < rowCount; row++) {
00307         for (col = 0; col < colCount; col++) {
00308             if (m_pGrid->IsInSelection(row, col)) {
00309                 startRow = row;
00310                 startCol = col;
00311                 break;
00312             }
00313         }
00314         if (startRow != -1) break;
00315     }
00316
00317     // search last end
00318     int endRow = -1;
00319     int endCol = -1;
00320     if (startRow != -1) {
00321         for (row = startRow; row < rowCount; row++) {
00322             for (col = startCol; col < colCount; col++) {
00323                 if (m_pGrid->IsInSelection(row, col)) {
00324                     if (row > endRow) endRow = row;
00325                     if (col > endCol) endCol = col;
00326                 }
00327             }
00328         }
00329     }
00330
00331     // get cursor position, if no selection
00332     if (startRow == -1) {
00333         startRow = endRow = m_pGrid->GetGridCursorRow();
00334         startCol = endCol = m_pGrid->GetGridCursorCol();
00335     }
00336
00337     // copy to clipboard
00338     wxBusyCursor wait;
00339     if (!wxTheClipboard->Open()) return;
00340     wxString text;
00341     bool firstRow = true;
00342     for (row = startRow; row <= endRow; row++) {
00343         if (firstRow) {
00344             firstRow = false;
00345         } else {
00346             text += "\n";
00347         }
00348         bool firstCol = true;
00349         for (col = startCol; col <= endCol; col++) {
00350             if (firstCol) {
00351                 firstCol = false;
00352             } else {
00353                 text += "\t";
00354             }
00355             text += m_pGrid->GetCellValue(row, col);
00356             if (erase) m_pGrid->SetCellValue(row, col, "");
00357         }
00358     }
00359     wxTheClipboard->SetData(new wxTextDataObject(text));
00360     wxTheClipboard->Close();
00361     if (erase) m_dirty = true;
00362 }
00363
00364 void AddressManagerFrame::OnMenuEditCopy(wxCommandEvent& event)
00365 {
00366     // save current edit cell, if neccessary
00367     m_pGrid->DisableCellEditControl();
00368
00369     copy(false);
00370 }
00371
00372 // splits a wxString into lines
00373 // detects all possible line breaking charaters: \n, \r, \n\r or \r\n
00374 class LineSplitter
00375 {
00376 public:
00377     LineSplitter(const wxString& text) : m_text(text), m_ofs(0)
00378     {
00379         m_len = text.Length();
00380     }
00381
00382     bool extractNext()
00383     {
00384         if (m_ofs == m_len) return false;
00385         size_t end = m_ofs;
00386         while (end < m_len) {
00387             wxChar c = m_text[end];
00388             if (c == 10 || c == 13) {
00389                 m_currentLine = m_text.Mid(m_ofs, end - m_ofs);
00390                 if (end == m_len - 1) {
00391                     m_ofs = m_len;
00392                     return true;
00393                 }
00394                 if ((c == 10 && m_text[end + 1] == 13) ||
00395                     (c == 13 && m_text[end + 1] == 10))
00396                 {
00397                     m_ofs = end + 2;
00398                     return true;
00399                 }
00400                 m_ofs = end + 1;
00401                 return true;
00402             }
00403             end++;
00404         }
00405         m_currentLine = m_text.Mid(m_ofs, end - m_ofs);
00406         m_ofs = end;
00407         return true;
00408     }
00409
00410     wxString getNext()
00411     {
00412         return m_currentLine;
00413     }
00414
00415 private:
00416     const wxString& m_text;
00417     wxString m_currentLine;
00418     size_t m_ofs;
00419     size_t m_len;
00420 };
00421
00422
00423 void AddressManagerFrame::OnMenuEditPaste(wxCommandEvent& event)
00424 {
00425     // save current edit cell, if neccessary
00426     m_pGrid->DisableCellEditControl();
00427
00428     wxBusyCursor wait;
00429
00430     // search first start
00431     int rowCount = m_pGrid->GetRows();
00432     int colCount = m_pGrid->GetCols();
00433     int startRow = -1;
00434     int startCol = -1;
00435     int row, col;
00436     for (row = 0; row < rowCount; row++) {
00437         for (col = 0; col < colCount; col++) {
00438             if (m_pGrid->IsInSelection(row, col)) {
00439                 startRow = row;
00440                 startCol = col;
00441                 break;
00442             }
00443         }
00444         if (startRow != -1) break;
00445     }
00446
00447     // get cursor position, if no selection
00448     if (startRow == -1) {
00449         startRow = m_pGrid->GetGridCursorRow();
00450         startCol = m_pGrid->GetGridCursorCol();
00451     }
00452
00453     // paste from clipboard
00454     if (!wxTheClipboard->Open()) return;
00455     if (!wxTheClipboard->IsSupported(wxDF_TEXT)) return;
00456     wxTextDataObject data;
00457     wxTheClipboard->GetData(data);
00458     wxString text = data.GetText();
00459     m_pGrid->BeginBatch();
00460     LineSplitter ls(text);
00461     while (ls.extractNext()) {
00462         if (startRow >= rowCount - 1) {
00463             m_pGrid->AppendRows(1, false);
00464             rowCount++;
00465         }
00466         wxString line = ls.getNext();
00467         unsigned lpos = 0;
00468         for (int col = startCol; col < colCount; col++) {
00469             unsigned lsearch = lpos;
00470             while (lsearch < line.Length()) {
00471                 if (line[lsearch] == '\t') break;
00472                 lsearch++;
00473             }
00474             wxString word = line.Mid(lpos, lsearch - lpos);
00475             m_pGrid->SetCellValue(startRow, col, word);
00476             lpos = lsearch;
00477             lpos++;
00478             if (lpos >= line.Length()) break;
00479         }
00480         startRow++;
00481     }
00482     m_pGrid->EndBatch();
00483     wxTheClipboard->Close();
00484     m_dirty = true;
00485 }
00486
00487 bool substringMatch(const wxString& search, const wxString& value)
00488 {
00489     int slen = search.Length();
00490     int vlen = value.Length();
00491     if (slen == 0 || vlen == 0) return false;
00492
00493     for (int valueStart = 0; valueStart < vlen - 1; valueStart++) {
00494         int searchIndex = 0;
00495         for (int valueIndex = valueStart; valueIndex < vlen; valueIndex++) {
00496             if (wxTolower(search[searchIndex++]) != wxTolower(value[valueIndex])) break;
00497             if (searchIndex == slen) return true;
00498         }
00499     }
00500     return false;
00501 }
00502
00503 void AddressManagerFrame::OnMenuEditFind(wxCommandEvent& event)
00504 {
00505     // save current edit cell, if neccessary
00506     m_pGrid->DisableCellEditControl();
00507
00508     // get search text
00509     wxTextEntryDialog dialog(this, "Suchen nach:", "Address Manager", m_lastSearchString, wxOK | wxCANCEL);
00510     if (dialog.ShowModal() != wxID_OK) return;
00511     m_lastSearchString = dialog.GetValue();
00512
00513     // calulate next column to start from
00514     int row = m_pGrid->GetGridCursorRow();
00515     int rowCount = m_pGrid->GetRows();
00516     int colCount = m_pGrid->GetCols();
00517     int col = m_pGrid->GetGridCursorCol() + 1;
00518     if (col == colCount) {
00519         col = 0;
00520         row++;
00521         if (row == rowCount) row = 0;
00522     }
00523
00524     // search
00525     for (; row < rowCount; row++) {
00526         for (; col < colCount; col++) {
00527             if (substringMatch(m_lastSearchString, m_pGrid->GetCellValue(row, col))) {
00528                 m_pGrid->SetGridCursor(row, col);
00529                 m_pGrid->MakeCellVisible(row, col);
00530                 return;
00531             }
00532         }
00533         col = 0;
00534     }
00535
00536     // if not found, search from start
00537     for (row = 0; row < rowCount; row++) {
00538         for (col = 0; col < colCount; col++) {
00539             if (substringMatch(m_lastSearchString, m_pGrid->GetCellValue(row, col))) {
00540                 m_pGrid->SetGridCursor(row, col);
00541                 m_pGrid->MakeCellVisible(row, col);
00542                 return;
00543             }
00544         }
00545     }
00546 }
00547
00548 void AddressManagerFrame::OnMenuTableDoublet(wxCommandEvent& event)
00549 {
00550     // save current edit cell, if neccessary
00551     m_pGrid->DisableCellEditControl();
00552
00553     unsigned rowCount = m_pGrid->GetRows();
00554     unsigned colCount = m_pGrid->GetCols();
00555     if (rowCount < 2) return;
00556
00557     // get eMail index
00558     unsigned col;
00559     bool found = false;
00560     for (col = 0; col < colCount; col++) {
00561         wxString label = m_pGrid->GetColLabelValue(col);
00562         if (label.CmpNoCase("email") == 0) {
00563             found = true;
00564             break;
00565         }
00566     }
00567     if (!found) {
00568         wxMessageDialog errorDialog(this, "Doublettenableich nicht möglich, da es keine eMail-Tabellenspalte gibt.", "Address Manager", wxOK | wxICON_INFORMATION);
00569         errorDialog.ShowModal();
00570         return;
00571     }
00572
00573     // get row to start from
00574     unsigned row = m_pGrid->GetGridCursorRow();
00575
00576     // search
00577     for (; row < rowCount - 1; row++) {
00578         wxString value = m_pGrid->GetCellValue(row, col);
00579         if (value.Length() > 0 && value.CmpNoCase(m_pGrid->GetCellValue(row + 1, col)) == 0) {
00580             m_pGrid->SetGridCursor(row + 1, col);
00581             m_pGrid->MakeCellVisible(row + 1, col);
00582             m_pGrid->SelectBlock(row, 0, row + 1, colCount);
00583             return;
00584         }
00585     }
00586
00587     // if not found, search from start
00588     for (row = 0; row < rowCount - 1; row++) {
00589         wxString value = m_pGrid->GetCellValue(row, col);
00590         if (value.Length() > 0 && value.CmpNoCase(m_pGrid->GetCellValue(row + 1, col)) == 0) {
00591             m_pGrid->SetGridCursor(row + 1, col);
00592             m_pGrid->MakeCellVisible(row + 1, col);
00593             m_pGrid->SelectBlock(row, 0, row + 1, colCount);
00594             return;
00595         }
00596     }
00597 }
00598
00599 void AddressManagerFrame::OnMenuTableSort(wxCommandEvent& event)
00600 {
00601     // save current edit cell, if neccessary
00602     m_pGrid->DisableCellEditControl();
00603
00604     // copy column names
00605     ColumnFieldArray columns;
00606     columns.Add(NullColumnField());
00607     unsigned i = 0;
00608     for (i = 0; i < (unsigned) m_pGrid->GetCols(); i++) {
00609         columns.Add(ColumnField(m_pGrid->GetColLabelValue(i), i));
00610     }
00611
00612     // ask user for sort order
00613     SortDialog dialog(this, columns);
00614     if (dialog.ShowModal() != wxID_OK) return;
00615
00616     // get sort order
00617     wxBusyCursor wait;
00618     columns = dialog.getSortOrder();
00619     wxASSERT(columns.GetCount() > 0);
00620     int sortCol1 = -1;
00621     int sortCol2 = -1;
00622     int sortCol3 = -1;
00623     if (columns.GetCount() >= 1) sortCol1 = columns[0].getOldIndex();
00624     if (columns.GetCount() >= 2) sortCol2 = columns[1].getOldIndex();
00625     if (columns.GetCount() == 3) sortCol3 = columns[2].getOldIndex();
00626     m_pTable->Sort(sortCol1, sortCol2, sortCol3);
00627
00628     m_dirty = true;
00629
00630     int width, height;
00631     GetSize(&width, &height);
00632     SetSize(width - 1, height - 1);
00633     SetSize(width, height);
00634 }
00635
00636 void AddressManagerFrame::OnMenuTableConfig(wxCommandEvent& event)
00637 {
00638     // save current edit cell, if neccessary
00639     m_pGrid->DisableCellEditControl();
00640
00641     // copy column names
00642     ColumnFieldArray columns;
00643     unsigned i = 0;
00644     for (i = 0; i < (unsigned) m_pGrid->GetCols(); i++) {
00645         columns.Add(ColumnField(m_pGrid->GetColLabelValue(i), i, m_pGrid->GetColumnWidth(i)));
00646     }
00647
00648     // edit
00649     ColumnDialog dialog(this, columns);
00650     if (dialog.ShowModal() != wxID_OK) return;
00651
00652     // get all columns, which are not deleted
00653     wxBusyCursor wait;
00654     columns = dialog.getNewColumns();
00655
00656     // copy in new grid
00657     m_pTable->ChangeColumns(columns);
00658
00659     m_dirty = true;
00660
00661     int width, height;
00662     GetSize(&width, &height);
00663     SetSize(width - 1, height - 1);
00664     SetSize(width, height);
00665 }
00666
00667 void AddressManagerFrame::OnMenuExportEmail(wxCommandEvent& event)
00668 {
00669     // save current edit cell, if neccessary
00670     m_pGrid->DisableCellEditControl();
00671
00672     unsigned rowCount = m_pGrid->GetRows();
00673     unsigned colCount = m_pGrid->GetCols();
00674     if (rowCount < 1) return;
00675
00676     // get eMail index
00677     unsigned col;
00678     bool found = false;
00679     for (col = 0; col < colCount; col++) {
00680         wxString label = m_pGrid->GetColLabelValue(col);
00681         if (label.CmpNoCase("email") == 0) {
00682             found = true;
00683             break;
00684         }
00685     }
00686     if (!found) {
00687         wxMessageDialog errorDialog(this, "eMail-Export nicht möglich, da es keine eMail-Tabellenspalte gibt.", "Address Manager", wxOK | wxICON_INFORMATION);
00688         errorDialog.ShowModal();
00689         return;
00690     }
00691
00692     // init array for testing for valid email characters
00693     bool validChars[256];
00694     unsigned i;
00695     for (i = 0; i <= 255; i++) validChars[i] = false;
00696     for (i = 'a'; i <= 'z'; i++) validChars[i] = true;
00697     for (i = 'A'; i <= 'Z'; i++) validChars[i] = true;
00698     for (i = '0'; i <= '9'; i++) validChars[i] = true;
00699     validChars['@'] = true;
00700     validChars['.'] = true;
00701     validChars['_'] = true;
00702     validChars['-'] = true;
00703     validChars['~'] = true;
00704
00705     // open export file
00706 #if defined(__WXMSW__)
00707     wxFileOutputStream fileOutStream("c:\\email-liste.txt");
00708 #else
00709     wxFileOutputStream fileOutStream("Macintosh HD:email-liste.txt");
00710 #endif
00711     wxTextOutputStream ostr(fileOutStream);
00712
00713     // export
00714     int count = 0;
00715     for (unsigned row = 0; row < rowCount; row++) {
00716         wxString email = m_pGrid->GetCellValue(row, col);
00717         email.Trim(true);
00718         email.Trim(false);
00719
00720         // check for valid emails
00721         unsigned atcount = 0;
00722         unsigned atposition = 0;
00723         if (email.Length() < 3) continue;
00724         for (unsigned i = 0; i < email.Length(); i++) {
00725             wxChar c = email[i];
00726             if (!validChars[c]) continue;
00727             if (c == '@') {
00728                 atcount++;
00729                 atposition = i;
00730                 if (atcount > 1) continue;
00731             }
00732         }
00733         if (atcount != 1) continue;
00734         if (atposition == 0 || atposition == email.Length() - 1) continue;
00735
00736         // write email
00737         ostr << "\t\t" << email << "\n";
00738         count++;
00739     }
00740
00741     // show number of exported emails
00742     wxString msg;
00743     msg << "Es wurden " << count << " eMails exportiert.";
00744     wxMessageBox(msg, "Address Manager", wxICON_INFORMATION | wxOK, this);
00745 }
00746
00747 void AddressManagerFrame::OnMenuExportSMS(wxCommandEvent& event)
00748 {
00749     // save current edit cell, if neccessary
00750     m_pGrid->DisableCellEditControl();
00751
00752     wxMessageBox("Noch nicht implementiert.", "Address Manager", wxICON_INFORMATION | wxOK, this);
00753 }
00754
00755 void AddressManagerFrame::OnMenuExportFax(wxCommandEvent& event)
00756 {
00757     // save current edit cell, if neccessary
00758     m_pGrid->DisableCellEditControl();
00759
00760     wxMessageBox("Noch nicht implementiert.", "Address Manager", wxICON_INFORMATION | wxOK, this);
00761 }
00762
00763 // Ensure that the grid's edit control always has the focus.
00764 void AddressManagerFrame::OnActivate(wxActivateEvent& event)
00765 {
00766     if (m_pGrid) m_pGrid->OnActivate(event.GetActive());
00767 }
00768
00769 // hack: enable scrollbars, if neccessary
00770 void AddressManagerFrame::OnSize( wxSizeEvent &event )
00771 {
00772     wxFrame::OnSize(event);
00773     if (m_pGrid) {
00774         m_pGrid->UpdateDimensions();
00775         m_pGrid->Refresh();
00776     }
00777 }
00778
00779
00780 void AddressManagerFrame::OnClose(wxCloseEvent& event)
00781 {
00782     // save current edit cell, if neccessary
00783     m_pGrid->DisableCellEditControl();
00784
00785     // avoid if we can
00786     if (event.CanVeto()) {
00787         if (!onExit()) {
00788             event.Veto();
00789         } else {
00790             Destroy();
00791         }
00792     } else {
00793         Destroy();
00794     }
00795 }
00796
00797 void AddressManagerFrame::setDirty()
00798 {
00799     m_dirty = true;
00800 }
00801


AddressManagerFrame.h Source File

AddressManagerFrame.h

00001 /*
00002  * Purpose: AddressManager frame
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #ifndef ADDRESS_MANAGER_FRAME_H
00008 #define ADDRESS_MANAGER_FRAME_H
00009
00010 #include "AddressManager.h"
00011 #include "AddressGridTable.h"
00012
00016 class AddressManagerFrame: public wxFrame
00017 {
00018 public:
00022     AddressManagerFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
00023
00027     ~AddressManagerFrame();
00028
00032     void OnAbout(wxCommandEvent& event);
00033
00037     void OnMenuFileNew(wxCommandEvent& event);
00038
00042     void OnMenuFileOpen(wxCommandEvent& event);
00043
00047     void OnMenuFileClose(wxCommandEvent& event);
00048
00055     bool FileSaveImpl();
00056
00060     void OnMenuFileSave(wxCommandEvent& event);
00061
00067     bool FileSaveAsImpl();
00068
00072     void OnMenuFileSaveAs(wxCommandEvent& event);
00073
00077     void OnMenuFileExit(wxCommandEvent& event);
00078
00082     void OnMenuEditCut(wxCommandEvent& event);
00083
00087     void OnMenuEditCopy(wxCommandEvent& event);
00088
00092     void OnMenuEditPaste(wxCommandEvent& event);
00093
00097     void OnMenuEditFind(wxCommandEvent& event);
00098
00102     void OnMenuTableDoublet(wxCommandEvent& event);
00103
00107     void OnMenuTableSort(wxCommandEvent& event);
00108
00112     void OnMenuTableConfig(wxCommandEvent& event);
00113
00117     void OnMenuExportEmail(wxCommandEvent& event);
00118
00122     void OnMenuExportSMS(wxCommandEvent& event);
00123
00127     void OnMenuExportFax(wxCommandEvent& event);
00128
00132     void OnActivate(wxActivateEvent& event);
00133
00137     void OnSize(wxSizeEvent &event);
00138
00146     bool onExit();
00147
00151     void OnClose(wxCloseEvent& event);
00152
00156     void setDirty();
00157
00158 DECLARE_EVENT_TABLE()
00159
00160 private:
00161     void copy(bool erase);
00162     wxGrid* m_pGrid;
00163     AddressGridTable* m_pTable;
00164     wxString m_currentFilename;
00165     wxString m_lastSearchString;
00166     bool m_dirty;
00167 };
00168
00169 #endif


Member List

AddressGridTable Member List

This is the complete list of members for AddressGridTable, including all inherited members.
ChangeColumns(ColumnFieldArray &column) | AddressGridTable
Initialize() | AddressGridTable
Initialize(wxDataInputStream &in) | AddressGridTable
NotifyColsAppended(int numCols) | wxGridTableBaseWithNotifyMethods
NotifyColsDeleted(int pos, int numCols) | wxGridTableBaseWithNotifyMethods
NotifyColsInserted(int pos, int numCols) | wxGridTableBaseWithNotifyMethods
NotifyRowsAppended(int numRows) | wxGridTableBaseWithNotifyMethods
NotifyRowsDeleted(int pos, int numRows) | wxGridTableBaseWithNotifyMethods
NotifyRowsInserted(int pos, int numRows) | wxGridTableBaseWithNotifyMethods
RequestViewGetValues() | wxGridTableBaseWithNotifyMethods
RequestViewSendValues() | wxGridTableBaseWithNotifyMethods
serialize(wxDataOutputStream &out) | AddressGridTable
Sort(int col1, int col2, int col3) | AddressGridTable


Member List

AddressManagerAboutDialog Member List

This is the complete list of members for AddressManagerAboutDialog, including all inherited members.


Member List

AddressManagerApp Member List

This is the complete list of members for AddressManagerApp, including all inherited members.
OnExit() | AddressManagerApp | [virtual]
OnInit(void) | AddressManagerApp | [virtual]


Member List

AddressManagerFrame Member List

This is the complete list of members for AddressManagerFrame, including all inherited members.
AddressManagerFrame(wxFrame *frame, const wxString &title, const wxPoint &pos, const wxSize &size) | AddressManagerFrame
FileSaveAsImpl() | AddressManagerFrame
FileSaveImpl() | AddressManagerFrame
OnAbout(wxCommandEvent &event) | AddressManagerFrame
OnActivate(wxActivateEvent &event) | AddressManagerFrame
OnClose(wxCloseEvent &event) | AddressManagerFrame
onExit() | AddressManagerFrame
OnMenuEditCopy(wxCommandEvent &event) | AddressManagerFrame
OnMenuEditCut(wxCommandEvent &event) | AddressManagerFrame
OnMenuEditFind(wxCommandEvent &event) | AddressManagerFrame
OnMenuEditPaste(wxCommandEvent &event) | AddressManagerFrame
OnMenuExportEmail(wxCommandEvent &event) | AddressManagerFrame
OnMenuExportFax(wxCommandEvent &event) | AddressManagerFrame
OnMenuExportSMS(wxCommandEvent &event) | AddressManagerFrame
OnMenuFileClose(wxCommandEvent &event) | AddressManagerFrame
OnMenuFileExit(wxCommandEvent &event) | AddressManagerFrame
OnMenuFileNew(wxCommandEvent &event) | AddressManagerFrame
OnMenuFileOpen(wxCommandEvent &event) | AddressManagerFrame
OnMenuFileSave(wxCommandEvent &event) | AddressManagerFrame
OnMenuFileSaveAs(wxCommandEvent &event) | AddressManagerFrame
OnMenuTableConfig(wxCommandEvent &event) | AddressManagerFrame
OnMenuTableDoublet(wxCommandEvent &event) | AddressManagerFrame
OnMenuTableSort(wxCommandEvent &event) | AddressManagerFrame
OnSize(wxSizeEvent &event) | AddressManagerFrame
setDirty() | AddressManagerFrame
~AddressManagerFrame() | AddressManagerFrame


Member List

ColumnDialog Member List

This is the complete list of members for ColumnDialog, including all inherited members.
ColumnDialog(wxWindow *parent, ColumnFieldArray &columns) | ColumnDialog
getNewColumns() | ColumnDialog
~ColumnDialog() | ColumnDialog


Member List

ColumnField Member List

This is the complete list of members for ColumnField, including all inherited members.
ColumnField(wxString name, int oldIndex=-1, int oldWidth=0) | ColumnField
getName() | ColumnField
getOldIndex() | ColumnField
getOldWidth() | ColumnField
isNew() | ColumnField
setName(wxString name) | ColumnField


Member List

NullColumnField Member List

This is the complete list of members for NullColumnField, including all inherited members.
ColumnField(wxString name, int oldIndex=-1, int oldWidth=0) | ColumnField
getName() | ColumnField
getOldIndex() | ColumnField
getOldWidth() | ColumnField
isNew() | ColumnField
setName(wxString name) | ColumnField


Member List

SortDialog Member List

This is the complete list of members for SortDialog, including all inherited members.
getSortOrder() | SortDialog
OnOK(wxCommandEvent &event) | SortDialog
SortDialog(wxWindow *parent, ColumnFieldArray &columns) | SortDialog


Member List

wxGridTableBaseWithNotifyMethods Member List

This is the complete list of members for wxGridTableBaseWithNotifyMethods, including all inherited members.
NotifyColsAppended(int numCols) | wxGridTableBaseWithNotifyMethods
NotifyColsDeleted(int pos, int numCols) | wxGridTableBaseWithNotifyMethods
NotifyColsInserted(int pos, int numCols) | wxGridTableBaseWithNotifyMethods
NotifyRowsAppended(int numRows) | wxGridTableBaseWithNotifyMethods
NotifyRowsDeleted(int pos, int numRows) | wxGridTableBaseWithNotifyMethods
NotifyRowsInserted(int pos, int numRows) | wxGridTableBaseWithNotifyMethods
RequestViewGetValues() | wxGridTableBaseWithNotifyMethods
RequestViewSendValues() | wxGridTableBaseWithNotifyMethods


ColumnField.h Source File

ColumnField.h

00001 /*
00002  * Purpose: Helper class for sorting and changing columns
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #ifndef COLUMN_FIELD_H
00008 #define COLUMN_FIELD_H
00009
00013 class ColumnField
00014 {
00015 public:
00022     ColumnField(wxString name, int oldIndex = -1, int oldWidth = 0);
00023
00028     bool isNew();
00029
00033     int getOldIndex();
00034
00038     int getOldWidth();
00039
00043     wxString getName();
00044
00048     void setName(wxString name);
00049
00050 private:
00051     wxString m_name;
00052     int m_oldIndex;
00053     int m_oldWidth;
00054 };
00055
00061 class NullColumnField : public ColumnField
00062 {
00063 public:
00064     NullColumnField() : ColumnField("(keine)") {}
00065 };
00066
00067 #endif  // COLUMN_FIELD_H


dialogs.cpp Source File

dialogs.cpp

00001 /*
00002  * Purpose: All modal dialogs for AddressManager
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 // ==========================================================================
00008 // headers, declarations, constants
00009 // ==========================================================================
00010
00011 #include "wx/wx.h"
00012
00013 #include "wx/statline.h"
00014 #include "wx/minifram.h"
00015
00016 #include "dialogs.h"
00017
00018 #include "wx/arrimpl.cpp"
00019 WX_DEFINE_OBJARRAY(ColumnFieldArray);
00020
00021 // --------------------------------------------------------------------------
00022 // constants
00023 // --------------------------------------------------------------------------
00024 extern char * addresses_xpm[];
00025
00026 // IDs for the controls and the menu commands
00027 enum
00028 {
00029     ID_LISTBOX = 1,
00030     ID_NEW_BUTTON,
00031     ID_RENAME_BUTTON,
00032     ID_UP_BUTTON,
00033     ID_REMOVE_BUTTON,
00034     ID_DOWN_BUTTON
00035 };
00036
00037 // --------------------------------------------------------------------------
00038 // event tables and other macros for wxWindows
00039 // --------------------------------------------------------------------------
00040
00041 // Event tables
00042 BEGIN_EVENT_TABLE(ColumnDialog, wxDialog)
00043     EVT_LISTBOX(ID_LISTBOX, ColumnDialog::OnListBox)
00044     EVT_BUTTON(ID_NEW_BUTTON, ColumnDialog::OnNewButton)
00045     EVT_BUTTON(ID_RENAME_BUTTON, ColumnDialog::OnRenameButton)
00046     EVT_BUTTON(ID_UP_BUTTON, ColumnDialog::OnUpButton)
00047     EVT_BUTTON(ID_REMOVE_BUTTON, ColumnDialog::OnRemoveButton)
00048     EVT_BUTTON(ID_DOWN_BUTTON, ColumnDialog::OnDownButton)
00049 END_EVENT_TABLE()
00050
00051
00052 // ==========================================================================
00053 // implementation
00054 // ==========================================================================
00055
00056 // --------------------------------------------------------------------------
00057 // ColumnDialog
00058 // --------------------------------------------------------------------------
00059
00060
00061 ColumnField::ColumnField(wxString name, int oldIndex, int oldWidth)
00062 {
00063     m_name = name;
00064     m_oldIndex = oldIndex;
00065     m_oldWidth = oldWidth;
00066 }
00067
00068 bool ColumnField::isNew()
00069 {
00070     return m_oldIndex == -1;
00071 }
00072
00073 int ColumnField::getOldIndex()
00074 {
00075     return m_oldIndex;
00076 }
00077
00078 int ColumnField::getOldWidth()
00079 {
00080     return m_oldWidth;
00081 }
00082
00083 wxString ColumnField::getName()
00084 {
00085     return m_name;
00086 }
00087
00088 void ColumnField::setName(wxString name)
00089 {
00090     m_name = name;
00091 }
00092
00093
00094 ColumnDialog::ColumnDialog(wxWindow *parent, ColumnFieldArray& columns)
00095                  : wxDialog(parent, -1,
00096                             _("Tabellenkonfiguration"),
00097                             wxDefaultPosition,
00098                             wxDefaultSize,
00099                             wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
00100 {
00101     m_columns = columns;
00102
00103     // create and populate the list of columns
00104     m_listBox = new wxListBox( this, ID_LISTBOX,
00105         wxDefaultPosition,
00106         wxDefaultSize,
00107         0, NULL,
00108         wxLB_SINGLE | wxLB_NEEDED_SB | wxLB_HSCROLL );
00109
00110     for (unsigned i = 0; i < m_columns.GetCount(); i++) {
00111         wxString name = m_columns[i].getName();
00112         m_listBox->Append(name, &m_columns[i]);
00113     }
00114
00115     wxBoxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL);
00116     topSizer->Add(new wxStaticText(this, -1, "Neue Tabellenspalte:"), 0, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00117     m_newColumnTextCtrl = new wxTextCtrl(this, -1);
00118     topSizer->Add(m_newColumnTextCtrl, 1, wxLEFT | wxTOP, 10);
00119     topSizer->Add(new wxButton(this, ID_NEW_BUTTON, "Hinzufügen"), 0, wxALIGN_RIGHT | wxLEFT | wxTOP | wxRIGHT, 10);
00120
00121     wxBoxSizer* middleSizer = new wxBoxSizer(wxHORIZONTAL);
00122     middleSizer->Add(m_listBox, 0, wxLEFT | wxTOP | wxEXPAND, 10);
00123
00124     wxBoxSizer* listButtonsSizer = new wxBoxSizer(wxVERTICAL);
00125     listButtonsSizer->Add(new wxButton(this, ID_UP_BUTTON, "/\\"), 0, wxLEFT | wxTOP | wxEXPAND, 10);
00126     listButtonsSizer->Add(new wxButton(this, ID_REMOVE_BUTTON, "Löschen"), 0, wxLEFT | wxTOP | wxEXPAND, 10);
00127     listButtonsSizer->Add(new wxButton(this, ID_DOWN_BUTTON, "\\/"), 0, wxLEFT | wxTOP | wxEXPAND, 10);
00128
00129     middleSizer->Add(listButtonsSizer, 0, wxCENTRE);
00130
00131     middleSizer->Add(CreateTextSizer(_("Geben Sie im Textfeld\n"
00132                                         "'Neue Tabellenspalte' den\n"
00133                                         "Namen einer neuen\n"
00134                                         "Tabellenspalte ein und klicken\n"
00135                                         "auf 'Hinzufügen' wenn Sie eine\n"
00136                                         "neue Tabellenspalte erstellen\n"
00137                                         "möchten, oder wählen Sie in der\n"
00138                                         "Liste links eine bestehende\n"
00139                                         "Tabellenspalte aus, wenn Sie\n"
00140                                         "diese verschieben, löschen\n"
00141                                         "oder umbennen möchten.")),
00142                                   0, wxLEFT | wxTOP | wxRIGHT, 10);
00143
00144     wxBoxSizer* bottomSizer = new wxBoxSizer(wxHORIZONTAL);
00145     bottomSizer->Add(new wxStaticText(this, -1, "Gewählte Tabellenspalte:"), 0, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00146     m_editColumnTextCtrl = new wxTextCtrl(this, -1);
00147     m_editColumnTextCtrl->Enable(false);
00148     bottomSizer->Add(m_editColumnTextCtrl, 1, wxALIGN_CENTER | wxLEFT | wxTOP, 10);
00149     m_editButton = new wxButton(this, ID_RENAME_BUTTON, "Umbenennen");
00150     m_editButton->Enable(false);
00151     bottomSizer->Add(m_editButton, 0, wxALIGN_RIGHT | wxLEFT | wxTOP | wxRIGHT, 10);
00152
00153     wxBoxSizer* okCancelSizer = new wxBoxSizer(wxHORIZONTAL);
00154     okCancelSizer->Add(new wxButton(this, wxID_OK, "OK"), 0, wxTOP, 10);
00155     okCancelSizer->Add(new wxButton(this, wxID_CANCEL, "Abbrechen"), 0, wxALL, 10);
00156
00157     wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
00158     topsizer->Add(topSizer, 0, wxEXPAND);
00159     topsizer->Add(middleSizer, 1, wxEXPAND);
00160     topsizer->Add(bottomSizer, 0, wxEXPAND);
00161     topsizer->Add(okCancelSizer, 0, wxALIGN_RIGHT);
00162
00163     SetAutoLayout(TRUE);     // tell dialog to use sizer
00164     SetSizer(topsizer);      // actually set the sizer
00165
00166     topsizer->Fit(this);            // set size to minimum size as calculated by the sizer
00167     topsizer->SetSizeHints(this);   // set size hints to honour mininum size
00168
00169     Centre(wxBOTH | wxCENTRE_ON_SCREEN);
00170 }
00171
00172 ColumnDialog::~ColumnDialog()
00173 {
00174     for (int i = 0; i < m_listBox->GetCount(); i++) {
00175         ColumnField* pField = (ColumnField*)m_listBox->GetClientData(i);
00176         if (pField->isNew()) delete pField;
00177     }
00178 }
00179
00180 void ColumnDialog::OnListBox(wxCommandEvent& event)
00181 {
00182     int sel = event.GetSelection();
00183     if (sel != -1) {
00184         m_editColumnTextCtrl->SetValue(m_listBox->GetString(sel));
00185         m_editColumnTextCtrl->Enable(true);
00186         m_editButton->Enable(true);
00187     }
00188 }
00189
00190 void ColumnDialog::OnNewButton(wxCommandEvent &event)
00191 {
00192     wxString name = m_newColumnTextCtrl->GetValue();
00193     name.Trim(true);
00194     name.Trim(false);
00195     if (name.Length() == 0) {
00196         wxMessageDialog dialog(this, "Der Name einer Tabellenspalte kann nicht leer sein.",
00197             "Address Manager", wxOK | wxICON_INFORMATION);
00198         dialog.ShowModal();
00199         return;
00200     }
00201     for (int i = 0; i < m_listBox->GetCount(); i++) {
00202         if (m_listBox->GetString(i) == name) {
00203             wxMessageDialog dialog(this, "Es existiert bereits eine Tabellenspalte gleichen Namens.",
00204                 "Address Manager", wxOK | wxICON_INFORMATION);
00205             dialog.ShowModal();
00206             return;
00207         }
00208     }
00209     m_listBox->Append(name, new ColumnField(name));
00210     m_listBox->Select(m_listBox->GetCount() - 1);
00211     m_editColumnTextCtrl->SetValue(name);
00212     m_editColumnTextCtrl->Enable(true);
00213     m_editButton->Enable(true);
00214 }
00215
00216 void ColumnDialog::OnRenameButton(wxCommandEvent &event)
00217 {
00218     int sel = m_listBox->GetSelection();
00219     if (sel != -1) {
00220         wxString name = m_editColumnTextCtrl->GetValue();
00221         name.Trim(true);
00222         name.Trim(false);
00223         if (name.Length() == 0) {
00224             wxMessageDialog dialog(this, "Der Name einer Tabellenspalte kann nicht leer sein.",
00225                 "Address Manager", wxOK | wxICON_INFORMATION);
00226             dialog.ShowModal();
00227             return;
00228         }
00229         for (int i = 0; i < m_listBox->GetCount(); i++) {
00230             if (i != sel && m_listBox->GetString(i) == name) {
00231                 wxMessageDialog dialog(this, "Es existiert bereits eine Tabellenspalte gleichen Namens.",
00232                     "Address Manager", wxOK | wxICON_INFORMATION);
00233                 dialog.ShowModal();
00234                 return;
00235             }
00236         }
00237         m_listBox->SetString(sel, name);
00238         ColumnField* pField = (ColumnField*) m_listBox->GetClientData(sel);
00239         pField->setName(name);
00240     }
00241 }
00242
00243 void ColumnDialog::OnUpButton(wxCommandEvent &event)
00244 {
00245     int sel = m_listBox->GetSelection();
00246     if (sel > 0) {
00247         void* pClientData = m_listBox->GetClientData(sel - 1);
00248         wxString name = m_listBox->GetString(sel - 1);
00249         m_listBox->SetClientData(sel - 1, m_listBox->GetClientData(sel));
00250         m_listBox->SetString(sel - 1, m_listBox->GetString(sel));
00251         m_listBox->SetClientData(sel, pClientData);
00252         m_listBox->SetString(sel, name);
00253         m_listBox->Select(sel - 1);
00254     }
00255 }
00256
00257 void ColumnDialog::OnRemoveButton(wxCommandEvent &event)
00258 {
00259     int sel = m_listBox->GetSelection();
00260     if (sel != -1) {
00261         if (m_listBox->GetCount() == 1) {
00262             wxMessageDialog dialog(this, "Es muß mindestens eine Tabellenspalte vorhanden sein.",
00263                 "Address Manager", wxOK | wxICON_INFORMATION);
00264             dialog.ShowModal();
00265             return;
00266         }
00267         ColumnField* pField = (ColumnField*) m_listBox->GetClientData(sel);
00268         m_listBox->Delete(sel);
00269         m_editColumnTextCtrl->SetValue("");
00270         m_editColumnTextCtrl->Enable(false);
00271         m_editButton->Enable(false);
00272         if (pField->isNew()) delete pField;
00273     }
00274 }
00275
00276 void ColumnDialog::OnDownButton(wxCommandEvent &event)
00277 {
00278     int sel = m_listBox->GetSelection();
00279     if (sel != -1 && sel < m_listBox->GetCount() - 1) {
00280         void* pClientData = m_listBox->GetClientData(sel + 1);
00281         wxString name = m_listBox->GetString(sel + 1);
00282         m_listBox->SetClientData(sel + 1, m_listBox->GetClientData(sel));
00283         m_listBox->SetString(sel + 1, m_listBox->GetString(sel));
00284         m_listBox->SetClientData(sel, pClientData);
00285         m_listBox->SetString(sel, name);
00286         m_listBox->Select(sel + 1);
00287     }
00288 }
00289
00290
00291 ColumnFieldArray ColumnDialog::getNewColumns()
00292 {
00293     ColumnFieldArray columns;
00294     for (int i = 0; i < m_listBox->GetCount(); i++) {
00295         columns.Add(*((ColumnField*)m_listBox->GetClientData(i)));
00296     }
00297     return columns;
00298 }
00299
00300
00301 // --------------------------------------------------------------------------
00302 // SortDialog
00303 // --------------------------------------------------------------------------
00304
00305 BEGIN_EVENT_TABLE(SortDialog, wxDialog)
00306     EVT_BUTTON(wxID_OK, SortDialog::OnOK)
00307 END_EVENT_TABLE()
00308
00309
00310 SortDialog::SortDialog(wxWindow *parent, ColumnFieldArray& columns)
00311                  : wxDialog(parent, -1,
00312                             _("Sortieren"),
00313                             wxDefaultPosition,
00314                             wxDefaultSize,
00315                             wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
00316 {
00317     m_columns = columns;
00318
00319     // create and populate the list of columns
00320     m_sort1Choice = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, 0, NULL);
00321     m_sort2Choice = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, 0, NULL);
00322     m_sort3Choice = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, 0, NULL);
00323
00324     for (unsigned i = 0; i < m_columns.GetCount(); i++) {
00325         wxString name = m_columns[i].getName();
00326         m_sort1Choice->Append(name, &m_columns[i]);
00327         m_sort2Choice->Append(name, &m_columns[i]);
00328         m_sort3Choice->Append(name, &m_columns[i]);
00329     }
00330     m_sort1Choice->SetSelection(0);
00331     m_sort2Choice->SetSelection(0);
00332     m_sort3Choice->SetSelection(0);
00333
00334     wxBoxSizer* sort1HeadSizer = new wxBoxSizer(wxHORIZONTAL);
00335     wxBoxSizer* sort1ContentSizer = new wxBoxSizer(wxHORIZONTAL);
00336     sort1HeadSizer->Add(new wxStaticText(this, -1, "Sortieren nach"), 0, wxCENTER | wxLEFT | wxTOP, 10);
00337     sort1HeadSizer->Add(new wxStaticLine(this, -1), 1, wxCENTER | wxLEFT | wxRIGHT | wxTOP, 10);
00338     sort1ContentSizer->Add(m_sort1Choice, 0, wxLEFT | wxTOP, 10);
00339     m_sort1CheckboxUp = new wxRadioButton(this, -1, "Aufsteigend", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
00340     m_sort1CheckboxDown = new wxRadioButton(this, -1, "Absteigend");
00341     wxBoxSizer* rb1Sizer = new wxBoxSizer(wxVERTICAL);
00342     rb1Sizer->Add(m_sort1CheckboxUp, 0, wxTOP, 5);
00343     rb1Sizer->Add(m_sort1CheckboxDown, 0, wxTOP, 5);
00344     sort1ContentSizer->Add(rb1Sizer, 0, wxLEFT | wxRIGHT, 10);
00345
00346     wxBoxSizer* sort2HeadSizer = new wxBoxSizer(wxHORIZONTAL);
00347     wxBoxSizer* sort2ContentSizer = new wxBoxSizer(wxHORIZONTAL);
00348     sort2HeadSizer->Add(new wxStaticText(this, -1, "Anschließend nach"), 0, wxCENTER | wxLEFT | wxTOP, 10);
00349     sort2HeadSizer->Add(new wxStaticLine(this, -1), 1, wxCENTER | wxLEFT | wxRIGHT | wxTOP, 10);
00350     sort2ContentSizer->Add(m_sort2Choice, 0, wxLEFT | wxTOP, 10);
00351     m_sort2CheckboxUp = new wxRadioButton(this, -1, "Aufsteigend", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
00352     m_sort2CheckboxDown = new wxRadioButton(this, -1, "Absteigend");
00353     wxBoxSizer* rb2Sizer = new wxBoxSizer(wxVERTICAL);
00354     rb2Sizer->Add(m_sort2CheckboxUp, 0, wxTOP, 5);
00355     rb2Sizer->Add(m_sort2CheckboxDown, 0, wxTOP, 5);
00356     sort2ContentSizer->Add(rb2Sizer, 0, wxLEFT | wxRIGHT, 10);
00357
00358     wxBoxSizer* sort3HeadSizer = new wxBoxSizer(wxHORIZONTAL);
00359     wxBoxSizer* sort3ContentSizer = new wxBoxSizer(wxHORIZONTAL);
00360     sort3HeadSizer->Add(new wxStaticText(this, -1, "Zuletzt nach"), 0, wxCENTER | wxLEFT | wxTOP, 10);
00361     sort3HeadSizer->Add(new wxStaticLine(this, -1), 1, wxCENTER | wxLEFT | wxRIGHT | wxTOP, 10);
00362     sort3ContentSizer->Add(m_sort3Choice, 0, wxLEFT | wxTOP, 10);
00363     m_sort3CheckboxUp = new wxRadioButton(this, -1, "Aufsteigend", wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
00364     m_sort3CheckboxDown = new wxRadioButton(this, -1, "Absteigend");
00365     wxBoxSizer* rb3Sizer = new wxBoxSizer(wxVERTICAL);
00366     rb3Sizer->Add(m_sort3CheckboxUp, 0, wxTOP, 5);
00367     rb3Sizer->Add(m_sort3CheckboxDown, 0, wxTOP, 5);
00368     sort3ContentSizer->Add(rb3Sizer, 0, wxLEFT | wxRIGHT, 10);
00369
00370     wxBoxSizer* okCancelSizer = new wxBoxSizer(wxHORIZONTAL);
00371     wxButton* okButton = new wxButton(this, wxID_OK, "OK");
00372     okButton->SetDefault();
00373     okCancelSizer->Add(okButton, 0, wxTOP, 10);
00374     okCancelSizer->Add(new wxButton(this, wxID_CANCEL, "Abbrechen"), 0, wxALL, 10);
00375
00376     wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL);
00377     topsizer->Add(sort1HeadSizer, 0, wxEXPAND);
00378     topsizer->Add(sort1ContentSizer, 0, wxLEFT | wxRIGHT, 10);
00379     topsizer->Add(sort2HeadSizer, 0, wxEXPAND);
00380     topsizer->Add(sort2ContentSizer, 0, wxLEFT | wxRIGHT, 10);
00381     topsizer->Add(sort3HeadSizer, 0, wxEXPAND);
00382     topsizer->Add(sort3ContentSizer, 0, wxLEFT | wxRIGHT, 10);
00383     topsizer->Add(okCancelSizer, 0, wxTOP | wxALIGN_RIGHT, 10);
00384
00385     SetAutoLayout(TRUE);     // tell dialog to use sizer
00386     SetSizer(topsizer);      // actually set the sizer
00387
00388     topsizer->Fit(this);            // set size to minimum size as calculated by the sizer
00389     topsizer->SetSizeHints(this);   // set size hints to honour mininum size
00390
00391     Centre(wxBOTH | wxCENTRE_ON_SCREEN);
00392 }
00393
00394 ColumnFieldArray SortDialog::getSortOrder()
00395 {
00396     ColumnFieldArray columns;
00397     int sel1 = m_sort1Choice->GetSelection();
00398     int sel2 = m_sort2Choice->GetSelection();
00399     int sel3 = m_sort3Choice->GetSelection();
00400     if (sel1 != 0) columns.Add(*((ColumnField*)m_sort1Choice->GetClientData(sel1)));
00401     if (sel2 != 0) columns.Add(*((ColumnField*)m_sort2Choice->GetClientData(sel2)));
00402     if (sel3 != 0) columns.Add(*((ColumnField*)m_sort3Choice->GetClientData(sel3)));
00403     return columns;
00404 }
00405
00406 void SortDialog::OnOK(wxCommandEvent& event)
00407 {
00408     int sel1 = m_sort1Choice->GetSelection();
00409     int sel2 = m_sort2Choice->GetSelection();
00410     int sel3 = m_sort3Choice->GetSelection();
00411     if (sel1 == 0 && sel2 == 0 && sel3 == 0) {
00412         wxMessageDialog dialog(this, "Bitte wählen Sie zumindest eine Tabellenspalte, nach der sortiert werden soll,\n"
00413             "oder brechen Sie die Auswahl mit Klick auf die Abbrechen-Schaltfläche ab.",
00414             "Address Manager", wxOK | wxICON_INFORMATION);
00415         dialog.ShowModal();
00416         return;
00417     }
00418     if (sel2 != 0 && sel1 == 0) {
00419         wxMessageDialog dialog(this, "Bitte wählen Sie auch die Tabellenspalte aus, nach der zuerst sortiert wird,\n"
00420             "oder wählen Sie nur bei 'Sortieren nach' eine Tabellenspalte aus.",
00421             "Address Manager", wxOK | wxICON_INFORMATION);
00422         dialog.ShowModal();
00423         return;
00424     }
00425     if (sel3 != 0 && (sel1 == 0 || sel2 == 0)) {
00426         wxMessageDialog dialog(this, "Bitte wählen Sie auch die Tabellenspalte aus, nach der zuerst und als zweites sortiert wird,\n"
00427             "oder wählen Sie nur bei 'Sortieren nach' und / oder bei 'Anschließend nach' eine Tabellenspalte aus.",
00428             "Address Manager", wxOK | wxICON_INFORMATION);
00429         dialog.ShowModal();
00430         return;
00431     }
00432     if ((sel1 != 0 && sel1 == sel2) || (sel1 != 0 && sel1 == sel3) || (sel2 != 0 && sel2 == sel3)) {
00433         wxMessageDialog dialog(this, "Bitte wählen Sie nur unterschiedliche Tabellenspalten oder '(keine)' aus.",
00434             "Address Manager", wxOK | wxICON_INFORMATION);
00435         dialog.ShowModal();
00436         return;
00437     }
00438
00439     wxDialog::OnOK(event);
00440 }
00441
00442
00443 // --------------------------------------------------------------------------
00444 // AddressManagerAboutDialog
00445 // --------------------------------------------------------------------------
00446
00447 AddressManagerAboutDialog::AddressManagerAboutDialog(wxWindow *parent)
00448                : wxDialog(parent, -1,
00449                           _("Über Address Manager"),
00450                           wxDefaultPosition,
00451                           wxDefaultSize,
00452                           wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
00453 {
00454     // layout components
00455     wxBitmap bmp = wxBitmap(addresses_xpm);
00456     wxStaticBitmap *sbmp = new wxStaticBitmap(this, -1, bmp);
00457     wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
00458     wxBoxSizer *picAndTextSizer = new wxBoxSizer( wxHORIZONTAL );
00459     picAndTextSizer->Add( sbmp, 0, wxCENTRE | wxTOP | wxLEFT, 10);
00460     picAndTextSizer->Add( CreateTextSizer(_("Address Manager Version 1.0\n\n"
00461                                   "(c) 2002 Frank Buß, fb@frank-buss.de")),
00462                                   0, wxCENTRE | wxTOP | wxLEFT | wxRIGHT, 10);
00463     vertSizer->Add(picAndTextSizer, 0);
00464     vertSizer->Add(CreateButtonSizer(wxOK), 0, wxCENTRE | wxALL, 10);
00465
00466     // activate
00467     SetSizer(vertSizer);
00468     SetAutoLayout(true);
00469     vertSizer->SetSizeHints(this);
00470     vertSizer->Fit(this);
00471     Centre(wxBOTH | wxCENTRE_ON_SCREEN);
00472 }


dialogs.h Source File

dialogs.h

00001 /*
00002  * Purpose: All modal dialogs for AddressManager
00003  * Author:  Frank Buß
00004  * Created: 2002
00005  */
00006
00007 #ifndef ADDRESS_MANAGER_DIALOGS_H
00008 #define ADDRESS_MANAGER_DIALOGS_H
00009
00010
00011 #include <wx/wx.h>
00012
00013 #include "AddressManager.h"
00014
00018 class ColumnDialog : public wxDialog
00019 {
00020 public:
00026     ColumnDialog(wxWindow* parent, ColumnFieldArray& columns);
00027
00031     ~ColumnDialog();
00032
00033     // event handlers
00034     void OnListBox(wxCommandEvent &event);
00035     void OnNewButton(wxCommandEvent &event);
00036     void OnRenameButton(wxCommandEvent &event);
00037     void OnUpButton(wxCommandEvent &event);
00038     void OnRemoveButton(wxCommandEvent &event);
00039     void OnDownButton(wxCommandEvent &event);
00040
00048     ColumnFieldArray getNewColumns();
00049
00050 private:
00051     // any class wishing to process wxWindows events must use this macro
00052     DECLARE_EVENT_TABLE()
00053
00054     wxListBox*  m_listBox;
00055     wxTextCtrl* m_newColumnTextCtrl;
00056     wxTextCtrl* m_editColumnTextCtrl;
00057     wxButton* m_editButton;
00058
00059     ColumnFieldArray m_columns;
00060 };
00061
00065 class SortDialog : public wxDialog
00066 {
00067 public:
00073     SortDialog(wxWindow* parent, ColumnFieldArray& columns);
00074
00081     ColumnFieldArray getSortOrder();
00082
00086     void OnOK(wxCommandEvent& event);
00087
00088 private:
00089     DECLARE_EVENT_TABLE()
00090
00091     wxChoice* m_sort1Choice;
00092     wxChoice* m_sort2Choice;
00093     wxChoice* m_sort3Choice;
00094     wxRadioButton* m_sort1CheckboxUp;
00095     wxRadioButton* m_sort1CheckboxDown;
00096     wxRadioButton* m_sort2CheckboxUp;
00097     wxRadioButton* m_sort2CheckboxDown;
00098     wxRadioButton* m_sort3CheckboxUp;
00099     wxRadioButton* m_sort3CheckboxDown;
00100
00101     ColumnFieldArray m_columns;
00102 };
00103
00104
00105
00109 class AddressManagerAboutDialog : public wxDialog
00110 {
00111 public:
00112     AddressManagerAboutDialog(wxWindow *parent);
00113 };
00114
00115
00116 #endif  // ADDRESS_MANAGER_DIALOGS