]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dirdlg.cpp | |
3 | // Purpose: wxDirDialog | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "dirdlg.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/defs.h" | |
17 | #include "wx/utils.h" | |
18 | #include "wx/dialog.h" | |
19 | #include "wx/dirdlg.h" | |
20 | ||
21 | #include "wx/cmndata.h" | |
22 | ||
2f1ae414 | 23 | #if !USE_SHARED_LIBRARY |
e9576ca5 | 24 | IMPLEMENT_CLASS(wxDirDialog, wxDialog) |
2f1ae414 | 25 | #endif |
519cb848 SC |
26 | |
27 | // the data we need to pass to our standard file hook routine | |
28 | // includes a pointer to the dialog, a pointer to the standard | |
29 | // file reply record (so we can inspect the current selection) | |
30 | // and a copy of the "previous" file spec of the reply record | |
31 | // so we can see if the selection has changed | |
32 | ||
33 | struct UserDataRec { | |
34 | StandardFileReply *sfrPtr; | |
35 | FSSpec oldSelectionFSSpec; | |
36 | DialogPtr theDlgPtr; | |
37 | }; | |
38 | typedef struct UserDataRec | |
39 | UserDataRec, *UserDataRecPtr; | |
40 | ||
2f1ae414 SC |
41 | #if !TARGET_CARBON |
42 | ||
43 | enum { | |
44 | kSelectItem = 10, // select button item number | |
45 | kSFGetFolderDlgID = 250, // dialog resource number | |
46 | kStrListID = 250, // our strings | |
47 | kSelectStrNum = 1, // word 'Select: ' for button | |
48 | kDesktopStrNum = 2, // word 'Desktop' for button | |
49 | kSelectNoQuoteStrNum = 3, // word 'Select: ' for button | |
50 | ||
51 | kUseQuotes = true, // parameter for SetButtonName | |
52 | kDontUseQuotes = false | |
53 | }; | |
54 | ||
55 | ||
519cb848 SC |
56 | static void GetLabelString(StringPtr theStr, short stringNum) |
57 | { | |
58 | GetIndString(theStr, kStrListID, stringNum); | |
59 | } | |
60 | ||
61 | static void CopyPStr(StringPtr src, StringPtr dest) | |
62 | { | |
63 | BlockMoveData(src, dest, 1 + src[0]); | |
64 | } | |
65 | ||
66 | static char GetSelectKey(void) | |
67 | { | |
68 | // this is the key used to trigger the select button | |
69 | ||
70 | // NOT INTERNATIONAL SAVVY; should at least grab it from resources | |
71 | ||
72 | return 's'; | |
73 | } | |
74 | ||
75 | ||
76 | // SetButtonName sets the name of the Select button in the dialog | |
77 | // | |
78 | // To do this, we need to call the Script Manager to truncate the | |
79 | // label in the middle to fit the button and to merge the button | |
80 | // name with the word Select (possibly followed by quotes). Using | |
81 | // the Script Manager avoids all sorts of problems internationally. | |
82 | // | |
83 | // buttonName is the name to appear following the word Select | |
84 | // quoteFlag should be true if the name is to appear in quotes | |
85 | ||
86 | static void SetButtonName(DialogPtr theDlgPtr, short buttonID, StringPtr buttonName, | |
87 | Boolean quoteFlag) | |
88 | { | |
89 | short buttonType; | |
90 | Handle buttonHandle; | |
91 | Rect buttonRect; | |
92 | short textWidth; | |
93 | Handle labelHandle; | |
94 | Handle nameHandle; | |
95 | Str15 keyStr; | |
96 | Str255 labelStr; | |
97 | OSErr err; | |
98 | ||
99 | nameHandle = nil; | |
100 | labelHandle = nil; | |
101 | ||
102 | // get the details of the button from the dialog | |
103 | ||
104 | GetDialogItem(theDlgPtr, buttonID, &buttonType, &buttonHandle, &buttonRect); | |
105 | ||
106 | Content-type: text/html ]>