modify ceStackButtonsRight to place dialog ok/cancel buttons in

bottom menubar where possible; move XP_LOGW to cedebug.c
This commit is contained in:
ehouse 2008-02-16 17:14:35 +00:00
parent 3ec8ee536e
commit 4a464b6ef5
6 changed files with 97 additions and 36 deletions

View file

@ -19,6 +19,8 @@
#include "cedebug.h" #include "cedebug.h"
#ifdef DEBUG
#define CASE_STR(c) case c: str = #c; break #define CASE_STR(c) case c: str = #c; break
const char* const char*
@ -56,4 +58,15 @@ messageToStr( UINT message )
return str; return str;
} /* messageToStr */ } /* messageToStr */
void
XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg )
{
XP_UCHAR buf[512];
(void)WideCharToMultiByte( CP_ACP, 0, arg, -1,
buf, sizeof(buf), NULL, NULL );
XP_LOGF( "%s: %s", prefix, buf );
}
#undef CASE_STR #undef CASE_STR
#endif /* DEBUG */

View file

@ -24,4 +24,10 @@
const char* messageToStr( UINT message ); const char* messageToStr( UINT message );
#ifdef DEBUG
void XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg );
#else
# define XP_LOGW( prefix, arg )
#endif
#endif /* _CEDEBUG_H_ */ #endif /* _CEDEBUG_H_ */

View file

@ -226,7 +226,7 @@ ceIsLandscape( CEAppGlobals* globals )
/* Can't figure out how to do this on CE. IsWindowVisible doesn't work, and /* Can't figure out how to do this on CE. IsWindowVisible doesn't work, and
GetWindowInfo isn't even there. */ GetWindowInfo isn't even there. */
static XP_Bool static XP_Bool
ceIsVisible( HWND hwnd ) ceIsVisible( HWND XP_UNUSED_CE(hwnd) )
{ {
#ifdef _WIN32_WCE /* GetWindowInfo isn't on CE */ #ifdef _WIN32_WCE /* GetWindowInfo isn't on CE */
return XP_TRUE; return XP_TRUE;
@ -243,12 +243,54 @@ ceIsVisible( HWND hwnd )
#endif #endif
} /* ceIsVisible */ } /* ceIsVisible */
#ifdef _WIN32_WCE
static XP_Bool
mkFullscreenWithSoftkeys( CEAppGlobals* globals, HWND hDlg )
{
/* XP_Bool fullScreen = XP_FALSE; /\* probably want this TRUE for */
/* small-screened smartphones only. *\/ */
/* if ( fullScreen ) { */
/* SHINITDLGINFO info; */
/* info.dwMask = SHIDIM_FLAGS; */
/* info.dwFlags = SHIDIF_SIZEDLG */
/* /\* | SHIDIF_DONEBUTTON *\/ */
/* | SHIDIF_WANTSCROLLBAR; */
/* info.hDlg = hDlg; */
/* BOOL b = SHInitDialog( &info ); */
/* XP_LOGF( "SHInitDialog=>%d", (int)b ); */
/* } */
XP_Bool success = XP_FALSE;
SHMENUBARINFO mbi;
XP_MEMSET( &mbi, 0, sizeof(mbi) );
mbi.cbSize = sizeof(mbi);
mbi.hwndParent = hDlg;
mbi.nToolBarId = IDM_OKCANCEL_MENUBAR;
mbi.hInstRes = globals->hInst;
success = SHCreateMenuBar( &mbi );
if ( !success ) {
XP_LOGF( "SHCreateMenuBar failed" );
}
return success;
} /* mkFullscreenWithSoftkeys */
#endif
void void
ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg ) ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg )
{ {
XP_Bool justRemove = XP_FALSE;
XP_ASSERT( !!globals ); XP_ASSERT( !!globals );
if ( ceIsLandscape( globals ) ) { #ifdef _WIN32_WCE
if ( mkFullscreenWithSoftkeys( globals, hDlg ) ) {
justRemove = XP_TRUE;
}
#endif
if ( justRemove || ceIsLandscape( globals ) ) {
XP_U16 resIDs[] = { IDOK, IDCANCEL }; XP_U16 resIDs[] = { IDOK, IDCANCEL };
RECT wrect, crect; RECT wrect, crect;
XP_U16 left, top; XP_U16 left, top;
@ -282,10 +324,10 @@ ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg )
/* Make sure we're not proposing to make the dialog wider than the /* Make sure we're not proposing to make the dialog wider than the
screen */ screen */
GetWindowRect( hDlg, &wrect ); GetWindowRect( hDlg, &wrect );
newWidth = wrect.right - wrect.left + butWidth newWidth = wrect.right - wrect.left +
+ HPADDING_L + HPADDING_R; butWidth + HPADDING_L + HPADDING_R;
if ( newWidth <= mainWidth ) { if ( justRemove || (newWidth <= mainWidth) ) {
GetClientRect( hDlg, &crect ); GetClientRect( hDlg, &crect );
barHt = wrect.bottom - wrect.top - crect.bottom; barHt = wrect.bottom - wrect.top - crect.bottom;
@ -305,21 +347,16 @@ ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg )
} }
} }
if ( justRemove ) {
MoveWindow( hDlg, wrect.left, wrect.top,
wrect.right - wrect.left, wrect.bottom - wrect.top - butHeight - 2,
FALSE );
} else {
butWidth += HPADDING_L + HPADDING_R; butWidth += HPADDING_L + HPADDING_R;
MoveWindow( hDlg, wrect.left - (butWidth/2), wrect.top, MoveWindow( hDlg, wrect.left - (butWidth/2), wrect.top,
newWidth, wrect.bottom - wrect.top - butHeight - 2, newWidth, wrect.bottom - wrect.top - butHeight - 2,
FALSE ); FALSE );
} }
} }
}
} /* ceStackButtonsRight */ } /* ceStackButtonsRight */
#ifdef DEBUG
void
XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg )
{
XP_UCHAR buf[512];
(void)WideCharToMultiByte( CP_ACP, 0, arg, -1,
buf, sizeof(buf), NULL, NULL );
XP_LOGF( "%s: %s", prefix, buf );
}
#endif

