Advertisement
Guest User

Untitled

a guest
Oct 1st, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.50 KB | None | 0 0
  1. #include<windows.h>
  2. #include<iostream>
  3. #include<sstream>
  4. #include<QtCore/QMimeData>
  5. #include<QtCore/QObject>
  6. #include<QtCore/QDebug>
  7. #include<QtGui/QMoveEvent>
  8. #include<QtGui/QPainter>
  9. #include<QtGui/QBitmap>
  10. #include<QtGui/QColor>
  11. #include<QtGui/QImage>
  12. #include<QtWidgets/QApplication>
  13. #include<QtWidgets/QMainWindow>
  14. #include<QtWidgets/QPushButton>
  15. #include<QtWidgets/QStatusBar>
  16. #include<QtWidgets/QGroupBox>
  17. #include<QtWidgets/QLabel>
  18.  
  19.  
  20. using namespace std;
  21.  
  22. namespace{
  23. void MsgBox( const std::string msg, const std::string caption = "result" ){
  24. MessageBox( NULL, msg.c_str(), caption.c_str(), MB_OK );
  25. return;
  26. }
  27.  
  28. void MsgBox( const std::wstring msg, const std::wstring caption = L"result" ){
  29. MessageBoxW( NULL, msg.c_str(), caption.c_str(), MB_OK );
  30. return;
  31. }
  32. }
  33.  
  34.  
  35. // utf-8 で保存しないと意味ないらしい...
  36. #pragma execution_character_set("utf-8")
  37.  
  38.  
  39.  
  40. /* -+-+-+-+- Mainにも公開するもの -+-+-+-+- */
  41.  
  42.  
  43. namespace QtUse{
  44.  
  45. namespace LocaleSet{
  46. enum LOCALNUMBERS{
  47. Japanese = 1,
  48. English = 2,
  49. Spanish = 3,
  50. French = 4,
  51. Russian = 5,
  52. Latin = 6,
  53. Chinese = 7,
  54. Italian = 8,
  55. Unknown = 100
  56. };
  57. }
  58.  
  59. namespace QtRrc{
  60.  
  61. class ICursor{
  62. public:
  63. virtual ~ICursor(){}
  64. virtual bool fromFile( const std::string filepath ) = 0;
  65. virtual QCursor cur( void ) = 0;
  66. virtual bool empty( void ) = 0;
  67. };
  68.  
  69. class IIcon{
  70. public:
  71. virtual ~IIcon(){}
  72. virtual bool fromFile( const std::string filepath ) = 0;
  73. virtual QIcon ico( void ) = 0;
  74. virtual bool empty( void ) = 0;
  75. };
  76.  
  77. class IImage{
  78. public:
  79. virtual ~IImage(){}
  80. virtual bool fromFile( const std::string filepath ) = 0;
  81. virtual QImage img( void ) = 0;
  82. virtual int height( void ) = 0;
  83. virtual int width( void ) = 0;
  84. virtual bool empty( void ) = 0;
  85. };
  86. }
  87.  
  88. namespace QtEvent{
  89.  
  90. class IWindowEvent{
  91. public:
  92. protected:
  93. private:
  94. };
  95.  
  96. class IMainWindowEvent : public IWindowEvent{
  97. public:
  98. protected:
  99. private:
  100. };
  101. }
  102.  
  103. namespace QtWindow{
  104.  
  105. class IWindow{
  106. public:
  107. virtual ~IWindow(){}
  108. virtual QWidget* widget( void ) const = 0;
  109. virtual HWND hWnd( void ) const = 0;
  110. virtual int id( void ) const = 0;
  111. virtual void setFont( LOGFONT lf ) = 0;
  112. virtual LOGFONT font( void ) const = 0;
  113. virtual void setCursor( QtUse::QtRrc::ICursor* cursor ) = 0;
  114. // virtual cursor( void )
  115. virtual void setAcceptDrops( bool state ) = 0;
  116. virtual bool acceptDrops( void ) const = 0;
  117. virtual void setLocale( int nLocale ) = 0;
  118. virtual int locale( void ) const = 0;
  119. virtual void setToolTip( const std::string msg ) = 0;
  120. virtual std::string toolTip( void ) const = 0;
  121. virtual void setColor( COLORREF foreColor, COLORREF bgColor ) = 0;
  122. virtual void show( void ) = 0;
  123. virtual void hide( void ) = 0;
  124. virtual void move( int x, int y ) = 0;
  125. virtual int x( void ) const = 0;
  126. virtual int y( void ) const = 0;
  127. virtual void resize( int height, int width ) = 0;
  128. virtual int height( void ) const = 0;
  129. virtual int width( void ) const = 0;
  130. virtual void setVisible( bool state ) = 0;
  131. virtual bool visible( void ) const = 0;
  132. virtual void setEnabled( bool state ) = 0;
  133. virtual bool isEnabled( void ) const = 0;
  134. virtual void setFocus( void ) = 0;
  135. virtual bool focus( void ) const = 0;
  136. virtual void setText( const std::string text ) = 0;
  137. virtual std::string getText( void ) const = 0;
  138. };
  139.  
  140. class IMainWindow : public IWindow{
  141. public:
  142. virtual ~IMainWindow(){}
  143. virtual void setIcon( QtUse::QtRrc::IIcon* icon ) = 0;
  144. virtual int addEvent( QtUse::QtEvent::IMainWindowEvent* event ) = 0;
  145. };
  146. }
  147.  
  148. namespace QtWorker{
  149.  
  150. class IApplication{
  151. public:
  152. virtual ~IApplication(){}
  153. virtual void setIcon( QtUse::QtRrc::IIcon* icon ) = 0;
  154. virtual int exec( void ) = 0;
  155. };
  156.  
  157. class IPainter{
  158. public:
  159. virtual ~IPainter(){}
  160. virtual bool begin( QtUse::QtWindow::IWindow* window ) = 0;
  161. virtual bool end( void ) = 0;
  162. virtual bool show( int x, int y, int height, int width, QtUse::QtRrc::IImage* image ) = 0;
  163. };
  164. }
  165. }
  166.  
  167.  
  168. /* -+-+-+-+- DLLのヘッダ -+-+-+-+- */
  169.  
  170. namespace Crack{
  171. QString StringToQstring( const std::string str );
  172. std::string QstringToString( const QString &qstr );
  173. std::wstring QstringToWstring( const QString &qstr );
  174. QLocale::Language LocalesetToQlocalelanguage( int nLocale );
  175. int QlocalelanguageToLocaleset( QLocale::Language lang );
  176. QString ColorrefToQstringCss( QString objectName, COLORREF fore, COLORREF back );
  177. QCursor CreateQcursor( const std::string filepath );
  178. QIcon CreateQicon( const std::string filepath );
  179. QFont LogfontToQfont( LOGFONT *lf );
  180. LOGFONT QfontToLogfont( QFont* f );
  181. QString CreateBorderCss( QString objectName, bool state );
  182. QString CreateObjectName( const std::string TypeName, int id );
  183. int CalcIdFromObjectName( const QString objectName );
  184. }
  185.  
  186.  
  187. namespace QtRrcConcrete{
  188.  
  189. class CCursor : public QtUse::QtRrc::ICursor{
  190. public:
  191. CCursor( int id );
  192. ~CCursor();
  193.  
  194. bool fromFile( const std::string filepath );
  195. QCursor cur( void );
  196. bool empty( void );
  197. private:
  198. QCursor cur_;
  199. int id_;
  200. };
  201. }
  202.  
  203. namespace QtRrcConcrete{
  204.  
  205. class CIcon : public QtUse::QtRrc::IIcon{
  206. public:
  207. CIcon( int id );
  208. ~CIcon();
  209.  
  210. bool fromFile( const std::string filepath );
  211. QIcon ico( void );
  212. bool empty( void );
  213. private:
  214. QIcon ico_;
  215. int id_;
  216. };
  217. }
  218.  
  219. namespace QtRrcConcrete{
  220.  
  221. class CImage : public QtUse::QtRrc::IImage{
  222. public:
  223. CImage( int id );
  224. ~CImage();
  225.  
  226. bool fromFile( const std::string filepath );
  227. QImage img( void );
  228. int height( void );
  229. int width( void );
  230. bool empty( void );
  231. private:
  232. QImage img_;
  233. int id_;
  234. };
  235. }
  236.  
  237. namespace QtWorkerConcrete{
  238.  
  239. class CApplication : public QtUse::QtWorker::IApplication{
  240. public:
  241. CApplication( int argc, char *argv[] );
  242. ~CApplication();
  243.  
  244. void setIcon( QtUse::QtRrc::IIcon* icon );
  245. int exec( void );
  246. private:
  247. QApplication* app;
  248. };
  249. }
  250.  
  251. namespace QtWorkerConcrete{
  252.  
  253. class CPainter : public QtUse::QtWorker::IPainter{
  254. public:
  255. CPainter();
  256. ~CPainter();
  257.  
  258. bool begin( QtUse::QtWindow::IWindow* window );
  259. bool end( void );
  260. bool show( int x, int y, int height, int width, QtUse::QtRrc::IImage* image );
  261. private:
  262. QPainter painter;
  263. };
  264. }
  265.  
  266. namespace QtWindowConcrete{
  267.  
  268. class WMainWindow : public QMainWindow, public QtUse::QtWindow::IMainWindow{
  269. public:
  270. WMainWindow( QWidget* parent, int id );
  271. ~WMainWindow();
  272.  
  273. QWidget* widget( void ) const;
  274. HWND hWnd( void ) const;
  275. int id( void ) const;
  276. void setFont( LOGFONT lf );
  277. LOGFONT font( void ) const;
  278. void setCursor( QtUse::QtRrc::ICursor* cursor );
  279. // cursor( void );
  280. void setAcceptDrops( bool state );
  281. bool acceptDrops( void ) const;
  282. void setLocale( int nLocale );
  283. int locale( void ) const;
  284. void setToolTip( const std::string msg );
  285. std::string toolTip( void ) const;
  286. void setColor( COLORREF foreColor, COLORREF bgColor );
  287. void show( void );
  288. void hide( void );
  289. void move( int x, int y );
  290. int x( void ) const;
  291. int y( void ) const;
  292. void resize( int height, int width );
  293. int height( void ) const;
  294. int width( void ) const;
  295. void setVisible( bool state );
  296. bool visible( void ) const;
  297. void setEnabled( bool state );
  298. bool isEnabled( void ) const;
  299. void setFocus( void );
  300. bool focus( void ) const;
  301. void setText( const std::string text );
  302. std::string getText( void ) const;
  303.  
  304. void setIcon( QtUse::QtRrc::IIcon* icon );
  305. int addEvent( QtUse::QtEvent::IMainWindowEvent* event );
  306. protected:
  307. private:
  308. int id_;
  309. QtUse::QtEvent::IMainWindowEvent* event_;
  310. };
  311. }
  312.  
  313.  
  314. namespace Factories{
  315. // リソース系
  316. QtUse::QtRrc::ICursor* CreateCursorInstance( int id );
  317. QtUse::QtRrc::IIcon* CreateIconInstance( int id );
  318. QtUse::QtRrc::IImage* CreateImageInstance( int id );
  319.  
  320. // ワーカ系
  321. QtUse::QtWorker::IApplication* CreateApplicationInstance( int argc, int argv[] );
  322. QtUse::QtWorker::IPainter* CreatePainterInstance( void );
  323.  
  324. // ウィンドウ系
  325. QtUse::QtWindow::IMainWindow* CreateMainWindowInstance( QWidget* parent, int id );
  326. }
  327.  
  328.  
  329.  
  330.  
  331.  
  332. /* -+-+-+-+- DLL定義 -+-+-+-+- */
  333.  
  334. namespace Crack{
  335. QString StringToQstring( const std::string str ){
  336. return QString::fromStdString( str );
  337. }
  338.  
  339. std::string QstringToString( const QString &qstr ){
  340. return qstr.toStdString();
  341. }
  342.  
  343. std::wstring QstringToWstring( const QString &qstr ){
  344. return qstr.toStdWString();
  345. }
  346.  
  347. QLocale::Language LocalesetToQlocalelanguage( int nLocale ){
  348. if( nLocale == QtUse::LocaleSet::Japanese ){
  349. return QLocale::Japanese;
  350. }else if( nLocale == QtUse::LocaleSet::English ){
  351. return QLocale::QLocale::English;
  352. }else if( nLocale == QtUse::LocaleSet::Spanish ){
  353. return QLocale::QLocale::Spanish;
  354. }else if( nLocale == QtUse::LocaleSet::French ){
  355. return QLocale::QLocale::French;
  356. }else if( nLocale == QtUse::LocaleSet::Russian ){
  357. return QLocale::QLocale::Russian;
  358. }else if( nLocale == QtUse::LocaleSet::Latin ){
  359. return QLocale::QLocale::Latin;
  360. }else if( nLocale == QtUse::LocaleSet::Chinese ){
  361. return QLocale::QLocale::Chinese;
  362. }else if( nLocale == QtUse::LocaleSet::Italian ){
  363. return QLocale::QLocale::Italian;
  364. }
  365. // return -1;
  366. }
  367.  
  368. int QlocalelanguageToLocaleset( QLocale::Language lang ){
  369. if( lang == QLocale::Japanese ){
  370. return QtUse::LocaleSet::Japanese;
  371. }else if( lang == QLocale::English ){
  372. return QtUse::LocaleSet::English;
  373. }else if( lang == QLocale::Spanish ){
  374. return QtUse::LocaleSet::Spanish;
  375. }else if( lang == QLocale::French ){
  376. return QtUse::LocaleSet::French;
  377. }else if( lang == QLocale::Russian ){
  378. return QtUse::LocaleSet::Russian;
  379. }else if( lang == QLocale::Latin ){
  380. return QtUse::LocaleSet::Latin;
  381. }else if( lang == QLocale::Chinese ){
  382. return QtUse::LocaleSet::Chinese;
  383. }else if( lang == QLocale::Italian ){
  384. return QtUse::LocaleSet::Italian;
  385. }else{
  386. return QtUse::LocaleSet::Unknown;
  387. }
  388. }
  389.  
  390. QString ColorrefToQstringCss( QString objectName, COLORREF fore, COLORREF back ){
  391. std::string css;
  392. int r1, r2, g1, g2, b1, b2;
  393.  
  394. QColor f( fore );
  395. QColor b( back );
  396.  
  397. f.getRgb( &r1, &g1, &b1 );
  398. b.getRgb( &r2, &g2, &b2 );
  399.  
  400. css = std::string( "#" );
  401. css += Crack::QstringToString( objectName );
  402. css += std::string( "{" );
  403.  
  404. if( f.isValid() ){
  405. css += std::string( "color: rgb(" );
  406. css += std::to_string( r1 );
  407. css += std::string( "," );
  408. css += std::to_string( g1 );
  409. css += std::string( "," );
  410. css += std::to_string( b1 );
  411. css += std::string( ");" );
  412. }
  413.  
  414. if( b.isValid() ){
  415. css += std::string( "background-color: rgb(" );
  416. css += std::to_string( r2 );
  417. css += std::string( "," );
  418. css += std::to_string( g2 );
  419. css += std::string( "," );
  420. css += std::to_string( b2 );
  421. css += std::string( ");" );
  422. }
  423.  
  424. css += std::string( " }" );
  425.  
  426. return Crack::StringToQstring( css );
  427. }
  428.  
  429. QCursor CreateQcursor( const std::string filepath ){
  430. QPixmap p( StringToQstring( filepath ) );
  431. QCursor c( p );
  432. return c;
  433. }
  434.  
  435. QIcon CreateQicon( const std::string filepath ){
  436. QPixmap p( StringToQstring( filepath ) );
  437. QIcon i( p );
  438. return i;
  439. }
  440.  
  441. QFont LogfontToQfont( LOGFONT *lf ){
  442. QFont result;
  443.  
  444. result.setPointSize( lf->lfHeight );
  445.  
  446. if( lf->lfWeight == FW_BOLD ) result.setBold(true);
  447. else result.setBold(false);
  448.  
  449.  
  450. if( lf->lfItalic == TRUE ) result.setItalic(true);
  451. else result.setItalic(false);
  452.  
  453. if( lf->lfUnderline == TRUE ) result.setUnderline(true);
  454. else result.setUnderline(false);
  455.  
  456. if( lf->lfStrikeOut == TRUE ) result.setStrikeOut(true);
  457. else result.setStrikeOut(false);
  458.  
  459.  
  460. result.setFamily( lf->lfFaceName );
  461. return result;
  462. }
  463.  
  464. LOGFONT QfontToLogfont( QFont* f ){
  465. LOGFONT result = { 0 };
  466.  
  467. result.lfHeight = f->pointSize();
  468.  
  469. if( f->bold() ) result.lfWeight = FW_BOLD;
  470.  
  471. if( f->italic() ) result.lfItalic = TRUE;
  472. else result.lfItalic = FALSE;
  473.  
  474. if( f->underline() ) result.lfUnderline = TRUE;
  475. else result.lfUnderline = FALSE;
  476.  
  477. if( f->strikeOut() ) result.lfStrikeOut = TRUE;
  478. else result.lfStrikeOut = FALSE;
  479.  
  480. strcpy( result.lfFaceName, Crack::QstringToString(f->family()).c_str() );
  481.  
  482. return result;
  483. }
  484.  
  485. QString CreateBorderCss( QString objectName, bool state ){
  486. std::string css;
  487.  
  488. css = std::string( "#" );
  489. css += Crack::QstringToString( objectName );
  490. css += std::string( "{" );
  491.  
  492. if( state ){
  493. css += std::string( "border: 1px solid black;" );
  494. }else{
  495. css += std::string( "border: none;" );
  496. }
  497.  
  498. css += std::string( "}" );
  499.  
  500. return Crack::StringToQstring( css );
  501. }
  502.  
  503. QString CreateObjectName( const std::string TypeName, int id ){
  504. std::string name;
  505.  
  506. name = std::string("Crack_") + TypeName + std::string("_") + std::to_string( id );
  507.  
  508. return Crack::StringToQstring( name );
  509. }
  510.  
  511. int CalcIdFromObjectName( const QString objectName ){
  512. int result;
  513. int pos;
  514. std::string temp;
  515.  
  516. temp = Crack::QstringToString( objectName );
  517.  
  518. pos = temp.find_last_of( "_" );
  519.  
  520. temp.replace( 0, pos + 1, "" );
  521.  
  522. {
  523. bool ok;
  524. QString converter;
  525. converter = Crack::StringToQstring( temp );
  526. result = converter.toInt( &ok );
  527. if( ok ){
  528. return result;
  529. }else{
  530. return -1;
  531. }
  532. }
  533. }
  534. }
  535.  
  536. namespace QtRrcConcrete{
  537.  
  538. CCursor::CCursor( int id ) : id_(id){}
  539.  
  540. CCursor::~CCursor(){}
  541.  
  542. bool CCursor::fromFile( const std::string filepath ){
  543. cur_ = Crack::CreateQcursor( filepath );
  544. }
  545.  
  546. QCursor CCursor::cur( void ){
  547. return cur_;
  548. }
  549.  
  550. bool CCursor::empty( void ){
  551. if( cur_.pixmap().isNull() ){
  552. if( cur_.bitmap()->isNull() ){
  553. return true;
  554. }else{
  555. return false;
  556. }
  557. }else{
  558. return false;
  559. }
  560. }
  561. }
  562.  
  563.  
  564. namespace QtRrcConcrete{
  565.  
  566. CIcon::CIcon( int id ) : id_(id){}
  567.  
  568. CIcon::~CIcon(){}
  569.  
  570. bool CIcon::fromFile( const std::string filepath ){
  571. ico_ = Crack::CreateQicon( filepath );
  572. }
  573.  
  574. QIcon CIcon::ico( void ){
  575. return ico_;
  576. }
  577.  
  578. bool CIcon::empty( void ){
  579. return ico_.isNull();
  580. }
  581. }
  582.  
  583.  
  584. namespace QtRrcConcrete{
  585.  
  586. CImage::CImage( int id ) : id_(id){}
  587.  
  588. CImage::~CImage(){}
  589.  
  590. bool CImage::fromFile( const std::string filepath ){
  591. img_.load( Crack::StringToQstring( filepath ) );
  592. }
  593.  
  594. QImage CImage::img( void ){
  595. return img_;
  596. }
  597.  
  598. int CImage::height( void ){
  599. return img_.height();
  600. }
  601.  
  602. int CImage::width( void ){
  603. return img_.width();
  604. }
  605.  
  606. bool CImage::empty( void ){
  607. return img_.isNull();
  608. }
  609. }
  610.  
  611. namespace QtWorkerConcrete{
  612.  
  613. CApplication::CApplication( int argc, char *argv[] ){
  614. app = new QApplication( argc, argv );
  615. }
  616.  
  617. CApplication::~CApplication(){
  618. delete app;
  619. }
  620.  
  621. void CApplication::setIcon( QtUse::QtRrc::IIcon* icon ){
  622. app->setWindowIcon( icon->ico() );
  623. return;
  624. }
  625.  
  626. int CApplication::exec( void ){
  627. return app->exec();
  628. }
  629. }
  630.  
  631. namespace QtWorkerConcrete{
  632.  
  633. CPainter::CPainter(){}
  634.  
  635. CPainter::~CPainter(){}
  636.  
  637. bool CPainter::begin( QtUse::QtWindow::IWindow* window ){
  638. return painter.begin( window->widget() );
  639. }
  640.  
  641. bool CPainter::end( void ){
  642. return painter.end();
  643. }
  644.  
  645. bool CPainter::show( int x, int y, int height, int width, QtUse::QtRrc::IImage* image ){
  646. int h, w;
  647. QPixmap p;
  648.  
  649. if( image->empty() ) return false;
  650.  
  651. p = QPixmap::fromImage( image->img() );
  652.  
  653. if( height <= 0 ){
  654. h = image->height();
  655. }else{
  656. h = height;
  657. }
  658.  
  659. if( width <= 0 ){
  660. w = image->width();
  661. }else{
  662. w = width;
  663. }
  664.  
  665. painter.drawPixmap( x, y, w, h, p, 0, 0, image->width(), image->height() );
  666. return true;
  667. }
  668. }
  669.  
  670.  
  671. namespace QtWindowConcrete{
  672.  
  673.  
  674. WMainWindow::WMainWindow( QWidget* parent, int id ) : id_(id){
  675. event_ = nullptr;
  676. // QMainWindow::setObjectName( Crack::CreateObjectName( "MainWindow", id_ ) );
  677. this->show();
  678. }
  679.  
  680. WMainWindow::~WMainWindow(){
  681.  
  682. }
  683.  
  684. QWidget* WMainWindow::widget( void ) const{
  685.  
  686. }
  687.  
  688.  
  689. HWND WMainWindow::hWnd( void ) const{
  690.  
  691. }
  692.  
  693. int WMainWindow::id( void ) const{
  694.  
  695. }
  696.  
  697. void WMainWindow::setFont( LOGFONT lf ){
  698.  
  699. }
  700.  
  701. LOGFONT WMainWindow::font( void ) const{
  702.  
  703. }
  704.  
  705. void WMainWindow::setCursor( QtUse::QtRrc::ICursor* cursor ){
  706.  
  707. }
  708.  
  709. void WMainWindow::setAcceptDrops( bool state ){
  710.  
  711. }
  712.  
  713. bool WMainWindow::acceptDrops( void ) const{
  714.  
  715. }
  716.  
  717. void WMainWindow::setLocale( int nLocale ){
  718.  
  719. }
  720.  
  721. int WMainWindow::locale( void ) const{
  722.  
  723. }
  724.  
  725. void WMainWindow::setToolTip( const std::string msg ){
  726.  
  727. }
  728.  
  729. std::string WMainWindow::toolTip( void ) const{
  730.  
  731. }
  732.  
  733. void WMainWindow::setColor( COLORREF foreColor, COLORREF bgColor ){
  734.  
  735. }
  736.  
  737.  
  738. void WMainWindow::show( void ){
  739. QMainWindow::show();
  740. return;
  741. }
  742.  
  743. void WMainWindow::hide( void ){
  744.  
  745. }
  746.  
  747. void WMainWindow::move( int x, int y ){
  748.  
  749. }
  750.  
  751. int WMainWindow::x( void ) const{
  752.  
  753. }
  754.  
  755. int WMainWindow::y( void ) const{
  756.  
  757. }
  758.  
  759. void WMainWindow::resize( int height, int width ){
  760.  
  761. }
  762.  
  763. int WMainWindow::height( void ) const{
  764.  
  765. }
  766.  
  767. int WMainWindow::width( void ) const{
  768.  
  769. }
  770.  
  771. void WMainWindow::setVisible( bool state ){
  772.  
  773. }
  774.  
  775. bool WMainWindow::visible( void ) const{
  776.  
  777. }
  778.  
  779. void WMainWindow::setEnabled( bool state ){
  780.  
  781. }
  782.  
  783. bool WMainWindow::isEnabled( void ) const{
  784.  
  785. }
  786.  
  787. void WMainWindow::setFocus( void ){
  788.  
  789. }
  790.  
  791. bool WMainWindow::focus( void ) const{
  792.  
  793. }
  794.  
  795. void WMainWindow::setText( const std::string text ){
  796.  
  797. }
  798.  
  799. std::string WMainWindow::getText( void ) const{
  800.  
  801. }
  802.  
  803. void WMainWindow::setIcon( QtUse::QtRrc::IIcon* icon ){
  804.  
  805. }
  806.  
  807. int WMainWindow::addEvent( QtUse::QtEvent::IMainWindowEvent* event ){
  808.  
  809. }
  810. }
  811.  
  812.  
  813.  
  814.  
  815. namespace Factories{
  816. // リソース系
  817. QtUse::QtRrc::ICursor* CreateCursorInstance( int id ){
  818. return new QtRrcConcrete::CCursor( id );
  819. }
  820.  
  821. QtUse::QtRrc::IIcon* CreateIconInstance( int id ){
  822. return new QtRrcConcrete::CIcon( id );
  823. }
  824.  
  825. QtUse::QtRrc::IImage* CreateImageInstance( int id ){
  826. return new QtRrcConcrete::CImage( id );
  827. }
  828.  
  829. // ワーカ系
  830. QtUse::QtWorker::IApplication* CreateApplicationInstance( int argc, char *argv[] ){
  831. return new QtWorkerConcrete::CApplication( argc, argv );
  832. }
  833.  
  834. QtUse::QtWorker::IPainter* CreatePainterInstance( void ){
  835. return new QtWorkerConcrete::CPainter();
  836. }
  837.  
  838. // ウィンドウ系
  839. QtUse::QtWindow::IMainWindow* CreateMainWindowInstance( QWidget* parent, int id ){
  840. if( parent == nullptr ){
  841. return new QtWindowConcrete::WMainWindow( Q_NULLPTR, id );
  842. }else{
  843. return new QtWindowConcrete::WMainWindow( parent, id );
  844. }
  845. }
  846. }
  847.  
  848.  
  849.  
  850.  
  851. /* -+-+-+-+- 実行ファイル側 -+-+-+-+- */
  852.  
  853. namespace QtInstanceDesigner{
  854. class QtFactory{
  855. public:
  856. QtFactory(){} // 本来ならここでDLLリンク
  857. ~QtFactory(){} // 本来ならここでDLLリンク破棄
  858.  
  859. QtUse::QtRrc::ICursor* createCursor( int id ){
  860. return Factories::CreateCursorInstance( id );
  861. }
  862.  
  863. QtUse::QtRrc::IIcon* createIcon( int id ){
  864. return Factories::CreateIconInstance( id );
  865. }
  866.  
  867. QtUse::QtRrc::IImage* createImage( int id ){
  868. return Factories::CreateImageInstance( id );
  869. }
  870.  
  871. QtUse::QtWorker::IApplication* createApplication( int argc, char *argv[] ){
  872. return Factories::CreateApplicationInstance( argc, argv );
  873. }
  874.  
  875. QtUse::QtWorker::IPainter* createPainter( void ){
  876. return Factories::CreatePainterInstance();
  877. }
  878.  
  879. QtUse::QtWindow::IMainWindow* createMainWindow( QWidget* parent, int id ){
  880. return Factories::CreateMainWindowInstance( parent, id );
  881. }
  882. private:
  883. };
  884. }
  885.  
  886.  
  887. namespace WindowX{
  888.  
  889. class IMain{
  890. public:
  891. virtual ~IMain(){}
  892. protected:
  893. virtual int main( int argc, char* argv[] ) = 0;
  894. virtual void init( void ) = 0;
  895. virtual void uninit( void ) = 0;
  896. virtual void setup( void ) = 0;
  897. };
  898.  
  899. class CMain : public IMain{
  900. public:
  901. CMain(){
  902. factory = new QtInstanceDesigner::QtFactory();
  903. }
  904.  
  905. ~CMain(){
  906. delete factory;
  907. }
  908.  
  909. int operator()( int argc, char *argv[] ){
  910. return this->main( argc, argv );
  911. }
  912. public:
  913. // ここにイベント系
  914. private:
  915. void init( void ){
  916. window = factory->createMainWindow( nullptr, 1 );
  917. }
  918.  
  919. void uninit( void ){
  920. delete window;
  921. }
  922.  
  923. void setup( void ){
  924. window->show();
  925. }
  926.  
  927. int main( int argc, char* argv[] ){
  928. app = factory->createApplication( argc, argv );
  929.  
  930. this->init();
  931. MsgBox( "1" );
  932. this->setup();
  933. MsgBox( "2" );
  934. int res = app->exec();
  935. MsgBox( "3" );
  936. this->uninit();
  937. MsgBox( "4" );
  938. delete app;
  939. MsgBox( "5" );
  940. return res;
  941. }
  942. private:
  943. QtUse::QtWindow::IMainWindow* window;
  944. QtUse::QtWorker::IApplication* app;
  945. private:
  946. QtInstanceDesigner::QtFactory* factory;
  947. };
  948. }
  949.  
  950. int main( int argc, char *argv[] ){
  951. WindowX::CMain Main;
  952. return Main( argc, argv );
  953. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement