[aquaskk-changes 105] CVS update: AquaSKK

Back to archive index

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 ‚ÌŒó•âƒŠƒXƒg‚ðì¬
+    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;
+    }
+
+    // –¢Žg—pID‚ðŒŸõ
+    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‚ðŠÜ‚ÞƒfƒBƒXƒvƒŒƒC‚Ì‹éŒ`‚ðŽæ“¾
+    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‚ÌŒó•âƒŠƒXƒg‚ðì¬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;
-	}
-	
-	// –¢Žg—pID‚ðŒŸõ
-	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ƒ…ƒAƒ‹ƒfƒBƒXƒvƒŒƒC‚ɑΉžB
+
 2005-12-11  Tomotaka SUWA  <t.suw****@mac*****>
 
 	* BIMComponent.cpp (BIMCopyTextServiceInputModeList): ƒTƒ|[ƒg‚·‚é‚悤‚ɏC³B


aquaskk-changes メーリングリストの案内
Back to archive index