Tomotaka SUWA
t-suw****@users*****
2005年 12月 19日 (月) 23:03:37 JST
Index: AquaSKK/CandidatesManager.mm diff -u AquaSKK/CandidatesManager.mm:1.3 AquaSKK/CandidatesManager.mm:1.4 --- AquaSKK/CandidatesManager.mm:1.3 Wed Nov 9 00:02:24 2005 +++ AquaSKK/CandidatesManager.mm Mon Dec 19 23:03:37 2005 @@ -1,5 +1,5 @@ /* -*- objc -*- - $Id: CandidatesManager.mm,v 1.3 2005/11/08 15:02:24 t-suwa Exp $ + $Id: CandidatesManager.mm,v 1.4 2005/12/19 14:03:37 t-suwa Exp $ MacOS X implementation of the SKK input method. @@ -28,119 +28,104 @@ #include "CppCFString.h" #include "CandidatesManager.h" -static CandidatesManager* _shared_instance = NULL; - -CandidatesManager& CandidatesManager::sharedManager() -{ - if (_shared_instance == NULL) - { - _shared_instance = new CandidatesManager(); +CandidatesManager& CandidatesManager::sharedManager() { + static CandidatesManager obj; + return obj; +} + +CandidatesManager::CandidatesManager() { + // empty +} + +CandidatesManager::~CandidatesManager() { + // empty +} + +unsigned CandidatesManager::createAndShow(int qd_x, int qd_y, const CppCFString& candidates_string, bool showLast) { + const CppCFString space(" "); + const CppCFString space_ref("[20]"); + const CppCFString blockopen("["); + const CppCFString blockopen_ref("[5b]"); + const CppCFString slash("/"); + const CppCFString slash_ref("[2f]"); + const CppCFString semicolon(";"); + const CppCFString semicolon_ref("[3b]"); + + // NSArray ÌóâXgðì¬ + std::vector<CppCFString> cands_vec = candidates_string.split(' '); + NSMutableArray* cands_array = [[NSMutableArray alloc] init]; + for(std::vector<CppCFString>::const_iterator ite = cands_vec.begin(); ite != cands_vec.end(); ++ ite) { + CppCFString tmp = ite->replaceClone(space_ref, space); + tmp.replace(semicolon_ref, semicolon); + tmp.replace(slash_ref, slash); + tmp.replace(blockopen_ref, blockopen); + + UniChar* unistr = tmp.toUniCharPtr(); + NSString* cand = [NSString stringWithCharacters:unistr length:tmp.length()]; + [cands_array addObject:cand]; + delete[] unistr; + } + + // ¢gpIDðõ + unsigned int window_id = 0; + for(unsigned int i = 0; ; ++ i) { + if(cand_windows[i] == NULL) { + window_id = i; + break; } - return *_shared_instance; -} + } -CandidatesManager::CandidatesManager() -{ + // J[\ÊuðÜÞfBXvCÌé`ðæ¾ + CGDirectDisplayID disp[1]; + CGDisplayCount count; + CGGetDisplaysWithPoint(CGPointMake(qd_x, qd_y), 1, disp, &count); + CGRect screen = CGDisplayBounds(disp[0]); + screen.size.width += screen.origin.x; -} + // QuickDrawÀWðCoreGraphicsÀWÖÏ· + NSSize mainscreen_size = [[NSScreen mainScreen] frame].size; + float cg_x = qd_x; + float cg_y = mainscreen_size.height - qd_y; -CandidatesManager::~CandidatesManager() -{ - -} + // CWCð쬵A + CandidatesWindowController* cwc = [[CandidatesWindowController alloc] initWithCandidates:cands_array]; + NSSize cwc_size = [[cwc window] frame].size; -unsigned CandidatesManager::createAndShow(int qd_x,int qd_y,const CppCFString& candidates_string, bool showLast) -{ - const CppCFString space(" "); - const CppCFString space_ref("[20]"); - const CppCFString blockopen("["); - const CppCFString blockopen_ref("[5b]"); - const CppCFString slash("/"); - const CppCFString slash_ref("[2f]"); - const CppCFString semicolon(";"); - const CppCFString semicolon_ref("[3b]"); - - // NSArrayÌóâXgðì¬B - std::vector<CppCFString> cands_vec = candidates_string.split(' '); - NSMutableArray* cands_array = [[NSMutableArray alloc] init]; - for (std::vector<CppCFString>::const_iterator ite = cands_vec.begin();ite != cands_vec.end();ite++) - { - CppCFString tmp = ite->replaceClone(space_ref, space); - tmp.replace(semicolon_ref, semicolon); - tmp.replace(slash_ref, slash); - tmp.replace(blockopen_ref, blockopen); - UniChar* unistr = tmp.toUniCharPtr(); - - NSString* cand = [NSString stringWithCharacters:unistr - length:tmp.length()]; - [cands_array addObject:cand]; - - delete[] unistr; - } - - // ¢gpIDðõ - unsigned int window_id = 0; - for (unsigned int i = 0;;i++) - { - if (cand_windows[i] == NULL) - { - window_id = i; - break; - } - } - - // QuickDrawÀWðCoreGraphicsÀWÖÏ·B - NSSize mainscreen_size = [[NSScreen mainScreen] frame].size; - float cg_x = qd_x; - float cg_y = mainscreen_size.height - qd_y; - - // CWCð쬵A - CandidatesWindowController* cwc = [[CandidatesWindowController alloc] initWithCandidates:cands_array]; - NSSize cwc_size = [[cwc window] frame].size; - - // ÀWðßA - float window_x = cg_x; - float window_y = cg_y - cwc_size.height; - if (window_x < 0) window_x = 0; - if (window_x + cwc_size.width > mainscreen_size.width) - window_x = mainscreen_size.width - cwc_size.width; - if (window_y < 0) window_y = 0; - if (window_y + cwc_size.height > mainscreen_size.height) - window_y = mainscreen_size.height - cwc_size.height; - [[cwc window] setFrameOrigin:NSMakePoint(window_x,window_y)]; - - // \¦·éB - if(showLast) { - [cwc setCurrentFrame:[cwc getNumOfFrames] - 1]; - } - [cwc showWindow:nil]; - - // ±ÌCWCðo^B - cand_windows[window_id] = cwc; - - return window_id; + // ÀWðßA + float window_x = cg_x; + float window_y = cg_y - cwc_size.height; + if (window_x + cwc_size.width > screen.size.width) + window_x = screen.size.width - cwc_size.width; + [[cwc window] setFrameOrigin:NSMakePoint(window_x,window_y)]; + + // \¦·é + if(showLast) { + [cwc setCurrentFrame:[cwc getNumOfFrames] - 1]; + } + [cwc showWindow:nil]; + + // ±ÌCWCðo^ + cand_windows[window_id] = cwc; + + return window_id; } -void CandidatesManager::windowNext(unsigned int window_id) -{ - [cand_windows[window_id] showNextFrame]; +void CandidatesManager::windowNext(unsigned int window_id) { + [cand_windows[window_id] showNextFrame]; } -void CandidatesManager::windowPrev(unsigned int window_id) -{ - [cand_windows[window_id] showPrevFrame]; +void CandidatesManager::windowPrev(unsigned int window_id) { + [cand_windows[window_id] showPrevFrame]; } -void CandidatesManager::closeWindow(unsigned int window_id) -{ - CandidatesWindowController* cwc = cand_windows[window_id]; - [[cwc window] orderOut:nil]; - [cwc release]; - - cand_windows[window_id] = NULL; +void CandidatesManager::closeWindow(unsigned int window_id) { + CandidatesWindowController* cwc = cand_windows[window_id]; + + [[cwc window] orderOut:nil]; + [cwc release]; + cand_windows[window_id] = NULL; } -CandidatesWindowController* CandidatesManager::getWindowController(unsigned window_id) -{ - return cand_windows[window_id]; +CandidatesWindowController* CandidatesManager::getWindowController(unsigned window_id) { + return cand_windows[window_id]; } Index: AquaSKK/ChangeLog diff -u AquaSKK/ChangeLog:1.19 AquaSKK/ChangeLog:1.20 --- AquaSKK/ChangeLog:1.19 Sun Dec 11 09:32:07 2005 +++ AquaSKK/ChangeLog Mon Dec 19 23:03:37 2005 @@ -1,3 +1,7 @@ +2005-12-19 Tomotaka SUWA <t.suw****@mac*****> + + * CandidatesManager.mm (createAndShow): f AfBXvCÉÎB + 2005-12-11 Tomotaka SUWA <t.suw****@mac*****> * BIMComponent.cpp (BIMCopyTextServiceInputModeList): T|[g·éæ¤ÉC³B