Skip to content

Commit

Permalink
fix some code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Sep 26, 2024
1 parent 78dda49 commit 7c7eb4e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 139 deletions.
10 changes: 5 additions & 5 deletions examples/touchweb/src/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#include "mainwindow.h"
#include "application.h"

#if defined(M8)
#define APP_NAME U("MaCross Mobile (M8)")
#if defined(MOBILE_PHONE)
#define APP_NAME U("Agave Mobile (Mobile)")
#define APP_NAME_LEN 19
#elif defined(WINCE)
#define APP_NAME U("MaCross Mobile (WinCE)")
#define APP_NAME U("Agave Mobile (WinCE)")
#define APP_NAME_LEN 22
#elif defined(__linux)
#define APP_NAME U("MaCross Mobile (Linux)")
#define APP_NAME U("Agave Mobile (Linux)")
#define APP_NAME_LEN 22
#elif defined(WIN32)
#define APP_NAME U("MaCross Mobile (WIN32)")
#define APP_NAME U("Agave Mobile (WIN32)")
#define APP_NAME_LEN 22
#endif

Expand Down
4 changes: 2 additions & 2 deletions examples/touchweb/src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ bool Application::report(void)
std::string reportform = std::string("mac=");
reportform += mac;
reportform += std::string("&ver="APP_VERSION);
#if defined(M8)
#if defined(MOBILE_PHONE)
reportform += std::string("&os=m8");
#elif defined(WINCE)
reportform += std::string("&os=wince");
Expand All @@ -236,7 +236,7 @@ bool Application::report(void)
reportform += std::string("&pdr=0");
reportform += std::string("&oem=0");

std::string url("http://www.zncsoft.net/signal?");
std::string url("http://www.agave.com/signal?");
url += reportform;
macross_network_request(REQUEST_POST, url.c_str(), 0, 30);
#endif
Expand Down
36 changes: 6 additions & 30 deletions examples/touchweb/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

#define SETUI(x) (x)

#ifdef M8
#ifdef MOBILE_PHONE
#define DEFAULT_WIDTH SETUI(480)
#define DEFAULT_HEIGHT SETUI(688)
#else
#define DEFAULT_WIDTH SETUI(240)
#define DEFAULT_HEIGHT SETUI(320)
#define DEFAULT_WIDTH SETUI(480)
#define DEFAULT_HEIGHT SETUI(480)
#endif

#if defined(WINCE) && !defined(M8)
#if defined(WINCE) && !defined(MOBILE_PHONE)
extern int global_scale;
#define GLOBAL_SCALE global_scale
#elif defined(M8)
#elif defined(MOBILE_PHONE)
#define GLOBAL_SCALE 2
#else
#define GLOBAL_SCALE 1
Expand All @@ -36,7 +36,7 @@

#define BUTTON_HEIGHT (TITLE_HEIGHT*1.4)

#ifdef M8
#ifdef MOBILE_PHONE
#define MAX_TABS 12
#else
#define MAX_TABS 5
Expand Down Expand Up @@ -89,27 +89,3 @@
x=(x/ABS(x)*st);\
}while(0)

#if 0
#include <windows.h>
//debug tools
//FILE* pf=_wfopen(L"Disk\\new_tg.log", L"a+");
#define debug_str_val(s, v) \
do { \
FILE* pf=_wfopen(L"Storage Card\\tg.log", L"a+"); \
fprintf(pf, "%s :%d\n", s, v); \
fclose(pf); \
} while(0)

#define debug_wstr_val(s, v) \
do { \
FILE* pf=_wfopen(L"Storage Card\\tg.log", L"a+"); \
fwprintf(pf, L"%s :%d\n", s, v); \
fclose(pf); \
} while(0)

#define debug_str(s) \
do { \
OutputDebugStringA(s); \
}while(0)

#endif
6 changes: 1 addition & 5 deletions examples/touchweb/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ MainWindow::~MainWindow()

