summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2RemoveFavoriteDialog.cpp
blob: 2c65212dedc746be446e28bbdcdc9b60845f1bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "StdAfx.h"
#include "CTokenizer.h"
#include "T2Name.h"
#include "T2NameList.h"
#include "T2NameTable.h"
#include "T2RemoveFavoriteDialog.h"
#include "../T2TowerDoc.h"

T2RemoveFavoriteDialog::T2RemoveFavoriteDialog()
    : mNameType(0)
{
    mNameTable = NULL;
    mCloseButton = NULL;
    mDeleteButton = NULL;
}

/*virtual*/ T2RemoveFavoriteDialog::~T2RemoveFavoriteDialog() {
}

/*virtual*/ void T2RemoveFavoriteDialog::OnT2Create() {
    mDeleteButton = GetDlgItem(1001);
    mCloseButton = GetDlgItem(1002);
    mNameTable = (T2NameTable *) GetDlgItem(1005);
}

/*virtual*/ void T2RemoveFavoriteDialog::CreateDlgItem(CTokenizer& inTokenizer, T2DialogDef& inDef) {
    if (!_stricmp(inTokenizer.Current(), "NMTBL")) {
        RECT rect;
        UINT id = inTokenizer.NextInteger();
        rect.left = inTokenizer.NextInteger();
        rect.top = inTokenizer.NextInteger();
        rect.right = inTokenizer.NextInteger();
        rect.bottom = inTokenizer.NextInteger();

        T2NameTable *item = new T2NameTable(mTowerDoc, mImageObj, mPalette);
        item->Create("", inDef.flags, rect, this, id);
        item->CreateSubItem(NULL);
        if (mCurrentFont >= 0)
            item->SetFont(*mFonts[mCurrentFont]);
    } else {
        T2Dialog::CreateDlgItem(inTokenizer, inDef);
    }
}

/*virtual*/ void T2RemoveFavoriteDialog::OnT2Destroy() {
}

/*virtual*/ BOOL T2RemoveFavoriteDialog::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) {
    WORD code = HIWORD(inWParam);
    WORD id = LOWORD(inWParam);
    BOOL result = false;

    if (id == 1002 && code == 0) {
        DestroyWindow();
        result = true;
    } else if (id == 1001 && code == 0) {
#line 67
        _ASSERT(mNameTable != NULL);

        T2Name *theName = mNameTable->GetSelectedName();
        if (theName) {
            CString str;
            unsigned int id;
            theName->GetName(str, id);
            switch (mNameType) {
                case kPeopleNameType:
                    mNameTable->RemoveCurrentCell();
                    break;
                case kTenantNameType:
                    mNameTable->RemoveCurrentCell();
                    break;
            }
        }
    } else {
        result = T2Dialog::OnT2DialogCommand(inWParam, inLParam);
    }

    return result;
}

void T2RemoveFavoriteDialog::InitializeForRemovePeople(T2TowerDoc* inDoc) {
#line 98
    _ASSERT(mNameTable != NULL);
    mNameTable->InsertCols(1, 0, NULL);

#line 100
    _ASSERT(inDoc->mNameDB != NULL);

    LArrayIterator iterator(*inDoc->mNameDB);
    T2Name *name = NULL;
    int o = 0; // unused

    while (iterator.Next(&name)) {
        if (name->IsFavorite() && name->GetType() == kPeopleNameType)
            mNameTable->Add(name);
    }

    // "cお好み削除"
    CString dialogText = "\x63\x82\xA8\x8D\x44\x82\xDD\x8D\xED\x8F\x9C";
    // "-人"
    dialogText += "\x2D\x90\x6C";

    SetWindowText(dialogText);
    mNameType = kPeopleNameType;
}

void T2RemoveFavoriteDialog::InitializeForRemoveTenant(T2TowerDoc* inDoc) {
#line 122
    _ASSERT(mNameTable != NULL);
    mNameTable->InsertCols(1, 0, NULL);

#line 124
    _ASSERT(inDoc->mNameDB != NULL);

    LArrayIterator iterator(*inDoc->mNameDB);
    T2Name *name = NULL;
    int o = 0; // unused

    while (iterator.Next(&name)) {
        if (name->IsFavorite() && name->GetType() == kTenantNameType)
            mNameTable->Add(name);
    }

    // "cお好み削除"
    CString dialogText = "\x63\x82\xA8\x8D\x44\x82\xDD\x8D\xED\x8F\x9C";
    // "-テナント"
    dialogText += "\x2D\x83\x65\x83\x69\x83\x93\x83\x67";

    SetWindowText(dialogText);
    mNameType = kTenantNameType;
}