[sword-svn] r53 - in trunk/src: . gui
dtrotzjr at www.crosswire.org
dtrotzjr at www.crosswire.org
Tue Dec 11 01:42:02 MST 2007
Author: dtrotzjr
Date: 2007-12-11 01:42:01 -0700 (Tue, 11 Dec 2007)
New Revision: 53
Modified:
trunk/src/SwRd.vcb
trunk/src/SwRd.vco
trunk/src/gui/Main.cpp
trunk/src/gui/NavFind.cpp
trunk/src/gui/NavFind.h
trunk/src/gui/TextControl.cpp
trunk/src/gui/TextControl.h
Log:
Added the NavFind portrait/landscape handling.
Modified: trunk/src/SwRd.vcb
===================================================================
(Binary files differ)
Modified: trunk/src/SwRd.vco
===================================================================
(Binary files differ)
Modified: trunk/src/gui/Main.cpp
===================================================================
--- trunk/src/gui/Main.cpp 2007-12-10 18:18:33 UTC (rev 52)
+++ trunk/src/gui/Main.cpp 2007-12-11 08:42:01 UTC (rev 53)
@@ -57,8 +57,8 @@
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_BIBLEREADER));
wc.hCursor = 0;
- wc.hbrBackground = 0;// we paint our own background, was: (HBRUSH) GetStockObject(WHITE_BRUSH);
- wc.lpszMenuName = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); // Setting this does not prevent us from drawing our ownbackground. dtrotzjr
+ wc.lpszMenuName = 0;
wc.lpszClassName = szWindowClass;
return RegisterClass(&wc);
Modified: trunk/src/gui/NavFind.cpp
===================================================================
--- trunk/src/gui/NavFind.cpp 2007-12-10 18:18:33 UTC (rev 52)
+++ trunk/src/gui/NavFind.cpp 2007-12-11 08:42:01 UTC (rev 53)
@@ -26,62 +26,55 @@
goID=navigator->getID();
resultsID=navigator->getID();
- // test if display is portrait or landscape, and adjust 'preview' and hits
- // listbox window size and other controls accordingly.
- int scrHeight = 100; // if landscape mode height of search lisbox
- int extrawidth = 65; // if mode = landscape, make controls and preview extrawide
- if (IsPortrait()) {
- scrHeight = 173; // height of search lisbox in portrait mode
- extrawidth = 0; // controls and preview don't need to be extrawide
- }
-
// create windows ce managed controls
queryEdit = CreateWindow(_T("edit"), NULL,
WS_CHILD | ES_AUTOHSCROLL | ES_LEFT | WS_TABSTOP | WS_BORDER,
- 0, 0, 180, 24,
+ 0,0,0,0,
g_hWnd, NULL, g_hInst, NULL);
search = CreateWindow(_T("button"), L"Search",
WS_CHILD | BS_PUSHBUTTON,
- 180, 0, 60+extrawidth, 24,
+ 0,0,0,0,
g_hWnd, registerID(searchID), g_hInst, NULL);
+
+ // Radio Buttons
rangeBible = CreateWindow(_T("button"), L"Whole bible",
WS_CHILD | BS_RADIOBUTTON,
- 0,24,120,24, g_hWnd, registerID(rangeBibleID),g_hInst, NULL);
+ 0,0,0,0,
+ g_hWnd, registerID(rangeBibleID),g_hInst, NULL);
rangeTestament = CreateWindow(_T("button"), L"This testament",
WS_CHILD | BS_RADIOBUTTON,
- 0,48,120,24, g_hWnd, registerID(rangeTestamentID),g_hInst, NULL);
+ 0,0,0,0,
+ g_hWnd, registerID(rangeTestamentID),g_hInst, NULL);
rangeBook = CreateWindow(_T("button"), L"This book",
WS_CHILD | BS_RADIOBUTTON,
- 0,72,120+extrawidth,24, g_hWnd, registerID(rangeBookID),g_hInst, NULL);
+ 0,0,0,0,
+ g_hWnd, registerID(rangeBookID),g_hInst, NULL);
methodMultiword = CreateWindow(_T("button"), L"Multi-word",
WS_CHILD | BS_RADIOBUTTON,
- 120,24,120+extrawidth,24, g_hWnd, registerID(methodMultiwordID),g_hInst, NULL);
+ 0,0,0,0,
+ g_hWnd, registerID(methodMultiwordID),g_hInst, NULL);
methodExactphrase = CreateWindow(_T("button"), L"Exact phrase",
WS_CHILD | BS_RADIOBUTTON,
- 120,48,120+extrawidth,24, g_hWnd, registerID(methodExactphraseID),g_hInst, NULL);
- title = CreateWindow(_T("static"),L"",
- WS_CHILD,
- 120,72,120+extrawidth,24, g_hWnd, NULL, g_hInst, NULL);
+ 0,0,0,0,
+ g_hWnd, registerID(methodExactphraseID),g_hInst, NULL);
check(rangeBook);
rangeMode=RANGEBOOK;
check(methodMultiword);
methodMode=METHODMULTIWORD;
-
-
results = CreateWindow(_T("listbox"),NULL,
WS_CHILD | WS_VSCROLL | LBS_DISABLENOSCROLL | LBS_NOTIFY | WS_BORDER | LBS_NOINTEGRALHEIGHT,
- // 0,96,80,173, g_hWnd, registerID(resultsID), g_hInst, NULL); //bottom row of screen
- // above was original setting for portrait mode
- 0,96,80,scrHeight, g_hWnd, registerID(resultsID), g_hInst, NULL); //bottom row of screen
+ 0,0,0,0,
+ g_hWnd, registerID(resultsID), g_hInst, NULL); //bottom row of screen
// the last figure in above line needs to be 100 for landscape or 173 for portrait (scrHeight)
progressBar = CreateWindow(PROGRESS_CLASS, L"",
WS_CHILD | WS_BORDER | PBS_SMOOTH,
- 80,96,100,24, g_hWnd, NULL, g_hInst, NULL);
+ 0,0,0,0,
+ g_hWnd, NULL, g_hInst, NULL);
go = CreateWindow(_T("button"), L"Go to",
WS_CHILD | BS_PUSHBUTTON,
- 180,96,60+extrawidth,24,
+ 0,0,0,0,
g_hWnd, registerID(goID), g_hInst, NULL);
// HTML control
// preview=new TextControl(80,120,160,148); // this is OK for portrait
@@ -89,12 +82,13 @@
// preview window does not have scroll bars. Are long verses going to
// become a problem? Maybe it's not that important. If it is, then add scrollbars.
- preview=new TextControl(80,120,160+extrawidth,148); // the last figure is the height
+ preview=new TextControl(0,0,0,0, true); // the last figure is the height
// I haven't bothered changing the height - what is off-screen simply doesn't show.
// There is no test and no error.
preview->clearText();
preview->addText(UString(L"preview"));
preview->endOfText();
+ placeWidgets();
}
NavFind::~NavFind() {
@@ -111,7 +105,7 @@
ShowWindow(rangeBook,SW_SHOW);
ShowWindow(methodMultiword,SW_SHOW);
ShowWindow(methodExactphrase,SW_SHOW);
- ShowWindow(title,SW_SHOW);
+ //ShowWindow(title,SW_SHOW);
ShowWindow(results,SW_SHOW);
ShowWindow(progressBar,SW_SHOW);
@@ -131,7 +125,7 @@
ShowWindow(rangeBook,SW_HIDE);
ShowWindow(methodMultiword,SW_HIDE);
ShowWindow(methodExactphrase,SW_HIDE);
- ShowWindow(title,SW_HIDE);
+ //ShowWindow(title,SW_HIDE);
ShowWindow(results,SW_HIDE);
ShowWindow(progressBar,SW_HIDE);
@@ -141,11 +135,49 @@
}
void NavFind::paint() {
+ placeWidgets();
// this method can be used to do custom painting, for an example, see NavBooks::paint()
// propagate to HTML control
preview->paint();
}
+void NavFind::placeWidgets(){
+ int width = GetSystemMetrics(SM_CXSCREEN);
+ int height = GetSystemMetrics(SM_CYSCREEN);
+ int searchBtnW = 60;
+ int pad = 2;
+ int btnH = 24;
+ int margin = 2;
+ int row0 = margin;
+ int row1 = row0 + pad + btnH;
+ int row2 = row1 + pad + btnH;
+ int row3 = row2 + pad + btnH;
+ int row4 = row3 + pad + btnH;
+ int row5 = row4 + pad + btnH;
+ int col0 = margin;
+ int textW = (width - (2*margin + pad))/2;
+ int col1 = margin + textW + pad;
+ int gotoBtnW = 60;
+ int queryW = width - (margin + searchBtnW + pad + margin);
+ int listH = height - (row4 + margin + 2*MENU_HEIGHT);
+ int listW = 80;
+ int prevH = height - (row5 + margin);
+ int prevW = width - (margin + listW + pad + margin);
+ int progW = width - (margin + listW + pad + pad + gotoBtnW + margin);
+
+ MoveWindow(queryEdit,col0, row0, queryW, btnH,TRUE);
+ MoveWindow(search,col0 + queryW + pad, row0, searchBtnW, btnH,TRUE);
+ MoveWindow(rangeBible,col0,row1,textW,btnH,TRUE);
+ MoveWindow(rangeTestament,col0,row2,textW,btnH,TRUE);
+ MoveWindow(rangeBook,col0,row3,textW,btnH,TRUE);
+ MoveWindow(methodMultiword,col1,row1,textW,btnH,TRUE);
+ MoveWindow(methodExactphrase,col1,row2,textW,btnH,TRUE);
+ MoveWindow(results,margin,row4,listW,listH,TRUE);
+ MoveWindow(progressBar,col0 + listW + pad,row4,progW,btnH,TRUE);
+ MoveWindow(go,col0 + listW + pad + progW + pad,row4, gotoBtnW,btnH,TRUE);
+ preview->moveTo(margin + listW + pad,row5,prevW,prevH);
+}
+
void NavFind::buttonClicked(int id) {
// is it one of our registered ID's?
if (id==searchID) {
Modified: trunk/src/gui/NavFind.h
===================================================================
--- trunk/src/gui/NavFind.h 2007-12-10 18:18:33 UTC (rev 52)
+++ trunk/src/gui/NavFind.h 2007-12-11 08:42:01 UTC (rev 53)
@@ -23,6 +23,7 @@
void searchFor(UString query);
virtual void setProgress(int percent);
virtual void addResult(UString verse);
+ void placeWidgets();
private:
//Navigator* navigator;
std::vector<Verse> verses;
Modified: trunk/src/gui/TextControl.cpp
===================================================================
--- trunk/src/gui/TextControl.cpp 2007-12-10 18:18:33 UTC (rev 52)
+++ trunk/src/gui/TextControl.cpp 2007-12-11 08:42:01 UTC (rev 53)
@@ -26,7 +26,8 @@
#define endHtml(window) SendMessage(window, DTM_ENDOFSOURCE, 0, 0);
#define controlToVerse(window,versenr) SendMessage(window, DTM_ANCHORW, FALSE, (LPARAM)(toUString(versenr).c_str()))
-TextControl::TextControl(int x, int y, int width, int height){
+TextControl::TextControl(int x, int y, int width, int height, bool preview){
+ this->preview = preview;
if(width < height)
portrait = true;
@@ -51,6 +52,8 @@
}
void TextControl::paint() {
+ if(preview)
+ return;
// Detect if we switched from portrait to landscape. If so lets resize the window appropiately.
int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);
@@ -64,6 +67,10 @@
}
}
+TextControl::moveTo(int x, int y, int width, int height){
+ MoveWindow(htmlControl, x, y, width, height, TRUE);
+}
+
void TextControl::clearText() {
clearHtml(htmlControl);
buffer.clear();
Modified: trunk/src/gui/TextControl.h
===================================================================
--- trunk/src/gui/TextControl.h 2007-12-10 18:18:33 UTC (rev 52)
+++ trunk/src/gui/TextControl.h 2007-12-11 08:42:01 UTC (rev 53)
@@ -9,7 +9,8 @@
class TextControl {
public:
- TextControl(int x, int y, int width, int height);
+ TextControl(int x, int y, int width, int height, bool preview = false);
+ moveTo(int x, int y, int width, int height);
virtual ~TextControl();
void show();
@@ -24,6 +25,7 @@
UString buffer;
RECT area;
bool portrait;
+ bool preview;
};
#endif
More information about the sword-cvs
mailing list