a99  V32.6
allegro Windows Hauptprogramm
 Alle Klassen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
alistbox.cpp
gehe zur Dokumentation dieser Datei
1 // aListBox.cpp : ListBox mit Groessenaenderung
2 //
3 // Copyright 2011 Universitätsbibliothek Braunschweig, more see bottom
4 
5 #include "stdafx.h"
6 #include "program.h"
7 #include "ca99.h"
8 #include "a99.h"
9 #include "winx.h"
10 #include "aListBox.h"
11 #include "wkv.h"
12 
13 #ifdef _DEBUG
14 #define new DEBUG_NEW
15 #undef THIS_FILE
16 static char THIS_FILE[] = __FILE__;
17 #endif
18 
19 extern a99 *dlg;
20 
21 
22 /////////////////////////////////////////////////////////////////////////////
23 // CaListBox
24 
26 {
27  B=0;
28 }
29 
31 {
32 }
33 
34 
35 BEGIN_MESSAGE_MAP(CaListBox, CListBox)
36  //{{AFX_MSG_MAP(CaListBox)
37  ON_WM_CHAR()
38  ON_WM_KEYDOWN()
39  ON_WM_SYSKEYDOWN()
40  ON_WM_LBUTTONDOWN()
41  ON_WM_LBUTTONUP()
42  ON_WM_CONTEXTMENU()
43  //}}AFX_MSG_MAP
44 END_MESSAGE_MAP()
45 
46 /////////////////////////////////////////////////////////////////////////////
47 // CaListBox message handlers
48 
49 int lsc=0;
50 
51 void CaListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
52 {
53  int i=nChar; int j=EOF; CHAR *p;
54  extern int Esc; // default: 92
55 
56 if(GetParent()==dlg) // not if parent is main window
57  if(nChar==VK_ESCAPE) return; // Esc nicht verarb!
58 
59 if(i==8) GetParent()->PostMessage(WM_GOODBYE, 31, 46); //BackSpace->VK_DELETE
60 else
61  {
62  if(i<27) j=UtPfind(i);
63  if(i==Esc) { if(!lsc) { lsc=1; return; } else lsc=0; }
64  if(i>27 && lsc==1)
65  {
66  j=UtPfind(i);
67  }
68  lsc=0;
69  if(j!=EOF)
70  {
71  p=pa[j];
72  if(tolower((char)*p)=='x' && p[1]==' ') { dlg->FLEXecute((char *)p); return; }
73  }
74  if(i>31)
75  {
76 
77  GetParent()->PostMessage(WM_GOODBYE, 32, i);
78 
79  }
80  else CListBox::OnChar(nChar, nRepCnt, nFlags);
81  }
82 }
83 
84 void CaListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
85 {
86 
87 if(GetParent()==dlg) // not if parent is main window
88  if(nChar==VK_ESCAPE) return; // Esc nicht verarb!
89  if(nChar==VK_DELETE) GetParent()->PostMessage(WM_GOODBYE, 31, 46); //Del
90  if(nChar==VK_INSERT) GetParent()->PostMessage(WM_GOODBYE, 31, 45); //Insert
91 
92  if(GetParent()!=dlg) // not if parent is main window
93  if(nChar>32 && nChar<38)
94 {
95  // 33=PgUp, 34=PgDn, 35=End, 36=HOME, 37=LEFT, 118=F7, 116=F5, 120=F9
96 
97  GetParent()->PostMessage(WM_GOODBYE, 31, nChar);
98  return;
99 }
100  if(nChar>112 && nChar<124)
101 {
102 
103  GetParent()->PostMessage(WM_GOODBYE, 31, nChar);
104  return;
105 }
106 
107  // 38=CUp , 40=CDn CUp braucht Sonderbehandlung:
108  if(nChar==38) GetParent()->PostMessage(WM_GOODBYE,31,nChar);
109 
110  CListBox::OnChar(nChar, nRepCnt, nFlags);
111 }
112 
113 void CaListBox::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) //Alt-Taste
114 {
115 // sprintf(Aerror,"%d,%d",nChar,nFlags);
116 // dlg->m_enter.SetWindowText(Aerror); *Aerror=0;
117 if(nChar==219 || nChar==221) GetParent()->PostMessage(WM_GOODBYE,31,nChar);
118 else if(nChar==37) dlg->OnBack();
119 else if(nChar==39) dlg->OnForw();
120 else CListBox::OnSysKeyDown(nChar,nRepCnt,nFlags);
121 }
122 
123 void CaListBox::OnLButtonDown( UINT u, CPoint p)
124 {
125  CWnd::OnLButtonDown(u,p);
126  d=GetCurSel();
127 }
128 
129 void CaListBox::OnLButtonUp( UINT ui, CPoint p)
130 {
131  lm=true;
132  CWnd::OnLButtonUp(ui,p);
133  u=GetCurSel();
134 }
135 
136 // Rechte Maustaste? onlist.flx
137 void CaListBox::OnContextMenu(CWnd* pWnd, CPoint point)
138 {
139 // dlg->FLEXecute("X onlist");
140 }
141 
142 void CaListBox::movewin(int cx,int cy,int md) // md=1 : result set mode, else 0
143 {
144 extern int wihi, wiwi, wcx, wcy;
145 int wh=wihi,ww=wiwi;
146 wcx=cx, wcy=cy;
147 if(!B)
148 {
149  WINDOWPLACEMENT pl;
150  GetWindowPlacement(&pl);
151  L=pl.rcNormalPosition.left;
152  R=pl.rcNormalPosition.right;
153  T=pl.rcNormalPosition.top;
154  B=pl.rcNormalPosition.bottom/(1+md*0.8);
155 // sprintf(Aerror,"eL=%d,eR=%d,eT=%d,eB=%d",L,R,T,B); MessageBox(Aerror);
156 }
157  if(md==1) { Ba=B; B=B*0.94; } if(md==-1) B=Ba;
158 #ifdef ND2
159  MoveWindow(L*cx/ww,18,((R-L)*cx)/ww,((B-T)*cy)/wihi);
160 #else
161  MoveWindow(L*cx/ww,T*cy/wihi,((R-L)*cx)/ww,((B-T)*cy)/wihi);
162 #endif
163 }
164 
165 
166 void CaListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
167 {
168  // our code to draw the specified item
169  CDC dc;
170 
171  dc.Attach(lpDrawItemStruct->hDC); //Get device context object
172  CRect rt;
173 extern a99 *dlg; // main dialog
174 extern Wkv *wkv;
175 extern char fowi, fomd;
176 extern int flxflg;
177  int r,g,b;
178 // works not
179 // COLORREF cr=dc.GetBkColor();
180 // r=cr&3; g=(cr&12)/4; b=(cr&48)/16;
181 //
182 // what window are we in?
183 
184  if(this==dlg->winxi->m_ixl || this==dlg->winxj->m_ixl) // index
185  {
186  r=255, g=255, b=255;
187  if(fowi==2 || fomd || flxflg) r=250,g=250,b=170; // offline: yellow
188  }
189  else if(this==&wkv->m_brief) // BRief list
190  {
191  r=215, g=255, b=215; // normal: result set
192  if(wkv->resT==0) r=250,g=250,b=150; // offline: yellow
193  if(wkv->docT>2) r=236, g=236, b=255; // view: lilac
194  }
195  else r=g=b=255; // listbox of main window
196  rt = lpDrawItemStruct->rcItem; //Get item rect
197  int nitem = lpDrawItemStruct->itemID;
198 
199  if(nitem<0) { return; } // Kein Inhalt im item
200 
201  CString strTemp;
202  GetText( nitem, strTemp); // Get Item content
203 
204 
205  UINT state = lpDrawItemStruct->itemState; //Get state of the button
206  dc.SetTextColor(RGB(0,0,0));
207 
208  if ( (state & ODS_FOCUS ) ) // If the button is focused
209  {
210  dc.FillSolidRect(rt, RGB(120, 240, 255)); //Background lightblue color
211  }
212  else if ( (state & ODS_SELECTED ) ) // If the button is selected
213  {
214  dc.FillSolidRect(rt, RGB(192, 192, 192)); //Background grey color
215  }
216  else
217  {
218  dc.FillSolidRect(rt, RGB(r, g, b)); //Background custom color, see above
219  }
220 
221  // Set the color of the caption to be yellow
222 
223  int iChange = 2;
224  rt.left += iChange;
225  rt.right -= iChange;
226 
227  dc.DrawText(strTemp,rt,DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
228  // Draw out the caption
229  if ( (state & ODS_FOCUS ) ) // If the button is focused
230  {
231  // Draw a focus rect which indicates the user
232  // that the button is focused
233  //iChange = 1;
234  //rt.top += iChange;
235  //rt.bottom -= iChange;
236  iChange = 1;
237  rt.left -= iChange;
238  rt.right += iChange;
239  dc.DrawFocusRect(rt);
240  }
241  dc.Detach();
242 
243 }
244 
245 
246 /*
247  Copyright 2011 Universitätsbibliothek Braunschweig
248 
249  Licensed under the Apache License, Version 2.0 (the "License");
250  you may not use this file except in compliance with the License.
251  You may obtain a copy of the License at
252 
253  http://www.apache.org/licenses/LICENSE-2.0
254 
255  Unless required by applicable law or agreed to in writing, software
256  distributed under the License is distributed on an "AS IS" BASIS,
257  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
258  See the License for the specific language governing permissions and
259  limitations under the License.
260 */
261