void IImgLayer::End() { assert(m_IsInited == true); if (m_IsInited) { //delete update data queue ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); if(m_pUpdateDataForeGrnd_List){ delete m_pUpdateDataForeGrnd_List; m_pUpdateDataForeGrnd_List = NULL; } if(m_pUpdateDataBackGrnd_List){ delete m_pUpdateDataBackGrnd_List; m_pUpdateDataBackGrnd_List = NULL; } ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); //release image if(m_Img){ delete m_Img; m_Img = NULL; } m_IsInited = false; } }
void IImgLayer::Init(const LPRECT lprc) { assert(m_IsInited == false); if (m_IsInited == false) { //create new update data queue ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); if(m_pUpdateDataForeGrnd_List){ delete m_pUpdateDataForeGrnd_List; m_pUpdateDataForeGrnd_List = NULL; } if(m_pUpdateDataBackGrnd_List){ delete m_pUpdateDataBackGrnd_List; m_pUpdateDataBackGrnd_List = NULL; } m_pUpdateDataForeGrnd_List = new LPUpdateData_List; m_pUpdateDataBackGrnd_List = new LPUpdateData_List; ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); m_LayerRect = (*lprc); if(m_Img){ delete m_Img; m_Img = NULL; } m_Img = new IplImageExt(); m_Img->Init( lprc->right - lprc->left, lprc->bottom - lprc->top, IPL_DEPTH_8U, 4); m_IsInited = true; } }
void ImgLayer::ClearUpdateData() { ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); m_pEditQueueForeGrnd->clear(); ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); IImgLayer::ClearUpdateData(); }
void IImgLayer::LockUpdateData() { ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); LPUpdateData_List* utmp = m_pUpdateDataForeGrnd_List; m_pUpdateDataForeGrnd_List = m_pUpdateDataBackGrnd_List; m_pUpdateDataBackGrnd_List = utmp; ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); }
void ImgLayer::PushSubEditNodeQueue(IEditNode* pNode) { ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); if (!m_pEditQueueBackGrnd->empty()) { EditQueue::iterator itr = m_pEditQueueBackGrnd->begin(); for (; itr != m_pEditQueueBackGrnd->end(); itr++) { if (((*itr).pNode == pNode) && ((*itr).flag == EDIT_FLAG::SUB_EDIT)) { ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); return; } } } EditQueueNode qnode; qnode.pNode = pNode; qnode.flag = EDIT_FLAG::SUB_EDIT; m_pEditQueueBackGrnd->push_back(qnode); ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); }
void ImgLayer::LockUpdateData() { //swap back groud qeue to fore ground qeue ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); EditQueue* etmp = m_pEditQueueForeGrnd; m_pEditQueueForeGrnd = m_pEditQueueBackGrnd; m_pEditQueueBackGrnd = etmp; ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); IImgLayer::LockUpdateData(); }
void IImgLayer::ClearUpdateData() { ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); LPUpdateData_List::iterator itr = m_pUpdateDataForeGrnd_List->begin(); for(; itr != m_pUpdateDataForeGrnd_List->end(); itr++){ if(*itr){ delete (*itr); } } m_pUpdateDataForeGrnd_List->clear(); ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); }
void ImgLayer::Init(const LPRECT lprc) { IImgLayer::Init(lprc); //create new edit node queue ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); m_pEditQueueForeGrnd = new EditQueue; m_pEditQueueBackGrnd = new EditQueue; ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); m_IsLockPixelAlpha = false; m_IsLockVisiblePixel = false; m_IsLockLayerPosition = false; m_IsClipWithUnderLayer = false; }
/* 描画イメージのアップデート @param[in] lprc アップデートする範囲 */ void ImgLayer::UpdateEditNode(LPRECT lprc) { ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); if (!m_pEditQueueForeGrnd->empty()) { EditQueue::iterator itr = m_pEditQueueForeGrnd->begin(); for (; itr != m_pEditQueueForeGrnd->end(); itr++) { if ((*itr).flag == EDIT_FLAG::ADD_EDIT) { if ((*itr).pNode->node_flag == NODE_FLAG::EDIT_DRAW) { AddEditNode(dynamic_cast<EditNode*>((*itr).pNode), lprc); } else if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) { MoveNode* pNode = dynamic_cast<MoveNode*>((*itr).pNode); assert(pNode); m_LayerRect.left += pNode->move_x; m_LayerRect.right += pNode->move_x; m_LayerRect.top += pNode->move_y; m_LayerRect.bottom += pNode->move_y; delete pNode; (*itr).pNode = NULL; } } else if ((*itr).flag == EDIT_FLAG::SUB_EDIT) { if ((*itr).pNode->node_flag == NODE_FLAG::EDIT_DRAW) { SubEditNode(dynamic_cast<EditNode*>((*itr).pNode), lprc); } else if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) { assert(0); //MoveNode* pNode = dynamic_cast<MoveNode*>((*itr).pNode); //assert(pNode); //m_LayerRect.left -= pNode->move_x; //m_LayerRect.right -= pNode->move_x; //m_LayerRect.top -= pNode->move_y; //m_LayerRect.bottom -= pNode->move_y; } } } } ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); }
void IImgLayer::PushUpdateData(LPUPDATE_DATA data) { ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); m_pUpdateDataBackGrnd_List->push_back( data ); ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); //call event ImgLayerEventListener_List::iterator el_itr = m_ImgLayerEventListener_List.begin(); for(; el_itr != m_ImgLayerEventListener_List.end(); el_itr++){ if((*el_itr)->IsLockLayerEvent() == false && (*el_itr)->IsCalledImgLayer() == false){ //無限にイベント呼び出しが続かないようにフラグを立てる (*el_itr)->SetCalledImgLayer(true); // (*el_itr)->OnImgLayerPushUpdateData(data); } (*el_itr)->SetCalledImgLayer(false); } }
void ImgLayer::End() { assert( _CrtCheckMemory() ); //delete edit node queue ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); if (m_pEditQueueForeGrnd) { EditQueue::iterator itr = m_pEditQueueForeGrnd->begin(); for (; itr != m_pEditQueueForeGrnd->end(); itr++) { if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) { delete (*itr).pNode; } } m_pEditQueueForeGrnd->clear(); delete m_pEditQueueForeGrnd; m_pEditQueueForeGrnd = NULL; } if (m_pEditQueueBackGrnd) { EditQueue::iterator itr = m_pEditQueueBackGrnd->begin(); for (; itr != m_pEditQueueBackGrnd->end(); itr++) { if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) { delete (*itr).pNode; } } m_pEditQueueBackGrnd->clear(); delete m_pEditQueueBackGrnd; m_pEditQueueBackGrnd = NULL; } ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE ); IImgLayer::End(); assert( _CrtCheckMemory() ); }
/** * MessageDraw draws MAX_VIEWED_MESSAGES of message lines on the * currently active screen at given x and y coordinate. The amount of * space from line to line is also given by an interleave variable. * * NOTE: * It is assumed that the currently active screen is where the messages * need to be drawn. * * @param x -- Starting x to draw * @param y -- Starting y to draw * @param interleave -- How far down to next line * @param color -- Color of text * *<!-----------------------------------------------------------------------*/ T_void MessageDraw( T_word16 x, T_word16 y, T_word16 interleave, T_color color) { T_word16 i ; T_word16 current ; T_word16 y_pos; T_word16 x_pos; T_byte8 ncolor; T_resourceFile res; T_resource font; T_bitfont *p_font; DebugRoutine("MessageDraw") ; /* lock in font */ res = ResourceOpen ("sample.res"); font=ResourceFind (res,"FontTiny"); p_font=ResourceLock (font); GrSetBitFont (p_font); /* Loop through up to MAX_VIEWED_MESSAGES, but stop if we reach the */ /* end of the message list. Keep track of the current message and */ /* also the position on the screen. */ for (i=0, current=G_currentMessage, y_pos = y; (i<MAX_VIEWED_MESSAGES) && (current < G_numMessages); i++, current++, y_pos+=interleave) { /* draw each character, checking for embedded color controls */ x_pos=0; ncolor=G_extendedColors[7]; MessageDrawLine(x_pos, y_pos, P_Messages[current], ncolor); } #if 0 if (P_Messages[current][0]=='^') { /* special color imbedded in string */ val=0; val+=((P_Messages[current][1]-'0')*100); val+=((P_Messages[current][2]-'0')*10); val+=((P_Messages[current][3]-'0')); if (val < MAX_EXTENDED_COLORS) { ncolor = G_extendedColors[val]; } else DebugCheck (0); /* hide color code chars */ temp+=4; } GrSetCursorPosition(x, y_pos) ; GrDrawShadowedText(temp, ncolor, COLOR_BLACK) ; #endif /* unlock the font */ ResourceUnlock (font); ResourceClose (res); DebugEnd() ; }
bool ImgLayer::Update(const LPRECT enable_lprc, LPRECT updated_lprc) { if (m_pUpdateDataForeGrnd_List->empty()) { return false; } UPDATE_DATA udLayer; bool isLayerRect = false; udLayer.isAll = false; //更新情報の縮小化 ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); LPUpdateData_List::iterator itr = m_pUpdateDataForeGrnd_List->begin(); for (; itr != m_pUpdateDataForeGrnd_List->end(); itr++) { bool isAll = (*itr)->isAll; switch ((*itr)->update_flag) { case UPDATE_FLAG::UPDATE_LAYER_IMAGE: if (isAll) {//全体更新 udLayer.isAll = isAll; } else if (udLayer.isAll == false) {//部分更新 if (isLayerRect == false) {//範囲の初期値がないなら udLayer.rect = (*itr)->rect; isLayerRect = true; } else {//範囲がすでに存在しているなら OrRect(&((*itr)->rect), &(udLayer.rect), &(udLayer.rect)); } } break; case UPDATE_FLAG::NO_UPDATE: break; default: OutputError::PushLog( LOG_LEVEL::_WARN, "ImgLayer::Update() unknown update_flag"); break; } //最大範囲の更新だったら抜ける。 if ((*itr)->update_flag == UPDATE_FLAG::UPDATE_LAYER_IMAGE && isAll) { break; } } ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE ); if (udLayer.isAll) { udLayer.rect = m_LayerRect; isLayerRect = true; } if (enable_lprc) { AndRect(&(udLayer.rect), enable_lprc, &(udLayer.rect)); } //update if (isLayerRect) { UpdateEditNode(&udLayer.rect); } (*updated_lprc) = udLayer.rect; return IImgLayer::Update(enable_lprc, updated_lprc); }
T_void FormGenericControl(E_Boolean *exitflag) { static T_word32 delta = 0, lastupdate = 0; T_keyboardEventHandler keyhandl; T_mouseEventHandler mousehandl; T_bitmap *p_bitmap; T_resource r_bitmap; T_bitmap *p_oldBitmap; T_word16 hotX, hotY; DebugRoutine("FormGenericControl"); lastupdate = TickerGet(); *exitflag = FALSE; /** Initialize the mouse. **/ MouseGetBitmap(&hotX, &hotY, &p_oldBitmap); p_bitmap = (T_bitmap *)PictureLock("UI/MOUSE/DEFAULT", &r_bitmap); DebugCheck(p_bitmap != NULL); MouseSetDefaultBitmap(0, 0, p_bitmap); MouseUseDefaultBitmap(); /* show the mouse and set the keyboard/mouse event handlers */ keyhandl = KeyboardGetEventHandler(); mousehandl = MouseGetEventHandler(); /* flush the keyboard */ KeyboardDebounce(); MouseSetEventHandler(FormHandleMouse); KeyboardSetEventHandler(FormHandleKey); // MouseShow(); do { delta = TickerGet(); /* update color every 4 ticks */ if ((delta - lastupdate) > 0) { lastupdate = delta; ColorUpdate(delta - lastupdate); } /* update events */ GraphicUpdateAllGraphics(); // MouseHide(); MouseUpdateEvents(); KeyboardUpdateEvents(); SoundUpdate(); // MouseShow(); // delay (20); } while (*exitflag == FALSE && KeyboardGetScanCode(KEY_SCAN_CODE_ESC) == FALSE); /* clean up */ // MouseHide(); FormCleanUp(); MouseSetEventHandler(mousehandl); KeyboardSetEventHandler(keyhandl); KeyboardDebounce(); /** free up the mouse pointer resource. **/ ResourceUnlock(r_bitmap); ResourceUnfind(r_bitmap); /* Turn off the mouse */ MouseSetDefaultBitmap(hotX, hotY, p_oldBitmap); MouseUseDefaultBitmap(); DebugEnd(); }