bool MainWindow::Create(void* hInst)
{
#ifdef M8
return m_impl->Create(hInst, "Agave", 0, 32, DEFAULT_WIDTH, DEFAULT_HEIGHT);
#else
return m_impl->Create(hInst, "Agave", 0, 0, m_impl->SysWidth(), m_impl->SysHeight());
#endif
return m_impl->Create(hInst, "Agave", 0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}

bool MainWindow::Destroy(void)
Expand Down
2 changes: 1 addition & 1 deletion examples/touchweb/src/webview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int start_offset_Y(MaCrossView* v, int currentY, int height)
#define start_offset_Y(v, cy, h) (0)
#endif

#if defined(M8)
#if defined(MOBILE_PHONE)
#define DEFAULE_SCALE 2
#else
#define DEFAULE_SCALE GLOBAL_SCALE
Expand Down
3 changes: 0 additions & 3 deletions examples/touchweb/src/win32/application_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,5 @@ void System_init(void)
int dpi = GetDeviceCaps(hdc, LOGPIXELSX);
global_scale = (dpi / 96) ? (dpi / 96) : 1;
ReleaseDC(0, hdc);
#if defined(M8)
CoInitializeEx(0, COINIT_MULTITHREADED);
#endif
#endif
}
47 changes: 8 additions & 39 deletions examples/touchweb/src/win32/mainwindow_win32.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* mainwindow_win32.cpp - MaCross application
/* mainwindow_win32.cpp - Agave application
*
* Copyright (C) 2010 Zhang Ji Peng
* Contact : onecoolx@gmail.com
Expand All @@ -16,15 +16,6 @@
#include <aygshell.h>
#endif

#if defined(WINCE) && defined(M8)
#include <mzfc_inc.h>
#include <InitGuid.h>
#include <IMzUnknown.h>
#include <IMzUnknown_IID.h>
#include <IFileBrowser.h>
#include <IFileBrowser_GUID.h>
#endif

HWND g_MainWnd = 0;

#ifdef WINCE
Expand Down Expand Up @@ -171,18 +162,18 @@ bool MainWindowImpl::Create(void* hInstance, const char* title, int x, int y, in

m_data->m_hInst = hInstance;
#if defined(WINCE)
g_MainWnd = m_data->m_hWnd = CreateWindow(_T("MaCross"), _T("MaCross"), WS_VISIBLE, x, y, w, h,
g_MainWnd = m_data->m_hWnd = CreateWindow(_T("Agave"), _T("Agave"), WS_VISIBLE, x, y, w, h,
NULL, NULL, (HINSTANCE)hInstance, this);
#else
g_MainWnd = m_data->m_hWnd = CreateWindowA("MaCross", title, WS_VISIBLE, x, y, w, h + GetSystemMetrics(SM_CYCAPTION),
g_MainWnd = m_data->m_hWnd = CreateWindowA("Agave", title, WS_VISIBLE, x, y, w, h + GetSystemMetrics(SM_CYCAPTION),
NULL, NULL, (HINSTANCE)hInstance, this);
#endif

if (!m_data->m_hWnd) {
return false;
}

#if defined(WINCE) && !defined(M8)
#if defined(WINCE)
SetForegroundWindow(m_data->m_hWnd);
SHFullScreen(m_data->m_hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);
#endif
Expand Down Expand Up @@ -364,7 +355,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
HDC hdc;
MainWindowImpl* window;

#if defined(WINCE) && !defined(M8)
#if defined(WINCE)
static SHACTIVATEINFO s_sai;
#endif
switch (message) {
Expand All @@ -375,13 +366,13 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
SetWindowLong(hWnd, GWL_USERDATA, (LONG)cs->lpCreateParams);
window = (MainWindowImpl*)cs->lpCreateParams;
window->OnCreate(r.left, r.top, r.right - r.left, r.bottom - r.top);
#if defined(WINCE) && !defined(M8)
#if defined(WINCE)
memset(&s_sai, 0, sizeof (s_sai));
s_sai.cbSize = sizeof (s_sai);
#endif
}
break;
#if defined(WINCE) && !defined(M8)
#if defined(WINCE)
case WM_WINDOWPOSCHANGED: {
LPWINDOWPOS lps = (LPWINDOWPOS)lParam;
if (lps->hwndInsertAfter == HWND_TOP) {
Expand Down Expand Up @@ -479,7 +470,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l

bool MainWindowImpl::getChooseFile(uchar_t* name, unsigned int len)
{
#if (defined(WIN32) || defined(WINCE)) && !defined(M8)
#if (defined(WIN32) || defined(WINCE))
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));

Expand All @@ -500,28 +491,6 @@ bool MainWindowImpl::getChooseFile(uchar_t* name, unsigned int len)
} else {
return false;
}
#elif defined(M8)
IMzSelect* pSelect = NULL;
IFileBrowser* pFile = NULL;
bool ret = false;
if (SUCCEEDED(CoCreateInstance(CLSID_FileBrowser, NULL, CLSCTX_INPROC_SERVER, IID_MZ_FileBrowser, (void**)&pFile ) ) ) {
if ( SUCCEEDED( pFile->QueryInterface(IID_MZ_Select, (void**)&pSelect ) ) ) {
pFile->SetParentWnd(g_MainWnd);
pFile->SetOpenDirectoryPath(L"\\Disk");
pFile->SetExtFilter(L"*.*;");
pFile->SetOpenDocumentType(DOCUMENT_SELECT_SINGLE_FILE);
if (pSelect->Invoke()) {
_tcsncpy(name, pFile->GetSelectedFileName(), len);
ret = true;
}
pSelect->Release();
}
pFile->Release();
return ret;
} else {
return false;
}
#else
return false;
#endif
}
Expand Down
Loading

0 comments on commit 7c7eb4e

Please sign in to comment.