| 1 |
/* ‰~”Õ•¡ŽÊ‰® - EnbanKensa |
| 2 |
* Copyright (C) 2005 Kagetani Hideto |
| 3 |
*/ |
| 4 |
#include "stdafx.h" |
| 5 |
#include "ui.h" |
| 6 |
#include "ThemeMessageDlg.h" |
| 7 |
#include "EnbanKensaDlg.h" |
| 8 |
#include "EnbanKensa.h" |
| 9 |
|
| 10 |
static BOOL g_bAbort=FALSE; |
| 11 |
static HWND g_hWnd=NULL; |
| 12 |
|
| 13 |
static void UIFlushMessage() |
| 14 |
{ |
| 15 |
MSG msg; |
| 16 |
while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) != 0 ){ |
| 17 |
TranslateMessage( &msg ); |
| 18 |
DispatchMessage( &msg ); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
void UISetHWND(HWND hWnd) |
| 23 |
{ |
| 24 |
g_hWnd = hWnd; |
| 25 |
} |
| 26 |
|
| 27 |
BOOL UICheckAbort() |
| 28 |
{ |
| 29 |
UIFlushMessage(); |
| 30 |
return g_bAbort; |
| 31 |
} |
| 32 |
|
| 33 |
void UISetAbort() |
| 34 |
{ |
| 35 |
g_bAbort=TRUE; |
| 36 |
} |
| 37 |
|
| 38 |
void UIClearAbort() |
| 39 |
{ |
| 40 |
g_bAbort=FALSE; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
int UIDispMessage(const char *message, int type) |
| 45 |
{ |
| 46 |
CThemeSet *pThemeClass = ((CEnbanKensaApp *)AfxGetApp())->GetThemeClass(); |
| 47 |
CThemeMessageDlg *pDlg; |
| 48 |
UINT nFlags=0; |
| 49 |
int ret; |
| 50 |
|
| 51 |
switch(type){ |
| 52 |
case UIDMT_ERROR: |
| 53 |
nFlags = MB_ICONSTOP|MB_OK; |
| 54 |
break; |
| 55 |
case UIDMT_QUESTION: |
| 56 |
nFlags = MB_ICONQUESTION|MB_YESNO; |
| 57 |
break; |
| 58 |
default: |
| 59 |
nFlags = MB_OK; |
| 60 |
} |
| 61 |
pDlg = new CThemeMessageDlg; |
| 62 |
pDlg->SetTheme(pThemeClass); |
| 63 |
ret = pDlg->Disp(message, NULL, nFlags); |
| 64 |
|
| 65 |
delete pDlg; |
| 66 |
|
| 67 |
return (ret==IDOK||ret==IDYES) ? UIDMRET_OK : UIDMRET_CANCEL; |
| 68 |
} |
| 69 |
|
| 70 |
void UIDispInfo(const char *message, ...) |
| 71 |
{ |
| 72 |
va_list args; |
| 73 |
char *buf=NULL; |
| 74 |
int bufsize=80; |
| 75 |
int ret; |
| 76 |
|
| 77 |
while(1){ |
| 78 |
buf = (char *)realloc(buf, bufsize); |
| 79 |
if(buf==NULL){ |
| 80 |
return; |
| 81 |
} |
| 82 |
va_start(args, message); |
| 83 |
ret = _vsnprintf(buf, bufsize, message, args); |
| 84 |
va_end(args); |
| 85 |
if(ret >= 0){ |
| 86 |
break; |
| 87 |
} |
| 88 |
bufsize += 80; |
| 89 |
} |
| 90 |
|
| 91 |
::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_DISPINFO, (LPARAM)buf); |
| 92 |
free(buf); |
| 93 |
} |
| 94 |
|
| 95 |
void UIDrawLine(int x0, int y0, int x1, int y1, const UICOLOR *color) |
| 96 |
{ |
| 97 |
DRAWLINE_t dl; |
| 98 |
|
| 99 |
dl.x0 = x0; |
| 100 |
dl.y0 = y0; |
| 101 |
dl.x1 = x1; |
| 102 |
dl.y1 = y1; |
| 103 |
dl.color = RGB((color->red>>8), (color->green>>8), (color->blue>>8)); |
| 104 |
::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_DRAWLINE, (LPARAM)&dl); |
| 105 |
} |
| 106 |
|
| 107 |
void UIDrawBox(int x0, int y0, int x1, int y1, const UICOLOR *color, BOOL fill) |
| 108 |
{ |
| 109 |
DRAWBOX_t db; |
| 110 |
|
| 111 |
db.x0 = x0; |
| 112 |
db.y0 = y0; |
| 113 |
db.x1 = x1; |
| 114 |
db.y1 = y1; |
| 115 |
db.color = RGB((color->red>>8), (color->green>>8), (color->blue>>8)); |
| 116 |
db.fill = fill; |
| 117 |
::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_DRAWBOX, (LPARAM)&db); |
| 118 |
} |
| 119 |
|
| 120 |
void UIDrawText(int x0, int y0, const UICOLOR *color, const char *text) |
| 121 |
{ |
| 122 |
DRAWTEXT_t dt; |
| 123 |
|
| 124 |
dt.x0 = x0; |
| 125 |
dt.y0 = y0; |
| 126 |
dt.color = RGB((color->red>>8), (color->green>>8), (color->blue>>8)); |
| 127 |
dt.text = text; |
| 128 |
::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_DRAWTEXT, (LPARAM)&dt); |
| 129 |
} |
| 130 |
|
| 131 |
void UIGetDrawableSize(int *width, int *height) |
| 132 |
{ |
| 133 |
DRAWABLESIZE_t ds; |
| 134 |
|
| 135 |
::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_GETDRAWABLESIZE, (LPARAM)&ds); |
| 136 |
*width = ds.width; |
| 137 |
*height = ds.height; |
| 138 |
} |
| 139 |
|
| 140 |
int UISetting(OPTIONS *option) |
| 141 |
{ |
| 142 |
return ::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_SETTING, (LPARAM)option); |
| 143 |
} |
| 144 |
|
| 145 |
void UIDispDiscInfo(UITRACKINFO *uiTrackInfo, int num_track) |
| 146 |
{ |
| 147 |
int i; |
| 148 |
UIDISCINFO disc_info; |
| 149 |
|
| 150 |
for(i=0; i<num_track; i++){ |
| 151 |
if(uiTrackInfo[i].session<1){ |
| 152 |
continue; |
| 153 |
} |
| 154 |
TRACE("%d,%d,0x%08lX,0x%08lX,0x%08lX,%s,%s\n", |
| 155 |
uiTrackInfo[i].session, |
| 156 |
uiTrackInfo[i].track, |
| 157 |
uiTrackInfo[i].start_lba, |
| 158 |
uiTrackInfo[i].end_lba, |
| 159 |
uiTrackInfo[i].blocks, |
| 160 |
uiTrackInfo[i].mode, |
| 161 |
uiTrackInfo[i].comment); |
| 162 |
} |
| 163 |
disc_info.track_info = uiTrackInfo; |
| 164 |
disc_info.tracks = num_track; |
| 165 |
::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_DISCINFO, (LPARAM)&disc_info); |
| 166 |
} |