Develop and Download Open Source Software

Browse CVS Repository

Contents of /enbanfukusyaya/EnbanFukusyaYa/MacOSX/ui.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download)
Mon Apr 18 22:59:27 2005 UTC (18 years, 11 months ago) by bananajinn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +8 -0 lines
*** empty log message ***

1 #import <Cocoa/Cocoa.h>
2 #import "ui.h"
3 #import "MainWindowControl.h"
4
5 static BOOL g_bAbort=FALSE;
6 static MainWindowControl *g_mwc=NULL;
7
8 static void UIFlushMessage()
9 {
10 #ifndef USE_THREAD
11 NSEvent *ev;
12 while(1){
13 ev = [NSApp nextEventMatchingMask: NSAnyEventMask
14 untilDate: [NSDate date]
15 inMode: NSEventTrackingRunLoopMode /*NSDefaultRunLoopMode*/
16 dequeue: YES];
17 if(ev==nil)
18 break;
19 [NSApp sendEvent: ev];
20 }
21 #endif
22 }
23
24 //void UISetCurrentEvent(NSEvent *ev)
25 //{
26 // g_currEvent = ev;
27 //}
28
29 void UISetMWC(void *mwc)
30 {
31 g_mwc = (MainWindowControl *)mwc;
32 }
33
34 BOOL UICheckAbort()
35 {
36 UIFlushMessage();
37 return g_bAbort;
38 }
39
40 void UISetAbort()
41 {
42 g_bAbort=TRUE;
43 }
44
45 void UIClearAbort()
46 {
47 g_bAbort=FALSE;
48 }
49
50
51 int UIDispMessage(const char *message, int type)
52 {
53 int ret;
54 NSString *msgStr;
55
56 msgStr = [NSString stringWithCString : message];
57 switch(type){
58 case UIDMT_ERROR:
59 ret = NSRunAlertPanel(@"ERROR", msgStr, @"OK", nil, nil);
60 ret = UIDMRET_OK;
61 break;
62 case UIDMT_QUESTION:
63 ret = NSRunAlertPanel(@"QUESTION", msgStr, @"YES", @"NO", nil);
64 ret = (ret==0) ? UIDMRET_CANCEL : UIDMRET_OK;
65 break;
66 default:
67 ret = NSRunInformationalAlertPanel(@"Information", msgStr, @"OK", nil, nil);
68 }
69 return ret;
70 }
71
72 void UIMeter1Initialize(const char *message)
73 {
74 // ::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_METER1INIT, (LPARAM)message);
75 [g_mwc uiCtlMeter1Initialize : message];
76 }
77
78 void UIMeter2Initialize(const char *message)
79 {
80 // ::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_METER2INIT, (LPARAM)message);
81 [g_mwc uiCtlMeter2Initialize : message];
82 }
83
84 void UIMeter1Update(int percentage)
85 {
86 // ::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_METER1SETPOS, (LPARAM)percentage);
87 [g_mwc uiCtlMeter1Update : percentage];
88 }
89
90 void UIMeter2Update(int percentage)
91 {
92 // ::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_METER2SETPOS, (LPARAM)percentage);
93 [g_mwc uiCtlMeter2Update : percentage];
94 }
95
96 void UIDispInfo(const char *message)
97 {
98 [g_mwc uiCtlDispInfo : message];
99 }
100
101 int UISetting(OPTIONS *option)
102 {
103 // return ::SendMessage(g_hWnd, WM_USER_UICTL, UICTL_SETTING, (LPARAM)option);
104 return [g_mwc uiCtlSetting : option];
105 }
106
107 int UIFileDialog(BOOL bOpen, char *filename, int size, const char *suffix)
108 {
109 NSOpenPanel *op=NULL;
110 NSSavePanel *sp=NULL;
111 NSArray *fileTypes;
112 int iSts;
113
114 fileTypes = [NSArray arrayWithObjects :
115 [NSString stringWithCString : suffix], nil];
116 if(bOpen){
117 op = [NSOpenPanel openPanel];
118 iSts = [op runModalForDirectory : NSHomeDirectory()
119 file : [NSString stringWithCString : filename]
120 types : fileTypes];
121 }
122 else{
123 sp = [NSSavePanel savePanel];
124 iSts = [sp runModalForDirectory : NSHomeDirectory()
125 file : [NSString stringWithCString : filename]];
126 }
127 if(iSts != NSOKButton){
128 return UIDMRET_CANCEL;
129 }
130 if(bOpen){
131 strncpy(filename, [[op filename] cString], size-1);
132 }
133 else{
134 strncpy(filename, [[sp filename] cString], size-1);
135 }
136 filename[size-1] = '\0';
137
138 return UIDMRET_OK;
139 }
140
141 int UINetDialog(BOOL bServer, char *remote, int size, int *port_number)
142 {
143 return [g_mwc uiCtlNetSetting : bServer
144 remoteAddress : remote
145 addressSize : size
146 portNumber : port_number];
147 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26