View file

@ -50,10 +50,4 @@ void ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg );
/* Are we drawing things in landscape mode? */ /* Are we drawing things in landscape mode? */
XP_Bool ceIsLandscape( CEAppGlobals* globals ); XP_Bool ceIsLandscape( CEAppGlobals* globals );
#ifdef DEBUG
void XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg );
#else
# define XP_LOGW( prefix, arg )
#endif
#endif #endif

View file

@ -18,6 +18,7 @@
#define IDD_COLORSDLG 118 #define IDD_COLORSDLG 118
#define IDD_COLOREDITDLG 119 #define IDD_COLOREDITDLG 119
#define IDM_MAIN_MENUBAR 120 #define IDM_MAIN_MENUBAR 120
#define IDM_OKCANCEL_MENUBAR 121
#define IDB_ORIGIN 124 #define IDB_ORIGIN 124
#ifdef XWFEATURE_SEARCHLIMIT #ifdef XWFEATURE_SEARCHLIMIT
# define IDD_ASKHINTLIMTS 125 # define IDD_ASKHINTLIMTS 125
@ -183,14 +184,14 @@
#define ID_BONUS_RES 9998 #define ID_BONUS_RES 9998
#define IDM_MAIN_COMMAND1 40001 #define IDM_MAIN_COMMAND1 40001
#define IDS_FILE 40002 #define IDS_MENU 40002
#define IDS_GAME 40003 #define IDS_DONE 40003
#define IDS_MOVE 40004 #define IDS_CANCEL 40004
#define IDS_MENU 40005 #define IDS_OK 40005
#define IDS_DONE 40006
// Don't use the numbers after 4005: one string needs not to be there // Don't use the numbers after 4009: one string needs not to be there
// to stop the progression in cedict.c // to stop the progression in cedict.c
#define IDS_DICTDIRS 40007 #define IDS_DICTDIRS 40009
// Next default values for new objects // Next default values for new objects
// //

View file

@ -122,6 +122,7 @@ BEGIN
END END
END END
#ifdef _WIN32_WCE
// soft key bar described at // soft key bar described at
// http://msdn2.microsoft.com/en-us/library/aa457781.aspx // http://msdn2.microsoft.com/en-us/library/aa457781.aspx
IDM_MAIN_MENUBAR RCDATA IDM_MAIN_MENUBAR RCDATA
@ -135,6 +136,18 @@ BEGIN
0 // Use the 0th popup above -- the only one 0 // Use the 0th popup above -- the only one
END END
IDM_OKCANCEL_MENUBAR RCDATA
BEGIN
0, 2,
I_IMAGENONE, IDCANCEL, TBSTATE_ENABLED,
TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_CANCEL, 0,
NOMENU,
I_IMAGENONE, IDOK, TBSTATE_ENABLED,
TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE, IDS_OK, 0,
NOMENU
END
#endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Dialog // Dialog
@ -735,9 +748,6 @@ BEGIN
IDS_APP_TITLE "Crosswords" IDS_APP_TITLE "Crosswords"
IDC_XWORDS4 "XWORDS4" IDC_XWORDS4 "XWORDS4"
#endif #endif
IDS_FILE "File"
IDS_GAME "Game"
IDS_MOVE "Move"
IDS_MENU "Menu" IDS_MENU "Menu"
IDS_DONE "Done" IDS_DONE "Done"
#ifdef _WIN32_WCE #ifdef _WIN32_WCE